Diff
Modified: tags/Safari-535.6.2/Source/WebCore/ChangeLog (97667 => 97668)
--- tags/Safari-535.6.2/Source/WebCore/ChangeLog 2011-10-17 23:30:36 UTC (rev 97667)
+++ tags/Safari-535.6.2/Source/WebCore/ChangeLog 2011-10-17 23:34:05 UTC (rev 97668)
@@ -1,3 +1,33 @@
+2011-10-17 Lucas Forschler <lforsch...@apple.com>
+
+ Merge 97514.
+
+ 2011-10-14 Jeff Miller <je...@apple.com>
+
+ 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-10-06 Antoine Labour <pi...@chromium.org>
Webkit API for compositor
Modified: tags/Safari-535.6.2/Source/WebCore/WebCore.exp.in (97667 => 97668)
--- tags/Safari-535.6.2/Source/WebCore/WebCore.exp.in 2011-10-17 23:30:36 UTC (rev 97667)
+++ tags/Safari-535.6.2/Source/WebCore/WebCore.exp.in 2011-10-17 23:34:05 UTC (rev 97668)
@@ -1103,6 +1103,7 @@
__ZNK7WebCore10ScrollView16contentsToWindowERKNS_8IntPointE
__ZNK7WebCore10ScrollView16windowToContentsERKNS_8IntPointE
__ZNK7WebCore10ScrollView18visibleContentRectEb
+__ZNK7WebCore10ScrollView18contentsToRootViewERKNS_7IntRectE
__ZNK7WebCore11CachedImage5imageEv
__ZNK7WebCore11FrameLoader10isCompleteEv
__ZNK7WebCore11FrameLoader14cancelledErrorERKNS_15ResourceRequestE
Modified: tags/Safari-535.6.2/Source/WebCore/platform/ScrollView.cpp (97667 => 97668)
--- tags/Safari-535.6.2/Source/WebCore/platform/ScrollView.cpp 2011-10-17 23:30:36 UTC (rev 97667)
+++ tags/Safari-535.6.2/Source/WebCore/platform/ScrollView.cpp 2011-10-17 23:34:05 UTC (rev 97668)
@@ -679,6 +679,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: tags/Safari-535.6.2/Source/WebCore/platform/ScrollView.h (97667 => 97668)
--- tags/Safari-535.6.2/Source/WebCore/platform/ScrollView.h 2011-10-17 23:30:36 UTC (rev 97667)
+++ tags/Safari-535.6.2/Source/WebCore/platform/ScrollView.h 2011-10-17 23:34:05 UTC (rev 97668)
@@ -197,6 +197,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: tags/Safari-535.6.2/Source/WebCore/platform/Widget.cpp (97667 => 97668)
--- tags/Safari-535.6.2/Source/WebCore/platform/Widget.cpp 2011-10-17 23:30:36 UTC (rev 97667)
+++ tags/Safari-535.6.2/Source/WebCore/platform/Widget.cpp 2011-10-17 23:34:05 UTC (rev 97668)
@@ -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: tags/Safari-535.6.2/Source/WebCore/platform/Widget.h (97667 => 97668)
--- tags/Safari-535.6.2/Source/WebCore/platform/Widget.h 2011-10-17 23:30:36 UTC (rev 97667)
+++ tags/Safari-535.6.2/Source/WebCore/platform/Widget.h 2011-10-17 23:34:05 UTC (rev 97668)
@@ -177,6 +177,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: tags/Safari-535.6.2/Source/WebKit2/ChangeLog (97667 => 97668)
--- tags/Safari-535.6.2/Source/WebKit2/ChangeLog 2011-10-17 23:30:36 UTC (rev 97667)
+++ tags/Safari-535.6.2/Source/WebKit2/ChangeLog 2011-10-17 23:34:05 UTC (rev 97668)
@@ -1,3 +1,21 @@
+2011-10-17 Lucas Forschler <lforsch...@apple.com>
+
+ Merge 97514.
+
+ 2011-10-14 Jeff Miller <je...@apple.com>
+
+ 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-10-06 Anders Carlsson <ander...@apple.com>
When building with clang, enable -Wglobal-constructors and -Wexit-time-destructors
Modified: tags/Safari-535.6.2/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleHitTestResult.cpp (97667 => 97668)
--- tags/Safari-535.6.2/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleHitTestResult.cpp 2011-10-17 23:30:36 UTC (rev 97667)
+++ tags/Safari-535.6.2/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleHitTestResult.cpp 2011-10-17 23:34:05 UTC (rev 97668)
@@ -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>
@@ -102,7 +103,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