Changeset 151451 in webkit


Ignore:
Timestamp:
Jun 11, 2013, 12:03:09 PM (12 years ago)
Author:
robert@webkit.org
Message:

Positioned Replaced Elements That Aren't RenderReplaced get Incorrect Width
https://bugs.webkit.org/show_bug.cgi?id=93735

Reviewed by Darin Adler.

Source/WebCore:

Replaced elements that aren't RenderReplaced aren't |isReplaced| and don't have an
intrinsic height or width. This causes them to go down the wrong height and width computation
path in RenderBox when they are absolute positioned.

The notion of |isReplaced| is entwined with the notion of being |isInline| so it isn't really
possible to make them isReplaced without re-wiring a lot of code. So instead use an ad-hoc definition
of isReplacedElement in RenderBox to bring all replaced elements into the height and width calculation.
To make sure we get the right height and width in there, give non-RenderReplaced replaced renderers
the helpers for returning their approximation of intrinsic height and width.

Test: fast/replaced/width-and-height-of-positioned-replaced-elements.html

  • rendering/RenderBox.cpp:

(WebCore::isReplacedElement):
(WebCore::RenderBox::computePositionedLogicalWidth):
(WebCore::RenderBox::computePositionedLogicalHeight):

  • rendering/RenderBox.h:

(WebCore::RenderBox::intrinsicSize):

  • rendering/RenderButton.h:
  • rendering/RenderListBox.cpp:

(WebCore::RenderListBox::RenderListBox):
(WebCore::RenderListBox::computeLogicalHeight):

  • rendering/RenderListBox.h:
  • rendering/RenderMenuList.h:
  • rendering/RenderReplaced.h:
  • rendering/RenderTextControl.cpp:

(WebCore::RenderTextControl::RenderTextControl):
(WebCore::RenderTextControl::computeLogicalHeight):

  • rendering/RenderTextControl.h:

LayoutTests:

  • fast/forms/onselect-textfield-expected.txt:
  • fast/replaced/width-and-height-of-positioned-replaced-elements-expected.png: Added.
  • fast/replaced/width-and-height-of-positioned-replaced-elements-expected.txt: Added.
  • fast/replaced/width-and-height-of-positioned-replaced-elements.html: Added.
  • platform/mac-wk2/fast/replaced/width-and-height-of-positioned-replaced-elements-expected.txt: Added.
  • platform/mac/fast/forms/button-positioned-expected.txt:
  • platform/mac/fast/forms/input-appearance-preventDefault-expected.txt:
  • platform/mac/fast/replaced/width-and-height-of-positioned-replaced-elements-expected.txt: Added.
  • platform/qt/fast/forms/button-positioned-expected.txt:
  • platform/qt/fast/forms/input-appearance-preventDefault-expected.txt:
Location:
trunk
Files:
6 added
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r151448 r151451  
     12013-05-27  Robert Hogan  <robert@webkit.org>
     2
     3        Positioned Replaced Elements That Aren't RenderReplaced get Incorrect Width
     4        https://bugs.webkit.org/show_bug.cgi?id=93735
     5
     6        Reviewed by Darin Adler.
     7
     8        * fast/forms/onselect-textfield-expected.txt:
     9        * fast/replaced/width-and-height-of-positioned-replaced-elements-expected.png: Added.
     10        * fast/replaced/width-and-height-of-positioned-replaced-elements-expected.txt: Added.
     11        * fast/replaced/width-and-height-of-positioned-replaced-elements.html: Added.
     12        * platform/mac-wk2/fast/replaced/width-and-height-of-positioned-replaced-elements-expected.txt: Added.
     13        * platform/mac/fast/forms/button-positioned-expected.txt:
     14        * platform/mac/fast/forms/input-appearance-preventDefault-expected.txt:
     15        * platform/mac/fast/replaced/width-and-height-of-positioned-replaced-elements-expected.txt: Added.
     16        * platform/qt/fast/forms/button-positioned-expected.txt:
     17        * platform/qt/fast/forms/input-appearance-preventDefault-expected.txt:
     18
    1192013-06-11  Robert Hogan  <robert@webkit.org>
    220
  • trunk/LayoutTests/fast/forms/onselect-textfield-expected.txt

    r25234 r151451  
    1010Double clicking to make selection for text field
    1111onselect fired for text field
    12 After double clicking: text field selection start: 6 end: 10
     12After double clicking: text field selection start: 0 end: 5
    1313
    1414Calling blur on text field
    15 After blur: text field selection start: 6 end: 10
     15After blur: text field selection start: 0 end: 5
    1616
    1717Calling focus on text field
    18 After focus: text field selection start: 6 end: 10
     18After focus: text field selection start: 0 end: 5
    1919
  • trunk/LayoutTests/platform/mac/fast/forms/button-positioned-expected.txt

    r149210 r151451  
    44  RenderBlock {HTML} at (0,0) size 800x600
    55    RenderBody {BODY} at (8,8) size 784x584
    6 layer at (10,10) size 154x18
    7   RenderButton {BUTTON} at (10,10) size 154x18 [bgcolor=#C0C0C0] [border: none (2px outset #C0C0C0) none (2px outset #C0C0C0)]
    8     RenderBlock (anonymous) at (8,2) size 138x13
    9       RenderText {#text} at (0,0) size 138x13
    10         text run at (0,0) width 138: "This button is positioned."
    11 layer at (10,10) size 175x18
    12   RenderButton {INPUT} at (10,10) size 175x18 [bgcolor=#C0C0C0]
    13     RenderBlock (anonymous) at (8,2) size 159x13
    14       RenderText at (0,0) size 159x13
    15         text run at (0,0) width 159: "This button is also positioned"
     6layer at (10,10) size 170x15
     7  RenderButton {BUTTON} at (10,10) size 170x15 [bgcolor=#C0C0C0] [border: none (2px outset #C0C0C0) none (2px outset #C0C0C0)]
     8    RenderBlock (anonymous) at (8,2) size 154x13
     9      RenderText {#text} at (8,0) size 138x13
     10        text run at (8,0) width 138: "This button is positioned."
     11layer at (10,10) size 191x18
     12  RenderButton {INPUT} at (10,10) size 191x18 [bgcolor=#C0C0C0]
     13    RenderBlock (anonymous) at (8,2) size 175x13
     14      RenderText at (8,0) size 159x13
     15        text run at (8,0) width 159: "This button is also positioned"
  • trunk/LayoutTests/platform/mac/fast/forms/input-appearance-preventDefault-expected.txt

    r117673 r151451  
    99      RenderText {#text} at (0,0) size 0x0
    1010      RenderText {#text} at (0,0) size 0x0
    11 layer at (12,52) size 123x19
    12   RenderTextControl {INPUT} at (12,52) size 123x19 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
    13 layer at (15,55) size 117x13 scrollWidth 130
    14   RenderBlock {DIV} at (3,3) size 117x13
     11layer at (12,52) size 129x25
     12  RenderTextControl {INPUT} at (12,52) size 129x25 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
     13layer at (15,58) size 123x13 scrollWidth 130
     14  RenderBlock {DIV} at (3,6) size 123x13
    1515    RenderText {#text} at (0,0) size 129x13
    1616      text run at (0,0) width 129: "No caret should be here"
  • trunk/LayoutTests/platform/qt/fast/forms/button-positioned-expected.txt

    r122879 r151451  
    44  RenderBlock {HTML} at (0,0) size 800x600
    55    RenderBody {BODY} at (8,8) size 784x584
    6 layer at (10,10) size 162x31
    7   RenderButton {BUTTON} at (10,10) size 162x31 [bgcolor=#C0C0C0]
    8     RenderBlock (anonymous) at (6,6) size 150x19
    9       RenderText {#text} at (0,0) size 150x19
    10         text run at (0,0) width 150: "This button is positioned."
    11 layer at (10,10) size 186x31
    12   RenderButton {INPUT} at (10,10) size 186x31 [bgcolor=#C0C0C0]
    13     RenderBlock (anonymous) at (6,6) size 174x19
    14       RenderText at (0,0) size 174x19
    15         text run at (0,0) width 174: "This button is also positioned"
     6layer at (10,10) size 174x29
     7  RenderButton {BUTTON} at (10,10) size 174x29 [bgcolor=#C0C0C0]
     8    RenderBlock (anonymous) at (6,6) size 162x19
     9      RenderText {#text} at (6,0) size 150x19
     10        text run at (6,0) width 150: "This button is positioned."
     11layer at (10,10) size 198x29
     12  RenderButton {INPUT} at (10,10) size 198x29 [bgcolor=#C0C0C0]
     13    RenderBlock (anonymous) at (6,6) size 186x19
     14      RenderText at (6,0) size 174x19
     15        text run at (6,0) width 174: "This button is also positioned"
  • trunk/LayoutTests/platform/qt/fast/forms/input-appearance-preventDefault-expected.txt

    r122879 r151451  
    99      RenderText {#text} at (0,0) size 0x0
    1010      RenderText {#text} at (0,0) size 0x0
    11 layer at (12,52) size 192x23
    12   RenderTextControl {INPUT} at (12,52) size 192x23
    13 layer at (14,54) size 188x19
    14   RenderBlock {DIV} at (2,2) size 188x19
     11layer at (12,52) size 196x27
     12  RenderTextControl {INPUT} at (12,52) size 196x27
     13layer at (14,56) size 192x19
     14  RenderBlock {DIV} at (2,4) size 192x19
    1515    RenderText {#text} at (0,0) size 146x19
    1616      text run at (0,0) width 146: "No caret should be here"
  • trunk/Source/WebCore/ChangeLog

    r151449 r151451  
     12013-05-27  Robert Hogan  <robert@webkit.org>
     2
     3        Positioned Replaced Elements That Aren't RenderReplaced get Incorrect Width
     4        https://bugs.webkit.org/show_bug.cgi?id=93735
     5
     6        Reviewed by Darin Adler.
     7
     8        Replaced elements that aren't RenderReplaced aren't |isReplaced| and don't have an
     9        intrinsic height or width. This causes them to go down the wrong height and width computation
     10        path in RenderBox when they are absolute positioned.
     11       
     12        The notion of |isReplaced| is entwined with the notion of being |isInline| so it isn't really
     13        possible to make them isReplaced without re-wiring a lot of code. So instead use an ad-hoc definition
     14        of isReplacedElement in RenderBox to bring all replaced elements into the height and width calculation.
     15        To make sure we get the right height and width in there, give non-RenderReplaced replaced renderers
     16        the helpers for returning their approximation of intrinsic height and width.
     17
     18        Test: fast/replaced/width-and-height-of-positioned-replaced-elements.html
     19
     20        * rendering/RenderBox.cpp:
     21        (WebCore::isReplacedElement):
     22        (WebCore::RenderBox::computePositionedLogicalWidth):
     23        (WebCore::RenderBox::computePositionedLogicalHeight):
     24        * rendering/RenderBox.h:
     25        (WebCore::RenderBox::intrinsicSize):
     26        * rendering/RenderButton.h:
     27        * rendering/RenderListBox.cpp:
     28        (WebCore::RenderListBox::RenderListBox):
     29        (WebCore::RenderListBox::computeLogicalHeight):
     30        * rendering/RenderListBox.h:
     31        * rendering/RenderMenuList.h:
     32        * rendering/RenderReplaced.h:
     33        * rendering/RenderTextControl.cpp:
     34        (WebCore::RenderTextControl::RenderTextControl):
     35        (WebCore::RenderTextControl::computeLogicalHeight):
     36        * rendering/RenderTextControl.h:
     37
    1382013-06-11  Ryosuke Niwa  <rniwa@webkit.org>
    239
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r151402 r151451  
    30353035}
    30363036
     3037static bool isReplacedElement(const RenderBox* child)
     3038{
     3039    // FIXME: Bug 117267, we should make form control elements isReplaced too so that we can just check for that.
     3040    return child->isReplaced() || (child->node() && child->node()->isElementNode() && toElement(child->node())->isFormControlElement() && !child->isFieldset());
     3041}
     3042
    30373043void RenderBox::computePositionedLogicalWidth(LogicalExtentComputedValues& computedValues, RenderRegion* region) const
    30383044{
    3039     if (isReplaced()) {
     3045    if (isReplacedElement(this)) {
    30403046        // FIXME: Positioned replaced elements inside a flow thread are not working properly
    30413047        // with variable width regions (see https://bugs.webkit.org/show_bug.cgi?id=69896 ).
     
    33793385void RenderBox::computePositionedLogicalHeight(LogicalExtentComputedValues& computedValues) const
    33803386{
    3381     if (isReplaced()) {
     3387    if (isReplacedElement(this)) {
    33823388        computePositionedLogicalHeightReplaced(computedValues);
    33833389        return;
  • trunk/Source/WebCore/rendering/RenderBox.h

    r151402 r151451  
    400400    }
    401401
    402     virtual LayoutSize intrinsicSize() const { return LayoutSize(); }
    403402    LayoutUnit intrinsicLogicalWidth() const { return style()->isHorizontalWritingMode() ? intrinsicSize().width() : intrinsicSize().height(); }
    404403    LayoutUnit intrinsicLogicalHeight() const { return style()->isHorizontalWritingMode() ? intrinsicSize().height() : intrinsicSize().width(); }
     
    642641    LayoutUnit viewLogicalHeightForPercentages() const;
    643642
     643    virtual LayoutSize intrinsicSize() const { return LayoutSize(); }
    644644    void computePositionedLogicalHeight(LogicalExtentComputedValues&) const;
    645645    void computePositionedLogicalWidthUsing(Length logicalWidth, const RenderBoxModelObject* containerBlock, TextDirection containerDirection,
  • trunk/Source/WebCore/rendering/RenderButton.h

    r150312 r151451  
    6868    void timerFired(Timer<RenderButton>*);
    6969
     70    virtual LayoutSize intrinsicSize() const OVERRIDE FINAL { return LayoutSize(maxPreferredLogicalWidth(), LayoutUnit()); }
     71
    7072    RenderTextFragment* m_buttonText;
    7173    RenderBlock* m_inner;
  • trunk/Source/WebCore/rendering/RenderListBox.cpp

    r150796 r151451  
    9090    , m_optionsWidth(0)
    9191    , m_indexOffset(0)
     92    , m_intrinsicLogicalHeight(0)
    9293{
    9394    ASSERT(element);
     
    270271void RenderListBox::computeLogicalHeight(LayoutUnit, LayoutUnit logicalTop, LogicalExtentComputedValues& computedValues) const
    271272{
    272     LayoutUnit height = itemHeight() * size() - rowSpacing + borderAndPaddingHeight();
    273     RenderBox::computeLogicalHeight(height, logicalTop, computedValues);
     273    m_intrinsicLogicalHeight = itemHeight() * size() - rowSpacing + borderAndPaddingHeight();
     274    RenderBox::computeLogicalHeight(m_intrinsicLogicalHeight, logicalTop, computedValues);
    274275}
    275276
  • trunk/Source/WebCore/rendering/RenderListBox.h

    r150399 r151451  
    8989    virtual void stopAutoscroll();
    9090
     91    virtual LayoutSize intrinsicSize() const OVERRIDE FINAL { return LayoutSize(maxPreferredLogicalWidth(), m_intrinsicLogicalHeight); }
     92
    9193    virtual bool shouldPanScroll() const { return true; }
    9294    virtual void panScroll(const IntPoint&);
     
    150152    int m_optionsWidth;
    151153    int m_indexOffset;
     154    mutable LayoutUnit m_intrinsicLogicalHeight;
    152155
    153156    RefPtr<Scrollbar> m_vBar;
  • trunk/Source/WebCore/rendering/RenderMenuList.h

    r150312 r151451  
    7676    virtual const char* renderName() const { return "RenderMenuList"; }
    7777
     78    virtual LayoutSize intrinsicSize() const OVERRIDE FINAL { return LayoutSize(maxPreferredLogicalWidth(), logicalHeight()); }
    7879    virtual void computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const OVERRIDE;
    7980    virtual void computePreferredLogicalWidths() OVERRIDE;
  • trunk/Source/WebCore/rendering/RenderReplaced.h

    r150312 r151451  
    4444    virtual void layout();
    4545
    46     virtual LayoutSize intrinsicSize() const OVERRIDE { return m_intrinsicSize; }
     46    virtual LayoutSize intrinsicSize() const OVERRIDE FINAL { return m_intrinsicSize; }
    4747    virtual void computeIntrinsicRatioInformation(FloatSize& intrinsicSize, double& intrinsicRatio, bool& isPercentageIntrinsicSize) const;
    4848
  • trunk/Source/WebCore/rendering/RenderTextControl.cpp

    r150716 r151451  
    3939RenderTextControl::RenderTextControl(Element* element)
    4040    : RenderBlock(element)
     41    , m_intrinsicLogicalHeight(0)
    4142{
    4243    ASSERT(isHTMLTextFormControlElement(element));
     
    143144}
    144145
    145 void RenderTextControl::computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logicalTop, LogicalExtentComputedValues& computedValues) const
     146void RenderTextControl::computeLogicalHeight(LayoutUnit, LayoutUnit logicalTop, LogicalExtentComputedValues& computedValues) const
    146147{
    147148    HTMLElement* innerText = innerTextElement();
     
    149150    if (RenderBox* innerTextBox = innerText->renderBox()) {
    150151        LayoutUnit nonContentHeight = innerTextBox->borderAndPaddingHeight() + innerTextBox->marginHeight();
    151         logicalHeight = computeControlLogicalHeight(innerTextBox->lineHeight(true, HorizontalLine, PositionOfInteriorLineBoxes), nonContentHeight) + borderAndPaddingHeight();
     152        m_intrinsicLogicalHeight = computeControlLogicalHeight(innerTextBox->lineHeight(true, HorizontalLine, PositionOfInteriorLineBoxes), nonContentHeight) + borderAndPaddingHeight();
    152153
    153154        // We are able to have a horizontal scrollbar if the overflow style is scroll, or if its auto and there's no word wrap.
    154155        if ((isHorizontalWritingMode() && (style()->overflowX() == OSCROLL ||  (style()->overflowX() == OAUTO && innerText->renderer()->style()->overflowWrap() == NormalOverflowWrap)))
    155156            || (!isHorizontalWritingMode() && (style()->overflowY() == OSCROLL ||  (style()->overflowY() == OAUTO && innerText->renderer()->style()->overflowWrap() == NormalOverflowWrap))))
    156             logicalHeight += scrollbarThickness();
    157     }
    158 
    159     RenderBox::computeLogicalHeight(logicalHeight, logicalTop, computedValues);
     157            m_intrinsicLogicalHeight += scrollbarThickness();
     158    }
     159    RenderBox::computeLogicalHeight(m_intrinsicLogicalHeight, logicalTop, computedValues);
    160160}
    161161
  • trunk/Source/WebCore/rendering/RenderTextControl.h

    r150312 r151451  
    8282
    8383    virtual bool requiresForcedStyleRecalcPropagation() const { return true; }
     84
     85    virtual LayoutSize intrinsicSize() const OVERRIDE FINAL { return LayoutSize(maxPreferredLogicalWidth(), m_intrinsicLogicalHeight); }
     86
     87    mutable LayoutUnit m_intrinsicLogicalHeight;
    8488};
    8589
Note: See TracChangeset for help on using the changeset viewer.