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

Side by Side Diff: third_party/WebKit/Source/core/input/EventHandler.cpp

Issue 2785853002: Selection Action mode triggered like a context menu (Closed)
Patch Set: fixing tests Created 3 years, 7 months 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights
3 * reserved. 3 * reserved.
4 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) 4 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org)
5 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) 5 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies)
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 1792 matching lines...) Expand 10 before | Expand all | Expand 10 after
1803 } 1803 }
1804 1804
1805 static bool ShouldShowContextMenuAtSelection(const FrameSelection& selection) { 1805 static bool ShouldShowContextMenuAtSelection(const FrameSelection& selection) {
1806 const VisibleSelection& visible_selection = 1806 const VisibleSelection& visible_selection =
1807 selection.ComputeVisibleSelectionInDOMTreeDeprecated(); 1807 selection.ComputeVisibleSelectionInDOMTreeDeprecated();
1808 if (!visible_selection.IsRange() && !visible_selection.RootEditableElement()) 1808 if (!visible_selection.IsRange() && !visible_selection.RootEditableElement())
1809 return false; 1809 return false;
1810 return selection.SelectionHasFocus(); 1810 return selection.SelectionHasFocus();
1811 } 1811 }
1812 1812
1813 WebInputEventResult EventHandler::SendContextMenuEventForKey( 1813 WebInputEventResult EventHandler::ShowNonLocatedContextMenu(
yosin_UTC9 2017/05/25 04:47:21 Can we have another patch rename |SendContextMenuE
amaralp1 2017/05/25 07:11:56 Done. https://codereview.chromium.org/2905783002
1814 Element* override_target_element, 1814 Element* override_target_element,
1815 WebMenuSourceType source_type) { 1815 WebMenuSourceType source_type) {
1816 FrameView* view = frame_->View(); 1816 FrameView* view = frame_->View();
1817 if (!view) 1817 if (!view)
1818 return WebInputEventResult::kNotHandled; 1818 return WebInputEventResult::kNotHandled;
1819 1819
1820 Document* doc = frame_->GetDocument(); 1820 Document* doc = frame_->GetDocument();
1821 if (!doc) 1821 if (!doc)
1822 return WebInputEventResult::kNotHandled; 1822 return WebInputEventResult::kNotHandled;
1823 1823
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1875 if (!target_node) 1875 if (!target_node)
1876 target_node = doc; 1876 target_node = doc;
1877 1877
1878 // Use the focused node as the target for hover and active. 1878 // Use the focused node as the target for hover and active.
1879 HitTestRequest request(HitTestRequest::kActive); 1879 HitTestRequest request(HitTestRequest::kActive);
1880 HitTestResult result(request, location_in_root_frame); 1880 HitTestResult result(request, location_in_root_frame);
1881 result.SetInnerNode(target_node); 1881 result.SetInnerNode(target_node);
1882 doc->UpdateHoverActiveState(request, result.InnerElement()); 1882 doc->UpdateHoverActiveState(request, result.InnerElement());
1883 1883
1884 // The contextmenu event is a mouse event even when invoked using the 1884 // The contextmenu event is a mouse event even when invoked using the
1885 // keyboard. This is required for web compatibility. 1885 // keyboard or other methods. This is required for web compatibility.
1886 WebInputEvent::Type event_type = WebInputEvent::kMouseDown; 1886 WebInputEvent::Type event_type = WebInputEvent::kMouseDown;
1887 if (frame_->GetSettings() && 1887 if (frame_->GetSettings() &&
1888 frame_->GetSettings()->GetShowContextMenuOnMouseUp()) 1888 frame_->GetSettings()->GetShowContextMenuOnMouseUp())
1889 event_type = WebInputEvent::kMouseUp; 1889 event_type = WebInputEvent::kMouseUp;
1890 1890
1891 WebInputEvent::Modifiers modifiers;
1892 switch (source_type) {
1893 case kMenuSourceTouch:
1894 case kMenuSourceLongPress:
1895 case kMenuSourceTouchHandle:
1896 modifiers = WebInputEvent::kIsCompatibilityEventForTouch;
1897 break;
1898 default:
1899 modifiers = WebInputEvent::kNoModifiers;
1900 break;
1901 }
1902
1891 WebMouseEvent mouse_event( 1903 WebMouseEvent mouse_event(
1892 event_type, 1904 event_type,
1893 WebFloatPoint(location_in_root_frame.X(), location_in_root_frame.Y()), 1905 WebFloatPoint(location_in_root_frame.X(), location_in_root_frame.Y()),
1894 WebFloatPoint(global_position.X(), global_position.Y()), 1906 WebFloatPoint(global_position.X(), global_position.Y()),
1895 WebPointerProperties::Button::kNoButton, /* clickCount */ 0, 1907 WebPointerProperties::Button::kNoButton, /* clickCount */ 0, modifiers,
1896 ((source_type == kMenuSourceTouchHandle)
1897 ? WebInputEvent::kIsCompatibilityEventForTouch
1898 : WebInputEvent::kNoModifiers),
1899 TimeTicks::Now().InSeconds()); 1908 TimeTicks::Now().InSeconds());
1900 1909
1901 // TODO(dtapuska): Transition the mouseEvent to be created really in viewport 1910 // TODO(dtapuska): Transition the mouseEvent to be created really in viewport
1902 // coordinates instead of root frame coordinates. 1911 // coordinates instead of root frame coordinates.
1903 mouse_event.SetFrameScale(1); 1912 mouse_event.SetFrameScale(1);
1904 1913
1905 return SendContextMenuEvent(mouse_event, override_target_element); 1914 return SendContextMenuEvent(mouse_event, override_target_element);
1906 } 1915 }
1907 1916
1908 void EventHandler::ScheduleHoverStateUpdate() { 1917 void EventHandler::ScheduleHoverStateUpdate() {
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
2126 MouseEventWithHitTestResults& mev, 2135 MouseEventWithHitTestResults& mev,
2127 LocalFrame* subframe) { 2136 LocalFrame* subframe) {
2128 WebInputEventResult result = 2137 WebInputEventResult result =
2129 subframe->GetEventHandler().HandleMouseReleaseEvent(mev.Event()); 2138 subframe->GetEventHandler().HandleMouseReleaseEvent(mev.Event());
2130 if (result != WebInputEventResult::kNotHandled) 2139 if (result != WebInputEventResult::kNotHandled)
2131 return result; 2140 return result;
2132 return WebInputEventResult::kHandledSystem; 2141 return WebInputEventResult::kHandledSystem;
2133 } 2142 }
2134 2143
2135 } // namespace blink 2144 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698