Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1101)

Unified Diff: Source/core/page/EventHandler.cpp

Issue 766143002: Fix contextmenu event location for menu key in an iframe (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/page/EventHandler.cpp
diff --git a/Source/core/page/EventHandler.cpp b/Source/core/page/EventHandler.cpp
index 9a76e6ebcaae7f80346e80340cb3bcfc03fc110b..d02a27a448ae0d41051c23fc9ccb14b7c90714c5 100644
--- a/Source/core/page/EventHandler.cpp
+++ b/Source/core/page/EventHandler.cpp
@@ -2784,12 +2784,10 @@ bool EventHandler::sendContextMenuEventForKey()
#else
int rightAligned = 0;
#endif
- IntPoint location;
-
+ IntPoint rootViewLocation;
Element* focusedElement = doc->focusedElement();
FrameSelection& selection = m_frame->selection();
Position start = selection.selection().start();
- bool shouldTranslateToRootView = true;
if (start.deprecatedNode() && (selection.rootEditableElement() || selection.isRange())) {
RefPtrWillBeRawPtr<Range> selectionRange = selection.toNormalizedRange();
@@ -2798,28 +2796,25 @@ bool EventHandler::sendContextMenuEventForKey()
int x = rightAligned ? firstRect.maxX() : firstRect.x();
// In a multiline edit, firstRect.maxY() would endup on the next line, so -1.
int y = firstRect.maxY() ? firstRect.maxY() - 1 : 0;
- location = IntPoint(x, y);
+ rootViewLocation = view->contentsToRootView(IntPoint(x, y));
} else if (focusedElement) {
IntRect clippedRect = focusedElement->boundsInRootViewSpace();
- location = IntPoint(clippedRect.center());
+ rootViewLocation = IntPoint(clippedRect.center());
} else {
- location = IntPoint(
+ rootViewLocation = IntPoint(
rightAligned ? view->contentsWidth() - kContextMenuMargin : kContextMenuMargin,
kContextMenuMargin);
- shouldTranslateToRootView = false;
}
m_frame->view()->setCursor(pointerCursor());
-
- IntPoint position = shouldTranslateToRootView ? view->contentsToRootView(location) : location;
- IntPoint globalPosition = view->hostWindow()->rootViewToScreen(IntRect(position, IntSize())).location();
+ IntPoint globalPosition = view->hostWindow()->rootViewToScreen(IntRect(rootViewLocation, IntSize())).location();
Node* targetNode = doc->focusedElement();
if (!targetNode)
targetNode = doc;
// Use the focused node as the target for hover and active.
- HitTestResult result(position);
+ HitTestResult result(rootViewLocation);
result.setInnerNode(targetNode);
doc->updateHoverActiveState(HitTestRequest::Active, result.innerElement());
@@ -2829,7 +2824,7 @@ bool EventHandler::sendContextMenuEventForKey()
if (m_frame->settings()->showContextMenuOnMouseUp())
eventType = PlatformEvent::MouseReleased;
- PlatformMouseEvent mouseEvent(position, globalPosition, RightButton, eventType, 1, false, false, false, false, PlatformMouseEvent::RealOrIndistinguishable, WTF::currentTime());
+ PlatformMouseEvent mouseEvent(rootViewLocation, globalPosition, RightButton, eventType, 1, false, false, false, false, PlatformMouseEvent::RealOrIndistinguishable, WTF::currentTime());
handleMousePressEvent(mouseEvent);
return sendContextMenuEvent(mouseEvent);

Powered by Google App Engine
This is Rietveld 408576698