Changeset 180615 in webkit


Ignore:
Timestamp:
Feb 24, 2015, 9:35:38 PM (10 years ago)
Author:
Simon Fraser
Message:

Clarify some resizing terminology in ScrollView/FrameView
https://bugs.webkit.org/show_bug.cgi?id=141996

Reviewed by Zalan Bujtas.

ScrollableArea/ScrollView/FrameView had some confusing terminology around
contentsResized/visibleContentsResized/fixedLayoutSizeChanged.

Clarify this by distinguishing between:

  1. Available size changes because of

i) non-overlay scrollbar presence

ii) ScrollableArea frame change

  1. Removing fixedLayoutSizeChanged() and just treating it like an available size change.

contentsResized() is relegated to simply being a hook that allows Mac to
flash overlay scrollbars.

The confusingly named visibleContentsResized() is now updateContentsSize(),
and is the way that a ScrollableArea tells its subclasss that it should recompute
the size of the contents (i.e. do a layout).

Source/WebCore:

  • page/FrameView.cpp:

(WebCore::FrameView::setContentsSize): No longer mysteriously skip the
FrameView implementation of contentsResized(), which used to do a setNeedsLayout()
which we didn't want to do from setContentsSize(), which itself happens as a result of layout.
(WebCore::FrameView::adjustViewSize): Whitespace.
(WebCore::FrameView::layout): Ditto.
(WebCore::FrameView::availableContentSizeChanged): Called on frame size change, or scrollbar
change.
(WebCore::FrameView::updateContentsSize): This actually does the layout.
(WebCore::FrameView::scrollbarStyleChanged): Always call the base class; ScrollView::scrollbarStyleChanged
will bail if not a forced update.
(WebCore::FrameView::setCustomFixedPositionLayoutRect): Forces a layout via updateContentsSize() now.
(WebCore::FrameView::contentsResized): Deleted.
(WebCore::FrameView::fixedLayoutSizeChanged): Deleted.
(WebCore::FrameView::visibleContentsResized): Deleted.

  • page/FrameView.h:
  • platform/ScrollView.cpp:

(WebCore::ScrollView::setFixedLayoutSize): Calls availableContentSizeChanged() now.
(WebCore::ScrollView::setUseFixedLayout): Ditto.
(WebCore::ScrollView::availableContentSizeChanged): Update scrollbars if that's not
the reason we are being called.
(WebCore::ScrollView::updateScrollbars): contentsResized() was the thing that caused setNeedsLayout();
replace it with availableContentSizeChanged(). visibleContentsResized() did the layout, and
replace with updateContentsSize().
(WebCore::ScrollView::setFrameRect): Call availableContentSizeChanged() now. This takes care of
updating scrollbars, so no need to explicitly do that.
(WebCore::ScrollView::scrollbarStyleChanged): Call the base class.
(WebCore::ScrollView::fixedLayoutSizeChanged): Deleted.

  • platform/ScrollView.h:
  • platform/ScrollableArea.cpp:

(WebCore::ScrollableArea::availableContentSizeChanged): Call scrollAnimator->contentsResized()
to flash the scrollbars.
(WebCore::ScrollableArea::scrolledToRight):
(WebCore::ScrollableArea::scrollbarStyleChanged): Call availableContentSizeChanged() since
scrollbar style affects available space.

  • platform/ScrollableArea.h:

(WebCore::ScrollableArea::updateContentsSize):
(WebCore::ScrollableArea::scrollbarStyleChanged): Deleted.

Source/WebKit2:

  • WebProcess/Plugins/PDF/PDFPlugin.mm:

(WebKit::PDFPlugin::scrollbarStyleChanged): Call the base class method,
which takes care of

Location:
trunk/Source
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/Source/WebCore/ChangeLog

    r180614 r180615  
     12015-02-24  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Clarify some resizing terminology in ScrollView/FrameView
     4        https://bugs.webkit.org/show_bug.cgi?id=141996
     5
     6        Reviewed by Zalan Bujtas.
     7
     8        ScrollableArea/ScrollView/FrameView had some confusing terminology around
     9        contentsResized/visibleContentsResized/fixedLayoutSizeChanged.
     10       
     11        Clarify this by distinguishing between:
     12        1. Available size changes because of
     13            i) non-overlay scrollbar presence
     14           ii) ScrollableArea frame change
     15        2. Removing fixedLayoutSizeChanged() and just treating it like an
     16           available size change.
     17           
     18        contentsResized() is relegated to simply being a hook that allows Mac to
     19        flash overlay scrollbars.
     20       
     21        The confusingly named visibleContentsResized() is now updateContentsSize(),
     22        and is the way that a ScrollableArea tells its subclasss that it should recompute
     23        the size of the contents (i.e. do a layout).
     24
     25        * page/FrameView.cpp:
     26        (WebCore::FrameView::setContentsSize): No longer mysteriously skip the
     27        FrameView implementation of contentsResized(), which used to do a setNeedsLayout()
     28        which we didn't want to do from setContentsSize(), which itself happens as a result of layout.
     29        (WebCore::FrameView::adjustViewSize): Whitespace.
     30        (WebCore::FrameView::layout): Ditto.
     31        (WebCore::FrameView::availableContentSizeChanged): Called on frame size change, or scrollbar
     32        change.
     33        (WebCore::FrameView::updateContentsSize): This actually does the layout.
     34        (WebCore::FrameView::scrollbarStyleChanged): Always call the base class;  ScrollView::scrollbarStyleChanged
     35        will bail if not a forced update.
     36        (WebCore::FrameView::setCustomFixedPositionLayoutRect): Forces a layout via updateContentsSize() now.
     37        (WebCore::FrameView::contentsResized): Deleted.
     38        (WebCore::FrameView::fixedLayoutSizeChanged): Deleted.
     39        (WebCore::FrameView::visibleContentsResized): Deleted.
     40        * page/FrameView.h:
     41        * platform/ScrollView.cpp:
     42        (WebCore::ScrollView::setFixedLayoutSize): Calls availableContentSizeChanged() now.
     43        (WebCore::ScrollView::setUseFixedLayout): Ditto.
     44        (WebCore::ScrollView::availableContentSizeChanged): Update scrollbars if that's not
     45        the reason we are being called.
     46        (WebCore::ScrollView::updateScrollbars): contentsResized() was the thing that caused setNeedsLayout();
     47        replace it with availableContentSizeChanged(). visibleContentsResized() did the layout, and
     48        replace with updateContentsSize().
     49        (WebCore::ScrollView::setFrameRect): Call availableContentSizeChanged() now. This takes care of
     50        updating scrollbars, so no need to explicitly do that.
     51        (WebCore::ScrollView::scrollbarStyleChanged): Call the base class.
     52        (WebCore::ScrollView::fixedLayoutSizeChanged): Deleted.
     53        * platform/ScrollView.h:
     54        * platform/ScrollableArea.cpp:
     55        (WebCore::ScrollableArea::availableContentSizeChanged): Call scrollAnimator->contentsResized()
     56        to flash the scrollbars.
     57        (WebCore::ScrollableArea::scrolledToRight):
     58        (WebCore::ScrollableArea::scrollbarStyleChanged): Call availableContentSizeChanged() since
     59        scrollbar style affects available space.
     60        * platform/ScrollableArea.h:
     61        (WebCore::ScrollableArea::updateContentsSize):
     62        (WebCore::ScrollableArea::scrollbarStyleChanged): Deleted.
     63
    1642015-02-24  Ryosuke Niwa  <rniwa@webkit.org>
    265
  • TabularUnified trunk/Source/WebCore/page/FrameView.cpp

    r180607 r180615  
    567567
    568568    ScrollView::setContentsSize(size);
    569     ScrollView::contentsResized();
     569    contentsResized();
    570570   
    571571    Page* page = frame().page();
     
    598598    const IntSize& size = rect.size();
    599599    ScrollView::setScrollOrigin(IntPoint(-rect.x(), -rect.y()), !frame().document()->printing(), size == contentsSize());
    600    
     600
    601601    setContentsSize(size);
    602602}
     
    12771277
    12781278            LayoutSize oldSize = m_size;
    1279 
    12801279            m_size = layoutSize();
    12811280
     
    22912290}
    22922291
    2293 void FrameView::contentsResized()
    2294 {
    2295     ScrollView::contentsResized();
     2292void FrameView::availableContentSizeChanged(AvailableSizeChangeReason reason)
     2293{
    22962294    setNeedsLayout();
    2297 }
    2298 
    2299 void FrameView::fixedLayoutSizeChanged()
    2300 {
    2301     // Can be triggered before the view is set, see comment in FrameView::visibleContentsResized().
    2302     // An ASSERT is triggered when a view schedules a layout before being attached to a frame.
    2303     if (!frame().view())
    2304         return;
    2305     ScrollView::fixedLayoutSizeChanged();
     2295    ScrollView::availableContentSizeChanged(reason);
    23062296}
    23072297
     
    23112301}
    23122302
    2313 void FrameView::visibleContentsResized()
     2303void FrameView::updateContentsSize()
    23142304{
    23152305    // We check to make sure the view is attached to a frame() as this method can
     
    34943484    frame().page()->chrome().client().recommendedScrollbarStyleDidChange(newStyle);
    34953485
    3496     if (forceUpdate)
    3497         ScrollView::scrollbarStyleChanged(newStyle, forceUpdate);
     3486    ScrollView::scrollbarStyleChanged(newStyle, forceUpdate);
    34983487}
    34993488
     
    44674456    m_useCustomFixedPositionLayoutRect = true;
    44684457    m_customFixedPositionLayoutRect = rect;
    4469     visibleContentsResized();
     4458    updateContentsSize();
    44704459}
    44714460
  • TabularUnified trunk/Source/WebCore/page/FrameView.h

    r180607 r180615  
    581581
    582582    virtual void repaintContentRectangle(const IntRect&) override;
    583     virtual void contentsResized() override;
    584     virtual void visibleContentsResized() override;
     583    virtual void updateContentsSize() override;
     584    virtual void availableContentSizeChanged(AvailableSizeChangeReason) override;
    585585    virtual void addedOrRemovedScrollbar() override;
    586     virtual void fixedLayoutSizeChanged() override;
    587586
    588587    virtual void delegatesScrollingDidChange() override;
  • TabularUnified trunk/Source/WebCore/platform/ScrollView.cpp

    r180607 r180615  
    347347    m_fixedLayoutSize = newSize;
    348348    if (m_useFixedLayout)
    349         fixedLayoutSizeChanged();
     349        availableContentSizeChanged(AvailableSizeChangeReason::AreaSizeChanged);
    350350}
    351351
     
    361361    m_useFixedLayout = enable;
    362362    if (!m_fixedLayoutSize.isEmpty())
    363         fixedLayoutSizeChanged();
    364 }
    365 
    366 void ScrollView::fixedLayoutSizeChanged()
    367 {
    368     updateScrollbars(scrollOffset());
    369     contentsResized();
     363        availableContentSizeChanged(AvailableSizeChangeReason::AreaSizeChanged);
     364}
     365
     366void ScrollView::availableContentSizeChanged(AvailableSizeChangeReason reason)
     367{
     368    ScrollableArea::availableContentSizeChanged(reason);
     369    if (reason != AvailableSizeChangeReason::ScrollbarsChanged)
     370        updateScrollbars(scrollOffset());
    370371}
    371372
     
    601602
    602603    // If we came in here with the view already needing a layout, then go ahead and do that
    603     // first.  (This will be the common case, e.g., when the page changes due to window resizing for example).
     604    // first. (This will be the common case, e.g., when the page changes due to window resizing for example).
    604605    // This layout will not re-enter updateScrollbars and does not count towards our max layout pass total.
    605606    if (!m_scrollbarsSuppressed && !hasOverlayScrollbars) {
    606607        m_inUpdateScrollbars = true;
    607         visibleContentsResized();
     608        updateContentsSize();
    608609        m_inUpdateScrollbars = false;
    609610    }
     
    697698        if ((sendContentResizedNotification || needAnotherPass) && m_updateScrollbarsPass < cMaxUpdateScrollbarsPass) {
    698699            m_updateScrollbarsPass++;
    699             contentsResized();
    700             visibleContentsResized();
     700            availableContentSizeChanged(AvailableSizeChangeReason::ScrollbarsChanged);
     701            updateContentsSize();
    701702            IntSize newDocSize = totalContentsSize();
    702703            if (newDocSize == docSize) {
     
    10481049
    10491050    Widget::setFrameRect(newRect);
    1050 
    10511051    frameRectsChanged();
    1052 
    1053     updateScrollbars(scrollOffset());
    1054 
     1052   
    10551053    if (!m_useFixedLayout && oldRect.size() != newRect.size())
    1056         contentsResized();
     1054        availableContentSizeChanged(AvailableSizeChangeReason::AreaSizeChanged);
    10571055}
    10581056
     
    11631161}
    11641162
    1165 void ScrollView::scrollbarStyleChanged(ScrollbarStyle, bool forceUpdate)
    1166 {
     1163void ScrollView::scrollbarStyleChanged(ScrollbarStyle newStyle, bool forceUpdate)
     1164{
     1165    ScrollableArea::scrollbarStyleChanged(newStyle, forceUpdate);
    11671166    if (!forceUpdate)
    11681167        return;
    11691168
    1170     contentsResized();
    11711169    updateScrollbars(scrollOffset());
    11721170    positionScrollbarLayers();
  • TabularUnified trunk/Source/WebCore/platform/ScrollView.h

    r180607 r180615  
    390390    virtual void paintOverhangAreas(GraphicsContext*, const IntRect& horizontalOverhangArea, const IntRect& verticalOverhangArea, const IntRect& dirtyRect);
    391391
    392     virtual void visibleContentsResized() = 0;
     392    virtual void availableContentSizeChanged(AvailableSizeChangeReason) override;
    393393    virtual void addedOrRemovedScrollbar() = 0;
    394394    virtual void delegatesScrollingDidChange() { }
    395     virtual void fixedLayoutSizeChanged();
    396395
    397396    // These functions are used to create/destroy scrollbars.
  • TabularUnified trunk/Source/WebCore/platform/ScrollableArea.cpp

    r180474 r180615  
    315315}
    316316
     317void ScrollableArea::availableContentSizeChanged(AvailableSizeChangeReason)
     318{
     319    if (ScrollAnimator* scrollAnimator = existingScrollAnimator())
     320        scrollAnimator->contentsResized(); // This flashes overlay scrollbars.
     321}
     322
    317323bool ScrollableArea::hasOverlayScrollbars() const
    318324{
     
    478484{
    479485    return scrollPosition().x() >= maximumScrollPosition().x();
     486}
     487
     488void ScrollableArea::scrollbarStyleChanged(ScrollbarStyle, bool)
     489{
     490    availableContentSizeChanged(AvailableSizeChangeReason::ScrollbarsChanged);
    480491}
    481492
  • TabularUnified trunk/Source/WebCore/platform/ScrollableArea.h

    r180607 r180615  
    113113    WEBCORE_EXPORT virtual void contentsResized();
    114114
     115    // Force the contents to recompute their size (i.e. do layout).
     116    virtual void updateContentsSize() { }
     117
     118    enum class AvailableSizeChangeReason {
     119        ScrollbarsChanged,
     120        AreaSizeChanged
     121    };
     122    WEBCORE_EXPORT virtual void availableContentSizeChanged(AvailableSizeChangeReason);
     123
    115124    bool hasOverlayScrollbars() const;
    116125    WEBCORE_EXPORT virtual void setScrollbarOverlayStyle(ScrollbarOverlayStyle);
     
    202211
    203212    virtual bool shouldSuspendScrollAnimations() const { return true; }
    204     virtual void scrollbarStyleChanged(ScrollbarStyle, bool /*forceUpdate*/) { }
     213    WEBCORE_EXPORT virtual void scrollbarStyleChanged(ScrollbarStyle /*newStyle*/, bool /*forceUpdate*/);
    205214    virtual void setVisibleScrollerThumbRect(const IntRect&) { }
    206215   
  • TabularUnified trunk/Source/WebKit2/ChangeLog

    r180607 r180615  
     12015-02-24  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Clarify some resizing terminology in ScrollView/FrameView
     4        https://bugs.webkit.org/show_bug.cgi?id=141996
     5
     6        Reviewed by Zalan Bujtas.
     7
     8        ScrollableArea/ScrollView/FrameView had some confusing terminology around
     9        contentsResized/visibleContentsResized/fixedLayoutSizeChanged.
     10       
     11        Clarify this by distinguishing between:
     12        1. Available size changes because of
     13            i) non-overlay scrollbar presence
     14           ii) ScrollableArea frame change
     15        2. Removing fixedLayoutSizeChanged() and just treating it like an
     16           available size change.
     17           
     18        contentsResized() is relegated to simply being a hook that allows Mac to
     19        flash overlay scrollbars.
     20       
     21        The confusingly named visibleContentsResized() is now updateContentsSize(),
     22        and is the way that a ScrollableArea tells its subclasss that it should recompute
     23        the size of the contents (i.e. do a layout).
     24
     25        * WebProcess/Plugins/PDF/PDFPlugin.mm:
     26        (WebKit::PDFPlugin::scrollbarStyleChanged): Call the base class method,
     27        which takes care of
     28
    1292015-02-24  Simon Fraser  <simon.fraser@apple.com>
    230
  • TabularUnified trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm

    r180607 r180615  
    725725{
    726726    // FIXME: Walk up the frame tree and look for a scrollable parent frame or RenderLayer.
    727     return 0;
     727    return nullptr;
    728728}
    729729
     
    798798    setScrollOffset(newScrollOffset);
    799799   
     800    ScrollableArea::scrollbarStyleChanged(style, forceUpdate);
    800801    // As size of the content area changes, scrollbars may need to appear or to disappear.
    801802    updateScrollbars();
    802    
    803     ScrollableArea::contentsResized();
    804803}
    805804
Note: See TracChangeset for help on using the changeset viewer.