Title: [102271] branches/safari-534.53-branch/Source

Diff

Modified: branches/safari-534.53-branch/Source/WebCore/ChangeLog (102270 => 102271)


--- branches/safari-534.53-branch/Source/WebCore/ChangeLog	2011-12-07 21:43:11 UTC (rev 102270)
+++ branches/safari-534.53-branch/Source/WebCore/ChangeLog	2011-12-07 22:36:52 UTC (rev 102271)
@@ -1,3 +1,33 @@
+2011-12-07  Lucas Forschler  <[email protected]>
+
+    Merge 97514
+
+    2011-10-14  Jeff Miller  <[email protected]>
+
+            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.
+
 2011-12-06  Lucas Forschler  <[email protected]>
 
     Merge 98406

Modified: branches/safari-534.53-branch/Source/WebCore/WebCore.exp.in (102270 => 102271)


--- branches/safari-534.53-branch/Source/WebCore/WebCore.exp.in	2011-12-07 21:43:11 UTC (rev 102270)
+++ branches/safari-534.53-branch/Source/WebCore/WebCore.exp.in	2011-12-07 22:36:52 UTC (rev 102271)
@@ -1077,6 +1077,7 @@
 __ZNK7WebCore10ScrollView16contentsToWindowERKNS_8IntPointE
 __ZNK7WebCore10ScrollView16windowToContentsERKNS_8IntPointE
 __ZNK7WebCore10ScrollView18visibleContentRectEb
+__ZNK7WebCore10ScrollView18contentsToRootViewERKNS_7IntRectE
 __ZNK7WebCore11CachedImage5imageEv
 __ZNK7WebCore11FrameLoader10isCompleteEv
 __ZNK7WebCore11FrameLoader12blockedErrorERKNS_15ResourceRequestE

Modified: branches/safari-534.53-branch/Source/WebCore/platform/ScrollView.cpp (102270 => 102271)


--- branches/safari-534.53-branch/Source/WebCore/platform/ScrollView.cpp	2011-12-07 21:43:11 UTC (rev 102270)
+++ branches/safari-534.53-branch/Source/WebCore/platform/ScrollView.cpp	2011-12-07 22:36:52 UTC (rev 102271)
@@ -675,6 +675,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);

Modified: branches/safari-534.53-branch/Source/WebCore/platform/ScrollView.h (102270 => 102271)


--- branches/safari-534.53-branch/Source/WebCore/platform/ScrollView.h	2011-12-07 21:43:11 UTC (rev 102270)
+++ branches/safari-534.53-branch/Source/WebCore/platform/ScrollView.h	2011-12-07 22:36:52 UTC (rev 102271)
@@ -196,6 +196,11 @@
     void setScrollbarsSuppressed(bool suppressed, bool repaintOnUnsuppress = false);
     bool scrollbarsSuppressed() const { return m_scrollbarsSuppressed; }
 
+    IntPoint rootViewToContents(const IntPoint&) const;
+    IntPoint contentsToRootView(const IntPoint&) const;
+    IntRect rootViewToContents(const IntRect&) const;
+    IntRect contentsToRootView(const IntRect&) const;
+
     // Event coordinates are assumed to be in the coordinate space of a window that contains
     // the entire widget hierarchy. It is up to the platform to decide what the precise definition
     // of containing window is. (For example on Mac it is the containing NSWindow.)

Modified: branches/safari-534.53-branch/Source/WebCore/platform/Widget.cpp (102270 => 102271)


--- branches/safari-534.53-branch/Source/WebCore/platform/Widget.cpp	2011-12-07 21:43:11 UTC (rev 102270)
+++ branches/safari-534.53-branch/Source/WebCore/platform/Widget.cpp	2011-12-07 22:36:52 UTC (rev 102271)
@@ -69,6 +69,42 @@
         parent()->removeChild(this);
 }
 
+IntRect Widget::convertFromRootView(const IntRect& rootRect) const
+{
+    if (const ScrollView* parentScrollView = parent()) {
+        IntRect parentRect = parentScrollView->convertFromRootView(rootRect);
+        return convertFromContainingView(parentRect);
+    }
+    return rootRect;
+}
+
+IntRect Widget::convertToRootView(const IntRect& localRect) const
+{
+    if (const ScrollView* parentScrollView = parent()) {
+        IntRect parentRect = convertToContainingView(localRect);
+        return parentScrollView->convertToRootView(parentRect);
+    }
+    return localRect;
+}
+
+IntPoint Widget::convertFromRootView(const IntPoint& rootPoint) const
+{
+    if (const ScrollView* parentScrollView = parent()) {
+        IntPoint parentPoint = parentScrollView->convertFromRootView(rootPoint);
+        return convertFromContainingView(parentPoint);
+    }
+    return rootPoint;
+}
+
+IntPoint Widget::convertToRootView(const IntPoint& localPoint) const
+{
+    if (const ScrollView* parentScrollView = parent()) {
+        IntPoint parentPoint = convertToContainingView(localPoint);
+        return parentScrollView->convertToRootView(parentPoint);
+    }
+    return localPoint;
+}
+
 IntRect Widget::convertFromContainingWindow(const IntRect& windowRect) const
 {
     if (const ScrollView* parentScrollView = parent()) {

Modified: branches/safari-534.53-branch/Source/WebCore/platform/Widget.h (102270 => 102271)


--- branches/safari-534.53-branch/Source/WebCore/platform/Widget.h	2011-12-07 21:43:11 UTC (rev 102270)
+++ branches/safari-534.53-branch/Source/WebCore/platform/Widget.h	2011-12-07 22:36:52 UTC (rev 102271)
@@ -200,6 +200,12 @@
 
     virtual void notifyWidget(WidgetNotification) { }
 
+    IntRect convertToRootView(const IntRect&) const;
+    IntRect convertFromRootView(const IntRect&) const;
+
+    IntPoint convertToRootView(const IntPoint&) const;
+    IntPoint convertFromRootView(const IntPoint&) const;
+
     // It is important for cross-platform code to realize that Mac has flipped coordinates.  Therefore any code
     // that tries to convert the location of a rect using the point-based convertFromContainingWindow will end
     // up with an inaccurate rect.  Always make sure to use the rect-based convertFromContainingWindow method

Modified: branches/safari-534.53-branch/Source/WebKit2/ChangeLog (102270 => 102271)


--- branches/safari-534.53-branch/Source/WebKit2/ChangeLog	2011-12-07 21:43:11 UTC (rev 102270)
+++ branches/safari-534.53-branch/Source/WebKit2/ChangeLog	2011-12-07 22:36:52 UTC (rev 102271)
@@ -1,5 +1,23 @@
 2011-12-07  Lucas Forschler  <[email protected]>
 
+    Merge 97514
+
+    2011-10-14  Jeff Miller  <[email protected]>
+
+            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.
+
+2011-12-07  Lucas Forschler  <[email protected]>
+
     Merge 98646
 
     2011-10-27  Anders Carlsson  <[email protected]>

Modified: branches/safari-534.53-branch/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleHitTestResult.cpp (102270 => 102271)


--- branches/safari-534.53-branch/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleHitTestResult.cpp	2011-12-07 21:43:11 UTC (rev 102270)
+++ branches/safari-534.53-branch/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleHitTestResult.cpp	2011-12-07 22:36:52 UTC (rev 102271)
@@ -32,6 +32,7 @@
 #include <WebCore/Document.h>
 #include <WebCore/Frame.h>
 #include <WebCore/FrameLoader.h>
+#include <WebCore/FrameView.h>
 #include <WebCore/KURL.h>
 #include <wtf/text/WTFString.h>
 
@@ -107,7 +108,25 @@
 
 WebCore::IntRect InjectedBundleHitTestResult::imageRect() const
 {
-    return m_hitTestResult.imageRect();
+    WebCore::IntRect imageRect = m_hitTestResult.imageRect();
+    if (imageRect.isEmpty())
+        return imageRect;
+        
+    // The image rect in WebCore::HitTestResult is in frame coordinates, but we need it in WKView
+    // coordinates since WebKit2 clients don't have enough context to do the conversion themselves.
+    WebFrame* webFrame = frame();
+    if (!webFrame)
+        return imageRect;
+    
+    WebCore::Frame* coreFrame = webFrame->coreFrame();
+    if (!coreFrame)
+        return imageRect;
+    
+    WebCore::FrameView* view = coreFrame->view();
+    if (!view)
+        return imageRect;
+    
+    return view->contentsToRootView(imageRect);
 }
 
 bool InjectedBundleHitTestResult::isSelected() const
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to