Changeset 124168 in webkit


Ignore:
Timestamp:
Jul 30, 2012 8:38:53 PM (12 years ago)
Author:
jchaffraix@webkit.org
Message:

Remove overflow: scroll handling in block flow layout methods
https://bugs.webkit.org/show_bug.cgi?id=92689

Reviewed by Simon Fraser.

The overflow: scroll scrollbars creation was done at layout time for all RenderBlocks and
descendants. This was not only wrong ('overflow' only changes at style change time) but it
was also introducing some code duplication.

The gist of this change is to share the code by moving it to RenderLayer::updateScrollbarsAfterStyleChange,
this includes the code from bug 69993 to special case list box part.

Covered by existing tests:

  • All fast/overflow ones.
  • For the list box change:

fast/forms/select-overflow-scroll-inherited.html
fast/forms/select-overflow-scroll.html

  • For the flexbox:

css3/flexbox/preferred-widths-orthogonal.html
css3/flexbox/preferred-widths.html

  • rendering/RenderBlock.cpp:

(WebCore::RenderBlock::layoutBlock):

  • rendering/RenderDeprecatedFlexibleBox.cpp:

(WebCore::RenderDeprecatedFlexibleBox::layoutBlock):

  • rendering/RenderGrid.cpp:

(WebCore::RenderGrid::layoutBlock):

  • rendering/RenderFlexibleBox.cpp:

(WebCore::RenderFlexibleBox::layoutBlock):
Removed the common code here.

  • rendering/RenderFlexibleBox.cpp:

(WebCore::RenderFlexibleBox::computePreferredLogicalWidths):
Changed to an ASSERT now that the right scrollbars are created. This is
fine as overflow-x/y are physical coordinates and our access was following that.

  • rendering/RenderLayer.cpp:

(WebCore::RenderLayer::invalidateScrollbarRect):
Added an early return here if we are not attached yet as RenderLayer::styleChanged
is called at attachment time before we are inserted in the tree. This is fine as the
scrollbars are part of the object which will be painted after the first layout.

(WebCore::overflowRequiresAScrollbar):
(WebCore::overflowDefinesAutomaticScrollbar):
Split the logic in those 2 functions.

(WebCore::RenderLayer::updateScrollbarsAfterLayout):
Updated to use the require / can-have functions. Also added
an early return for list box parts as required by bug 69993.

(WebCore::RenderLayer::updateScrollbarsAfterStyleChange):
Added an early return for list box parts as required by bug 69993,
also removed some unneeded NULL-checks that were added for list box parts.

Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r124162 r124168  
     12012-07-30  Julien Chaffraix  <jchaffraix@webkit.org>
     2
     3        Remove overflow: scroll handling in block flow layout methods
     4        https://bugs.webkit.org/show_bug.cgi?id=92689
     5
     6        Reviewed by Simon Fraser.
     7
     8        The overflow: scroll scrollbars creation was done at layout time for all RenderBlocks and
     9        descendants. This was not only wrong ('overflow' only changes at style change time) but it
     10        was also introducing some code duplication.
     11
     12        The gist of this change is to share the code by moving it to RenderLayer::updateScrollbarsAfterStyleChange,
     13        this includes the code from bug 69993 to special case list box part.
     14
     15        Covered by existing tests:
     16        - All fast/overflow ones.
     17        - For the list box change:
     18            fast/forms/select-overflow-scroll-inherited.html
     19            fast/forms/select-overflow-scroll.html
     20        - For the flexbox:
     21            css3/flexbox/preferred-widths-orthogonal.html
     22            css3/flexbox/preferred-widths.html
     23
     24        * rendering/RenderBlock.cpp:
     25        (WebCore::RenderBlock::layoutBlock):
     26        * rendering/RenderDeprecatedFlexibleBox.cpp:
     27        (WebCore::RenderDeprecatedFlexibleBox::layoutBlock):
     28        * rendering/RenderGrid.cpp:
     29        (WebCore::RenderGrid::layoutBlock):
     30        * rendering/RenderFlexibleBox.cpp:
     31        (WebCore::RenderFlexibleBox::layoutBlock):
     32        Removed the common code here.
     33
     34        * rendering/RenderFlexibleBox.cpp:
     35        (WebCore::RenderFlexibleBox::computePreferredLogicalWidths):
     36        Changed to an ASSERT now that the right scrollbars are created. This is
     37        fine as overflow-x/y are physical coordinates and our access was following that.
     38
     39        * rendering/RenderLayer.cpp:
     40        (WebCore::RenderLayer::invalidateScrollbarRect):
     41        Added an early return here if we are not attached yet as RenderLayer::styleChanged
     42        is called at attachment time before we are inserted in the tree. This is fine as the
     43        scrollbars are part of the object which will be painted after the first layout.
     44
     45        (WebCore::overflowRequiresAScrollbar):
     46        (WebCore::overflowDefinesAutomaticScrollbar):
     47        Split the logic in those 2 functions.
     48
     49        (WebCore::RenderLayer::updateScrollbarsAfterLayout):
     50        Updated to use the require / can-have functions. Also added
     51        an early return for list box parts as required by bug 69993.
     52
     53        (WebCore::RenderLayer::updateScrollbarsAfterStyleChange):
     54        Added an early return for list box parts as required by bug 69993,
     55        also removed some unneeded NULL-checks that were added for list box parts.
     56
    1572012-07-30  Vivek Galatage  <vivekgalatage@gmail.com>
    258
  • trunk/Source/WebCore/rendering/RenderBlock.cpp

    r123988 r124168  
    14731473    }
    14741474
    1475     // For overflow:scroll blocks, ensure we have both scrollbars in place always.
    1476     if (scrollsOverflow() && style()->appearance() != ListboxPart) {
    1477         if (styleToUse->overflowX() == OSCROLL)
    1478             layer()->setHasHorizontalScrollbar(true);
    1479         if (styleToUse->overflowY() == OSCROLL)
    1480             layer()->setHasVerticalScrollbar(true);
    1481     }
    1482 
    14831475    LayoutUnit repaintLogicalTop = ZERO_LAYOUT_UNIT;
    14841476    LayoutUnit repaintLogicalBottom = ZERO_LAYOUT_UNIT;
  • trunk/Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp

    r122264 r124168  
    263263    initMaxMarginValues();
    264264
    265     // For overflow:scroll blocks, ensure we have both scrollbars in place always.
    266     if (scrollsOverflow()) {
    267         if (style()->overflowX() == OSCROLL)
    268             layer()->setHasHorizontalScrollbar(true);
    269         if (style()->overflowY() == OSCROLL)
    270             layer()->setHasVerticalScrollbar(true);
    271     }
    272 
    273265    if (isHorizontal())
    274266        layoutHorizontalBox(relayoutChildren);
  • trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp

    r123909 r124168  
    195195    if (hasOverflowClip()) {
    196196        if (isHorizontalWritingMode() && styleToUse->overflowY() == OSCROLL) {
    197             layer()->setHasVerticalScrollbar(true);
     197            ASSERT(layer()->hasVerticalScrollbar());
    198198            scrollbarWidth = verticalScrollbarWidth();
    199199        } else if (!isHorizontalWritingMode() && styleToUse->overflowX() == OSCROLL) {
    200             layer()->setHasHorizontalScrollbar(true);
     200            ASSERT(layer()->hasHorizontalScrollbar());
    201201            scrollbarWidth = horizontalScrollbarHeight();
    202202        }
     
    248248
    249249    m_overflow.clear();
    250 
    251     // For overflow:scroll blocks, ensure we have both scrollbars in place always.
    252     if (scrollsOverflow()) {
    253         if (style()->overflowX() == OSCROLL)
    254             layer()->setHasHorizontalScrollbar(true);
    255         if (style()->overflowY() == OSCROLL)
    256             layer()->setHasVerticalScrollbar(true);
    257     }
    258250
    259251    WTF::Vector<LineContext> lineContexts;
  • trunk/Source/WebCore/rendering/RenderGrid.cpp

    r122747 r124168  
    8080
    8181    m_overflow.clear();
    82 
    83     if (scrollsOverflow()) {
    84         if (style()->overflowX() == OSCROLL)
    85             layer()->setHasHorizontalScrollbar(true);
    86         if (style()->overflowY() == OSCROLL)
    87             layer()->setHasVerticalScrollbar(true);
    88     }
    8982
    9083    layoutGridItems();
  • trunk/Source/WebCore/rendering/RenderLayer.cpp

    r123990 r124168  
    22302230    RenderBox* box = renderBox();
    22312231    ASSERT(box);
     2232    // If we are not yet inserted into the tree, there is no need to repaint.
     2233    if (!box->parent())
     2234        return;
     2235
    22322236    if (scrollbar == m_vBar.get())
    22332237        scrollRect.move(verticalScrollbarStart(0, box->width()), box->borderTop());
     
    25232527    ASSERT(box);
    25242528
     2529    // List box parts handle the scrollbars by themselves so we have nothing to do.
     2530    if (box->style()->appearance() == ListboxPart)
     2531        return;
     2532
    25252533    bool hasHorizontalOverflow = this->hasHorizontalOverflow();
    25262534    bool hasVerticalOverflow = this->hasVerticalOverflow();
    25272535
    25282536    // overflow:scroll should just enable/disable.
    2529     if (m_hBar && renderer()->style()->overflowX() == OSCROLL)
     2537    if (renderer()->style()->overflowX() == OSCROLL)
    25302538        m_hBar->setEnabled(hasHorizontalOverflow);
    2531     if (m_vBar && renderer()->style()->overflowY() == OSCROLL)
     2539    if (renderer()->style()->overflowY() == OSCROLL)
    25322540        m_vBar->setEnabled(hasVerticalOverflow);
    25332541
     
    48194827}
    48204828
    4821 static bool overflowCanHaveAScrollbar(EOverflow overflow)
    4822 {
    4823     return overflow == OAUTO || overflow == OSCROLL || overflow == OOVERLAY;
     4829static bool overflowRequiresScrollbar(EOverflow overflow)
     4830{
     4831    return overflow == OSCROLL;
     4832}
     4833
     4834static bool overflowDefinesAutomaticScrollbar(EOverflow overflow)
     4835{
     4836    return overflow == OAUTO || overflow == OOVERLAY;
    48244837}
    48254838
     
    48274840{
    48284841    // Overflow are a box concept.
    4829     if (!renderBox())
    4830         return;
    4831 
    4832     EOverflow overflowX = renderBox()->style()->overflowX();
    4833     EOverflow overflowY = renderBox()->style()->overflowY();
    4834     if (hasHorizontalScrollbar() && !overflowCanHaveAScrollbar(overflowX))
    4835         setHasHorizontalScrollbar(false);
    4836     if (hasVerticalScrollbar() && !overflowCanHaveAScrollbar(overflowY))
    4837         setHasVerticalScrollbar(false);
     4842    RenderBox* box = renderBox();
     4843    if (!box)
     4844        return;
     4845
     4846    // List box parts handle the scrollbars by themselves so we have nothing to do.
     4847    if (box->style()->appearance() == ListboxPart)
     4848        return;
     4849
     4850    EOverflow overflowX = box->style()->overflowX();
     4851    EOverflow overflowY = box->style()->overflowY();
     4852
     4853    // To avoid doing a relayout in updateScrollbarsAfterLayout, we try to keep any automatic scrollbar that was already present.
     4854    bool needsHorizontalScrollbar = (hasHorizontalScrollbar() && overflowDefinesAutomaticScrollbar(overflowX)) || overflowRequiresScrollbar(overflowX);
     4855    bool needsVerticalScrollbar = (hasVerticalScrollbar() && overflowDefinesAutomaticScrollbar(overflowY)) || overflowRequiresScrollbar(overflowY);
     4856    setHasHorizontalScrollbar(needsHorizontalScrollbar);
     4857    setHasVerticalScrollbar(needsVerticalScrollbar);
    48384858
    48394859    // With overflow: scroll, scrollbars are always visible but may be disabled.
    48404860    // When switching to another value, we need to re-enable them (see bug 11985).
    4841     if (hasHorizontalScrollbar() && oldStyle->overflowX() == OSCROLL && overflowX != OSCROLL) {
    4842         ASSERT(overflowCanHaveAScrollbar(overflowX));
     4861    if (needsHorizontalScrollbar && oldStyle && oldStyle->overflowX() == OSCROLL && overflowX != OSCROLL) {
     4862        ASSERT(hasHorizontalScrollbar());
    48434863        m_hBar->setEnabled(true);
    48444864    }
    48454865
    4846     if (hasVerticalScrollbar() && oldStyle->overflowY() == OSCROLL && overflowY != OSCROLL) {
    4847         ASSERT(overflowCanHaveAScrollbar(overflowY));
     4866    if (needsVerticalScrollbar && oldStyle && oldStyle->overflowY() == OSCROLL && overflowY != OSCROLL) {
     4867        ASSERT(hasVerticalScrollbar());
    48484868        m_vBar->setEnabled(true);
    48494869    }
Note: See TracChangeset for help on using the changeset viewer.