Changeset 155660 in webkit


Ignore:
Timestamp:
Sep 12, 2013 4:28:32 PM (11 years ago)
Author:
Simon Fraser
Message:

Avoid extra scrollbar-related layouts for overlay scrollbars
https://bugs.webkit.org/show_bug.cgi?id=121267

Source/WebCore:

Reviewed by Beth Dakin.

If ScrollView::updateScrollbars() detected that scrollbars were added
and removed, it would call contentsResized(), which calls setNeedsLayout(),
followed by visibleContentsResized() which would trigger layout. There is no
point doing this with overlay scrollbars, so avoid it by having
setHas*Scrollbar() return true if the addition/removal of a scrollbar changed
the available width.

No tests: we can't test overlay scrollbars in tests.

  • page/FrameView.cpp:

(WebCore::FrameView::setContentsSize): Drive-by assertion that
checks that the unsigned m_deferSetNeedsLayouts doesn't wrap when
decremented.

  • platform/ScrollView.cpp:

(WebCore::ScrollView::setHasHorizontalScrollbar): Return true if the addition/removal
changed available space.
(WebCore::ScrollView::setHasVerticalScrollbar): Ditto.
(WebCore::ScrollView::updateScrollbars): Only set sendContentResizedNotification
if available space was changed by addition/removal of scrollbars.

  • platform/ScrollView.h:

Source/WebKit2:

Reviewed by Beth Dakin.

view->resize() will call setNeedsLayout() if necessary, and may already have
done layout, so the extra setNeedsLayout() here was bad.

  • WebProcess/WebPage/WebPage.cpp:

(WebKit::WebPage::setSize):

Location:
trunk/Source
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r155655 r155660  
     12013-09-12  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Avoid extra scrollbar-related layouts for overlay scrollbars
     4        https://bugs.webkit.org/show_bug.cgi?id=121267
     5
     6        Reviewed by Beth Dakin.
     7
     8        If ScrollView::updateScrollbars() detected that scrollbars were added
     9        and removed, it would call contentsResized(), which calls setNeedsLayout(),
     10        followed by visibleContentsResized() which would trigger layout. There is no
     11        point doing this with overlay scrollbars, so avoid it by having
     12        setHas*Scrollbar() return true if the addition/removal of a scrollbar changed
     13        the available width.
     14       
     15        No tests: we can't test overlay scrollbars in tests.
     16
     17        * page/FrameView.cpp:
     18        (WebCore::FrameView::setContentsSize): Drive-by assertion that
     19        checks that the unsigned m_deferSetNeedsLayouts doesn't wrap when
     20        decremented.
     21        * platform/ScrollView.cpp:
     22        (WebCore::ScrollView::setHasHorizontalScrollbar): Return true if the addition/removal
     23        changed available space.
     24        (WebCore::ScrollView::setHasVerticalScrollbar): Ditto.
     25        (WebCore::ScrollView::updateScrollbars): Only set sendContentResizedNotification
     26        if available space was changed by addition/removal of scrollbars.
     27        * platform/ScrollView.h:
     28
    1292013-09-12  Zoltan Horvath  <zoltan@webkit.org>
    230
  • trunk/Source/WebCore/page/FrameView.cpp

    r155598 r155660  
    582582    page->chrome().contentsSizeChanged(&frame(), size); // Notify only.
    583583
     584    ASSERT(m_deferSetNeedsLayouts);
    584585    m_deferSetNeedsLayouts--;
    585586   
  • trunk/Source/WebCore/platform/ScrollView.cpp

    r154045 r155660  
    8585}
    8686
    87 void ScrollView::setHasHorizontalScrollbar(bool hasBar)
     87bool ScrollView::setHasHorizontalScrollbar(bool hasBar)
    8888{
    8989    ASSERT(!hasBar || !avoidScrollbarCreation());
     
    9393        didAddScrollbar(m_horizontalScrollbar.get(), HorizontalScrollbar);
    9494        m_horizontalScrollbar->styleChanged();
    95     } else if (!hasBar && m_horizontalScrollbar) {
     95        return !m_horizontalScrollbar->isOverlayScrollbar();
     96    }
     97   
     98    if (!hasBar && m_horizontalScrollbar) {
     99        bool wasOverlayScrollbar = m_horizontalScrollbar->isOverlayScrollbar();
    96100        willRemoveScrollbar(m_horizontalScrollbar.get(), HorizontalScrollbar);
    97101        removeChild(m_horizontalScrollbar.get());
    98102        m_horizontalScrollbar = 0;
    99     }
    100 }
    101 
    102 void ScrollView::setHasVerticalScrollbar(bool hasBar)
     103        return !wasOverlayScrollbar;
     104    }
     105
     106    return false;
     107}
     108
     109bool ScrollView::setHasVerticalScrollbar(bool hasBar)
    103110{
    104111    ASSERT(!hasBar || !avoidScrollbarCreation());
     
    108115        didAddScrollbar(m_verticalScrollbar.get(), VerticalScrollbar);
    109116        m_verticalScrollbar->styleChanged();
    110     } else if (!hasBar && m_verticalScrollbar) {
     117        return !m_verticalScrollbar->isOverlayScrollbar();
     118    }
     119   
     120    if (!hasBar && m_verticalScrollbar) {
     121        bool wasOverlayScrollbar = m_verticalScrollbar->isOverlayScrollbar();
    111122        willRemoveScrollbar(m_verticalScrollbar.get(), VerticalScrollbar);
    112123        removeChild(m_verticalScrollbar.get());
    113124        m_verticalScrollbar = 0;
    114     }
     125        return !wasOverlayScrollbar;
     126    }
     127
     128    return false;
    115129}
    116130
     
    543557            if (m_horizontalScrollbar)
    544558                m_horizontalScrollbar->invalidate();
    545             setHasHorizontalScrollbar(newHasHorizontalScrollbar);
    546             sendContentResizedNotification = true;
     559
     560            sendContentResizedNotification = setHasHorizontalScrollbar(newHasHorizontalScrollbar);
    547561        }
    548562
     
    552566            if (m_verticalScrollbar)
    553567                m_verticalScrollbar->invalidate();
    554             setHasVerticalScrollbar(newHasVerticalScrollbar);
    555             sendContentResizedNotification = true;
     568
     569            sendContentResizedNotification = setHasVerticalScrollbar(newHasVerticalScrollbar);
    556570        }
    557571
  • trunk/Source/WebCore/platform/ScrollView.h

    r155164 r155660  
    316316
    317317    // These functions are used to create/destroy scrollbars.
    318     void setHasHorizontalScrollbar(bool);
    319     void setHasVerticalScrollbar(bool);
     318    // They return true if the space taken up by the scrollbar changed.
     319    bool setHasHorizontalScrollbar(bool);
     320    bool setHasVerticalScrollbar(bool);
    320321
    321322    virtual void updateScrollCorner();
  • trunk/Source/WebKit2/ChangeLog

    r155642 r155660  
     12013-09-12  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Avoid extra scrollbar-related layouts for overlay scrollbars
     4        https://bugs.webkit.org/show_bug.cgi?id=121267
     5
     6        Reviewed by Beth Dakin.
     7       
     8        view->resize() will call setNeedsLayout() if necessary, and may already have
     9        done layout, so the extra setNeedsLayout() here was bad.
     10
     11        * WebProcess/WebPage/WebPage.cpp:
     12        (WebKit::WebPage::setSize):
     13
    1142013-09-12  Andre Moreira Magalhaes   <andre.magalhaes@collabora.co.uk>
    215
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp

    r155582 r155660  
    10691069    FrameView* view = m_page->mainFrame().view();
    10701070    view->resize(viewSize);
    1071     view->setNeedsLayout();
    10721071    m_drawingArea->setNeedsDisplay();
    10731072   
Note: See TracChangeset for help on using the changeset viewer.