Rename documentScrollOffsetRelativeTo* functions
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 1 Jan 2016 03:17:31 +0000 (03:17 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 1 Jan 2016 03:17:31 +0000 (03:17 +0000)
https://bugs.webkit.org/show_bug.cgi?id=152632

Reviewed by Zalan Bujtas.

ScrollView::documentScrollOffsetRelativeTo* functions return scroll positions,
not offsets, so rename them and fix their return types, and fix callers. Make
their code more similar.

Source/WebCore:

* platform/ScrollView.cpp:
(WebCore::ScrollView::documentScrollPositionRelativeToViewOrigin):
(WebCore::ScrollView::documentScrollPositionRelativeToScrollableAreaOrigin):
(WebCore::ScrollView::viewToContents):
(WebCore::ScrollView::contentsToView):
(WebCore::ScrollView::documentScrollOffsetRelativeToViewOrigin): Deleted.
(WebCore::ScrollView::documentScrollOffsetRelativeToScrollableAreaOrigin): Deleted.
* platform/ScrollView.h:
* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::calculateBackgroundImageGeometry):
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::scrollRectToVisible):

Source/WebKit2:

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::determinePrimarySnapshottedPlugIn):
(WebKit::WebPage::plugInIntersectsSearchRect):

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

Source/WebCore/ChangeLog
Source/WebCore/platform/ScrollView.cpp
Source/WebCore/platform/ScrollView.h
Source/WebCore/rendering/RenderBoxModelObject.cpp
Source/WebCore/rendering/RenderLayer.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/WebPage/WebPage.cpp

index 61c5ad0..0860edd 100644 (file)
@@ -1,5 +1,29 @@
 2015-12-31  Simon Fraser  <simon.fraser@apple.com>
 
+        Rename documentScrollOffsetRelativeTo* functions
+        https://bugs.webkit.org/show_bug.cgi?id=152632
+
+        Reviewed by Zalan Bujtas.
+
+        ScrollView::documentScrollOffsetRelativeTo* functions return scroll positions,
+        not offsets, so rename them and fix their return types, and fix callers. Make
+        their code more similar.
+
+        * platform/ScrollView.cpp:
+        (WebCore::ScrollView::documentScrollPositionRelativeToViewOrigin):
+        (WebCore::ScrollView::documentScrollPositionRelativeToScrollableAreaOrigin):
+        (WebCore::ScrollView::viewToContents):
+        (WebCore::ScrollView::contentsToView):
+        (WebCore::ScrollView::documentScrollOffsetRelativeToViewOrigin): Deleted.
+        (WebCore::ScrollView::documentScrollOffsetRelativeToScrollableAreaOrigin): Deleted.
+        * platform/ScrollView.h:
+        * rendering/RenderBoxModelObject.cpp:
+        (WebCore::RenderBoxModelObject::calculateBackgroundImageGeometry):
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::scrollRectToVisible):
+
+2015-12-31  Simon Fraser  <simon.fraser@apple.com>
+
         [iOS WK2] Fix incorrect scrollPosition handling
         https://bugs.webkit.org/show_bug.cgi?id=152630
 
index 7597bf0..a35a341 100644 (file)
@@ -402,20 +402,14 @@ ScrollPosition ScrollView::adjustScrollPositionWithinRange(const ScrollPosition&
     return scrollPoint.constrainedBetween(minimumScrollPosition(), maximumScrollPosition());
 }
 
-IntSize ScrollView::documentScrollOffsetRelativeToViewOrigin() const
+ScrollPosition ScrollView::documentScrollPositionRelativeToViewOrigin() const
 {
-    return toIntSize(scrollPosition()) - IntSize(0, headerHeight() + topContentInset(TopContentInsetType::WebCoreOrPlatformContentInset));
+    return scrollPosition() - IntSize(0, headerHeight() + topContentInset(TopContentInsetType::WebCoreOrPlatformContentInset));
 }
 
-IntPoint ScrollView::documentScrollPositionRelativeToViewOrigin() const
+ScrollPosition ScrollView::documentScrollPositionRelativeToScrollableAreaOrigin() const
 {
-    IntPoint scrollPosition = this->scrollPosition();
-    return IntPoint(scrollPosition.x(), scrollPosition.y() - headerHeight() - topContentInset(TopContentInsetType::WebCoreOrPlatformContentInset));
-}
-
-IntSize ScrollView::documentScrollOffsetRelativeToScrollableAreaOrigin() const
-{
-    return toIntSize(scrollPosition()) - IntSize(0, headerHeight());
+    return scrollPosition() - IntSize(0, headerHeight());
 }
 
 int ScrollView::scrollSize(ScrollbarOrientation orientation) const
@@ -841,23 +835,23 @@ void ScrollView::scrollContentsSlowPath(const IntRect& updateRect)
 
 IntPoint ScrollView::viewToContents(const IntPoint& point) const
 {
-    return point + documentScrollOffsetRelativeToViewOrigin();
+    return point + toIntSize(documentScrollPositionRelativeToViewOrigin());
 }
 
 IntPoint ScrollView::contentsToView(const IntPoint& point) const
 {
-    return point - documentScrollOffsetRelativeToViewOrigin();
+    return point - toIntSize(documentScrollPositionRelativeToViewOrigin());
 }
 
 IntRect ScrollView::viewToContents(IntRect rect) const
 {
-    rect.move(documentScrollOffsetRelativeToViewOrigin());
+    rect.moveBy(documentScrollPositionRelativeToViewOrigin());
     return rect;
 }
 
 IntRect ScrollView::contentsToView(IntRect rect) const
 {
-    rect.move(-documentScrollOffsetRelativeToViewOrigin());
+    rect.moveBy(-documentScrollPositionRelativeToViewOrigin());
     return rect;
 }
 
index 7ea30a2..641f6f4 100644 (file)
@@ -248,18 +248,17 @@ public:
     // scrollOffset() anchors its (0,0) point at the ScrollableArea's origin. When the Page has a
     // header, the header is positioned at (0,0), ABOVE the start of the Document. So when a page with
     // a header is pinned to the top, the scrollOffset() is (0,0), but the Document is actually at
-    // (0, -headerHeight()). documentScrollOffsetRelativeToScrollableAreaOrigin() will return this
+    // (0, -headerHeight()). documentScrollPositionRelativeToScrollableAreaOrigin() will return this
     // version of the offset, which tracks the top of Document relative to where scrolling was achored.
-    IntSize documentScrollOffsetRelativeToScrollableAreaOrigin() const;
+    ScrollPosition documentScrollPositionRelativeToScrollableAreaOrigin() const;
 
-    // scrollOffset() anchors its (0,0) point at the ScrollableArea's origin. The top of the scrolling
+    // scrollPostion() anchors its (0,0) point at the ScrollableArea's origin. The top of the scrolling
     // layer does not represent the top of the view when there is a topContentInset. Additionally, as
     // detailed above, the origin of the scrolling layer also does not necessarily correspond with the
-    // top of the document anyway, since there could also be header. documentScrollOffsetRelativeToViewOrigin()
+    // top of the document anyway, since there could also be header. documentScrollPositionRelativeToViewOrigin()
     // will return a version of the current scroll offset which tracks the top of the Document
     // relative to the very top of the view.
-    WEBCORE_EXPORT IntSize documentScrollOffsetRelativeToViewOrigin() const;
-    IntPoint documentScrollPositionRelativeToViewOrigin() const;
+    WEBCORE_EXPORT ScrollPosition documentScrollPositionRelativeToViewOrigin() const;
 
     virtual IntSize overhangAmount() const override;
 
index 040a025..1931449 100644 (file)
@@ -1115,10 +1115,10 @@ BackgroundImageGeometry RenderBoxModelObject::calculateBackgroundImageGeometry(c
                 // topContentInset so do not add it to the calculation below.
                 viewportRect.setLocation(frameView.scrollPositionForFixedPosition());
             } else {
-                // documentScrollOffsetRelativeToViewOrigin() includes -topContentInset in its height
+                // documentScrollPositionRelativeToViewOrigin() includes -topContentInset in its height
                 // so we need to account for that in calculating the phase size
                 topContentInset = frameView.topContentInset(ScrollView::TopContentInsetType::WebCoreOrPlatformContentInset);
-                viewportRect.setLocation(toLayoutPoint(frameView.documentScrollOffsetRelativeToViewOrigin()));
+                viewportRect.setLocation(frameView.documentScrollPositionRelativeToViewOrigin());
             }
 
             top += topContentInset;
index 228abd1..4e46236 100644 (file)
@@ -2524,8 +2524,7 @@ void RenderLayer::scrollRectToVisible(const LayoutRect& rect, const ScrollAlignm
 #if !PLATFORM(IOS)
             LayoutRect viewRect = frameView.visibleContentRect();
             LayoutRect visibleRectRelativeToDocument = viewRect;
-            IntSize documentScrollOffsetRelativeToScrollableAreaOrigin = frameView.documentScrollOffsetRelativeToScrollableAreaOrigin();
-            visibleRectRelativeToDocument.setLocation(IntPoint(documentScrollOffsetRelativeToScrollableAreaOrigin.width(), documentScrollOffsetRelativeToScrollableAreaOrigin.height()));
+            visibleRectRelativeToDocument.setLocation(frameView.documentScrollPositionRelativeToScrollableAreaOrigin());
 #else
             LayoutRect viewRect = frameView.unobscuredContentRect();
             LayoutRect visibleRectRelativeToDocument = viewRect;
index 894bb77..6916397 100644 (file)
@@ -1,5 +1,20 @@
 2015-12-31  Simon Fraser  <simon.fraser@apple.com>
 
+        Rename documentScrollOffsetRelativeTo* functions
+        https://bugs.webkit.org/show_bug.cgi?id=152632
+
+        Reviewed by Zalan Bujtas.
+
+        ScrollView::documentScrollOffsetRelativeTo* functions return scroll positions,
+        not offsets, so rename them and fix their return types, and fix callers. Make
+        their code more similar.
+
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::determinePrimarySnapshottedPlugIn):
+        (WebKit::WebPage::plugInIntersectsSearchRect):
+
+2015-12-31  Simon Fraser  <simon.fraser@apple.com>
+
         [iOS WK2] Fix incorrect scrollPosition handling
         https://bugs.webkit.org/show_bug.cgi?id=152630
 
index 8d9af8a..58d3ffa 100644 (file)
@@ -4799,8 +4799,8 @@ void WebPage::determinePrimarySnapshottedPlugIn()
                 continue;
 
             IntRect plugInRectRelativeToView = plugInImageElement.clientRect();
-            IntSize scrollOffset = mainFrame.view()->documentScrollOffsetRelativeToViewOrigin();
-            IntRect plugInRectRelativeToTopDocument(plugInRectRelativeToView.location() + scrollOffset, plugInRectRelativeToView.size());
+            ScrollPosition scrollPosition = mainFrame.view()->documentScrollPositionRelativeToViewOrigin();
+            IntRect plugInRectRelativeToTopDocument(plugInRectRelativeToView.location() + scrollPosition, plugInRectRelativeToView.size());
             HitTestResult hitTestResult(plugInRectRelativeToTopDocument.center());
             mainRenderView.hitTest(request, hitTestResult);
 
@@ -4809,7 +4809,7 @@ void WebPage::determinePrimarySnapshottedPlugIn()
                 continue;
 
             IntRect elementRectRelativeToView = element->clientRect();
-            IntRect elementRectRelativeToTopDocument(elementRectRelativeToView.location() + scrollOffset, elementRectRelativeToView.size());
+            IntRect elementRectRelativeToTopDocument(elementRectRelativeToView.location() + scrollPosition, elementRectRelativeToView.size());
             LayoutRect inflatedPluginRect = plugInRectRelativeToTopDocument;
             LayoutUnit xOffset = (inflatedPluginRect.width() * overlappingImageBoundsScale - inflatedPluginRect.width()) / 2;
             LayoutUnit yOffset = (inflatedPluginRect.height() * overlappingImageBoundsScale - inflatedPluginRect.height()) / 2;
@@ -4878,8 +4878,8 @@ bool WebPage::plugInIntersectsSearchRect(HTMLPlugInImageElement& plugInImageElem
     IntRect plugInRectRelativeToView = plugInImageElement.clientRect();
     if (plugInRectRelativeToView.isEmpty())
         return false;
-    IntSize scrollOffset = mainFrame.view()->documentScrollOffsetRelativeToViewOrigin();
-    IntRect plugInRectRelativeToTopDocument(plugInRectRelativeToView.location() + scrollOffset, plugInRectRelativeToView.size());
+    ScrollPosition scrollPosition = mainFrame.view()->documentScrollPositionRelativeToViewOrigin();
+    IntRect plugInRectRelativeToTopDocument(plugInRectRelativeToView.location() + toIntSize(scrollPosition), plugInRectRelativeToView.size());
 
     return plugInRectRelativeToTopDocument.intersects(searchRect);
 }