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

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

Issue 2807123002: Fix the wrong non-element node handling in EventHanlder and MouseEventManager (Closed)
Patch Set: Addressed Created 3 years, 8 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 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/input/GestureManager.h" 5 #include "core/input/GestureManager.h"
6 6
7 #include "core/dom/Document.h" 7 #include "core/dom/Document.h"
8 #include "core/dom/DocumentUserGestureToken.h" 8 #include "core/dom/DocumentUserGestureToken.h"
9 #include "core/editing/SelectionController.h" 9 #include "core/editing/SelectionController.h"
10 #include "core/events/GestureEvent.h" 10 #include "core/events/GestureEvent.h"
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 LocalFrame* main_frame = frame_->LocalFrameRoot(); 178 LocalFrame* main_frame = frame_->LocalFrameRoot();
179 if (main_frame && main_frame->View()) 179 if (main_frame && main_frame->View())
180 main_frame->View()->UpdateLifecycleToCompositingCleanPlusScrolling(); 180 main_frame->View()->UpdateLifecycleToCompositingCleanPlusScrolling();
181 adjusted_point = frame_view->RootFrameToContents( 181 adjusted_point = frame_view->RootFrameToContents(
182 FlooredIntPoint(gesture_event.PositionInRootFrame())); 182 FlooredIntPoint(gesture_event.PositionInRootFrame()));
183 current_hit_test = EventHandlingUtil::HitTestResultInFrame( 183 current_hit_test = EventHandlingUtil::HitTestResultInFrame(
184 frame_, adjusted_point, hit_type); 184 frame_, adjusted_point, hit_type);
185 } 185 }
186 186
187 // Capture data for showUnhandledTapUIIfNeeded. 187 // Capture data for showUnhandledTapUIIfNeeded.
188 Node* tapped_node = current_hit_test.InnerNode();
189 IntPoint tapped_position = 188 IntPoint tapped_position =
190 FlooredIntPoint(gesture_event.PositionInRootFrame()); 189 FlooredIntPoint(gesture_event.PositionInRootFrame());
191 Node* tapped_non_text_node = tapped_node; 190 Node* tapped_node = current_hit_test.InnerNode();
191 Element* tapped_element =
192 EventHandlingUtil::ParentElementIfNeeded(tapped_node);
192 UserGestureIndicator gesture_indicator(DocumentUserGestureToken::Create( 193 UserGestureIndicator gesture_indicator(DocumentUserGestureToken::Create(
193 tapped_node ? &tapped_node->GetDocument() : nullptr)); 194 tapped_node ? &tapped_node->GetDocument() : nullptr));
194 195
195 if (tapped_non_text_node && tapped_non_text_node->IsTextNode()) 196 mouse_event_manager_->SetClickElement(tapped_element);
196 tapped_non_text_node = FlatTreeTraversal::Parent(*tapped_non_text_node);
197
198 mouse_event_manager_->SetClickNode(tapped_non_text_node);
199 197
200 WebMouseEvent fake_mouse_down( 198 WebMouseEvent fake_mouse_down(
201 WebInputEvent::kMouseDown, gesture_event, 199 WebInputEvent::kMouseDown, gesture_event,
202 WebPointerProperties::Button::kLeft, gesture_event.TapCount(), 200 WebPointerProperties::Button::kLeft, gesture_event.TapCount(),
203 static_cast<WebInputEvent::Modifiers>( 201 static_cast<WebInputEvent::Modifiers>(
204 modifiers | WebInputEvent::Modifiers::kLeftButtonDown | 202 modifiers | WebInputEvent::Modifiers::kLeftButtonDown |
205 WebInputEvent::Modifiers::kIsCompatibilityEventForTouch), 203 WebInputEvent::Modifiers::kIsCompatibilityEventForTouch),
206 gesture_event.TimeStampSeconds()); 204 gesture_event.TimeStampSeconds());
207 205
208 // TODO(mustaq): We suppress MEs plus all it's side effects. What would that 206 // TODO(mustaq): We suppress MEs plus all it's side effects. What would that
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 modifiers | WebInputEvent::Modifiers::kIsCompatibilityEventForTouch), 253 modifiers | WebInputEvent::Modifiers::kIsCompatibilityEventForTouch),
256 gesture_event.TimeStampSeconds()); 254 gesture_event.TimeStampSeconds());
257 WebInputEventResult mouse_up_event_result = 255 WebInputEventResult mouse_up_event_result =
258 suppress_mouse_events_from_gestures_ 256 suppress_mouse_events_from_gestures_
259 ? WebInputEventResult::kHandledSuppressed 257 ? WebInputEventResult::kHandledSuppressed
260 : mouse_event_manager_->SetMousePositionAndDispatchMouseEvent( 258 : mouse_event_manager_->SetMousePositionAndDispatchMouseEvent(
261 current_hit_test.InnerNode(), current_hit_test.CanvasRegionId(), 259 current_hit_test.InnerNode(), current_hit_test.CanvasRegionId(),
262 EventTypeNames::mouseup, fake_mouse_up); 260 EventTypeNames::mouseup, fake_mouse_up);
263 261
264 WebInputEventResult click_event_result = WebInputEventResult::kNotHandled; 262 WebInputEventResult click_event_result = WebInputEventResult::kNotHandled;
265 if (tapped_non_text_node) { 263 if (tapped_element) {
266 if (current_hit_test.InnerNode()) { 264 if (current_hit_test.InnerNode()) {
267 // Updates distribution because a mouseup (or mousedown) event listener 265 // Updates distribution because a mouseup (or mousedown) event listener
268 // can make the tree dirty at dispatchMouseEvent() invocation above. 266 // can make the tree dirty at dispatchMouseEvent() invocation above.
269 // Unless distribution is updated, commonAncestor would hit DCHECK. Both 267 // Unless distribution is updated, commonAncestor would hit DCHECK. Both
270 // tappedNonTextNode and currentHitTest.innerNode()) don't need to be 268 // tappedNonTextNode and currentHitTest.innerNode()) don't need to be
271 // updated because commonAncestor() will exit early if their documents are 269 // updated because commonAncestor() will exit early if their documents are
272 // different. 270 // different.
273 tapped_non_text_node->UpdateDistribution(); 271 tapped_element->UpdateDistribution();
274 Node* click_target_node = current_hit_test.InnerNode()->CommonAncestor( 272 Node* click_target_node = current_hit_test.InnerNode()->CommonAncestor(
275 *tapped_non_text_node, EventHandlingUtil::ParentForClickEvent); 273 *tapped_element, EventHandlingUtil::ParentForClickEvent);
276 click_event_result = 274 click_event_result =
277 mouse_event_manager_->SetMousePositionAndDispatchMouseEvent( 275 mouse_event_manager_->SetMousePositionAndDispatchMouseEvent(
278 click_target_node, String(), EventTypeNames::click, 276 click_target_node, String(), EventTypeNames::click,
279 fake_mouse_up); 277 fake_mouse_up);
280 } 278 }
281 mouse_event_manager_->SetClickNode(nullptr); 279 mouse_event_manager_->SetClickElement(nullptr);
282 } 280 }
283 281
284 if (mouse_up_event_result == WebInputEventResult::kNotHandled) 282 if (mouse_up_event_result == WebInputEventResult::kNotHandled)
285 mouse_up_event_result = mouse_event_manager_->HandleMouseReleaseEvent( 283 mouse_up_event_result = mouse_event_manager_->HandleMouseReleaseEvent(
286 MouseEventWithHitTestResults(fake_mouse_up, current_hit_test)); 284 MouseEventWithHitTestResults(fake_mouse_up, current_hit_test));
287 mouse_event_manager_->ClearDragHeuristicState(); 285 mouse_event_manager_->ClearDragHeuristicState();
288 286
289 WebInputEventResult event_result = EventHandlingUtil::MergeEventResult( 287 WebInputEventResult event_result = EventHandlingUtil::MergeEventResult(
290 EventHandlingUtil::MergeEventResult(mouse_down_event_result, 288 EventHandlingUtil::MergeEventResult(mouse_down_event_result,
291 mouse_up_event_result), 289 mouse_up_event_result),
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 } 430 }
433 return WebInputEventResult::kNotHandled; 431 return WebInputEventResult::kNotHandled;
434 } 432 }
435 433
436 WTF::Optional<WTF::TimeTicks> GestureManager::GetLastShowPressTimestamp() 434 WTF::Optional<WTF::TimeTicks> GestureManager::GetLastShowPressTimestamp()
437 const { 435 const {
438 return last_show_press_timestamp_; 436 return last_show_press_timestamp_;
439 } 437 }
440 438
441 } // namespace blink 439 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698