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

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

Issue 2814343002: Fire a click event even when a clicked text node is removed in mouseup (Closed)
Patch Set: 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
« no previous file with comments | « third_party/WebKit/Source/core/input/MouseEventManager.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/MouseEventManager.h" 5 #include "core/input/MouseEventManager.h"
6 6
7 #include "core/clipboard/DataObject.h" 7 #include "core/clipboard/DataObject.h"
8 #include "core/clipboard/DataTransfer.h" 8 #include "core/clipboard/DataTransfer.h"
9 #include "core/dom/Element.h" 9 #include "core/dom/Element.h"
10 #include "core/dom/ElementTraversal.h" 10 #include "core/dom/ElementTraversal.h"
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 if (targetNode && targetNode->isTextNode()) 223 if (targetNode && targetNode->isTextNode())
224 targetNode = FlatTreeTraversal::parent(*targetNode); 224 targetNode = FlatTreeTraversal::parent(*targetNode);
225 225
226 setNodeUnderMouse(targetNode, canvasRegionId, webMouseEvent); 226 setNodeUnderMouse(targetNode, canvasRegionId, webMouseEvent);
227 227
228 return dispatchMouseEvent(m_nodeUnderMouse, eventType, webMouseEvent, 228 return dispatchMouseEvent(m_nodeUnderMouse, eventType, webMouseEvent,
229 canvasRegionId, nullptr); 229 canvasRegionId, nullptr);
230 } 230 }
231 231
232 WebInputEventResult MouseEventManager::dispatchMouseClickIfNeeded( 232 WebInputEventResult MouseEventManager::dispatchMouseClickIfNeeded(
233 const MouseEventWithHitTestResults& mev) { 233 const MouseEventWithHitTestResults& mev,
234 Node* releaseNode) {
234 // We only prevent click event when the click may cause contextmenu to popup. 235 // We only prevent click event when the click may cause contextmenu to popup.
235 // However, we always send auxclick. 236 // However, we always send auxclick.
236 bool contextMenuEvent = 237 bool contextMenuEvent =
237 !RuntimeEnabledFeatures::auxclickEnabled() && 238 !RuntimeEnabledFeatures::auxclickEnabled() &&
238 mev.event().button == WebPointerProperties::Button::Right; 239 mev.event().button == WebPointerProperties::Button::Right;
239 #if OS(MACOSX) 240 #if OS(MACOSX)
240 // FIXME: The Mac port achieves the same behavior by checking whether the 241 // FIXME: The Mac port achieves the same behavior by checking whether the
241 // context menu is currently open in WebPage::mouseEvent(). Consider merging 242 // context menu is currently open in WebPage::mouseEvent(). Consider merging
242 // the implementations. 243 // the implementations.
243 if (mev.event().button == WebPointerProperties::Button::Left && 244 if (mev.event().button == WebPointerProperties::Button::Left &&
244 mev.event().modifiers() & WebInputEvent::Modifiers::ControlKey) 245 mev.event().modifiers() & WebInputEvent::Modifiers::ControlKey)
245 contextMenuEvent = true; 246 contextMenuEvent = true;
246 #endif 247 #endif
247 248
248 WebInputEventResult clickEventResult = WebInputEventResult::NotHandled; 249 WebInputEventResult clickEventResult = WebInputEventResult::NotHandled;
249 const bool shouldDispatchClickEvent = 250 const bool shouldDispatchClickEvent =
250 m_clickCount > 0 && !contextMenuEvent && mev.innerNode() && m_clickNode && 251 m_clickCount > 0 && !contextMenuEvent && releaseNode && m_clickNode &&
251 mev.innerNode()->canParticipateInFlatTree() && 252 releaseNode->canParticipateInFlatTree() &&
252 m_clickNode->canParticipateInFlatTree() && 253 m_clickNode->canParticipateInFlatTree() &&
253 !(m_frame->eventHandler().selectionController().hasExtendedSelection() && 254 !(m_frame->eventHandler().selectionController().hasExtendedSelection() &&
254 isLinkSelection(mev)); 255 isLinkSelection(mev));
255 if (shouldDispatchClickEvent) { 256 if (shouldDispatchClickEvent) {
256 Node* clickTargetNode = nullptr; 257 Node* clickTargetNode = nullptr;
257 // Updates distribution because a 'mouseup' event listener can make the 258 if (m_clickNode == releaseNode) {
258 // tree dirty at dispatchMouseEvent() invocation above.
259 // Unless distribution is updated, commonAncestor would hit ASSERT.
260 if (m_clickNode == mev.innerNode()) {
261 clickTargetNode = m_clickNode; 259 clickTargetNode = m_clickNode;
262 clickTargetNode->updateDistribution();
263 } else if (m_clickNode->document() == mev.innerNode()->document()) { 260 } else if (m_clickNode->document() == mev.innerNode()->document()) {
261 // Updates distribution because a 'mouseup' event listener can make the
262 // tree dirty at dispatchMouseEvent() invocation above.
263 // Unless distribution is updated, commonAncestor would hit ASSERT.
264 m_clickNode->updateDistribution(); 264 m_clickNode->updateDistribution();
265 mev.innerNode()->updateDistribution(); 265 mev.innerNode()->updateDistribution();
266 clickTargetNode = mev.innerNode()->commonAncestor( 266 clickTargetNode = releaseNode->commonAncestor(
267 *m_clickNode, EventHandlingUtil::parentForClickEvent); 267 *m_clickNode, EventHandlingUtil::parentForClickEvent);
268 } 268 }
269 if (clickTargetNode) { 269 if (clickTargetNode) {
270 clickEventResult = dispatchMouseEvent( 270 clickEventResult = dispatchMouseEvent(
271 clickTargetNode, 271 clickTargetNode,
272 !RuntimeEnabledFeatures::auxclickEnabled() || 272 !RuntimeEnabledFeatures::auxclickEnabled() ||
273 (mev.event().button == WebPointerProperties::Button::Left) 273 (mev.event().button == WebPointerProperties::Button::Left)
274 ? EventTypeNames::click 274 ? EventTypeNames::click
275 : EventTypeNames::auxclick, 275 : EventTypeNames::auxclick,
276 mev.event(), mev.canvasRegionId(), nullptr); 276 mev.event(), mev.canvasRegionId(), nullptr);
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after
1013 1013
1014 void MouseEventManager::setClickCount(int clickCount) { 1014 void MouseEventManager::setClickCount(int clickCount) {
1015 m_clickCount = clickCount; 1015 m_clickCount = clickCount;
1016 } 1016 }
1017 1017
1018 bool MouseEventManager::mouseDownMayStartDrag() { 1018 bool MouseEventManager::mouseDownMayStartDrag() {
1019 return m_mouseDownMayStartDrag; 1019 return m_mouseDownMayStartDrag;
1020 } 1020 }
1021 1021
1022 } // namespace blink 1022 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/input/MouseEventManager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698