../WebCore: InjectedBundleHitTestResult::imageRect() should return rect in WKView coordinates
https://bugs.webkit.org/show_bug.cgi?id=69963
Add infrastructure to convert from any frame view's coordinate system to the
root view's coordinate system.
Reviewed by Simon Fraser.
No new tests (yet), this is covered by <https://bugs.webkit.org/show_bug.cgi?id=70136>.
* WebCore.exp.in: Exported WebCore::ScrollView::contentsToRootView(), used by InjectedBundleHitTestResult.cpp.
* platform/ScrollView.cpp:
(WebCore::ScrollView::rootViewToContents): Added (both point and rect versions).
(WebCore::ScrollView::contentsToRootView): Ditto.
* platform/ScrollView.h: Added member functions to convert to/from root view coordinates.
* platform/Widget.cpp:
(WebCore::Widget::convertFromRootView): Added (both point and rect versions).
(WebCore::Widget::convertToRootView): Ditto.
* platform/Widget.h: Added member functions to convert to/from root view coordinates.
../WebKit2: InjectedBundleHitTestResult::imageRect() should return rect in WKView coordinates
https://bugs.webkit.org/show_bug.cgi?id=69963
WebKit2 clients only have knowledge of the WKView's coordinate system, they have no way to
convert from subframe view coordinates , so any rect that we expose through WK2 APIs should
be in WKView coordinates.
Reviewed by Simon Fraser.
* WebProcess/InjectedBundle/InjectedBundleHitTestResult.cpp:
(WebKit::InjectedBundleHitTestResult::imageRect): Use WebCore::FrameView::contentsToRootView() to convert the image rect to WKView coordinates.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@97514 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/platform/ScrollView.cpp b/Source/WebCore/platform/ScrollView.cpp
index 2205b2e..8aebb00 100644
--- a/Source/WebCore/platform/ScrollView.cpp
+++ b/Source/WebCore/platform/ScrollView.cpp
@@ -681,6 +681,32 @@
hostWindow()->invalidateContentsForSlowScroll(updateRect, false);
}
+IntPoint ScrollView::rootViewToContents(const IntPoint& rootViewPoint) const
+{
+ IntPoint viewPoint = convertFromRootView(rootViewPoint);
+ return viewPoint + scrollOffset();
+}
+
+IntPoint ScrollView::contentsToRootView(const IntPoint& contentsPoint) const
+{
+ IntPoint viewPoint = contentsPoint - scrollOffset();
+ return convertToRootView(viewPoint);
+}
+
+IntRect ScrollView::rootViewToContents(const IntRect& rootViewRect) const
+{
+ IntRect viewRect = convertFromRootView(rootViewRect);
+ viewRect.move(scrollOffset());
+ return viewRect;
+}
+
+IntRect ScrollView::contentsToRootView(const IntRect& contentsRect) const
+{
+ IntRect viewRect = contentsRect;
+ viewRect.move(-scrollOffset());
+ return convertToRootView(viewRect);
+}
+
IntPoint ScrollView::windowToContents(const IntPoint& windowPoint) const
{
IntPoint viewPoint = convertFromContainingWindow(windowPoint);