[CSS Regions] Scrolling regions with the mouse wheel only works properly if hovering...
authorstavila@adobe.com <stavila@adobe.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 Mar 2014 16:29:09 +0000 (16:29 +0000)
committerstavila@adobe.com <stavila@adobe.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 Mar 2014 16:29:09 +0000 (16:29 +0000)
https://bugs.webkit.org/show_bug.cgi?id=129485

Reviewed by Andrei Bucur.

Source/WebCore:

When searching for the region under the mouse pointer (to identify which region to scroll),
the localToAbsolute method must be called on the region container, not the region itself.
Also, when calling the offsetFromContainer method on a named flow fragment,
it must only take into consideration the border and padding of the fragment container,
not its scrolled offset.

Test: fast/regions/wheel-scrollable-single-region.html

* rendering/RenderBox.cpp:
(WebCore::RenderBox::scroll):
* rendering/RenderFlowThread.cpp:
* rendering/RenderFlowThread.h:
* rendering/RenderNamedFlowFragment.cpp:
(WebCore::RenderNamedFlowFragment::offsetFromContainer):
* rendering/RenderNamedFlowFragment.h:
* rendering/RenderNamedFlowThread.cpp:
(WebCore::RenderNamedFlowThread::fragmentFromAbsolutePointAndBox):
* rendering/RenderNamedFlowThread.h:

LayoutTests:

Added layout tests for scrolling regions using the mouse wheel.

* fast/regions/wheel-scrollable-single-region-expected.html: Added.
* fast/regions/wheel-scrollable-single-region.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@165377 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/regions/wheel-scrollable-single-region-expected.html [new file with mode: 0644]
LayoutTests/fast/regions/wheel-scrollable-single-region.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderBox.cpp
Source/WebCore/rendering/RenderFlowThread.cpp
Source/WebCore/rendering/RenderFlowThread.h
Source/WebCore/rendering/RenderNamedFlowFragment.cpp
Source/WebCore/rendering/RenderNamedFlowFragment.h
Source/WebCore/rendering/RenderNamedFlowThread.cpp
Source/WebCore/rendering/RenderNamedFlowThread.h

index 18e8b3d..1a50dd8 100644 (file)
@@ -1,3 +1,15 @@
+2014-03-10  Radu Stavila  <stavila@adobe.com>
+
+        [CSS Regions] Scrolling regions with the mouse wheel only works properly if hovering over the region's padding
+        https://bugs.webkit.org/show_bug.cgi?id=129485
+
+        Reviewed by Andrei Bucur.
+
+        Added layout tests for scrolling regions using the mouse wheel.
+
+        * fast/regions/wheel-scrollable-single-region-expected.html: Added.
+        * fast/regions/wheel-scrollable-single-region.html: Added.
+
 2014-03-10  Michał Pakuła vel Rutka  <m.pakula@samsung.com>
 
         Unreviewed EFL gardening
diff --git a/LayoutTests/fast/regions/wheel-scrollable-single-region-expected.html b/LayoutTests/fast/regions/wheel-scrollable-single-region-expected.html
new file mode 100644 (file)
index 0000000..6c57b83
--- /dev/null
@@ -0,0 +1,55 @@
+<!DOCTYPE html>
+<html style="font: 16px/1.25 monospace;">
+    <head>
+        <script>
+            onload = function() {
+                if (window.eventSender) {
+                    eventSender.mouseMoveTo(250, 250);
+                    eventSender.continuousMouseScrollBy(0, -120);
+                    eventSender.mouseMoveTo(0, 0);
+                }
+            }
+        </script>
+
+        <style>
+            #container {
+                border: 2px solid green;
+                height: 300px;
+                overflow: visible;
+            }
+
+            #region {
+                width: 600px;
+                height: 200px;
+                border: thick solid red;
+                padding: 50px;
+                overflow: scroll;
+            }
+
+            #innerDiv {
+                width: 300px;
+                height: 100px;
+                background-color: red;
+                margin-left: 30px;
+            }
+
+            #innerDiv:hover
+            {
+                background-color: green;
+            }
+        </style>
+    </head>
+
+    <body onload="testScroll()">
+        <a style="font-size: 14px" href="https://bugs.webkit.org/show_bug.cgi?id=129485">[CSS Regions] Scrolling regions with the mouse wheel only works properly if hovering over the region's padding</a>
+        <p>This test passes if the <span style="color:red">region</span> properly scrolls its content using the mouse wheel.</p>
+
+        <div id="region">
+            <div id="container">
+                <div>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent interdum, sapien vitae faucibus suscipit, massa urna sagittis libero, ac imperdiet elit lacus a ligula. Mauris a orci sem.</div>
+                <div id="innerDiv"></div>
+                <div style="color:red">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent interdum, sapien vitae faucibus suscipit, massa urna sagittis libero, ac imperdiet elit lacus a ligula. Mauris a orci sem. Nullam ullamcorper ornare porttitor. Morbi laoreet pellentesque diam, vitae hendrerit sem fringilla id. Maecenas rutrum lacinia lobortis. Praesent elit lectus, porttitor sed semper vel, fringilla id dolor. Sed lacus nisl, rutrum sit amet euismod a, vulputate quis elit. Fusce commodo dui quis lacus viverra vel egestas velit tempus. Donec ut sapien sit amet purus luctus fermentum. Donec eleifend pretium neque quis bibendum. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Nam congue dapibus mi, id ultricies est sagittis et. Integer posuere, eros vitae laoreet congue, tortor purus euismod nibh, eu porta purus arcu id turpis. Donec vitae ultricies nibh. Nullam in urna dolor, at fringilla lorem. Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>
+            </div>
+        </div>
+    </body>
+</html>
diff --git a/LayoutTests/fast/regions/wheel-scrollable-single-region.html b/LayoutTests/fast/regions/wheel-scrollable-single-region.html
new file mode 100644 (file)
index 0000000..0386e52
--- /dev/null
@@ -0,0 +1,57 @@
+<!DOCTYPE html>
+<html style="font: 16px/1.25 monospace;">
+    <head>
+        <script>
+            onload = function() {
+                if (window.eventSender) {
+                    eventSender.mouseMoveTo(250, 250);
+                    eventSender.continuousMouseScrollBy(0, -120);
+                    eventSender.mouseMoveTo(0, 0);
+                }
+            }
+        </script>
+
+        <style>
+            #container {
+                border: 2px solid green;
+                height: 300px;
+                overflow: visible;
+                -webkit-flow-into: flow;
+            }
+
+            #region {
+                width: 600px;
+                height: 200px;
+                -webkit-flow-from: flow;
+                border: thick solid red;
+                padding: 50px;
+                overflow: scroll;
+            }
+
+            #innerDiv {
+                width: 300px;
+                height: 100px;
+                background-color: red;
+                margin-left: 30px;
+            }
+
+            #innerDiv:hover
+            {
+                background-color: green;
+            }
+        </style>
+    </head>
+
+    <body>
+        <a style="font-size: 14px" href="https://bugs.webkit.org/show_bug.cgi?id=129485">[CSS Regions] Scrolling regions with the mouse wheel only works properly if hovering over the region's padding</a>
+        <p>This test passes if the <span style="color:red">region</span> properly scrolls its content using the mouse wheel.</p>
+
+        <div id="region"></div>
+
+        <div id="container">
+            <div>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent interdum, sapien vitae faucibus suscipit, massa urna sagittis libero, ac imperdiet elit lacus a ligula. Mauris a orci sem.</div>
+            <div id="innerDiv"></div>
+            <div style="color:red">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent interdum, sapien vitae faucibus suscipit, massa urna sagittis libero, ac imperdiet elit lacus a ligula. Mauris a orci sem. Nullam ullamcorper ornare porttitor. Morbi laoreet pellentesque diam, vitae hendrerit sem fringilla id. Maecenas rutrum lacinia lobortis. Praesent elit lectus, porttitor sed semper vel, fringilla id dolor. Sed lacus nisl, rutrum sit amet euismod a, vulputate quis elit. Fusce commodo dui quis lacus viverra vel egestas velit tempus. Donec ut sapien sit amet purus luctus fermentum. Donec eleifend pretium neque quis bibendum. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Nam congue dapibus mi, id ultricies est sagittis et. Integer posuere, eros vitae laoreet congue, tortor purus euismod nibh, eu porta purus arcu id turpis. Donec vitae ultricies nibh. Nullam in urna dolor, at fringilla lorem. Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>
+        </div>
+    </body>
+</html>
index 75c2200..5a6dbc2 100644 (file)
@@ -1,3 +1,29 @@
+2014-03-10  Radu Stavila  <stavila@adobe.com>
+
+        [CSS Regions] Scrolling regions with the mouse wheel only works properly if hovering over the region's padding
+        https://bugs.webkit.org/show_bug.cgi?id=129485
+
+        Reviewed by Andrei Bucur.
+
+        When searching for the region under the mouse pointer (to identify which region to scroll), 
+        the localToAbsolute method must be called on the region container, not the region itself.
+        Also, when calling the offsetFromContainer method on a named flow fragment,
+        it must only take into consideration the border and padding of the fragment container,
+        not its scrolled offset.
+
+        Test: fast/regions/wheel-scrollable-single-region.html
+
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::scroll):
+        * rendering/RenderFlowThread.cpp:
+        * rendering/RenderFlowThread.h:
+        * rendering/RenderNamedFlowFragment.cpp:
+        (WebCore::RenderNamedFlowFragment::offsetFromContainer):
+        * rendering/RenderNamedFlowFragment.h:
+        * rendering/RenderNamedFlowThread.cpp:
+        (WebCore::RenderNamedFlowThread::fragmentFromAbsolutePointAndBox):
+        * rendering/RenderNamedFlowThread.h:
+
 2014-03-10  Jinwoo Song  <jinwoo7.song@samsung.com>
 
         Remove unused dispatchStorageEvent() from StorageAreaSync
index 1dbc261..a2a7b83 100644 (file)
 #include "PaintInfo.h"
 #include "RenderBoxRegionInfo.h"
 #include "RenderFlexibleBox.h"
-#include "RenderFlowThread.h"
 #include "RenderGeometryMap.h"
 #include "RenderInline.h"
 #include "RenderIterator.h"
 #include "RenderLayer.h"
 #include "RenderLayerCompositor.h"
 #include "RenderNamedFlowFragment.h"
+#include "RenderNamedFlowThread.h"
 #include "RenderTableCell.h"
 #include "RenderTheme.h"
 #include "RenderView.h"
@@ -781,7 +781,7 @@ bool RenderBox::scroll(ScrollDirection direction, ScrollGranularity granularity,
     RenderBlock* nextScrollBlock = containingBlock();
     if (nextScrollBlock && nextScrollBlock->isRenderNamedFlowThread()) {
         ASSERT(startBox);
-        nextScrollBlock = toRenderFlowThread(nextScrollBlock)->regionFromAbsolutePointAndBox(wheelEventAbsolutePoint, *startBox);
+        nextScrollBlock = toRenderNamedFlowThread(nextScrollBlock)->fragmentFromAbsolutePointAndBox(wheelEventAbsolutePoint, *startBox);
     }
 
     if (nextScrollBlock && !nextScrollBlock->isRenderView())
index 4a5cd23..75cd9c9 100644 (file)
@@ -436,28 +436,6 @@ RenderRegion* RenderFlowThread::regionAtBlockOffset(const RenderBox* clampBox, L
     return region ? clampBox->clampToStartAndEndRegions(region) : 0;
 }
 
-RenderRegion* RenderFlowThread::regionFromAbsolutePointAndBox(const IntPoint& absolutePoint, const RenderBox& flowedBox)
-{
-    RenderRegion* startRegion = nullptr;
-    RenderRegion* endRegion = nullptr;
-    getRegionRangeForBox(&flowedBox, startRegion, endRegion);
-
-    if (!startRegion)
-        return nullptr;
-
-    for (auto iter = m_regionList.find(startRegion), end = m_regionList.end(); iter != end; ++iter) {
-        RenderRegion* region = *iter;
-        IntRect regionAbsoluteRect(roundedIntPoint(region->localToAbsolute()), roundedIntSize(region->frameRect().size()));
-        if (regionAbsoluteRect.contains(absolutePoint))
-            return region;
-
-        if (region == endRegion)
-            break;
-    }
-
-    return nullptr;
-}
-
 LayoutPoint RenderFlowThread::adjustedPositionRelativeToOffsetParent(const RenderBoxModelObject& boxModelObject, const LayoutPoint& startPoint)
 {
     LayoutPoint referencePoint = startPoint;
index 23d0f25..823ac9f 100644 (file)
@@ -104,8 +104,6 @@ public:
 
     RenderRegion* regionAtBlockOffset(const RenderBox*, LayoutUnit, bool extendLastRegion = false, RegionAutoGenerationPolicy = AllowRegionAutoGeneration);
 
-    RenderRegion* regionFromAbsolutePointAndBox(const IntPoint&, const RenderBox& flowedBox);
-
     bool regionsHaveUniformLogicalWidth() const { return m_regionsHaveUniformLogicalWidth; }
     bool regionsHaveUniformLogicalHeight() const { return m_regionsHaveUniformLogicalHeight; }
 
index 355c552..0184820 100644 (file)
@@ -252,6 +252,14 @@ bool RenderNamedFlowFragment::shouldClipFlowThreadContent() const
     
     return isLastRegion() && (style().regionFragment() == BreakRegionFragment);
 }
+    
+LayoutSize RenderNamedFlowFragment::offsetFromContainer(RenderObject* o, const LayoutPoint&, bool*) const
+{
+    ASSERT(&fragmentContainer() == o);
+    ASSERT(container() == o);
+    UNUSED_PARAM(o);
+    return topLeftLocationOffset();
+}
 
 void RenderNamedFlowFragment::layoutBlock(bool relayoutChildren, LayoutUnit)
 {
index b1ec9d4..769cbc5 100644 (file)
@@ -68,6 +68,8 @@ public:
     RenderLayer& fragmentContainerLayer() const;
     
     virtual bool shouldClipFlowThreadContent() const override;
+    
+    virtual LayoutSize offsetFromContainer(RenderObject*, const LayoutPoint&, bool* offsetDependsOnPoint = 0) const override;
 
     bool isPseudoElementRegion() const { return parent() && parent()->isPseudoElement(); }
 
index 6db474b..1dd1fe0 100644 (file)
@@ -366,6 +366,29 @@ LayoutRect RenderNamedFlowThread::decorationsClipRectForBoxInNamedFlowFragment(c
     return visualOverflowRect;
 }
 
+RenderNamedFlowFragment* RenderNamedFlowThread::fragmentFromAbsolutePointAndBox(const IntPoint& absolutePoint, const RenderBox& flowedBox)
+{
+    RenderRegion* startRegion = nullptr;
+    RenderRegion* endRegion = nullptr;
+    getRegionRangeForBox(&flowedBox, startRegion, endRegion);
+    
+    if (!startRegion)
+        return nullptr;
+    
+    for (auto iter = m_regionList.find(startRegion), end = m_regionList.end(); iter != end; ++iter) {
+        RenderNamedFlowFragment* fragment = toRenderNamedFlowFragment(*iter);
+        RenderBlockFlow& fragmentContainer = fragment->fragmentContainer();
+        IntRect fragmentAbsoluteRect(roundedIntPoint(fragmentContainer.localToAbsolute()), roundedIntSize(fragmentContainer.paddingBoxRect().size()));
+        if (fragmentAbsoluteRect.contains(absolutePoint))
+            return fragment;
+        
+        if (fragment == endRegion)
+            break;
+    }
+    
+    return nullptr;
+}
+
 void RenderNamedFlowThread::computeOverflow(LayoutUnit oldClientAfterEdge, bool recomputeFloats)
 {
     RenderFlowThread::computeOverflow(oldClientAfterEdge, recomputeFloats);
index 5ad0faa..bec7114 100644 (file)
@@ -70,6 +70,8 @@ public:
 
     LayoutRect decorationsClipRectForBoxInNamedFlowFragment(const RenderBox&, RenderNamedFlowFragment&) const;
 
+    RenderNamedFlowFragment* fragmentFromAbsolutePointAndBox(const IntPoint&, const RenderBox& flowedBox);
+
     void registerNamedFlowContentElement(Element&);
     void unregisterNamedFlowContentElement(Element&);
     const NamedFlowContentElements& contentElements() const { return m_contentElements; }