Changeset 83672 in webkit


Ignore:
Timestamp:
Apr 12, 2011 5:20:11 PM (13 years ago)
Author:
weinig@apple.com
Message:

2011-04-12 Sam Weinig <sam@webkit.org>

Reviewed by Simon Fraser.

Frames prevent scrolling containing page
<rdar://problem/8990409>
https://bugs.webkit.org/show_bug.cgi?id=58392

Also fixes:
Should rubber-band on pages with no scrollbars
<rdar://problem/9034280>

  • page/FrameView.cpp: (WebCore::FrameView::FrameView): Make the main frame rubber-band horizontally and vertically always.
  • platform/ScrollTypes.h: Add ScrollElasticity enum.
  • platform/ScrollableArea.cpp: Default to no elasticity.

(WebCore::ScrollableArea::ScrollableArea):

  • platform/ScrollableArea.h: (WebCore::ScrollableArea::setVerticalScrollElasticity): (WebCore::ScrollableArea::verticalScrollElasticity): (WebCore::ScrollableArea::setHorizontalScrollElasticity): (WebCore::ScrollableArea::horizontalScrollElasticity): Add state for horizontal and vertical elasticity.
  • platform/mac/ScrollAnimatorMac.mm: (WebCore::ScrollAnimatorMac::handleWheelEvent): Bail out of new scrolling behavior if we can't rubber-band. By bailing before accepting the wheel event, we allow the wheel event to be forwarded. We will need to refine this logic to allow subframe scrolling in the future.

(WebCore::ScrollAnimatorMac::allowsVerticalStretching):
(WebCore::ScrollAnimatorMac::allowsHorizontalStretching):
Switch stretching behavior based on the ScrollableArea's elasticity.

Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r83671 r83672  
     12011-04-12  Sam Weinig  <sam@webkit.org>
     2
     3        Reviewed by Simon Fraser.
     4
     5        Frames prevent scrolling containing page
     6        <rdar://problem/8990409>
     7        https://bugs.webkit.org/show_bug.cgi?id=58392
     8
     9        Also fixes:
     10        Should rubber-band on pages with no scrollbars
     11        <rdar://problem/9034280>
     12
     13        * page/FrameView.cpp:
     14        (WebCore::FrameView::FrameView):
     15        Make the main frame rubber-band horizontally and vertically always.
     16
     17        * platform/ScrollTypes.h:
     18        Add ScrollElasticity enum.
     19
     20        * platform/ScrollableArea.cpp:
     21        Default to no elasticity.
     22
     23        (WebCore::ScrollableArea::ScrollableArea):
     24        * platform/ScrollableArea.h:
     25        (WebCore::ScrollableArea::setVerticalScrollElasticity):
     26        (WebCore::ScrollableArea::verticalScrollElasticity):
     27        (WebCore::ScrollableArea::setHorizontalScrollElasticity):
     28        (WebCore::ScrollableArea::horizontalScrollElasticity):
     29        Add state for horizontal and vertical elasticity.
     30
     31        * platform/mac/ScrollAnimatorMac.mm:
     32        (WebCore::ScrollAnimatorMac::handleWheelEvent):
     33        Bail out of new scrolling behavior if we can't rubber-band. By bailing before
     34        accepting the wheel event, we allow the wheel event to be forwarded. We will
     35        need to refine this logic to allow subframe scrolling in the future.
     36
     37        (WebCore::ScrollAnimatorMac::allowsVerticalStretching):
     38        (WebCore::ScrollAnimatorMac::allowsHorizontalStretching):
     39        Switch stretching behavior based on the ScrollableArea's elasticity.
     40
    1412011-04-12  Geoffrey Garen  <ggaren@apple.com>
    242
  • trunk/Source/WebCore/page/FrameView.cpp

    r83518 r83672  
    141141            m_page = page;
    142142            m_page->addScrollableArea(this);
     143
     144            if (m_frame == m_page->mainFrame()) {
     145                ScrollableArea::setVerticalScrollElasticity(ScrollElasticityAllowed);
     146                ScrollableArea::setHorizontalScrollElasticity(ScrollElasticityAllowed);
     147            }
    143148        }
    144149    }
  • trunk/Source/WebCore/platform/ScrollTypes.h

    r82067 r83672  
    109109    };
    110110
     111    enum ScrollElasticity {
     112        ScrollElasticityAutomatic,
     113        ScrollElasticityNone,
     114        ScrollElasticityAllowed
     115    };
     116
    111117    enum ScrollbarOrientation { HorizontalScrollbar, VerticalScrollbar };
    112118
  • trunk/Source/WebCore/platform/ScrollableArea.cpp

    r79511 r83672  
    4545    , m_constrainsScrollingToContentEdge(true)
    4646    , m_inLiveResize(false)
     47    , m_verticalScrollElasticity(ScrollElasticityNone)
     48    , m_horizontalScrollElasticity(ScrollElasticityNone)
    4749{
    4850}
  • trunk/Source/WebCore/platform/ScrollableArea.h

    r82171 r83672  
    5757    bool constrainsScrollingToContentEdge() const { return m_constrainsScrollingToContentEdge; }
    5858    void setConstrainsScrollingToContentEdge(bool constrainsScrollingToContentEdge) { m_constrainsScrollingToContentEdge = constrainsScrollingToContentEdge; }
     59
     60    void setVerticalScrollElasticity(ScrollElasticity scrollElasticity) { m_verticalScrollElasticity = scrollElasticity; }
     61    ScrollElasticity verticalScrollElasticity() const { return m_verticalScrollElasticity; }
     62
     63    void setHorizontalScrollElasticity(ScrollElasticity scrollElasticity) { m_horizontalScrollElasticity = scrollElasticity; }
     64    ScrollElasticity horizontalScrollElasticity() const { return m_horizontalScrollElasticity; }
    5965
    6066    bool inLiveResize() const { return m_inLiveResize; }
     
    131137    bool m_inLiveResize;
    132138
     139    ScrollElasticity m_verticalScrollElasticity;
     140    ScrollElasticity m_horizontalScrollElasticity;
     141
    133142protected:
    134143    // There are 8 possible combinations of writing mode and direction. Scroll origin will be non-zero in the x or y axis
  • trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm

    r83376 r83672  
    790790    }
    791791
     792    // FIXME: This is somewhat roundabout hack to allow forwarding wheel events
     793    // up to the parent scrollable area. It takes advantage of the fact that
     794    // the base class implemenatation of handleWheelEvent will not accept the
     795    // wheel event if there is nowhere to scroll.
     796    if (fabsf(wheelEvent.deltaY()) >= fabsf(wheelEvent.deltaX())) {
     797        if (!allowsVerticalStretching()) {
     798            ScrollAnimator::handleWheelEvent(wheelEvent);
     799            return;
     800        }
     801    } else {
     802        if (!allowsHorizontalStretching()) {
     803            ScrollAnimator::handleWheelEvent(wheelEvent);
     804            return;
     805        }
     806    }
     807
    792808    wheelEvent.accept();
    793809
     
    838854bool ScrollAnimatorMac::allowsVerticalStretching() const
    839855{
    840     Scrollbar* hScroller = m_scrollableArea->horizontalScrollbar();
    841     Scrollbar* vScroller = m_scrollableArea->verticalScrollbar();
    842     if (((vScroller && vScroller->enabled()) || (!hScroller || !hScroller->enabled())))
     856    switch (m_scrollableArea->verticalScrollElasticity()) {
     857    case ScrollElasticityAutomatic: {
     858        Scrollbar* hScroller = m_scrollableArea->horizontalScrollbar();
     859        Scrollbar* vScroller = m_scrollableArea->verticalScrollbar();
     860        return (((vScroller && vScroller->enabled()) || (!hScroller || !hScroller->enabled())));
     861    }
     862    case ScrollElasticityNone:
     863        return false;
     864    case ScrollElasticityAllowed:
    843865        return true;
    844 
     866    }
     867
     868    ASSERT_NOT_REACHED();
    845869    return false;
    846870}
     
    848872bool ScrollAnimatorMac::allowsHorizontalStretching() const
    849873{
    850     Scrollbar* hScroller = m_scrollableArea->horizontalScrollbar();
    851     Scrollbar* vScroller = m_scrollableArea->verticalScrollbar();
    852     if (((hScroller && hScroller->enabled()) || (!vScroller || !vScroller->enabled())))
     874    switch (m_scrollableArea->horizontalScrollElasticity()) {
     875    case ScrollElasticityAutomatic: {
     876        Scrollbar* hScroller = m_scrollableArea->horizontalScrollbar();
     877        Scrollbar* vScroller = m_scrollableArea->verticalScrollbar();
     878        return (((hScroller && hScroller->enabled()) || (!vScroller || !vScroller->enabled())));
     879    }
     880    case ScrollElasticityNone:
     881        return false;
     882    case ScrollElasticityAllowed:
    853883        return true;
    854 
     884    }
     885
     886    ASSERT_NOT_REACHED();
    855887    return false;
    856888}
     
    877909    else
    878910        deltaY = 0;
    879    
     911
    880912    bool isVerticallyStretched = false;
    881913    bool isHorizontallyStretched = false;
Note: See TracChangeset for help on using the changeset viewer.