summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-19 19:11:17 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-19 19:11:17 +0000
commit63c85eee887a619b61fe4454b579237fdcaf25b9 (patch)
treeab6a3ac8b4edb0e64bda0fcc48e48e9a17753668 /webkit
parent812f6a70e4900cb641b3a72292a019eb2a765bce (diff)
downloadchromium_src-63c85eee887a619b61fe4454b579237fdcaf25b9.zip
chromium_src-63c85eee887a619b61fe4454b579237fdcaf25b9.tar.gz
chromium_src-63c85eee887a619b61fe4454b579237fdcaf25b9.tar.bz2
Do correct hit testing for context menu items in WebViewImpl.
BUG=8100 Review URL: http://codereview.chromium.org/42377 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12124 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/glue/webview_impl.cc27
-rw-r--r--webkit/glue/webview_impl.h14
2 files changed, 21 insertions, 20 deletions
diff --git a/webkit/glue/webview_impl.cc b/webkit/glue/webview_impl.cc
index 69ca561..8c86ff8 100644
--- a/webkit/glue/webview_impl.cc
+++ b/webkit/glue/webview_impl.cc
@@ -446,11 +446,7 @@ void WebViewImpl::MouseContextMenu(const WebMouseEvent& event) {
MakePlatformMouseEvent pme(main_frame()->frameview(), event);
// Find the right target frame. See issue 1186900.
- IntPoint doc_point(
- page_->mainFrame()->view()->windowToContents(pme.pos()));
- HitTestResult result =
- page_->mainFrame()->eventHandler()->hitTestResultAtPoint(
- doc_point, false);
+ HitTestResult result = HitTestResultForWindowPos(pme.pos());
Frame* target_frame;
if (result.innerNonSharedNode())
target_frame = result.innerNonSharedNode()->document()->frame();
@@ -1385,12 +1381,7 @@ void WebViewImpl::CopyImageAt(int x, int y) {
if (!page_.get())
return;
- IntPoint point = IntPoint(x, y);
-
- Frame* frame = page_->mainFrame();
-
- HitTestResult result =
- frame->eventHandler()->hitTestResultAtPoint(point, false);
+ HitTestResult result = HitTestResultForWindowPos(IntPoint(x, y));
if (result.absoluteImageURL().isEmpty()) {
// There isn't actually an image at these coordinates. Might be because
@@ -1403,7 +1394,7 @@ void WebViewImpl::CopyImageAt(int x, int y) {
return;
}
- frame->editor()->copyImage(result);
+ page_->mainFrame()->editor()->copyImage(result);
}
void WebViewImpl::InspectElement(int x, int y) {
@@ -1413,10 +1404,7 @@ void WebViewImpl::InspectElement(int x, int y) {
if (x == -1 || y == -1) {
page_->inspectorController()->inspect(NULL);
} else {
- IntPoint point = IntPoint(x, y);
- HitTestResult result(point);
-
- result = page_->mainFrame()->eventHandler()->hitTestResultAtPoint(point, false);
+ HitTestResult result = HitTestResultForWindowPos(IntPoint(x, y));
if (!result.innerNonSharedNode())
return;
@@ -1713,3 +1701,10 @@ Node* WebViewImpl::GetFocusedNode() {
return document->focusedNode();
}
+
+HitTestResult WebViewImpl::HitTestResultForWindowPos(const IntPoint& pos) {
+ IntPoint doc_point(
+ page_->mainFrame()->view()->windowToContents(pos));
+ return page_->mainFrame()->eventHandler()->
+ hitTestResultAtPoint(doc_point, false);
+}
diff --git a/webkit/glue/webview_impl.h b/webkit/glue/webview_impl.h
index 78e0a63..4c6572d 100644
--- a/webkit/glue/webview_impl.h
+++ b/webkit/glue/webview_impl.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef WEBKIT_GLUE_WEBVIEW_IMPL_H__
-#define WEBKIT_GLUE_WEBVIEW_IMPL_H__
+#ifndef WEBKIT_GLUE_WEBVIEW_IMPL_H_
+#define WEBKIT_GLUE_WEBVIEW_IMPL_H_
#include <set>
@@ -26,6 +26,7 @@ namespace WebCore {
class ChromiumDataObject;
class Frame;
class HistoryItem;
+class HitTestResult;
class KeyboardEvent;
class Page;
class PlatformKeyboardEvent;
@@ -263,6 +264,11 @@ class WebViewImpl : public WebView, public base::RefCounted<WebViewImpl> {
// This is invoked after the download is completed (or fails).
void DeleteImageResourceFetcher(ImageResourceFetcher* fetcher);
+ // Converts |pos| from window coordinates to contents coordinates and gets
+ // the HitTestResult for it.
+ WebCore::HitTestResult HitTestResultForWindowPos(
+ const WebCore::IntPoint& pos);
+
// Returns the currently focused Node or NULL if no node has focus.
WebCore::Node* GetFocusedNode();
@@ -328,7 +334,7 @@ public:
private:
static const WebInputEvent* g_current_input_event;
- DISALLOW_EVIL_CONSTRUCTORS(WebViewImpl);
+ DISALLOW_COPY_AND_ASSIGN(WebViewImpl);
};
-#endif // WEBKIT_GLUE_WEBVIEW_IMPL_H__
+#endif // WEBKIT_GLUE_WEBVIEW_IMPL_H_