Index: third_party/WebKit/Source/core/input/EventHandler.cpp |
diff --git a/third_party/WebKit/Source/core/input/EventHandler.cpp b/third_party/WebKit/Source/core/input/EventHandler.cpp |
index e8eb453d76839e49a7a01538684714985bd0bef8..24652d867eff47a849cc6d8c706dd295c682d871 100644 |
--- a/third_party/WebKit/Source/core/input/EventHandler.cpp |
+++ b/third_party/WebKit/Source/core/input/EventHandler.cpp |
@@ -1888,6 +1888,62 @@ WebInputEventResult EventHandler::SendContextMenuEventForKey( |
return SendContextMenuEvent(mouse_event, override_target_element); |
} |
+WebInputEventResult EventHandler::SendContextMenuEventForTouchSelection() { |
+ // TODO(editing-dev): The use of UpdateStyleAndLayoutIgnorePendingStylesheets |
+ // needs to be audited. See http://crbug.com/590369 for more details. |
+ frame_->GetDocument()->UpdateStyleAndLayoutIgnorePendingStylesheets(); |
+ FrameSelection& selection = frame_->Selection(); |
+ if (!(selection.IsAvailable() && selection.IsHandleVisible() && |
+ selection.ComputeVisibleSelectionInFlatTree().IsRange())) |
+ return WebInputEventResult::kNotHandled; |
+ |
+ FrameView* view = frame_->View(); |
+ if (!view) |
+ return WebInputEventResult::kNotHandled; |
+ |
+ Document* doc = frame_->GetDocument(); |
+ if (!doc) |
+ return WebInputEventResult::kNotHandled; |
+ |
+ IntPoint location_in_root_frame; |
+ |
+ VisualViewport& visual_viewport = frame_->GetPage()->GetVisualViewport(); |
+ |
+ // TODO(xiaochengh): The use of UpdateStyleAndLayoutIgnorePendingStylesheets |
+ // needs to be audited. See http://crbug.com/590369 for more details. |
+ doc->UpdateStyleAndLayoutIgnorePendingStylesheets(); |
+ |
+ IntRect first_rect = frame_->GetEditor().FirstRectForRange( |
+ selection.ComputeVisibleSelectionInDOMTree() |
+ .ToNormalizedEphemeralRange()); |
+ |
+ location_in_root_frame = view->ContentsToRootFrame(first_rect.Center()); |
+ |
+ IntPoint location_in_viewport = |
+ visual_viewport.RootFrameToViewport(location_in_root_frame); |
+ IntPoint global_position = |
aelias_OOO_until_Jul13
2017/04/21 21:42:19
Could you refactor the code that's duplicated-ish
|
+ view->GetChromeClient() |
+ ->ViewportToScreen(IntRect(location_in_viewport, IntSize()), |
+ frame_->View()) |
+ .Location(); |
+ |
+ WebMouseEvent mouse_event( |
+ WebInputEvent::kMouseDown, |
+ WebFloatPoint(location_in_root_frame.X(), location_in_root_frame.Y()), |
+ WebFloatPoint(global_position.X(), global_position.Y()), |
+ WebPointerProperties::Button::kNoButton, /* clickCount */ 0, |
+ static_cast<WebInputEvent::Modifiers>( |
+ WebInputEvent::Modifiers::kRightButtonDown | |
+ WebInputEvent::kIsCompatibilityEventForTouch), |
+ TimeTicks::Now().InSeconds()); |
+ |
+ // TODO(dtapuska): Transition the mouseEvent to be created really in viewport |
+ // coordinates instead of root frame coordinates. |
+ mouse_event.SetFrameScale(1); |
+ |
+ return SendContextMenuEvent(mouse_event); |
+} |
+ |
void EventHandler::ScheduleHoverStateUpdate() { |
// TODO(https://crbug.com/668758): Use a normal BeginFrame update for this. |
if (!hover_timer_.IsActive() && |