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

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: nits and fix tests Created 3 years, 6 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::SendContextMenuEventForKey(
bokan 2017/05/24 19:15:52 This method should be renamed as it's not just for
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. This is required for web compatibility.
bokan 2017/05/24 19:15:52 keyboard or other methods.
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
1917 void EventHandler::SendContextMenuEventForTouchSelection(
1918 WebMenuSourceType menu_source) {
1919 // TODO(editing-dev): The use of UpdateStyleAndLayoutIgnorePendingStylesheets
1920 // needs to be audited. See http://crbug.com/590369 for more details.
1921 frame_->GetDocument()->UpdateStyleAndLayoutIgnorePendingStylesheets();
1922 FrameSelection& selection = frame_->Selection();
1923 if (!selection.IsAvailable() || !selection.IsHandleVisible() ||
bokan 2017/05/24 19:15:52 Do we need a new method here? Couldn't we just do
1924 selection.IsHidden())
1925 return;
1926 SendContextMenuEventForKey(nullptr, menu_source);
1927 }
1928
1908 void EventHandler::ScheduleHoverStateUpdate() { 1929 void EventHandler::ScheduleHoverStateUpdate() {
1909 // TODO(https://crbug.com/668758): Use a normal BeginFrame update for this. 1930 // TODO(https://crbug.com/668758): Use a normal BeginFrame update for this.
1910 if (!hover_timer_.IsActive() && 1931 if (!hover_timer_.IsActive() &&
1911 !mouse_event_manager_->IsMousePositionUnknown()) 1932 !mouse_event_manager_->IsMousePositionUnknown())
1912 hover_timer_.StartOneShot(0, BLINK_FROM_HERE); 1933 hover_timer_.StartOneShot(0, BLINK_FROM_HERE);
1913 } 1934 }
1914 1935
1915 void EventHandler::ScheduleCursorUpdate() { 1936 void EventHandler::ScheduleCursorUpdate() {
1916 // We only want one timer for the page, rather than each frame having it's own 1937 // We only want one timer for the page, rather than each frame having it's own
1917 // timer competing which eachother (since there's only one mouse cursor). 1938 // timer competing which eachother (since there's only one mouse cursor).
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
2126 MouseEventWithHitTestResults& mev, 2147 MouseEventWithHitTestResults& mev,
2127 LocalFrame* subframe) { 2148 LocalFrame* subframe) {
2128 WebInputEventResult result = 2149 WebInputEventResult result =
2129 subframe->GetEventHandler().HandleMouseReleaseEvent(mev.Event()); 2150 subframe->GetEventHandler().HandleMouseReleaseEvent(mev.Event());
2130 if (result != WebInputEventResult::kNotHandled) 2151 if (result != WebInputEventResult::kNotHandled)
2131 return result; 2152 return result;
2132 return WebInputEventResult::kHandledSystem; 2153 return WebInputEventResult::kHandledSystem;
2133 } 2154 }
2134 2155
2135 } // namespace blink 2156 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698