Changeset 163018 in webkit


Ignore:
Timestamp:
Jan 29, 2014 7:20:56 AM (10 years ago)
Author:
stavila@adobe.com
Message:

[CSSRegions] Unable to scroll a scrollable container for regions using mouse wheel
https://bugs.webkit.org/show_bug.cgi?id=123886

Source/WebCore:

When an element flowed into a scrollable region is scrolled using the mouse wheel, the event
needs to be propagated to the region containing that element, on top of which the cursor
is located.

Reviewed by Antti Koivisto.

Tests: fast/regions/wheel-scroll-abspos.html

fast/regions/wheel-scroll.html

  • page/EventHandler.cpp:

(WebCore::scrollNode):
(WebCore::EventHandler::defaultWheelEventHandler):

  • rendering/RenderBox.cpp:

(WebCore::RenderBox::scroll):
(WebCore::RenderBox::scrollWithWheelEventLocation):

  • rendering/RenderBox.h:
  • rendering/RenderFlowThread.cpp:

(WebCore::RenderFlowThread::regionFromAbsolutePointAndBox):

  • rendering/RenderFlowThread.h:

LayoutTests:

Added tests for scrolling elements flowed into scrollable regions.

Reviewed by Antti Koivisto.

  • fast/regions/wheel-scroll-abspos-expected.html: Added.
  • fast/regions/wheel-scroll-abspos.html: Added.
  • fast/regions/wheel-scroll-expected.html: Added.
  • fast/regions/wheel-scroll.html: Added.
Location:
trunk
Files:
4 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r163016 r163018  
     12014-01-29  Radu Stavila  <stavila@adobe.com>
     2
     3        [CSSRegions] Unable to scroll a scrollable container for regions using mouse wheel
     4        https://bugs.webkit.org/show_bug.cgi?id=123886
     5
     6        Added tests for scrolling elements flowed into scrollable regions.
     7
     8        Reviewed by Antti Koivisto.
     9
     10        * fast/regions/wheel-scroll-abspos-expected.html: Added.
     11        * fast/regions/wheel-scroll-abspos.html: Added.
     12        * fast/regions/wheel-scroll-expected.html: Added.
     13        * fast/regions/wheel-scroll.html: Added.
     14
    1152014-01-29  Krzysztof Czech  <k.czech@samsung.com>
    216
  • trunk/Source/WebCore/ChangeLog

    r163017 r163018  
     12014-01-29  Radu Stavila  <stavila@adobe.com>
     2
     3        [CSSRegions] Unable to scroll a scrollable container for regions using mouse wheel
     4        https://bugs.webkit.org/show_bug.cgi?id=123886
     5
     6        When an element flowed into a scrollable region is scrolled using the mouse wheel, the event
     7        needs to be propagated to the region containing that element, on top of which the cursor
     8        is located.
     9
     10        Reviewed by Antti Koivisto.
     11
     12        Tests: fast/regions/wheel-scroll-abspos.html
     13               fast/regions/wheel-scroll.html
     14
     15        * page/EventHandler.cpp:
     16        (WebCore::scrollNode):
     17        (WebCore::EventHandler::defaultWheelEventHandler):
     18        * rendering/RenderBox.cpp:
     19        (WebCore::RenderBox::scroll):
     20        (WebCore::RenderBox::scrollWithWheelEventLocation):
     21        * rendering/RenderBox.h:
     22        * rendering/RenderFlowThread.cpp:
     23        (WebCore::RenderFlowThread::regionFromAbsolutePointAndBox):
     24        * rendering/RenderFlowThread.h:
     25
    1262014-01-29  Carlos Garcia Campos  <cgarcia@igalia.com>
    227
  • trunk/Source/WebCore/page/EventHandler.cpp

    r163012 r163018  
    282282}
    283283
    284 static inline bool scrollNode(float delta, ScrollGranularity granularity, ScrollDirection positiveDirection, ScrollDirection negativeDirection, Node* node, Element** stopElement)
     284static inline bool scrollNode(float delta, ScrollGranularity granularity, ScrollDirection positiveDirection, ScrollDirection negativeDirection, Node* node, Element** stopElement, const IntPoint& absolutePoint)
    285285{
    286286    if (!delta)
     
    290290    RenderBox* enclosingBox = node->renderer()->enclosingBox();
    291291    float absDelta = delta > 0 ? delta : -delta;
    292     return enclosingBox->scroll(delta < 0 ? negativeDirection : positiveDirection, granularity, absDelta, stopElement);
     292
     293    return enclosingBox->scrollWithWheelEventLocation(delta < 0 ? negativeDirection : positiveDirection, granularity, absDelta, enclosingBox, stopElement, absolutePoint);
    293294}
    294295
     
    26132614    // Break up into two scrolls if we need to.  Diagonal movement on
    26142615    // a MacBook pro is an example of a 2-dimensional mouse wheel event (where both deltaX and deltaY can be set).
    2615     if (dominantDirection != DominantScrollDirectionVertical && scrollNode(wheelEvent->deltaX(), granularity, ScrollRight, ScrollLeft, startNode, &stopElement))
     2616    if (dominantDirection != DominantScrollDirectionVertical && scrollNode(wheelEvent->deltaX(), granularity, ScrollRight, ScrollLeft, startNode, &stopElement, roundedIntPoint(wheelEvent->absoluteLocation())))
    26162617        wheelEvent->setDefaultHandled();
    26172618   
    2618     if (dominantDirection != DominantScrollDirectionHorizontal && scrollNode(wheelEvent->deltaY(), granularity, ScrollDown, ScrollUp, startNode, &stopElement))
     2619    if (dominantDirection != DominantScrollDirectionHorizontal && scrollNode(wheelEvent->deltaY(), granularity, ScrollDown, ScrollUp, startNode, &stopElement, roundedIntPoint(wheelEvent->absoluteLocation())))
    26192620        wheelEvent->setDefaultHandled();
    26202621   
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r162960 r163018  
    761761}
    762762
    763 bool RenderBox::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier, Element** stopElement)
    764 {
    765     RenderLayer* l = layer();
    766     if (l && l->scroll(direction, granularity, multiplier)) {
     763bool RenderBox::scrollLayer(ScrollDirection direction, ScrollGranularity granularity, float multiplier, Element** stopElement)
     764{
     765    RenderLayer* boxLayer = layer();
     766    if (boxLayer && boxLayer->scroll(direction, granularity, multiplier)) {
    767767        if (stopElement)
    768768            *stopElement = element();
     769
    769770        return true;
    770771    }
     772
     773    return false;
     774}
     775
     776bool RenderBox::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier, Element** stopElement)
     777{
     778    if (scrollLayer(direction, granularity, multiplier, stopElement))
     779        return true;
    771780
    772781    if (stopElement && *stopElement && *stopElement == element())
     
    776785    if (b && !b->isRenderView())
    777786        return b->scroll(direction, granularity, multiplier, stopElement);
     787
     788    return false;
     789}
     790
     791bool RenderBox::scrollWithWheelEventLocation(ScrollDirection direction, ScrollGranularity granularity, float multiplier, RenderBox* startBox, Element** stopElement, IntPoint absolutePoint)
     792{
     793    if (scrollLayer(direction, granularity, multiplier, stopElement))
     794        return true;
     795
     796    if (stopElement && *stopElement && *stopElement == element())
     797        return true;
     798
     799    RenderBlock* nextScrollBlock = containingBlock();
     800    if (nextScrollBlock && nextScrollBlock->isRenderNamedFlowThread()) {
     801        ASSERT(startBox);
     802        nextScrollBlock = toRenderFlowThread(nextScrollBlock)->regionFromAbsolutePointAndBox(absolutePoint, *startBox);
     803    }
     804
     805    if (nextScrollBlock && !nextScrollBlock->isRenderView())
     806        return nextScrollBlock->scrollWithWheelEventLocation(direction, granularity, multiplier, startBox, stopElement, absolutePoint);
     807
    778808    return false;
    779809}
  • trunk/Source/WebCore/rendering/RenderBox.h

    r162892 r163018  
    454454    int scrollbarLogicalHeight() const { return style().isHorizontalWritingMode() ? horizontalScrollbarHeight() : verticalScrollbarWidth(); }
    455455    virtual bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1, Element** stopElement = 0);
     456    virtual bool scrollWithWheelEventLocation(ScrollDirection, ScrollGranularity, float multiplier, RenderBox* startBox, Element** stopElement, IntPoint absolutePoint);
    456457    virtual bool logicalScroll(ScrollLogicalDirection, ScrollGranularity, float multiplier = 1, Element** stopElement = 0);
    457458    bool canBeScrolledAndHasScrollableArea() const;
     
    658659#endif
    659660
     661    bool scrollLayer(ScrollDirection, ScrollGranularity, float multiplier, Element** stopElement);
     662
    660663    bool fixedElementLaysOutRelativeToFrame(const FrameView&) const;
    661664
  • trunk/Source/WebCore/rendering/RenderFlowThread.cpp

    r162602 r163018  
    461461    return region ? clampBox->clampToStartAndEndRegions(region) : 0;
    462462}
    463    
     463
     464RenderRegion* RenderFlowThread::regionFromAbsolutePointAndBox(const IntPoint& absolutePoint, const RenderBox& flowedBox)
     465{
     466    RenderRegion* startRegion = nullptr;
     467    RenderRegion* endRegion = nullptr;
     468    getRegionRangeForBox(&flowedBox, startRegion, endRegion);
     469
     470    if (!startRegion)
     471        return nullptr;
     472
     473    for (auto iter = m_regionList.find(startRegion), end = m_regionList.end(); iter != end; ++iter) {
     474        RenderRegion* region = *iter;
     475        IntRect regionAbsoluteRect(roundedIntPoint(region->localToAbsolute()), roundedIntSize(region->frameRect().size()));
     476        if (regionAbsoluteRect.contains(absolutePoint))
     477            return region;
     478
     479        if (region == endRegion)
     480            break;
     481    }
     482
     483    return nullptr;
     484}
     485
    464486LayoutPoint RenderFlowThread::adjustedPositionRelativeToOffsetParent(const RenderBoxModelObject& boxModelObject, const LayoutPoint& startPoint)
    465487{
  • trunk/Source/WebCore/rendering/RenderFlowThread.h

    r162366 r163018  
    116116    RenderRegion* regionAtBlockOffset(const RenderBox*, LayoutUnit, bool extendLastRegion = false, RegionAutoGenerationPolicy = AllowRegionAutoGeneration);
    117117
     118    RenderRegion* regionFromAbsolutePointAndBox(const IntPoint&, const RenderBox& flowedBox);
     119
    118120    bool regionsHaveUniformLogicalWidth() const { return m_regionsHaveUniformLogicalWidth; }
    119121    bool regionsHaveUniformLogicalHeight() const { return m_regionsHaveUniformLogicalHeight; }
Note: See TracChangeset for help on using the changeset viewer.