Title: [183510] trunk/Source/WebCore
- Revision
- 183510
- Author
- [email protected]
- Date
- 2015-04-28 14:51:04 -0700 (Tue, 28 Apr 2015)
Log Message
Provide contentsToView() and viewToContents() functions on ScrollView, and use them
https://bugs.webkit.org/show_bug.cgi?id=144357
Reviewed by Tim Horton.
Too much code was consulting topContentInset() and headerHeight() directly. Replace
with calls to new contentsToView() and viewToContents() functions, which wrap the
exisiting documentScrollOffsetRelativeToViewOrigin().
Use the new functions in FrameView and ScrollView coordinate mapping functions.
No behavior change.
* page/FrameView.cpp:
(WebCore::FrameView::convertFromRendererToContainingView):
(WebCore::FrameView::convertFromContainingViewToRenderer):
* platform/ScrollView.cpp:
(WebCore::ScrollView::viewToContents):
(WebCore::ScrollView::contentsToView):
(WebCore::ScrollView::rootViewToContents):
(WebCore::ScrollView::contentsToRootView):
(WebCore::ScrollView::rootViewToTotalContents):
(WebCore::ScrollView::windowToContents):
(WebCore::ScrollView::contentsToWindow):
* platform/ScrollView.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (183509 => 183510)
--- trunk/Source/WebCore/ChangeLog 2015-04-28 21:40:10 UTC (rev 183509)
+++ trunk/Source/WebCore/ChangeLog 2015-04-28 21:51:04 UTC (rev 183510)
@@ -1,3 +1,31 @@
+2015-04-28 Simon Fraser <[email protected]>
+
+ Provide contentsToView() and viewToContents() functions on ScrollView, and use them
+ https://bugs.webkit.org/show_bug.cgi?id=144357
+
+ Reviewed by Tim Horton.
+
+ Too much code was consulting topContentInset() and headerHeight() directly. Replace
+ with calls to new contentsToView() and viewToContents() functions, which wrap the
+ exisiting documentScrollOffsetRelativeToViewOrigin().
+
+ Use the new functions in FrameView and ScrollView coordinate mapping functions.
+
+ No behavior change.
+
+ * page/FrameView.cpp:
+ (WebCore::FrameView::convertFromRendererToContainingView):
+ (WebCore::FrameView::convertFromContainingViewToRenderer):
+ * platform/ScrollView.cpp:
+ (WebCore::ScrollView::viewToContents):
+ (WebCore::ScrollView::contentsToView):
+ (WebCore::ScrollView::rootViewToContents):
+ (WebCore::ScrollView::contentsToRootView):
+ (WebCore::ScrollView::rootViewToTotalContents):
+ (WebCore::ScrollView::windowToContents):
+ (WebCore::ScrollView::contentsToWindow):
+ * platform/ScrollView.h:
+
2015-04-28 Eric Carlson <[email protected]>
[Mac] Simplify code to support media engines which do not support target playback
Modified: trunk/Source/WebCore/page/FrameView.cpp (183509 => 183510)
--- trunk/Source/WebCore/page/FrameView.cpp 2015-04-28 21:40:10 UTC (rev 183509)
+++ trunk/Source/WebCore/page/FrameView.cpp 2015-04-28 21:51:04 UTC (rev 183510)
@@ -4199,9 +4199,8 @@
{
IntRect rect = snappedIntRect(enclosingLayoutRect(renderer->localToAbsoluteQuad(FloatRect(rendererRect)).boundingBox()));
- // Convert from page ("absolute") to FrameView coordinates.
if (!delegatesScrolling())
- rect.moveBy(-scrollPosition() + IntPoint(0, headerHeight() + topContentInset(TopContentInsetType::WebCoreOrPlatformContentInset)));
+ rect = contentsToView(rect);
return rect;
}
@@ -4212,7 +4211,7 @@
// Convert from FrameView coords into page ("absolute") coordinates.
if (!delegatesScrolling())
- rect.moveBy(documentScrollPositionRelativeToViewOrigin());
+ rect = viewToContents(rect);
// FIXME: we don't have a way to map an absolute rect down to a local quad, so just
// move the rect for now.
@@ -4226,7 +4225,8 @@
// Convert from page ("absolute") to FrameView coordinates.
if (!delegatesScrolling())
- point.moveBy(-scrollPosition() + IntPoint(0, headerHeight() + topContentInset(TopContentInsetType::WebCoreOrPlatformContentInset)));
+ point = contentsToView(point);
+
return point;
}
@@ -4236,7 +4236,7 @@
// Convert from FrameView coords into page ("absolute") coordinates.
if (!delegatesScrolling())
- point = point + documentScrollPositionRelativeToViewOrigin();
+ point = viewToContents(point);
return roundedIntPoint(renderer->absoluteToLocal(point, UseTransforms));
}
Modified: trunk/Source/WebCore/platform/ScrollView.cpp (183509 => 183510)
--- trunk/Source/WebCore/platform/ScrollView.cpp 2015-04-28 21:40:10 UTC (rev 183509)
+++ trunk/Source/WebCore/platform/ScrollView.cpp 2015-04-28 21:51:04 UTC (rev 183510)
@@ -864,13 +864,34 @@
hostWindow()->invalidateContentsForSlowScroll(updateRect);
}
+IntPoint ScrollView::viewToContents(const IntPoint& point) const
+{
+ return point + documentScrollOffsetRelativeToViewOrigin();
+}
+
+IntPoint ScrollView::contentsToView(const IntPoint& point) const
+{
+ return point - documentScrollOffsetRelativeToViewOrigin();
+}
+
+IntRect ScrollView::viewToContents(IntRect rect) const
+{
+ rect.move(documentScrollOffsetRelativeToViewOrigin());
+ return rect;
+}
+
+IntRect ScrollView::contentsToView(IntRect rect) const
+{
+ rect.move(-documentScrollOffsetRelativeToViewOrigin());
+ return rect;
+}
+
IntPoint ScrollView::rootViewToContents(const IntPoint& rootViewPoint) const
{
if (delegatesScrolling())
return convertFromRootView(rootViewPoint);
- IntPoint viewPoint = convertFromRootView(rootViewPoint);
- return viewPoint + documentScrollOffsetRelativeToViewOrigin();
+ return viewToContents(convertFromRootView(rootViewPoint));
}
IntPoint ScrollView::contentsToRootView(const IntPoint& contentsPoint) const
@@ -878,8 +899,7 @@
if (delegatesScrolling())
return convertToRootView(contentsPoint);
- IntPoint viewPoint = contentsPoint + IntSize(0, headerHeight() + topContentInset(TopContentInsetType::WebCoreOrPlatformContentInset)) - scrollOffset();
- return convertToRootView(viewPoint);
+ return convertToRootView(contentsToView(contentsPoint));
}
IntRect ScrollView::rootViewToContents(const IntRect& rootViewRect) const
@@ -887,28 +907,25 @@
if (delegatesScrolling())
return convertFromRootView(rootViewRect);
- IntRect viewRect = convertFromRootView(rootViewRect);
- viewRect.move(documentScrollOffsetRelativeToViewOrigin());
- return viewRect;
+ return viewToContents(convertFromRootView(rootViewRect));
}
-IntRect ScrollView::contentsToRootView(const IntRect& contentsRect) const
+IntPoint ScrollView::rootViewToTotalContents(const IntPoint& rootViewPoint) const
{
if (delegatesScrolling())
- return convertToRootView(contentsRect);
+ return convertFromRootView(rootViewPoint);
- IntRect viewRect = contentsRect;
- viewRect.move(-scrollOffset() + IntSize(0, headerHeight() + topContentInset(TopContentInsetType::WebCoreOrPlatformContentInset)));
- return convertToRootView(viewRect);
+ IntPoint viewPoint = convertFromRootView(rootViewPoint);
+ // Like rootViewToContents(), but ignores headerHeight.
+ return viewPoint + scrollOffset() - IntSize(0, topContentInset(TopContentInsetType::WebCoreOrPlatformContentInset));
}
-IntPoint ScrollView::rootViewToTotalContents(const IntPoint& rootViewPoint) const
+IntRect ScrollView::contentsToRootView(const IntRect& contentsRect) const
{
if (delegatesScrolling())
- return convertFromRootView(rootViewPoint);
+ return convertToRootView(contentsRect);
- IntPoint viewPoint = convertFromRootView(rootViewPoint);
- return viewPoint + scrollOffset() - IntSize(0, topContentInset(TopContentInsetType::WebCoreOrPlatformContentInset));
+ return convertToRootView(contentsToView(contentsRect));
}
IntPoint ScrollView::windowToContents(const IntPoint& windowPoint) const
@@ -916,8 +933,7 @@
if (delegatesScrolling())
return convertFromContainingWindow(windowPoint);
- IntPoint viewPoint = convertFromContainingWindow(windowPoint);
- return viewPoint + documentScrollOffsetRelativeToViewOrigin();
+ return viewToContents(convertFromContainingWindow(windowPoint));
}
IntPoint ScrollView::contentsToWindow(const IntPoint& contentsPoint) const
@@ -925,8 +941,7 @@
if (delegatesScrolling())
return convertToContainingWindow(contentsPoint);
- IntPoint viewPoint = contentsPoint + IntSize(0, headerHeight() + topContentInset(TopContentInsetType::WebCoreOrPlatformContentInset)) - scrollOffset();
- return convertToContainingWindow(viewPoint);
+ return convertToContainingWindow(contentsToView(contentsPoint));
}
IntRect ScrollView::windowToContents(const IntRect& windowRect) const
@@ -934,9 +949,7 @@
if (delegatesScrolling())
return convertFromContainingWindow(windowRect);
- IntRect viewRect = convertFromContainingWindow(windowRect);
- viewRect.move(documentScrollOffsetRelativeToViewOrigin());
- return viewRect;
+ return viewToContents(convertFromContainingWindow(windowRect));
}
IntRect ScrollView::contentsToWindow(const IntRect& contentsRect) const
@@ -944,9 +957,7 @@
if (delegatesScrolling())
return convertToContainingWindow(contentsRect);
- IntRect viewRect = contentsRect;
- viewRect.move(-scrollOffset() + IntSize(0, headerHeight() + topContentInset(TopContentInsetType::WebCoreOrPlatformContentInset)));
- return convertToContainingWindow(viewRect);
+ return convertToContainingWindow(contentsToView(contentsRect));
}
IntRect ScrollView::contentsToScreen(const IntRect& rect) const
Modified: trunk/Source/WebCore/platform/ScrollView.h (183509 => 183510)
--- trunk/Source/WebCore/platform/ScrollView.h 2015-04-28 21:40:10 UTC (rev 183509)
+++ trunk/Source/WebCore/platform/ScrollView.h 2015-04-28 21:51:04 UTC (rev 183510)
@@ -292,6 +292,12 @@
IntRect rootViewToContents(const IntRect&) const;
WEBCORE_EXPORT IntRect contentsToRootView(const IntRect&) const;
+ IntPoint viewToContents(const IntPoint&) const;
+ IntPoint contentsToView(const IntPoint&) const;
+
+ IntRect viewToContents(IntRect) const;
+ IntRect contentsToView(IntRect) const;
+
WEBCORE_EXPORT IntPoint rootViewToTotalContents(const IntPoint&) const;
// Event coordinates are assumed to be in the coordinate space of a window that contains
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes