<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[194448] trunk/Source</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/194448">194448</a></dd>
<dt>Author</dt> <dd>simon.fraser@apple.com</dd>
<dt>Date</dt> <dd>2015-12-30 12:15:27 -0800 (Wed, 30 Dec 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Add explicit conversions between scrollOffset and scrollPostion, and use them in a few places
https://bugs.webkit.org/show_bug.cgi?id=152594

Reviewed by Sam Weinig.

Add functions to ScrollableArea to convert between scrollPosition and scrollOffset,
and use them in places where code did the math with scrollOrigin.

Source/WebCore:

* page/FrameView.cpp:
(WebCore::FrameView::minimumScrollPosition):
(WebCore::FrameView::maximumScrollPosition): totalContentsSize().width() == contentsWidth(),
so we can use the base class maximumScrollPosition(), which also clamps.
* platform/ScrollView.cpp:
(WebCore::ScrollView::maximumScrollPosition):
(WebCore::ScrollView::setScrollOffset):
(WebCore::ScrollView::overhangAmount):
(WebCore::ScrollView::updateScrollbars):
(WebCore::ScrollView::calculateOverhangAreasForPainting):
(WebCore::ScrollView::minimumScrollPosition): Deleted. Can use base class implementation.
* platform/ScrollView.h:
* platform/ScrollableArea.cpp:
(WebCore::ScrollableArea::minimumScrollPosition):
(WebCore::ScrollableArea::maximumScrollPosition):
(WebCore::ScrollableArea::maximumScrollOffset):
(WebCore::ScrollableArea::scrollPositionFromOffset):
(WebCore::ScrollableArea::scrollOffsetFromPosition):
* platform/ScrollableArea.h:
(WebCore::ScrollableArea::scrollOrigin):
(WebCore::ScrollableArea::scrollOriginChanged):
* platform/ios/ScrollViewIOS.mm:
(WebCore::ScrollView::unobscuredContentRect):
* platform/mac/ScrollAnimatorMac.mm:
(WebCore::ScrollAnimatorMac::pinnedInDirection):
(WebCore::ScrollAnimatorMac::absoluteScrollPosition):
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::scrollPosition):
(WebCore::RenderLayer::maximumScrollPosition):
(WebCore::RenderLayer::overhangAmount):
(WebCore::RenderLayer::minimumScrollPosition): Deleted.
* rendering/RenderLayer.h:

Source/WebKit2:

* WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm:
(WebKit::RemoteLayerTreeDrawingArea::updateScrolledExposedRect):
* WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
(WebKit::TiledCoreAnimationDrawingArea::updateScrolledExposedRect):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorepageFrameViewcpp">trunk/Source/WebCore/page/FrameView.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformScrollViewcpp">trunk/Source/WebCore/platform/ScrollView.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformScrollViewh">trunk/Source/WebCore/platform/ScrollView.h</a></li>
<li><a href="#trunkSourceWebCoreplatformScrollableAreacpp">trunk/Source/WebCore/platform/ScrollableArea.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformScrollableAreah">trunk/Source/WebCore/platform/ScrollableArea.h</a></li>
<li><a href="#trunkSourceWebCoreplatformiosScrollViewIOSmm">trunk/Source/WebCore/platform/ios/ScrollViewIOS.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformmacScrollAnimatorMacmm">trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderLayercpp">trunk/Source/WebCore/rendering/RenderLayer.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderLayerh">trunk/Source/WebCore/rendering/RenderLayer.h</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPagemacRemoteLayerTreeDrawingAreamm">trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPagemacTiledCoreAnimationDrawingAreamm">trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (194447 => 194448)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-12-30 17:19:03 UTC (rev 194447)
+++ trunk/Source/WebCore/ChangeLog        2015-12-30 20:15:27 UTC (rev 194448)
</span><span class="lines">@@ -1,3 +1,46 @@
</span><ins>+2015-12-30  Simon Fraser  &lt;simon.fraser@apple.com&gt;
+
+        Add explicit conversions between scrollOffset and scrollPostion, and use them in a few places
+        https://bugs.webkit.org/show_bug.cgi?id=152594
+
+        Reviewed by Sam Weinig.
+
+        Add functions to ScrollableArea to convert between scrollPosition and scrollOffset,
+        and use them in places where code did the math with scrollOrigin.
+
+        * page/FrameView.cpp:
+        (WebCore::FrameView::minimumScrollPosition):
+        (WebCore::FrameView::maximumScrollPosition): totalContentsSize().width() == contentsWidth(),
+        so we can use the base class maximumScrollPosition(), which also clamps.
+        * platform/ScrollView.cpp:
+        (WebCore::ScrollView::maximumScrollPosition):
+        (WebCore::ScrollView::setScrollOffset):
+        (WebCore::ScrollView::overhangAmount):
+        (WebCore::ScrollView::updateScrollbars):
+        (WebCore::ScrollView::calculateOverhangAreasForPainting):
+        (WebCore::ScrollView::minimumScrollPosition): Deleted. Can use base class implementation.
+        * platform/ScrollView.h:
+        * platform/ScrollableArea.cpp:
+        (WebCore::ScrollableArea::minimumScrollPosition):
+        (WebCore::ScrollableArea::maximumScrollPosition):
+        (WebCore::ScrollableArea::maximumScrollOffset):
+        (WebCore::ScrollableArea::scrollPositionFromOffset):
+        (WebCore::ScrollableArea::scrollOffsetFromPosition):
+        * platform/ScrollableArea.h:
+        (WebCore::ScrollableArea::scrollOrigin):
+        (WebCore::ScrollableArea::scrollOriginChanged):
+        * platform/ios/ScrollViewIOS.mm:
+        (WebCore::ScrollView::unobscuredContentRect):
+        * platform/mac/ScrollAnimatorMac.mm:
+        (WebCore::ScrollAnimatorMac::pinnedInDirection):
+        (WebCore::ScrollAnimatorMac::absoluteScrollPosition):
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::scrollPosition):
+        (WebCore::RenderLayer::maximumScrollPosition):
+        (WebCore::RenderLayer::overhangAmount):
+        (WebCore::RenderLayer::minimumScrollPosition): Deleted.
+        * rendering/RenderLayer.h:
+
</ins><span class="cx"> 2015-12-30  Zalan Bujtas  &lt;zalan@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Move InlineTextBox's text decoration painting to its own class.
</span></span></pre></div>
<a id="trunkSourceWebCorepageFrameViewcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/FrameView.cpp (194447 => 194448)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/FrameView.cpp        2015-12-30 17:19:03 UTC (rev 194447)
+++ trunk/Source/WebCore/page/FrameView.cpp        2015-12-30 20:15:27 UTC (rev 194448)
</span><span class="lines">@@ -1853,9 +1853,9 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx">     
</span><del>-IntPoint FrameView::minimumScrollPosition() const
</del><ins>+ScrollPosition FrameView::minimumScrollPosition() const
</ins><span class="cx"> {
</span><del>-    IntPoint minimumPosition(ScrollView::minimumScrollPosition());
</del><ins>+    ScrollPosition minimumPosition = ScrollView::minimumScrollPosition();
</ins><span class="cx"> 
</span><span class="cx">     if (frame().isMainFrame() &amp;&amp; m_scrollPinningBehavior == PinToBottom)
</span><span class="cx">         minimumPosition.setY(maximumScrollPosition().y());
</span><span class="lines">@@ -1863,16 +1863,14 @@
</span><span class="cx">     return minimumPosition;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-IntPoint FrameView::maximumScrollPosition() const
</del><ins>+ScrollPosition FrameView::maximumScrollPosition() const
</ins><span class="cx"> {
</span><del>-    IntPoint maximumOffset(contentsWidth() - visibleWidth() - scrollOrigin().x(), totalContentsSize().height() - visibleHeight() - scrollOrigin().y());
</del><ins>+    ScrollPosition maximumPosition = ScrollView::maximumScrollPosition();
</ins><span class="cx"> 
</span><del>-    maximumOffset.clampNegativeToZero();
-
</del><span class="cx">     if (frame().isMainFrame() &amp;&amp; m_scrollPinningBehavior == PinToTop)
</span><del>-        maximumOffset.setY(minimumScrollPosition().y());
</del><ins>+        maximumPosition.setY(minimumScrollPosition().y());
</ins><span class="cx">     
</span><del>-    return maximumOffset;
</del><ins>+    return maximumPosition;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void FrameView::viewportContentsChanged()
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformScrollViewcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ScrollView.cpp (194447 => 194448)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ScrollView.cpp        2015-12-30 17:19:03 UTC (rev 194447)
+++ trunk/Source/WebCore/platform/ScrollView.cpp        2015-12-30 20:15:27 UTC (rev 194448)
</span><span class="lines">@@ -388,16 +388,12 @@
</span><span class="cx"> 
</span><span class="cx"> ScrollPosition ScrollView::maximumScrollPosition() const
</span><span class="cx"> {
</span><del>-    IntPoint maximumOffset(contentsWidth() - visibleWidth() - scrollOrigin().x(), totalContentsSize().height() - visibleHeight() - scrollOrigin().y());
-    maximumOffset.clampNegativeToZero();
-    return maximumOffset;
</del><ins>+    ScrollPosition maximumPosition = ScrollableArea::maximumScrollPosition();
+    // FIXME: can this be moved into the base class?
+    maximumPosition.clampNegativeToZero();
+    return maximumPosition;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-ScrollPosition ScrollView::minimumScrollPosition() const
-{
-    return IntPoint(-scrollOrigin().x(), -scrollOrigin().y());
-}
-
</del><span class="cx"> ScrollPosition ScrollView::adjustScrollPositionWithinRange(const ScrollPosition&amp; scrollPoint) const
</span><span class="cx"> {
</span><span class="cx">     if (!constrainsScrollingToContentEdge())
</span><span class="lines">@@ -441,18 +437,12 @@
</span><span class="cx"> 
</span><span class="cx"> void ScrollView::setScrollOffset(const IntPoint&amp; offset)
</span><span class="cx"> {
</span><del>-    int horizontalOffset = offset.x();
-    int verticalOffset = offset.y();
-    if (constrainsScrollingToContentEdge()) {
-        horizontalOffset = std::max(std::min(horizontalOffset, contentsWidth() - visibleWidth()), 0);
-        verticalOffset = std::max(std::min(verticalOffset, totalContentsSize().height() - visibleHeight()), 0);
-    }
</del><ins>+    IntPoint constrainedOffset = offset;
+    if (constrainsScrollingToContentEdge())
+        constrainedOffset = constrainedOffset.constrainedBetween(IntPoint(), maximumScrollOffset());
</ins><span class="cx"> 
</span><del>-    IntSize newOffset = m_scrollOffset;
-    newOffset.setWidth(horizontalOffset - scrollOrigin().x());
-    newOffset.setHeight(verticalOffset - scrollOrigin().y());
-
-    scrollTo(newOffset);
</del><ins>+    ScrollPosition newPosition = scrollPositionFromOffset(constrainedOffset);
+    scrollTo(toIntSize(newPosition));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void ScrollView::scrollPositionChangedViaPlatformWidget(const IntPoint&amp; oldPosition, const IntPoint&amp; newPosition)
</span><span class="lines">@@ -567,17 +557,17 @@
</span><span class="cx"> {
</span><span class="cx">     IntSize stretch;
</span><span class="cx"> 
</span><del>-    int physicalScrollY = scrollPosition().y() + scrollOrigin().y();
-    if (physicalScrollY &lt; 0)
-        stretch.setHeight(physicalScrollY);
-    else if (totalContentsSize().height() &amp;&amp; physicalScrollY &gt; totalContentsSize().height() - visibleHeight())
-        stretch.setHeight(physicalScrollY - (totalContentsSize().height() - visibleHeight()));
</del><ins>+    // FIXME: use maximumScrollOffset()
+    ScrollOffset scrollOffset = scrollOffsetFromPosition(scrollPosition());
+    if (scrollOffset.y() &lt; 0)
+        stretch.setHeight(scrollOffset.y());
+    else if (totalContentsSize().height() &amp;&amp; scrollOffset.y() &gt; totalContentsSize().height() - visibleHeight())
+        stretch.setHeight(scrollOffset.y() - (totalContentsSize().height() - visibleHeight()));
</ins><span class="cx"> 
</span><del>-    int physicalScrollX = scrollPosition().x() + scrollOrigin().x();
-    if (physicalScrollX &lt; 0)
-        stretch.setWidth(physicalScrollX);
-    else if (contentsWidth() &amp;&amp; physicalScrollX &gt; contentsWidth() - visibleWidth())
-        stretch.setWidth(physicalScrollX - (contentsWidth() - visibleWidth()));
</del><ins>+    if (scrollOffset.x() &lt; 0)
+        stretch.setWidth(scrollOffset.x());
+    else if (contentsWidth() &amp;&amp; scrollOffset.x() &gt; contentsWidth() - visibleWidth())
+        stretch.setWidth(scrollOffset.x() - (contentsWidth() - visibleWidth()));
</ins><span class="cx"> 
</span><span class="cx">     return stretch;
</span><span class="cx"> }
</span><span class="lines">@@ -765,7 +755,7 @@
</span><span class="cx">         adjustedScrollPosition = adjustScrollPositionWithinRange(adjustedScrollPosition);
</span><span class="cx"> 
</span><span class="cx">     if (adjustedScrollPosition != scrollPosition() || scrollOriginChanged()) {
</span><del>-        ScrollableArea::scrollToOffsetWithoutAnimation(adjustedScrollPosition + toIntSize(scrollOrigin()));
</del><ins>+        ScrollableArea::scrollToOffsetWithoutAnimation(scrollOffsetFromPosition(adjustedScrollPosition));
</ins><span class="cx">         resetScrollOriginChanged();
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -1265,30 +1255,30 @@
</span><span class="cx"> {
</span><span class="cx">     IntSize scrollbarSpace = scrollbarIntrusion();
</span><span class="cx"> 
</span><del>-    int physicalScrollY = scrollPosition().y() + scrollOrigin().y();
-    if (physicalScrollY &lt; 0) {
</del><ins>+    // FIXME: use maximumScrollOffset().
+    ScrollOffset scrollOffset = scrollOffsetFromPosition(scrollPosition());
+    if (scrollOffset.y() &lt; 0) {
</ins><span class="cx">         horizontalOverhangRect = frameRect();
</span><del>-        horizontalOverhangRect.setHeight(-physicalScrollY);
</del><ins>+        horizontalOverhangRect.setHeight(-scrollOffset.y());
</ins><span class="cx">         horizontalOverhangRect.setWidth(horizontalOverhangRect.width() - scrollbarSpace.width());
</span><del>-    } else if (totalContentsSize().height() &amp;&amp; physicalScrollY &gt; totalContentsSize().height() - visibleHeight()) {
-        int height = physicalScrollY - (totalContentsSize().height() - visibleHeight());
</del><ins>+    } else if (totalContentsSize().height() &amp;&amp; scrollOffset.y() &gt; totalContentsSize().height() - visibleHeight()) {
+        int height = scrollOffset.y() - (totalContentsSize().height() - visibleHeight());
</ins><span class="cx">         horizontalOverhangRect = frameRect();
</span><span class="cx">         horizontalOverhangRect.setY(frameRect().maxY() - height - scrollbarSpace.height());
</span><span class="cx">         horizontalOverhangRect.setHeight(height);
</span><span class="cx">         horizontalOverhangRect.setWidth(horizontalOverhangRect.width() - scrollbarSpace.width());
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    int physicalScrollX = scrollPosition().x() + scrollOrigin().x();
-    if (physicalScrollX &lt; 0) {
-        verticalOverhangRect.setWidth(-physicalScrollX);
</del><ins>+    if (scrollOffset.x() &lt; 0) {
+        verticalOverhangRect.setWidth(-scrollOffset.x());
</ins><span class="cx">         verticalOverhangRect.setHeight(frameRect().height() - horizontalOverhangRect.height() - scrollbarSpace.height());
</span><span class="cx">         verticalOverhangRect.setX(frameRect().x());
</span><span class="cx">         if (horizontalOverhangRect.y() == frameRect().y())
</span><span class="cx">             verticalOverhangRect.setY(frameRect().y() + horizontalOverhangRect.height());
</span><span class="cx">         else
</span><span class="cx">             verticalOverhangRect.setY(frameRect().y());
</span><del>-    } else if (contentsWidth() &amp;&amp; physicalScrollX &gt; contentsWidth() - visibleWidth()) {
-        int width = physicalScrollX - (contentsWidth() - visibleWidth());
</del><ins>+    } else if (contentsWidth() &amp;&amp; scrollOffset.x() &gt; contentsWidth() - visibleWidth()) {
+        int width = scrollOffset.x() - (contentsWidth() - visibleWidth());
</ins><span class="cx">         verticalOverhangRect.setWidth(width);
</span><span class="cx">         verticalOverhangRect.setHeight(frameRect().height() - horizontalOverhangRect.height() - scrollbarSpace.height());
</span><span class="cx">         verticalOverhangRect.setX(frameRect().maxX() - width - scrollbarSpace.width());
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformScrollViewh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ScrollView.h (194447 => 194448)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ScrollView.h        2015-12-30 17:19:03 UTC (rev 194447)
+++ trunk/Source/WebCore/platform/ScrollView.h        2015-12-30 20:15:27 UTC (rev 194448)
</span><span class="lines">@@ -228,7 +228,6 @@
</span><span class="cx">     virtual ScrollPosition scrollPosition() const override { return visibleContentRect(LegacyIOSDocumentVisibleRect).location(); }
</span><span class="cx"> 
</span><span class="cx">     virtual ScrollPosition maximumScrollPosition() const override; // The maximum position we can be scrolled to.
</span><del>-    virtual ScrollPosition minimumScrollPosition() const override; // The minimum position we can be scrolled to.
</del><span class="cx"> 
</span><span class="cx">     // Adjust the passed in scroll position to keep it between the minimum and maximum positions.
</span><span class="cx">     ScrollPosition adjustScrollPositionWithinRange(const ScrollPosition&amp;) const;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformScrollableAreacpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ScrollableArea.cpp (194447 => 194448)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ScrollableArea.cpp        2015-12-30 17:19:03 UTC (rev 194447)
+++ trunk/Source/WebCore/platform/ScrollableArea.cpp        2015-12-30 20:15:27 UTC (rev 194448)
</span><span class="lines">@@ -534,14 +534,29 @@
</span><span class="cx"> 
</span><span class="cx"> ScrollPosition ScrollableArea::minimumScrollPosition() const
</span><span class="cx"> {
</span><del>-    return IntPoint();
</del><ins>+    return scrollPositionFromOffset(ScrollPosition());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> ScrollPosition ScrollableArea::maximumScrollPosition() const
</span><span class="cx"> {
</span><del>-    return IntPoint(totalContentsSize().width() - visibleWidth(), totalContentsSize().height() - visibleHeight());
</del><ins>+    return scrollPositionFromOffset(ScrollPosition(totalContentsSize() - visibleSize()));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+ScrollOffset ScrollableArea::maximumScrollOffset() const
+{
+    return ScrollOffset(totalContentsSize() - visibleSize());
+}
+
+ScrollPosition ScrollableArea::scrollPositionFromOffset(ScrollOffset offset) const
+{
+    return IntPoint(toIntSize(offset) - toIntSize(m_scrollOrigin));
+}
+
+ScrollOffset ScrollableArea::scrollOffsetFromPosition(ScrollPosition position) const
+{
+    return IntPoint(toIntSize(position) + toIntSize(m_scrollOrigin));
+}
+
</ins><span class="cx"> bool ScrollableArea::scrolledToTop() const
</span><span class="cx"> {
</span><span class="cx">     return scrollPosition().y() &lt;= minimumScrollPosition().y();
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformScrollableAreah"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ScrollableArea.h (194447 => 194448)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ScrollableArea.h        2015-12-30 17:19:03 UTC (rev 194447)
+++ trunk/Source/WebCore/platform/ScrollableArea.h        2015-12-30 20:15:27 UTC (rev 194448)
</span><span class="lines">@@ -144,9 +144,6 @@
</span><span class="cx">     // This getter will return null if the ScrollAnimator hasn't been created yet.
</span><span class="cx">     ScrollAnimator* existingScrollAnimator() const { return m_scrollAnimator.get(); }
</span><span class="cx"> 
</span><del>-    const IntPoint&amp; scrollOrigin() const { return m_scrollOrigin; }
-    bool scrollOriginChanged() const { return m_scrollOriginChanged; }
-
</del><span class="cx">     virtual bool isActive() const = 0;
</span><span class="cx">     virtual int scrollSize(ScrollbarOrientation) const = 0;
</span><span class="cx">     virtual int scrollPosition(Scrollbar*) const = 0;
</span><span class="lines">@@ -184,10 +181,18 @@
</span><span class="cx">     virtual Scrollbar* horizontalScrollbar() const { return 0; }
</span><span class="cx">     virtual Scrollbar* verticalScrollbar() const { return 0; }
</span><span class="cx"> 
</span><ins>+    const IntPoint&amp; scrollOrigin() const { return m_scrollOrigin; }
+    bool scrollOriginChanged() const { return m_scrollOriginChanged; }
+
</ins><span class="cx">     virtual ScrollPosition scrollPosition() const;
</span><span class="cx">     virtual ScrollPosition minimumScrollPosition() const;
</span><span class="cx">     virtual ScrollPosition maximumScrollPosition() const;
</span><span class="cx"> 
</span><ins>+    ScrollOffset maximumScrollOffset() const;
+
+    WEBCORE_EXPORT ScrollPosition scrollPositionFromOffset(ScrollOffset) const;
+    WEBCORE_EXPORT ScrollOffset scrollOffsetFromPosition(ScrollPosition) const;
+
</ins><span class="cx">     WEBCORE_EXPORT virtual bool scrolledToTop() const;
</span><span class="cx">     WEBCORE_EXPORT virtual bool scrolledToBottom() const;
</span><span class="cx">     WEBCORE_EXPORT virtual bool scrolledToLeft() const;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosScrollViewIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/ScrollViewIOS.mm (194447 => 194448)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/ScrollViewIOS.mm        2015-12-30 17:19:03 UTC (rev 194447)
+++ trunk/Source/WebCore/platform/ios/ScrollViewIOS.mm        2015-12-30 20:15:27 UTC (rev 194448)
</span><span class="lines">@@ -107,8 +107,10 @@
</span><span class="cx">         return enclosingIntRect(r);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (!m_unobscuredContentSize.isEmpty())
</del><ins>+    if (!m_unobscuredContentSize.isEmpty()) {
+        // FIXME: is this correct in RTL documents?
</ins><span class="cx">         return IntRect(scrollOrigin() + m_scrollOffset, roundedIntSize(m_unobscuredContentSize));
</span><ins>+    }
</ins><span class="cx"> 
</span><span class="cx">     return unobscuredContentRectInternal();
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmacScrollAnimatorMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm (194447 => 194448)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm        2015-12-30 17:19:03 UTC (rev 194447)
+++ trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm        2015-12-30 20:15:27 UTC (rev 194448)
</span><span class="lines">@@ -1154,18 +1154,18 @@
</span><span class="cx">     FloatSize limitDelta;
</span><span class="cx">     if (fabsf(direction.height()) &gt;= fabsf(direction.width())) {
</span><span class="cx">         if (direction.height() &lt; 0) {
</span><del>-            // We are trying to scroll up.  Make sure we are not pinned to the top
</del><ins>+            // We are trying to scroll up. Make sure we are not pinned to the top
</ins><span class="cx">             limitDelta.setHeight(m_scrollableArea.visibleContentRect().y() + m_scrollableArea.scrollOrigin().y());
</span><span class="cx">         } else {
</span><del>-            // We are trying to scroll down.  Make sure we are not pinned to the bottom
</del><ins>+            // We are trying to scroll down. Make sure we are not pinned to the bottom
</ins><span class="cx">             limitDelta.setHeight(m_scrollableArea.totalContentsSize().height() - (m_scrollableArea.visibleContentRect().maxY() + m_scrollableArea.scrollOrigin().y()));
</span><span class="cx">         }
</span><span class="cx">     } else if (direction.width()) {
</span><span class="cx">         if (direction.width() &lt; 0) {
</span><del>-            // We are trying to scroll left.  Make sure we are not pinned to the left
</del><ins>+            // We are trying to scroll left. Make sure we are not pinned to the left
</ins><span class="cx">             limitDelta.setWidth(m_scrollableArea.visibleContentRect().x() + m_scrollableArea.scrollOrigin().x());
</span><span class="cx">         } else {
</span><del>-            // We are trying to scroll right.  Make sure we are not pinned to the right
</del><ins>+            // We are trying to scroll right. Make sure we are not pinned to the right
</ins><span class="cx">             limitDelta.setWidth(m_scrollableArea.totalContentsSize().width() - (m_scrollableArea.visibleContentRect().maxX() + m_scrollableArea.scrollOrigin().x()));
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="lines">@@ -1284,7 +1284,8 @@
</span><span class="cx"> 
</span><span class="cx"> IntPoint ScrollAnimatorMac::absoluteScrollPosition()
</span><span class="cx"> {
</span><del>-    return m_scrollableArea.visibleContentRect().location() + m_scrollableArea.scrollOrigin();
</del><ins>+    // FIXME: can this use m_scrollableArea.scrollPosition()?
+    return m_scrollableArea.scrollOffsetFromPosition(m_scrollableArea.visibleContentRect().location());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void ScrollAnimatorMac::immediateScrollByWithoutContentEdgeConstraints(const FloatSize&amp; delta)
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderLayercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (194447 => 194448)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderLayer.cpp        2015-12-30 17:19:03 UTC (rev 194447)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp        2015-12-30 20:15:27 UTC (rev 194448)
</span><span class="lines">@@ -2742,18 +2742,14 @@
</span><span class="cx"> 
</span><span class="cx"> ScrollPosition RenderLayer::scrollPosition() const
</span><span class="cx"> {
</span><ins>+    // FIXME: This needs scrollOffset/scrollPosition disambiguation.
</ins><span class="cx">     return ScrollPosition(m_scrollOffset);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-ScrollPosition RenderLayer::minimumScrollPosition() const
-{
-    return -scrollOrigin();
-}
-
</del><span class="cx"> ScrollPosition RenderLayer::maximumScrollPosition() const
</span><span class="cx"> {
</span><span class="cx">     // FIXME: m_scrollSize may not be up-to-date if m_scrollDimensionsDirty is true.
</span><del>-    return -scrollOrigin() + roundedIntSize(m_scrollSize) - visibleContentRectIncludingScrollbars(ContentsVisibleRect).size();
</del><ins>+    return scrollPositionFromOffset(roundedIntPoint(m_scrollSize) - visibleContentRectIncludingScrollbars(ContentsVisibleRect).size());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> IntRect RenderLayer::visibleContentRectInternal(VisibleContentRectIncludesScrollbars scrollbarInclusion, VisibleContentRectBehavior) const
</span><span class="lines">@@ -2773,17 +2769,17 @@
</span><span class="cx"> 
</span><span class="cx">     IntSize stretch;
</span><span class="cx"> 
</span><del>-    int physicalScrollY = scrollPosition().y() + scrollOrigin().y();
-    if (physicalScrollY &lt; 0)
-        stretch.setHeight(physicalScrollY);
-    else if (scrollableContentsSize().height() &amp;&amp; physicalScrollY &gt; scrollableContentsSize().height() - visibleHeight())
-        stretch.setHeight(physicalScrollY - (scrollableContentsSize().height() - visibleHeight()));
</del><ins>+    // FIXME: use maximumScrollOffset()
+    ScrollOffset scrollOffset = scrollOffsetFromPosition(scrollOrigin());
+    if (scrollOffset.y() &lt; 0)
+        stretch.setHeight(scrollOffset.y());
+    else if (scrollableContentsSize().height() &amp;&amp; scrollOffset.y() &gt; scrollableContentsSize().height() - visibleHeight())
+        stretch.setHeight(scrollOffset.y() - (scrollableContentsSize().height() - visibleHeight()));
</ins><span class="cx"> 
</span><del>-    int physicalScrollX = scrollPosition().x() + scrollOrigin().x();
-    if (physicalScrollX &lt; 0)
-        stretch.setWidth(physicalScrollX);
-    else if (scrollableContentsSize().width() &amp;&amp; physicalScrollX &gt; scrollableContentsSize().width() - visibleWidth())
-        stretch.setWidth(physicalScrollX - (scrollableContentsSize().width() - visibleWidth()));
</del><ins>+    if (scrollOffset.x() &lt; 0)
+        stretch.setWidth(scrollOffset.x());
+    else if (scrollableContentsSize().width() &amp;&amp; scrollOffset.x() &gt; scrollableContentsSize().width() - visibleWidth())
+        stretch.setWidth(scrollOffset.x() - (scrollableContentsSize().width() - visibleWidth()));
</ins><span class="cx"> 
</span><span class="cx">     return stretch;
</span><span class="cx"> #else
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderLayerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderLayer.h (194447 => 194448)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderLayer.h        2015-12-30 17:19:03 UTC (rev 194447)
+++ trunk/Source/WebCore/rendering/RenderLayer.h        2015-12-30 20:15:27 UTC (rev 194448)
</span><span class="lines">@@ -864,9 +864,10 @@
</span><span class="cx">     virtual IntPoint convertFromContainingViewToScrollbar(const Scrollbar*, const IntPoint&amp;) const override;
</span><span class="cx">     virtual int scrollSize(ScrollbarOrientation) const override;
</span><span class="cx">     virtual void setScrollOffset(const IntPoint&amp;) override;
</span><ins>+
</ins><span class="cx">     virtual ScrollPosition scrollPosition() const override;
</span><del>-    virtual ScrollPosition minimumScrollPosition() const override;
</del><span class="cx">     virtual ScrollPosition maximumScrollPosition() const override;
</span><ins>+
</ins><span class="cx">     virtual IntRect visibleContentRectInternal(VisibleContentRectIncludesScrollbars, VisibleContentRectBehavior) const override;
</span><span class="cx">     virtual IntSize visibleSize() const override;
</span><span class="cx">     virtual IntSize contentsSize() const override;
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (194447 => 194448)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2015-12-30 17:19:03 UTC (rev 194447)
+++ trunk/Source/WebKit2/ChangeLog        2015-12-30 20:15:27 UTC (rev 194448)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2015-12-30  Simon Fraser  &lt;simon.fraser@apple.com&gt;
+
+        Add explicit conversions between scrollOffset and scrollPostion, and use them in a few places
+        https://bugs.webkit.org/show_bug.cgi?id=152594
+
+        Reviewed by Sam Weinig.
+
+        Add functions to ScrollableArea to convert between scrollPosition and scrollOffset,
+        and use them in places where code did the math with scrollOrigin.
+
+        * WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm:
+        (WebKit::RemoteLayerTreeDrawingArea::updateScrolledExposedRect):
+        * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
+        (WebKit::TiledCoreAnimationDrawingArea::updateScrolledExposedRect):
+
</ins><span class="cx"> 2015-12-30  Zan Dobersek  &lt;zdobersek@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [TexMap] Clean up TextureMapperAnimation, TextureMapperAnimations
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPagemacRemoteLayerTreeDrawingAreamm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm (194447 => 194448)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm        2015-12-30 17:19:03 UTC (rev 194447)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm        2015-12-30 20:15:27 UTC (rev 194448)
</span><span class="lines">@@ -270,8 +270,8 @@
</span><span class="cx"> 
</span><span class="cx"> #if !PLATFORM(IOS)
</span><span class="cx">     if (!m_exposedRect.isInfinite()) {
</span><del>-        IntPoint scrollPositionWithOrigin = frameView-&gt;scrollPosition() + toIntSize(frameView-&gt;scrollOrigin());
-        m_scrolledExposedRect.moveBy(scrollPositionWithOrigin);
</del><ins>+        ScrollOffset scrollOffset = frameView-&gt;scrollOffsetFromPosition(frameView-&gt;scrollPosition());
+        m_scrolledExposedRect.moveBy(scrollOffset);
</ins><span class="cx">     }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPagemacTiledCoreAnimationDrawingAreamm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm (194447 => 194448)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm        2015-12-30 17:19:03 UTC (rev 194447)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm        2015-12-30 20:15:27 UTC (rev 194448)
</span><span class="lines">@@ -512,8 +512,8 @@
</span><span class="cx"> 
</span><span class="cx"> #if !PLATFORM(IOS)
</span><span class="cx">     if (!m_exposedRect.isInfinite()) {
</span><del>-        IntPoint scrollPositionWithOrigin = frameView-&gt;scrollPosition() + toIntSize(frameView-&gt;scrollOrigin());
-        m_scrolledExposedRect.moveBy(scrollPositionWithOrigin);
</del><ins>+        ScrollOffset scrollOffset = frameView-&gt;scrollOffsetFromPosition(frameView-&gt;scrollPosition());
+        m_scrolledExposedRect.moveBy(scrollOffset);
</ins><span class="cx">     }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>