Title: [194478] trunk/Source/WebCore
Revision
194478
Author
[email protected]
Date
2015-12-31 23:53:30 -0800 (Thu, 31 Dec 2015)

Log Message

Change RenderLayer::scrollTo() to take a ScrollPosition
https://bugs.webkit.org/show_bug.cgi?id=152633

Reviewed by Zalan Bujtas.

RenderLayer::scrollTo() took x and y offsets. Change this to take a position,
like ScrollView::scrollTo() and fix the one caller.

Preserve the dubious behavior of the adjustForIOSCaretWhenScrolling() code by converting
to and from offsets, even though testing suggests that this code can just be removed,
even with an extra wide caret for testing.

* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::scrollTo):
(WebCore::RenderLayer::setScrollOffset):
* rendering/RenderLayer.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (194477 => 194478)


--- trunk/Source/WebCore/ChangeLog	2016-01-01 03:17:31 UTC (rev 194477)
+++ trunk/Source/WebCore/ChangeLog	2016-01-01 07:53:30 UTC (rev 194478)
@@ -1,5 +1,24 @@
 2015-12-31  Simon Fraser  <[email protected]>
 
+        Change RenderLayer::scrollTo() to take a ScrollPosition
+        https://bugs.webkit.org/show_bug.cgi?id=152633
+
+        Reviewed by Zalan Bujtas.
+        
+        RenderLayer::scrollTo() took x and y offsets. Change this to take a position,
+        like ScrollView::scrollTo() and fix the one caller.
+        
+        Preserve the dubious behavior of the adjustForIOSCaretWhenScrolling() code by converting
+        to and from offsets, even though testing suggests that this code can just be removed,
+        even with an extra wide caret for testing.
+
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::scrollTo):
+        (WebCore::RenderLayer::setScrollOffset):
+        * rendering/RenderLayer.h:
+
+2015-12-31  Simon Fraser  <[email protected]>
+
         Rename documentScrollOffsetRelativeTo* functions
         https://bugs.webkit.org/show_bug.cgi?id=152632
 

Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (194477 => 194478)


--- trunk/Source/WebCore/rendering/RenderLayer.cpp	2016-01-01 03:17:31 UTC (rev 194477)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp	2016-01-01 07:53:30 UTC (rev 194478)
@@ -2326,38 +2326,37 @@
         scrollToOffsetWithoutAnimation(newScrollOffset);
 }
 
-// x and y are scroll offset values
-// FIXME: use a ScrollOffset, or change this to take a ScrollPosition.
-void RenderLayer::scrollTo(int x, int y)
+void RenderLayer::scrollTo(const ScrollPosition& position)
 {
     RenderBox* box = renderBox();
     if (!box)
         return;
 
+    ScrollPosition newPosition = position;
     if (box->style().overflowX() != OMARQUEE) {
         // Ensure that the dimensions will be computed if they need to be (for overflow:hidden blocks).
         if (m_scrollDimensionsDirty)
             computeScrollDimensions();
 #if PLATFORM(IOS)
         if (adjustForIOSCaretWhenScrolling()) {
-            int maxX = scrollWidth() - box->clientWidth();
-            if (x > maxX - caretWidth) {
-                x += caretWidth;
-                if (x <= caretWidth)
-                    x = 0;
-            } else if (x < m_scrollPosition.x() - caretWidth)
-                x -= caretWidth;
+            // FIXME: It's not clear what this code is trying to do. Behavior seems reasonable with it removed.
+            int maxOffset = scrollWidth() - box->clientWidth();
+            ScrollOffset newOffset = scrollOffsetFromPosition(newPosition);
+            int scrollXOffset = newOffset.x();
+            if (scrollXOffset > maxOffset - caretWidth) {
+                scrollXOffset += caretWidth;
+                if (scrollXOffset <= caretWidth)
+                    scrollXOffset = 0;
+            } else if (scrollXOffset < m_scrollPosition.x() - caretWidth)
+                scrollXOffset -= caretWidth;
+
+            newOffset.setX(scrollXOffset);
+            newPosition = scrollPositionFromOffset(newOffset);
         }
 #endif
     }
     
-    // FIXME: Eventually, we will want to perform a blit.  For now never
-    // blit, since the check for blitting is going to be very
-    // complicated (since it will involve testing whether our layer
-    // is either occluded by another layer or clipped by an enclosing
-    // layer or contains fixed backgrounds, etc.).
-    ScrollPosition newScrollPosition = scrollPositionFromOffset(ScrollOffset(x, y));
-    if (m_scrollPosition == newScrollPosition) {
+    if (m_scrollPosition == newPosition) {
 #if PLATFORM(IOS)
         if (m_requiresScrollBoundsOriginUpdate)
             updateCompositingLayersAfterScroll();
@@ -2366,7 +2365,7 @@
     }
     
     ScrollPosition oldPosition = IntPoint(m_scrollPosition);
-    m_scrollPosition = newScrollPosition;
+    m_scrollPosition = newPosition;
 
     RenderView& view = renderer().view();
 
@@ -2417,7 +2416,7 @@
     // Schedule the scroll and scroll-related DOM events.
     if (Element* element = renderer().element()) {
         element->document().eventQueue().enqueueOrDispatchScrollEvent(*element);
-        element->document().sendWillRevealEdgeEventsIfNeeded(oldPosition, newScrollPosition, visibleContentRect(), contentsSize(), element);
+        element->document().sendWillRevealEdgeEventsIfNeeded(oldPosition, newPosition, visibleContentRect(), contentsSize(), element);
     }
 
     if (scrollsOverflow())
@@ -2719,9 +2718,9 @@
     return scrollbar ? (scrollbar->totalSize() - scrollbar->visibleSize()) : 0;
 }
 
-void RenderLayer::setScrollOffset(const IntPoint& offset)
+void RenderLayer::setScrollOffset(const ScrollOffset& offset)
 {
-    scrollTo(offset.x(), offset.y());
+    scrollTo(scrollPositionFromOffset(offset));
 }
 
 int RenderLayer::scrollPosition(Scrollbar* scrollbar) const

Modified: trunk/Source/WebCore/rendering/RenderLayer.h (194477 => 194478)


--- trunk/Source/WebCore/rendering/RenderLayer.h	2016-01-01 03:17:31 UTC (rev 194477)
+++ trunk/Source/WebCore/rendering/RenderLayer.h	2016-01-01 07:53:30 UTC (rev 194478)
@@ -863,7 +863,7 @@
     virtual IntPoint convertFromScrollbarToContainingView(const Scrollbar*, const IntPoint&) const override;
     virtual IntPoint convertFromContainingViewToScrollbar(const Scrollbar*, const IntPoint&) const override;
     virtual int scrollSize(ScrollbarOrientation) const override;
-    virtual void setScrollOffset(const IntPoint&) override;
+    virtual void setScrollOffset(const ScrollOffset&) override;
 
     virtual ScrollPosition scrollPosition() const override { return m_scrollPosition; }
     virtual ScrollPosition maximumScrollPosition() const override;
@@ -892,7 +892,7 @@
     LayoutRect scrollCornerAndResizerRect() const;
 
     // NOTE: This should only be called by the overriden setScrollOffset from ScrollableArea.
-    void scrollTo(int, int);
+    void scrollTo(const ScrollPosition&);
     void updateCompositingLayersAfterScroll();
 
     IntSize scrollbarOffset(const Scrollbar*) const;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to