Title: [154383] trunk
Revision
154383
Author
[email protected]
Date
2013-08-21 05:53:04 -0700 (Wed, 21 Aug 2013)

Log Message

Harden RenderBox::canBeScrolledAndHasScrollableArea logic https://bugs.webkit.org/show_bug.cgi?id=104373

Reviewed by Simon Fraser.
Patch by Antonio Gomes <[email protected]>

Source/WebCore:

Previously if a say div has a overflown content on 'y' but is
styled as "overflow-x: auto; overflow-y: hidden", RenderBox::canBeProgramaticallyScrolled
would still return true. It interfers, among other things, with the way
autoscroll works.

Patch fixes it by adding two helper methods to RenderBox class in order to verify a box'
scrollability in a given axis (x or y); They are used when checking if a given box is in
fact programatically scrollable.

Test: fast/events/autoscroll-overflow-hidden-longhands.html

WebKit autoscroll behavior now matches Firefox and Opera12 (pre-blink)
in that sense.

* rendering/RenderBox.cpp:
(WebCore::RenderBox::canBeProgramaticallyScrolled):
* rendering/RenderBox.h:
(WebCore::RenderBox::hasScrollableOverflowX):
(WebCore::RenderBox::hasScrollableOverflowY):

LayoutTests:

Patch adds a test to ensure autoscrolling only happens on a given
axis if it is scrollable in that direction, according to its style.

* fast/events/autoscroll-overflow-hidden-longhands-expected.txt: Added.
* fast/events/autoscroll-overflow-hidden-longhands.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (154382 => 154383)


--- trunk/LayoutTests/ChangeLog	2013-08-21 12:52:31 UTC (rev 154382)
+++ trunk/LayoutTests/ChangeLog	2013-08-21 12:53:04 UTC (rev 154383)
@@ -1,3 +1,16 @@
+2013-08-20  Antonio Gomes  <[email protected]>
+
+        Harden RenderBox::canBeScrolledAndHasScrollableArea logic
+        https://bugs.webkit.org/show_bug.cgi?id=104373
+
+        Reviewed by Simon Fraser.
+
+        Patch adds a test to ensure autoscrolling only happens on a given
+        axis if it is scrollable in that direction, according to its style.
+
+        * fast/events/autoscroll-overflow-hidden-longhands-expected.txt: Added.
+        * fast/events/autoscroll-overflow-hidden-longhands.html: Added.
+
 2013-08-19  Antonio Gomes  <[email protected]>
 
         Text dragging can scroll overflow:hidden boxes

Added: trunk/LayoutTests/fast/events/autoscroll-overflow-hidden-longhands-expected.txt (0 => 154383)


--- trunk/LayoutTests/fast/events/autoscroll-overflow-hidden-longhands-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/events/autoscroll-overflow-hidden-longhands-expected.txt	2013-08-21 12:53:04 UTC (rev 154383)
@@ -0,0 +1,2 @@
+Try to autoscroll this text.
+PASSED : the autoscroll did not happen!

Added: trunk/LayoutTests/fast/events/autoscroll-overflow-hidden-longhands.html (0 => 154383)


--- trunk/LayoutTests/fast/events/autoscroll-overflow-hidden-longhands.html	                        (rev 0)
+++ trunk/LayoutTests/fast/events/autoscroll-overflow-hidden-longhands.html	2013-08-21 12:53:04 UTC (rev 154383)
@@ -0,0 +1,56 @@
+<html>
+    <head>
+        <script>
+       function log(msg)
+       {
+           document.getElementById('console').appendChild(document.createTextNode(msg + '\n'));
+       }
+
+       function test()
+       {
+           if (window.testRunner) {
+               testRunner.waitUntilDone();
+               testRunner.dumpAsText();
+               setTimeout(autoscrollTestPart1, 0);
+           }
+       }
+
+       function autoscrollTestPart1()
+       {
+           var textInDiv = document.getElementById('textInDiv');
+           if (window.eventSender) {
+               var x = textInDiv.offsetLeft + 17;
+               var y = textInDiv.offsetTop + 7;
+               eventSender.dragMode = false;
+               eventSender.mouseMoveTo(x, y);
+               eventSender.mouseDown();
+               eventSender.mouseMoveTo(x, y + 20);
+               eventSender.mouseMoveTo(x, y + 220);
+           }
+           setTimeout(autoscrollTestPart2, 100);
+       }
+
+       function autoscrollTestPart2()
+       {
+           if (window.eventSender)
+               eventSender.mouseUp();
+           var sd = document.getElementById('nonScrollableDiv');
+           if (sd.scrollTop == 0)
+               log("PASSED : the autoscroll did not happen!");
+           else
+               log("FAILED : the autoscroll has happened :-(");
+           
+           if (window.testRunner)
+               testRunner.notifyDone();
+       }       
+        </script>
+    </head>
+<body _onload_="test()">
+   <div id="nonScrollableDiv" style="height: 100px; overflow-x: auto; overflow-y: hidden; width: 100px">
+       <div id="tailDiv" style=" height: 1000px; background-color: yellow">
+           <span id='textInDiv'> Try to autoscroll this text.<br>
+       </div>
+   </div>
+   <div id="console"></div>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (154382 => 154383)


--- trunk/Source/WebCore/ChangeLog	2013-08-21 12:52:31 UTC (rev 154382)
+++ trunk/Source/WebCore/ChangeLog	2013-08-21 12:53:04 UTC (rev 154383)
@@ -1,3 +1,30 @@
+2013-08-20  Antonio Gomes  <[email protected]>
+
+        Harden RenderBox::canBeScrolledAndHasScrollableArea logic
+        https://bugs.webkit.org/show_bug.cgi?id=104373
+
+        Reviewed by Simon Fraser.
+
+        Previously if a say div has a overflown content on 'y' but is
+        styled as "overflow-x: auto; overflow-y: hidden", RenderBox::canBeProgramaticallyScrolled
+        would still return true. It interfers, among other things, with the way
+        autoscroll works.
+
+        Patch fixes it by adding two helper methods to RenderBox class in order to verify a box'
+        scrollability in a given axis (x or y); They are used when checking if a given box is in
+        fact programatically scrollable.
+
+        Test: fast/events/autoscroll-overflow-hidden-longhands.html
+
+        WebKit autoscroll behavior now matches Firefox and Opera12 (pre-blink)
+        in that sense.
+
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::canBeProgramaticallyScrolled):
+        * rendering/RenderBox.h:
+        (WebCore::RenderBox::hasScrollableOverflowX):
+        (WebCore::RenderBox::hasScrollableOverflowY):
+
 2013-08-19  Antonio Gomes  <[email protected]>
 
         Text dragging can scroll overflow:hidden boxes

Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (154382 => 154383)


--- trunk/Source/WebCore/rendering/RenderBox.cpp	2013-08-21 12:52:31 UTC (rev 154382)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp	2013-08-21 12:53:04 UTC (rev 154383)
@@ -790,7 +790,18 @@
     
 bool RenderBox::canBeProgramaticallyScrolled() const
 {
-    return (hasOverflowClip() && (scrollsOverflow() || (node() && node()->rendererIsEditable()))) || (node() && node()->isDocumentNode());
+    Node* node = this->node();
+    if (node && node->isDocumentNode())
+        return true;
+
+    if (!hasOverflowClip())
+        return false;
+
+    bool hasScrollableOverflow = hasScrollableOverflowX() || hasScrollableOverflowY();
+    if (scrollsOverflow() && hasScrollableOverflow)
+        return true;
+
+    return node && node->rendererIsEditable();
 }
 
 bool RenderBox::usesCompositedScrolling() const

Modified: trunk/Source/WebCore/rendering/RenderBox.h (154382 => 154383)


--- trunk/Source/WebCore/rendering/RenderBox.h	2013-08-21 12:52:31 UTC (rev 154382)
+++ trunk/Source/WebCore/rendering/RenderBox.h	2013-08-21 12:53:04 UTC (rev 154383)
@@ -463,6 +463,9 @@
     bool scrollsOverflow() const { return scrollsOverflowX() || scrollsOverflowY(); }
     bool scrollsOverflowX() const { return hasOverflowClip() && (style()->overflowX() == OSCROLL || hasAutoHorizontalScrollbar()); }
     bool scrollsOverflowY() const { return hasOverflowClip() && (style()->overflowY() == OSCROLL || hasAutoVerticalScrollbar()); }
+    bool hasScrollableOverflowX() const { return scrollsOverflowX() && scrollWidth() != clientWidth(); }
+    bool hasScrollableOverflowY() const { return scrollsOverflowY() && scrollHeight() != clientHeight(); }
+
     bool usesCompositedScrolling() const;
     
     bool hasUnsplittableScrollingOverflow() const;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to