| OLD | NEW |
| 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 Loading... |
| 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 Node* target, |
| 234 const WebMouseEvent& mouseEvent, |
| 235 const String& canvasRegionId) { |
| 234 // We only prevent click event when the click may cause contextmenu to popup. | 236 // We only prevent click event when the click may cause contextmenu to popup. |
| 235 // However, we always send auxclick. | 237 // However, we always send auxclick. |
| 236 bool contextMenuEvent = | 238 bool contextMenuEvent = |
| 237 !RuntimeEnabledFeatures::auxclickEnabled() && | 239 !RuntimeEnabledFeatures::auxclickEnabled() && |
| 238 mev.event().button == WebPointerProperties::Button::Right; | 240 mouseEvent.button == WebPointerProperties::Button::Right; |
| 239 #if OS(MACOSX) | 241 #if OS(MACOSX) |
| 240 // FIXME: The Mac port achieves the same behavior by checking whether the | 242 // FIXME: The Mac port achieves the same behavior by checking whether the |
| 241 // context menu is currently open in WebPage::mouseEvent(). Consider merging | 243 // context menu is currently open in WebPage::mouseEvent(). Consider merging |
| 242 // the implementations. | 244 // the implementations. |
| 243 if (mev.event().button == WebPointerProperties::Button::Left && | 245 if (mouseEvent.button == WebPointerProperties::Button::Left && |
| 244 mev.event().modifiers() & WebInputEvent::Modifiers::ControlKey) | 246 mouseEvent.modifiers() & WebInputEvent::Modifiers::ControlKey) |
| 245 contextMenuEvent = true; | 247 contextMenuEvent = true; |
| 246 #endif | 248 #endif |
| 247 | 249 |
| 248 WebInputEventResult clickEventResult = WebInputEventResult::NotHandled; | 250 WebInputEventResult clickEventResult = WebInputEventResult::NotHandled; |
| 249 const bool shouldDispatchClickEvent = | 251 const bool shouldDispatchClickEvent = m_clickCount > 0 && !contextMenuEvent && |
| 250 m_clickCount > 0 && !contextMenuEvent && mev.innerNode() && m_clickNode && | 252 target && m_clickNode && |
| 251 mev.innerNode()->canParticipateInFlatTree() && | 253 target->canParticipateInFlatTree() && |
| 252 m_clickNode->canParticipateInFlatTree() && | 254 m_clickNode->canParticipateInFlatTree(); |
| 253 !(m_frame->eventHandler().selectionController().hasExtendedSelection() && | |
| 254 isLinkSelection(mev)); | |
| 255 if (shouldDispatchClickEvent) { | 255 if (shouldDispatchClickEvent) { |
| 256 Node* clickTargetNode = nullptr; | 256 Node* clickTargetNode = nullptr; |
| 257 // Updates distribution because a 'mouseup' event listener can make the | 257 // Updates distribution because a 'mouseup' event listener can make the |
| 258 // tree dirty at dispatchMouseEvent() invocation above. | 258 // tree dirty at dispatchMouseEvent() invocation above. |
| 259 // Unless distribution is updated, commonAncestor would hit ASSERT. | 259 // Unless distribution is updated, commonAncestor would hit ASSERT. |
| 260 if (m_clickNode == mev.innerNode()) { | 260 if (m_clickNode == target) { |
| 261 clickTargetNode = m_clickNode; | 261 clickTargetNode = m_clickNode; |
| 262 clickTargetNode->updateDistribution(); | 262 clickTargetNode->updateDistribution(); |
| 263 } else if (m_clickNode->document() == mev.innerNode()->document()) { | 263 } else if (m_clickNode->document() == target->document()) { |
| 264 m_clickNode->updateDistribution(); | 264 m_clickNode->updateDistribution(); |
| 265 mev.innerNode()->updateDistribution(); | 265 target->updateDistribution(); |
| 266 clickTargetNode = mev.innerNode()->commonAncestor( | 266 clickTargetNode = target->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 (mouseEvent.button == WebPointerProperties::Button::Left) |
| 274 ? EventTypeNames::click | 274 ? EventTypeNames::click |
| 275 : EventTypeNames::auxclick, | 275 : EventTypeNames::auxclick, |
| 276 mev.event(), mev.canvasRegionId(), nullptr); | 276 mouseEvent, canvasRegionId, nullptr); |
| 277 } | 277 } |
| 278 } | 278 } |
| 279 return clickEventResult; | 279 return clickEventResult; |
| 280 } | 280 } |
| 281 | 281 |
| 282 void MouseEventManager::fakeMouseMoveEventTimerFired(TimerBase* timer) { | 282 void MouseEventManager::fakeMouseMoveEventTimerFired(TimerBase* timer) { |
| 283 TRACE_EVENT0("input", "MouseEventManager::fakeMouseMoveEventTimerFired"); | 283 TRACE_EVENT0("input", "MouseEventManager::fakeMouseMoveEventTimerFired"); |
| 284 DCHECK(timer == &m_fakeMouseMoveEventTimer); | 284 DCHECK(timer == &m_fakeMouseMoveEventTimer); |
| 285 DCHECK(!m_mousePressed); | 285 DCHECK(!m_mousePressed); |
| 286 | 286 |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 m_frame->document()->updateStyleAndLayoutIgnorePendingStylesheets(); | 566 m_frame->document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
| 567 | 567 |
| 568 if (FrameView* frameView = m_frame->view()) { | 568 if (FrameView* frameView = m_frame->view()) { |
| 569 if (frameView->isPointInScrollbarCorner( | 569 if (frameView->isPointInScrollbarCorner( |
| 570 flooredIntPoint(event.event().positionInRootFrame()))) | 570 flooredIntPoint(event.event().positionInRootFrame()))) |
| 571 return WebInputEventResult::NotHandled; | 571 return WebInputEventResult::NotHandled; |
| 572 } | 572 } |
| 573 | 573 |
| 574 bool singleClick = event.event().clickCount <= 1; | 574 bool singleClick = event.event().clickCount <= 1; |
| 575 | 575 |
| 576 m_mouseDownMayStartDrag = | 576 m_mouseDownMayStartDrag = singleClick && !isSelectionOverLink(event) && |
| 577 singleClick && !isLinkSelection(event) && !isExtendingSelection(event); | 577 !isExtendingSelection(event); |
| 578 | 578 |
| 579 m_frame->eventHandler().selectionController().handleMousePressEvent(event); | 579 m_frame->eventHandler().selectionController().handleMousePressEvent(event); |
| 580 | 580 |
| 581 m_mouseDown = event.event(); | 581 m_mouseDown = event.event(); |
| 582 | 582 |
| 583 if (m_frame->document()->isSVGDocument() && | 583 if (m_frame->document()->isSVGDocument() && |
| 584 m_frame->document()->accessSVGExtensions().zoomAndPanEnabled()) { | 584 m_frame->document()->accessSVGExtensions().zoomAndPanEnabled()) { |
| 585 if ((event.event().modifiers() & WebInputEvent::Modifiers::ShiftKey) && | 585 if ((event.event().modifiers() & WebInputEvent::Modifiers::ShiftKey) && |
| 586 singleClick) { | 586 singleClick) { |
| 587 m_svgPan = true; | 587 m_svgPan = true; |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1011 | 1011 |
| 1012 void MouseEventManager::setClickCount(int clickCount) { | 1012 void MouseEventManager::setClickCount(int clickCount) { |
| 1013 m_clickCount = clickCount; | 1013 m_clickCount = clickCount; |
| 1014 } | 1014 } |
| 1015 | 1015 |
| 1016 bool MouseEventManager::mouseDownMayStartDrag() { | 1016 bool MouseEventManager::mouseDownMayStartDrag() { |
| 1017 return m_mouseDownMayStartDrag; | 1017 return m_mouseDownMayStartDrag; |
| 1018 } | 1018 } |
| 1019 | 1019 |
| 1020 } // namespace blink | 1020 } // namespace blink |
| OLD | NEW |