Title: [107960] trunk/Source/WebKit/chromium
Revision
107960
Author
commit-qu...@webkit.org
Date
2012-02-16 11:36:26 -0800 (Thu, 16 Feb 2012)

Log Message

[chromium] Add method to WebPluginContainer to check if a rectangle is topmost
https://bugs.webkit.org/show_bug.cgi?id=78166

Patch by Viet-Trung Luu <viettrung...@chromium.org> on 2012-02-16
Reviewed by Darin Fisher.

* public/WebPluginContainer.h:
(WebPluginContainer):
* src/WebPluginContainerImpl.cpp:
* src/WebPluginContainerImpl.h:
(WebPluginContainerImpl):

Modified Paths

Diff

Modified: trunk/Source/WebKit/chromium/ChangeLog (107959 => 107960)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-02-16 19:15:40 UTC (rev 107959)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-02-16 19:36:26 UTC (rev 107960)
@@ -1,3 +1,16 @@
+2012-02-16  Viet-Trung Luu  <viettrung...@chromium.org>
+
+        [chromium] Add method to WebPluginContainer to check if a rectangle is topmost
+        https://bugs.webkit.org/show_bug.cgi?id=78166
+
+        Reviewed by Darin Fisher.
+
+        * public/WebPluginContainer.h:
+        (WebPluginContainer):
+        * src/WebPluginContainerImpl.cpp:
+        * src/WebPluginContainerImpl.h:
+        (WebPluginContainerImpl):
+
 2012-02-16  Yosifumi Inoue  <yo...@chromium.org>
 
         Build Fix: R107894 breaks Chromium Linux Build.

Modified: trunk/Source/WebKit/chromium/public/WebPluginContainer.h (107959 => 107960)


--- trunk/Source/WebKit/chromium/public/WebPluginContainer.h	2012-02-16 19:15:40 UTC (rev 107959)
+++ trunk/Source/WebKit/chromium/public/WebPluginContainer.h	2012-02-16 19:36:26 UTC (rev 107960)
@@ -100,6 +100,10 @@
     // Notifies that the zoom level has changed.
     virtual void zoomLevelChanged(double zoomLevel) = 0;
 
+    // Determines whether the given rectangle in this plugin is above all other
+    // content. The rectangle is in the plugin's coordinate system.
+    virtual bool isRectTopmost(const WebRect&) = 0;
+
     virtual WebPlugin* plugin() = 0;
     virtual void setPlugin(WebPlugin*) = 0;
 

Modified: trunk/Source/WebKit/chromium/src/WebPluginContainerImpl.cpp (107959 => 107960)


--- trunk/Source/WebKit/chromium/src/WebPluginContainerImpl.cpp	2012-02-16 19:15:40 UTC (rev 107959)
+++ trunk/Source/WebKit/chromium/src/WebPluginContainerImpl.cpp	2012-02-16 19:36:26 UTC (rev 107960)
@@ -60,6 +60,7 @@
 #include "FrameLoadRequest.h"
 #include "FrameView.h"
 #include "GraphicsContext.h"
+#include "HitTestResult.h"
 #include "HostWindow.h"
 #include "HTMLFormElement.h"
 #include "HTMLNames.h"
@@ -433,7 +434,27 @@
     WebViewImpl* view = WebViewImpl::fromPage(m_element->document()->frame()->page());
     view->fullFramePluginZoomLevelChanged(zoomLevel);
 }
+ 
+bool WebPluginContainerImpl::isRectTopmost(const WebRect& rect)
+{
+    Page* page = m_element->document()->page();
+    if (!page)
+        return false;
 
+    // hitTestResultAtPoint() takes a padding rectangle.
+    // FIXME: We'll be off by 1 when the width or height is even.
+    IntRect windowRect = convertToContainingWindow(static_cast<IntRect>(rect));
+    LayoutPoint center = windowRect.center();
+    // Make the rect we're checking (the point surrounded by padding rects) contained inside the requested rect. (Note that -1/2 is 0.)
+    LayoutSize padding((windowRect.width() - 1) / 2, (windowRect.height() - 1) / 2);
+    HitTestResult result =
+        page->mainFrame()->eventHandler()->hitTestResultAtPoint(center, false, false, DontHitTestScrollbars, HitTestRequest::ReadOnly | HitTestRequest::Active, padding);
+    const HitTestResult::NodeSet& nodes = result.rectBasedTestResult();
+    if (nodes.size() != 1)
+        return false;
+    return (nodes.first().get() == m_element);
+}
+
 void WebPluginContainerImpl::didReceiveResponse(const ResourceResponse& response)
 {
     // Make sure that the plugin receives window geometry before data, or else

Modified: trunk/Source/WebKit/chromium/src/WebPluginContainerImpl.h (107959 => 107960)


--- trunk/Source/WebKit/chromium/src/WebPluginContainerImpl.h	2012-02-16 19:15:40 UTC (rev 107959)
+++ trunk/Source/WebKit/chromium/src/WebPluginContainerImpl.h	2012-02-16 19:36:26 UTC (rev 107960)
@@ -104,6 +104,7 @@
     virtual WebString executeScriptURL(const WebURL&, bool popupsAllowed);
     virtual void loadFrameRequest(const WebURLRequest&, const WebString& target, bool notifyNeeded, void* notifyData);
     virtual void zoomLevelChanged(double zoomLevel);    
+    virtual bool isRectTopmost(const WebRect&);
 
     // This cannot be null.
     WebPlugin* plugin() { return m_webPlugin; }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to