Changeset 139536 in webkit


Ignore:
Timestamp:
Jan 11, 2013, 6:29:31 PM (12 years ago)
Author:
ojan@chromium.org
Message:

Fixed width overrides intrinsic min-width/max-width for text inputs and listboxes
https://bugs.webkit.org/show_bug.cgi?id=106675

Reviewed by Emil A Eklund.

Source/WebCore:

Implement computeIntrinsicLogicalWidths so that RenderBox::computeLogicalWidthInRegionUsing
can get the correct intrinsic sizes instead of the preferred sizes.

Test: fast/forms/select/listbox-intrinsic-min-width-applies-with-fixed-width.html

  • rendering/RenderListBox.cpp:

(WebCore::RenderListBox::computeIntrinsicLogicalWidths):
(WebCore):
(WebCore::RenderListBox::computePreferredLogicalWidths):

  • rendering/RenderListBox.h:

(RenderListBox):

  • rendering/RenderTextControl.cpp:

(WebCore::RenderTextControl::computeIntrinsicLogicalWidths):
(WebCore):
(WebCore::RenderTextControl::computePreferredLogicalWidths):

  • rendering/RenderTextControl.h:

(RenderTextControl):

LayoutTests:

  • fast/forms/file/intrinsic-min-width-overrides-width-expected.html:
  • fast/forms/file/intrinsic-min-width-overrides-width.html:
  • fast/forms/select/listbox-intrinsic-min-width-applies-with-fixed-width-expected.html: Added.
  • fast/forms/select/listbox-intrinsic-min-width-applies-with-fixed-width.html: Added.
Location:
trunk
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r139535 r139536  
     12013-01-11  Ojan Vafai  <ojan@chromium.org>
     2
     3        Fixed width overrides intrinsic min-width/max-width for text inputs and listboxes
     4        https://bugs.webkit.org/show_bug.cgi?id=106675
     5
     6        Reviewed by Emil A Eklund.
     7
     8        * fast/forms/file/intrinsic-min-width-overrides-width-expected.html:
     9        * fast/forms/file/intrinsic-min-width-overrides-width.html:
     10        * fast/forms/select/listbox-intrinsic-min-width-applies-with-fixed-width-expected.html: Added.
     11        * fast/forms/select/listbox-intrinsic-min-width-applies-with-fixed-width.html: Added.
     12
    1132013-01-10  Ojan Vafai  <ojan@chromium.org>
    214
  • trunk/LayoutTests/fast/forms/file/intrinsic-min-width-overrides-width-expected.html

    r139329 r139536  
    77</style>
    88
     9<input>
     10<input>
     11
     12<br>
     13
    914<input type="file">
    1015<input type="file">
  • trunk/LayoutTests/fast/forms/file/intrinsic-min-width-overrides-width.html

    r139329 r139536  
    2020</style>
    2121
     22<input class="min">
     23<input class="max">
     24
     25<br>
     26
    2227<input class="min" type="file">
    2328<input class="max" type="file">
  • trunk/Source/WebCore/ChangeLog

    r139535 r139536  
     12013-01-11  Ojan Vafai  <ojan@chromium.org>
     2
     3        Fixed width overrides intrinsic min-width/max-width for text inputs and listboxes
     4        https://bugs.webkit.org/show_bug.cgi?id=106675
     5
     6        Reviewed by Emil A Eklund.
     7
     8        Implement computeIntrinsicLogicalWidths so that RenderBox::computeLogicalWidthInRegionUsing
     9        can get the correct intrinsic sizes instead of the preferred sizes.
     10
     11        Test: fast/forms/select/listbox-intrinsic-min-width-applies-with-fixed-width.html
     12
     13        * rendering/RenderListBox.cpp:
     14        (WebCore::RenderListBox::computeIntrinsicLogicalWidths):
     15        (WebCore):
     16        (WebCore::RenderListBox::computePreferredLogicalWidths):
     17        * rendering/RenderListBox.h:
     18        (RenderListBox):
     19        * rendering/RenderTextControl.cpp:
     20        (WebCore::RenderTextControl::computeIntrinsicLogicalWidths):
     21        (WebCore):
     22        (WebCore::RenderTextControl::computePreferredLogicalWidths):
     23        * rendering/RenderTextControl.h:
     24        (RenderTextControl):
     25
    1262013-01-10  Ojan Vafai  <ojan@chromium.org>
    227
  • trunk/Source/WebCore/rendering/RenderListBox.cpp

    r139503 r139536  
    204204}
    205205
     206void RenderListBox::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const
     207{
     208    maxLogicalWidth = m_optionsWidth + 2 * optionsSpacingHorizontal;
     209    if (m_vBar)
     210        maxLogicalWidth += m_vBar->width();
     211    if (!style()->width().isPercent())
     212        minLogicalWidth = maxLogicalWidth;
     213}
     214
    206215void RenderListBox::computePreferredLogicalWidths()
    207216{
     
    213222    if (style()->width().isFixed() && style()->width().value() > 0)
    214223        m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = adjustContentBoxLogicalWidthForBoxSizing(style()->width().value());
    215     else {
    216         m_maxPreferredLogicalWidth = m_optionsWidth + 2 * optionsSpacingHorizontal;
    217         if (m_vBar)
    218             m_maxPreferredLogicalWidth += m_vBar->width();
    219 
    220         if (!style()->width().isPercent())
    221             m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth;
    222     }
     224    else
     225        computeIntrinsicLogicalWidths(m_minPreferredLogicalWidth, m_maxPreferredLogicalWidth);
    223226
    224227    if (style()->minWidth().isFixed() && style()->minWidth().value() > 0) {
  • trunk/Source/WebCore/rendering/RenderListBox.h

    r139503 r139536  
    7676    virtual bool logicalScroll(ScrollLogicalDirection, ScrollGranularity, float multiplier = 1, Node** stopNode = 0);
    7777
    78     virtual void computePreferredLogicalWidths();
     78    virtual void computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const OVERRIDE;
     79    virtual void computePreferredLogicalWidths() OVERRIDE;
    7980    virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const;
    8081    virtual void computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logicalTop, LogicalExtentComputedValues&) const OVERRIDE;
  • trunk/Source/WebCore/rendering/RenderTextControl.cpp

    r139216 r139536  
    255255}
    256256
     257void RenderTextControl::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const
     258{
     259    // Use average character width. Matches IE.
     260    AtomicString family = style()->font().family().family();
     261    maxLogicalWidth = preferredContentWidth(const_cast<RenderTextControl*>(this)->getAvgCharWidth(family));
     262    if (RenderBox* innerTextRenderBox = innerTextElement()->renderBox())
     263        maxLogicalWidth += innerTextRenderBox->paddingLeft() + innerTextRenderBox->paddingRight();
     264    if (!style()->width().isPercent())
     265        minLogicalWidth = maxLogicalWidth;
     266}
     267
    257268void RenderTextControl::computePreferredLogicalWidths()
    258269{
     
    264275    if (style()->width().isFixed() && style()->width().value() >= 0)
    265276        m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = adjustContentBoxLogicalWidthForBoxSizing(style()->width().value());
    266     else {
    267         // Use average character width. Matches IE.
    268         AtomicString family = style()->font().family().family();
    269         m_maxPreferredLogicalWidth = preferredContentWidth(getAvgCharWidth(family));
    270         if (RenderBox* innerTextRenderBox = innerTextElement()->renderBox())
    271             m_maxPreferredLogicalWidth += innerTextRenderBox->paddingLeft() + innerTextRenderBox->paddingRight();
    272 
    273         if (!style()->width().isPercent())
    274             m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth;
    275     }
     277    else
     278        computeIntrinsicLogicalWidths(m_minPreferredLogicalWidth, m_maxPreferredLogicalWidth);
    276279
    277280    if (style()->minWidth().isFixed() && style()->minWidth().value() > 0) {
  • trunk/Source/WebCore/rendering/RenderTextControl.h

    r131322 r139536  
    6969    virtual const char* renderName() const { return "RenderTextControl"; }
    7070    virtual bool isTextControl() const { return true; }
    71     virtual void computePreferredLogicalWidths();
     71    virtual void computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const OVERRIDE;
     72    virtual void computePreferredLogicalWidths() OVERRIDE;
    7273    virtual void removeLeftoverAnonymousBlock(RenderBlock*) { }
    7374    virtual bool avoidsFloats() const { return true; }
Note: See TracChangeset for help on using the changeset viewer.