Title: [90059] trunk
Revision
90059
Author
simon.fra...@apple.com
Date
2011-06-29 15:56:54 -0700 (Wed, 29 Jun 2011)

Log Message

2011-06-29  Simon Fraser  <simon.fra...@apple.com>

        Reviewed by Beth Dakin.

        Lay some groundwork for rubber-banding in overflow:scroll divs
        https://bugs.webkit.org/show_bug.cgi?id=63654

        Make it possible for scrollTop and scrollLeft on a RenderLayer to be
        set to negative values, which we will do during rubber-banding in
        future. Continue to clamp programmatic scrolls, and scroll positions
        set by layout between 0 and the max value.

        Test: fast/layers/negative-scroll-positions.html

        * rendering/RenderBox.cpp:
        (WebCore::RenderBox::setScrollLeft):
        (WebCore::RenderBox::setScrollTop):
        * rendering/RenderLayer.cpp:
        (WebCore::RenderLayer::scrollToOffset):
        (WebCore::RenderLayer::scrollTo):
        * rendering/RenderLayer.h:
        (WebCore::RenderLayer::scrollToXOffset):
        (WebCore::RenderLayer::scrollToYOffset):
        * rendering/RenderTextControlSingleLine.cpp:
        (WebCore::RenderTextControlSingleLine::forwardEvent):

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (90058 => 90059)


--- trunk/LayoutTests/ChangeLog	2011-06-29 22:53:15 UTC (rev 90058)
+++ trunk/LayoutTests/ChangeLog	2011-06-29 22:56:54 UTC (rev 90059)
@@ -1,3 +1,18 @@
+2011-06-29  Simon Fraser  <simon.fra...@apple.com>
+
+        Reviewed by Beth Dakin.
+
+        Lay some groundwork for rubber-banding in overflow:scroll divs
+        https://bugs.webkit.org/show_bug.cgi?id=63654
+
+        Test clamping of scrollTo with negative values.
+
+        * fast/layers/negative-scroll-positions-expected.txt: Added.
+        * fast/layers/negative-scroll-positions.html: Added.
+        * fast/layers/script-tests/TEMPLATE.html: Added.
+        * fast/layers/script-tests/negative-scroll-positions.js: Added.
+        (attemptScroll):
+
 2011-06-29  Jessie Berlin  <jber...@apple.com>
 
         eventSender.keyDown is unimplemented (WKTR)

Added: trunk/LayoutTests/fast/layers/negative-scroll-positions-expected.txt (0 => 90059)


--- trunk/LayoutTests/fast/layers/negative-scroll-positions-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/layers/negative-scroll-positions-expected.txt	2011-06-29 22:56:54 UTC (rev 90059)
@@ -0,0 +1,12 @@
+This tests the HTMLImageElement border property.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS attemptScroll(0, 0) is '0,0'
+PASS attemptScroll(50, 50) is '50,50'
+PASS attemptScroll(-50, -50) is '0,0'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Property changes on: trunk/LayoutTests/fast/layers/negative-scroll-positions-expected.txt
___________________________________________________________________

Added: svn:mime-type

Added: svn:keywords

Added: svn:eol-style

Added: trunk/LayoutTests/fast/layers/negative-scroll-positions.html (0 => 90059)


--- trunk/LayoutTests/fast/layers/negative-scroll-positions.html	                        (rev 0)
+++ trunk/LayoutTests/fast/layers/negative-scroll-positions.html	2011-06-29 22:56:54 UTC (rev 90059)
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="stylesheet" href=""
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src=""
+<script src=""
+</body>
+</html>
Property changes on: trunk/LayoutTests/fast/layers/negative-scroll-positions.html
___________________________________________________________________

Added: svn:mime-type

Added: svn:keywords

Added: svn:eol-style

Added: trunk/LayoutTests/fast/layers/script-tests/TEMPLATE.html (0 => 90059)


--- trunk/LayoutTests/fast/layers/script-tests/TEMPLATE.html	                        (rev 0)
+++ trunk/LayoutTests/fast/layers/script-tests/TEMPLATE.html	2011-06-29 22:56:54 UTC (rev 90059)
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="stylesheet" href=""
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src=""
+<script src=""
+</body>
+</html>
Property changes on: trunk/LayoutTests/fast/layers/script-tests/TEMPLATE.html
___________________________________________________________________

Added: svn:mime-type

Added: svn:keywords

Added: svn:eol-style

Added: trunk/LayoutTests/fast/layers/script-tests/negative-scroll-positions.js (0 => 90059)


--- trunk/LayoutTests/fast/layers/script-tests/negative-scroll-positions.js	                        (rev 0)
+++ trunk/LayoutTests/fast/layers/script-tests/negative-scroll-positions.js	2011-06-29 22:56:54 UTC (rev 90059)
@@ -0,0 +1,29 @@
+description(
+"This tests the HTMLImageElement border property."
+);
+
+var scroller = document.createElement('div');
+scroller.id = 'scroller';
+scroller.style.overflow = 'scroll';
+scroller.style.width = '200px';
+scroller.style.height = '200px';
+
+var contents = document.createElement('div');
+contents.style.width = '400px';
+contents.style.height = '400px';
+
+scroller.appendChild(contents);
+document.body.appendChild(scroller);
+
+function attemptScroll(x, y)
+{
+  scroller.scrollTop = x;
+  scroller.scrollLeft = y;
+  return scroller.scrollTop + ',' + scroller.scrollLeft;
+}
+
+shouldBe("attemptScroll(0, 0)", "'0,0'");
+shouldBe("attemptScroll(50, 50)", "'50,50'");
+shouldBe("attemptScroll(-50, -50)", "'0,0'");
+
+var successfullyParsed = true;
Property changes on: trunk/LayoutTests/fast/layers/script-tests/negative-scroll-positions.js
___________________________________________________________________

Added: svn:mime-type

Added: svn:keywords

Added: svn:eol-style

Modified: trunk/Source/WebCore/ChangeLog (90058 => 90059)


--- trunk/Source/WebCore/ChangeLog	2011-06-29 22:53:15 UTC (rev 90058)
+++ trunk/Source/WebCore/ChangeLog	2011-06-29 22:56:54 UTC (rev 90059)
@@ -1,3 +1,29 @@
+2011-06-29  Simon Fraser  <simon.fra...@apple.com>
+
+        Reviewed by Beth Dakin.
+
+        Lay some groundwork for rubber-banding in overflow:scroll divs
+        https://bugs.webkit.org/show_bug.cgi?id=63654
+
+        Make it possible for scrollTop and scrollLeft on a RenderLayer to be
+        set to negative values, which we will do during rubber-banding in
+        future. Continue to clamp programmatic scrolls, and scroll positions
+        set by layout between 0 and the max value.
+
+        Test: fast/layers/negative-scroll-positions.html
+
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::setScrollLeft):
+        (WebCore::RenderBox::setScrollTop):
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::scrollToOffset):
+        (WebCore::RenderLayer::scrollTo):
+        * rendering/RenderLayer.h:
+        (WebCore::RenderLayer::scrollToXOffset):
+        (WebCore::RenderLayer::scrollToYOffset):
+        * rendering/RenderTextControlSingleLine.cpp:
+        (WebCore::RenderTextControlSingleLine::forwardEvent):
+
 2011-06-29  Anders Carlsson  <ander...@apple.com>
 
         Reviewed by Simon Fraser.

Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (90058 => 90059)


--- trunk/Source/WebCore/rendering/RenderBox.cpp	2011-06-29 22:53:15 UTC (rev 90058)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp	2011-06-29 22:56:54 UTC (rev 90059)
@@ -446,13 +446,13 @@
 void RenderBox::setScrollLeft(int newLeft)
 {
     if (hasOverflowClip())
-        layer()->scrollToXOffset(newLeft);
+        layer()->scrollToXOffset(newLeft, RenderLayer::ScrollOffsetClamped);
 }
 
 void RenderBox::setScrollTop(int newTop)
 {
     if (hasOverflowClip())
-        layer()->scrollToYOffset(newTop);
+        layer()->scrollToYOffset(newTop, RenderLayer::ScrollOffsetClamped);
 }
 
 void RenderBox::absoluteRects(Vector<IntRect>& rects, const IntPoint& accumulatedOffset)

Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (90058 => 90059)


--- trunk/Source/WebCore/rendering/RenderLayer.cpp	2011-06-29 22:53:15 UTC (rev 90058)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp	2011-06-29 22:56:54 UTC (rev 90059)
@@ -1280,8 +1280,20 @@
     }
 }
 
-void RenderLayer::scrollToOffset(int x, int y)
+void RenderLayer::scrollToOffset(int x, int y, ScrollOffsetClamping clamp)
 {
+    if (clamp == ScrollOffsetClamped) {
+        RenderBox* box = renderBox();
+        if (!box)
+            return;
+
+        int maxX = scrollWidth() - box->clientWidth();
+        int maxY = scrollHeight() - box->clientHeight();
+
+        x = min(max(x, 0), maxX);
+        y = min(max(y, 0), maxY);
+    }
+    
     ScrollableArea::scrollToOffsetWithoutAnimation(IntPoint(x, y));
 }
 
@@ -1292,24 +1304,9 @@
         return;
 
     if (box->style()->overflowX() != OMARQUEE) {
-        if (x < 0)
-            x = 0;
-        if (y < 0)
-            y = 0;
-    
-        // Call the scrollWidth/Height functions so that the dimensions will be computed if they need
-        // to be (for overflow:hidden blocks).
-        int maxX = scrollWidth() - box->clientWidth();
-        if (maxX < 0)
-            maxX = 0;
-        int maxY = scrollHeight() - box->clientHeight();
-        if (maxY < 0)
-            maxY = 0;
-
-        if (x > maxX)
-            x = maxX;
-        if (y > maxY)
-            y = maxY;
+        // Ensure that the dimensions will be computed if they need to be (for overflow:hidden blocks).
+        if (m_scrollDimensionsDirty)
+            computeScrollDimensions();
     }
     
     // FIXME: Eventually, we will want to perform a blit.  For now never

Modified: trunk/Source/WebCore/rendering/RenderLayer.h (90058 => 90059)


--- trunk/Source/WebCore/rendering/RenderLayer.h	2011-06-29 22:53:15 UTC (rev 90058)
+++ trunk/Source/WebCore/rendering/RenderLayer.h	2011-06-29 22:56:54 UTC (rev 90059)
@@ -233,9 +233,14 @@
     int scrollYOffset() const { return m_scrollOffset.height() + m_scrollOrigin.y(); }
     IntSize scrollOffset() const { return IntSize(scrollXOffset(), scrollYOffset()); }
 
-    void scrollToOffset(int x, int y);
-    void scrollToXOffset(int x) { scrollToOffset(x, scrollYOffset()); }
-    void scrollToYOffset(int y) { scrollToOffset(scrollXOffset(), y); }
+    enum ScrollOffsetClamping {
+        ScrollOffsetUnclamped,
+        ScrollOffsetClamped
+    };
+    void scrollToOffset(int x, int y, ScrollOffsetClamping = ScrollOffsetUnclamped);
+    void scrollToXOffset(int x, ScrollOffsetClamping clamp = ScrollOffsetUnclamped) { scrollToOffset(x, scrollYOffset(), clamp); }
+    void scrollToYOffset(int y, ScrollOffsetClamping clamp = ScrollOffsetUnclamped) { scrollToOffset(scrollXOffset(), y, clamp); }
+
     void scrollRectToVisible(const IntRect&, const ScrollAlignment& alignX = ScrollAlignment::alignCenterIfNeeded, const ScrollAlignment& alignY = ScrollAlignment::alignCenterIfNeeded);
 
     IntRect getRectToExpose(const IntRect& visibleRect, const IntRect& exposeRect, const ScrollAlignment& alignX, const ScrollAlignment& alignY);

Modified: trunk/Source/WebCore/rendering/RenderTextControlSingleLine.cpp (90058 => 90059)


--- trunk/Source/WebCore/rendering/RenderTextControlSingleLine.cpp	2011-06-29 22:53:15 UTC (rev 90058)
+++ trunk/Source/WebCore/rendering/RenderTextControlSingleLine.cpp	2011-06-29 22:56:54 UTC (rev 90059)
@@ -401,7 +401,7 @@
     if (event->type() == eventNames().blurEvent) {
         if (innerTextRenderer) {
             if (RenderLayer* innerLayer = innerTextRenderer->layer())
-                innerLayer->scrollToOffset(!style()->isLeftToRightDirection() ? innerLayer->scrollWidth() : 0, 0);
+                innerLayer->scrollToOffset(!style()->isLeftToRightDirection() ? innerLayer->scrollWidth() : 0, 0, RenderLayer::ScrollOffsetClamped);
         }
 
         capsLockStateMayHaveChanged();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to