| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv
ed. | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv
ed. |
| 3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
| 4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) | 4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 #include "core/page/DragState.h" | 79 #include "core/page/DragState.h" |
| 80 #include "core/page/FocusController.h" | 80 #include "core/page/FocusController.h" |
| 81 #include "core/page/FrameTree.h" | 81 #include "core/page/FrameTree.h" |
| 82 #include "core/page/Page.h" | 82 #include "core/page/Page.h" |
| 83 #include "core/page/SpatialNavigation.h" | 83 #include "core/page/SpatialNavigation.h" |
| 84 #include "core/page/TouchAdjustment.h" | 84 #include "core/page/TouchAdjustment.h" |
| 85 #include "core/page/scrolling/ScrollState.h" | 85 #include "core/page/scrolling/ScrollState.h" |
| 86 #include "core/paint/PaintLayer.h" | 86 #include "core/paint/PaintLayer.h" |
| 87 #include "core/style/ComputedStyle.h" | 87 #include "core/style/ComputedStyle.h" |
| 88 #include "core/svg/SVGDocumentExtensions.h" | 88 #include "core/svg/SVGDocumentExtensions.h" |
| 89 #include "platform/Histogram.h" |
| 89 #include "platform/PlatformGestureEvent.h" | 90 #include "platform/PlatformGestureEvent.h" |
| 90 #include "platform/PlatformKeyboardEvent.h" | 91 #include "platform/PlatformKeyboardEvent.h" |
| 91 #include "platform/PlatformTouchEvent.h" | 92 #include "platform/PlatformTouchEvent.h" |
| 92 #include "platform/PlatformWheelEvent.h" | 93 #include "platform/PlatformWheelEvent.h" |
| 93 #include "platform/RuntimeEnabledFeatures.h" | 94 #include "platform/RuntimeEnabledFeatures.h" |
| 94 #include "platform/TraceEvent.h" | 95 #include "platform/TraceEvent.h" |
| 95 #include "platform/WindowsKeyboardCodes.h" | 96 #include "platform/WindowsKeyboardCodes.h" |
| 96 #include "platform/geometry/FloatPoint.h" | 97 #include "platform/geometry/FloatPoint.h" |
| 97 #include "platform/graphics/Image.h" | 98 #include "platform/graphics/Image.h" |
| 98 #include "platform/heap/Handle.h" | 99 #include "platform/heap/Handle.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 // we'd like to EventHandler::handleMousePressEvent to pass the event to the wid
get and thus the | 160 // we'd like to EventHandler::handleMousePressEvent to pass the event to the wid
get and thus the |
| 160 // event target node can't still be the shadow node. | 161 // event target node can't still be the shadow node. |
| 161 bool shouldRefetchEventTarget(const MouseEventWithHitTestResults& mev) | 162 bool shouldRefetchEventTarget(const MouseEventWithHitTestResults& mev) |
| 162 { | 163 { |
| 163 Node* targetNode = mev.innerNode(); | 164 Node* targetNode = mev.innerNode(); |
| 164 if (!targetNode || !targetNode->parentNode()) | 165 if (!targetNode || !targetNode->parentNode()) |
| 165 return true; | 166 return true; |
| 166 return targetNode->isShadowRoot() && isHTMLInputElement(*toShadowRoot(target
Node)->host()); | 167 return targetNode->isShadowRoot() && isHTMLInputElement(*toShadowRoot(target
Node)->host()); |
| 167 } | 168 } |
| 168 | 169 |
| 170 // These offsets change indicies into the ListenerHistogram |
| 171 // enumeration. The addition of a series of offsets then |
| 172 // produces the resulting ListenerHistogram value. |
| 173 const size_t kTouchTargetHistogramRootScrollerOffset = 4; |
| 174 const size_t kTouchTargetHistogramScrollableDocumentOffset = 2; |
| 175 const size_t kTouchTargetHistogramHandledOffset = 1; |
| 176 |
| 177 enum TouchTargetAndDispatchResultType { |
| 178 NonRootScrollerNonScrollableNotHandled, // Non-root-scroller, non-scrollable
document, not handled. |
| 179 NonRootScrollerNonScrollableHandled, // Non-root-scroller, non-scrollable do
cument, handled application. |
| 180 NonRootScrollerScrollableDocumentNotHandled, // Non-root-scroller, scrollabl
e document, not handled. |
| 181 NonRootScrollerScrollableDocumentHandled, // Non-root-scroller, scrollable d
ocument, handled application. |
| 182 RootScrollerNonScrollableNotHandled, // Root-scroller, non-scrollable docume
nt, not handled. |
| 183 RootScrollerNonScrollableHandled, // Root-scroller, non-scrollable document,
handled. |
| 184 RootScrollerScrollableDocumentNotHandled, // Root-scroller, scrollable docum
ent, not handled. |
| 185 RootScrollerScrollableDocumentHandled, // Root-scroller, scrollable document
, handled. |
| 186 TouchTargetAndDispatchResultTypeMax, |
| 187 }; |
| 188 |
| 189 TouchTargetAndDispatchResultType toTouchTargetHistogramValue(EventTarget* eventT
arget, DispatchEventResult dispatchResult) |
| 190 { |
| 191 int result = 0; |
| 192 Document* document = nullptr; |
| 193 |
| 194 if (const LocalDOMWindow* domWindow = eventTarget->toLocalDOMWindow()) { |
| 195 // Treat the window as a root scroller as well. |
| 196 document = domWindow->document(); |
| 197 result += kTouchTargetHistogramRootScrollerOffset; |
| 198 } else if (Node* node = eventTarget->toNode()) { |
| 199 // Report if the target node is the document or body. |
| 200 if (node->isDocumentNode() || static_cast<Node*>(node->document().docume
ntElement()) == node || static_cast<Node*>(node->document().body()) == node) { |
| 201 result += kTouchTargetHistogramRootScrollerOffset; |
| 202 } |
| 203 document = &node->document(); |
| 204 } |
| 205 |
| 206 if (document) { |
| 207 FrameView* view = document->view(); |
| 208 if (view && view->isScrollable()) |
| 209 result += kTouchTargetHistogramScrollableDocumentOffset; |
| 210 } |
| 211 |
| 212 if (dispatchResult != DispatchEventResult::NotCanceled) |
| 213 result += kTouchTargetHistogramHandledOffset; |
| 214 return static_cast<TouchTargetAndDispatchResultType>(result); |
| 215 } |
| 216 |
| 169 } // namespace | 217 } // namespace |
| 170 | 218 |
| 171 using namespace HTMLNames; | 219 using namespace HTMLNames; |
| 172 | 220 |
| 173 // The link drag hysteresis is much larger than the others because there | 221 // The link drag hysteresis is much larger than the others because there |
| 174 // needs to be enough space to cancel the link press without starting a link dra
g, | 222 // needs to be enough space to cancel the link press without starting a link dra
g, |
| 175 // and because dragging links is rare. | 223 // and because dragging links is rare. |
| 176 static const int LinkDragHysteresis = 40; | 224 static const int LinkDragHysteresis = 40; |
| 177 static const int ImageDragHysteresis = 5; | 225 static const int ImageDragHysteresis = 5; |
| 178 static const int TextDragHysteresis = 3; | 226 static const int TextDragHysteresis = 3; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 , m_mousePositionIsUnknown(true) | 320 , m_mousePositionIsUnknown(true) |
| 273 , m_mouseDownTimestamp(0) | 321 , m_mouseDownTimestamp(0) |
| 274 , m_touchPressed(false) | 322 , m_touchPressed(false) |
| 275 , m_inPointerCanceledState(false) | 323 , m_inPointerCanceledState(false) |
| 276 , m_scrollGestureHandlingNode(nullptr) | 324 , m_scrollGestureHandlingNode(nullptr) |
| 277 , m_lastGestureScrollOverWidget(false) | 325 , m_lastGestureScrollOverWidget(false) |
| 278 , m_longTapShouldInvokeContextMenu(false) | 326 , m_longTapShouldInvokeContextMenu(false) |
| 279 , m_activeIntervalTimer(this, &EventHandler::activeIntervalTimerFired) | 327 , m_activeIntervalTimer(this, &EventHandler::activeIntervalTimerFired) |
| 280 , m_lastShowPressTimestamp(0) | 328 , m_lastShowPressTimestamp(0) |
| 281 , m_deltaConsumedForScrollSequence(false) | 329 , m_deltaConsumedForScrollSequence(false) |
| 330 , m_waitingForFirstTouchMove(false) |
| 282 { | 331 { |
| 283 } | 332 } |
| 284 | 333 |
| 285 EventHandler::~EventHandler() | 334 EventHandler::~EventHandler() |
| 286 { | 335 { |
| 287 ASSERT(!m_fakeMouseMoveEventTimer.isActive()); | 336 ASSERT(!m_fakeMouseMoveEventTimer.isActive()); |
| 288 } | 337 } |
| 289 | 338 |
| 290 DEFINE_TRACE(EventHandler) | 339 DEFINE_TRACE(EventHandler) |
| 291 { | 340 { |
| (...skipping 3345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3637 using EventTargetSet = HeapHashSet<Member<EventTarget>>; | 3686 using EventTargetSet = HeapHashSet<Member<EventTarget>>; |
| 3638 // Set of targets involved in m_touches. | 3687 // Set of targets involved in m_touches. |
| 3639 EventTargetSet m_targets; | 3688 EventTargetSet m_targets; |
| 3640 }; | 3689 }; |
| 3641 | 3690 |
| 3642 } // namespace | 3691 } // namespace |
| 3643 | 3692 |
| 3644 WebInputEventResult EventHandler::dispatchTouchEvents(const PlatformTouchEvent&
event, | 3693 WebInputEventResult EventHandler::dispatchTouchEvents(const PlatformTouchEvent&
event, |
| 3645 HeapVector<TouchInfo>& touchInfos, bool freshTouchEvents, bool allTouchRelea
sed) | 3694 HeapVector<TouchInfo>& touchInfos, bool freshTouchEvents, bool allTouchRelea
sed) |
| 3646 { | 3695 { |
| 3696 bool touchStartOrFirstTouchMove = false; |
| 3697 if (event.type() == PlatformEvent::TouchStart) { |
| 3698 m_waitingForFirstTouchMove = true; |
| 3699 touchStartOrFirstTouchMove = true; |
| 3700 } else if (event.type() == PlatformEvent::TouchMove) { |
| 3701 touchStartOrFirstTouchMove = m_waitingForFirstTouchMove; |
| 3702 m_waitingForFirstTouchMove = false; |
| 3703 } |
| 3704 |
| 3647 // Build up the lists to use for the 'touches', 'targetTouches' and | 3705 // Build up the lists to use for the 'touches', 'targetTouches' and |
| 3648 // 'changedTouches' attributes in the JS event. See | 3706 // 'changedTouches' attributes in the JS event. See |
| 3649 // http://www.w3.org/TR/touch-events/#touchevent-interface for how these | 3707 // http://www.w3.org/TR/touch-events/#touchevent-interface for how these |
| 3650 // lists fit together. | 3708 // lists fit together. |
| 3651 | 3709 |
| 3652 // Holds the complete set of touches on the screen. | 3710 // Holds the complete set of touches on the screen. |
| 3653 TouchList* touches = TouchList::create(); | 3711 TouchList* touches = TouchList::create(); |
| 3654 | 3712 |
| 3655 // A different view on the 'touches' list above, filtered and grouped by | 3713 // A different view on the 'touches' list above, filtered and grouped by |
| 3656 // event target. Used for the 'targetTouches' list in the JS event. | 3714 // event target. Used for the 'targetTouches' list in the JS event. |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3723 continue; | 3781 continue; |
| 3724 | 3782 |
| 3725 const AtomicString& eventName(touchEventNameForTouchPointState(static_ca
st<PlatformTouchPoint::TouchState>(state))); | 3783 const AtomicString& eventName(touchEventNameForTouchPointState(static_ca
st<PlatformTouchPoint::TouchState>(state))); |
| 3726 for (const auto& eventTarget : changedTouches[state].m_targets) { | 3784 for (const auto& eventTarget : changedTouches[state].m_targets) { |
| 3727 EventTarget* touchEventTarget = eventTarget; | 3785 EventTarget* touchEventTarget = eventTarget; |
| 3728 TouchEvent* touchEvent = TouchEvent::create( | 3786 TouchEvent* touchEvent = TouchEvent::create( |
| 3729 touches, touchesByTarget.get(touchEventTarget), changedTouches[s
tate].m_touches.get(), | 3787 touches, touchesByTarget.get(touchEventTarget), changedTouches[s
tate].m_touches.get(), |
| 3730 eventName, touchEventTarget->toNode()->document().domWindow(), | 3788 eventName, touchEventTarget->toNode()->document().domWindow(), |
| 3731 event.getModifiers(), event.cancelable(), event.causesScrollingI
fUncanceled(), event.timestamp()); | 3789 event.getModifiers(), event.cancelable(), event.causesScrollingI
fUncanceled(), event.timestamp()); |
| 3732 | 3790 |
| 3733 eventResult = mergeEventResult(eventResult, toWebInputEventResult(to
uchEventTarget->dispatchEvent(touchEvent))); | 3791 DispatchEventResult domDispatchResult = touchEventTarget->dispatchEv
ent(touchEvent); |
| 3792 |
| 3793 // Only report for top level documents with a single touch on |
| 3794 // touch-start or the first touch-move. |
| 3795 if (touchStartOrFirstTouchMove && touchInfos.size() == 1 && event.ca
ncelable() && !m_frame->document()->ownerElement()) { |
| 3796 DEFINE_STATIC_LOCAL(EnumerationHistogram, rootDocumentListenerHi
stogram, ("Event.Touch.TargetAndDispatchResult", TouchTargetAndDispatchResultTyp
eMax)); |
| 3797 rootDocumentListenerHistogram.count(toTouchTargetHistogramValue(
eventTarget, domDispatchResult)); |
| 3798 } |
| 3799 eventResult = mergeEventResult(eventResult, toWebInputEventResult(do
mDispatchResult)); |
| 3734 } | 3800 } |
| 3735 } | 3801 } |
| 3736 | 3802 |
| 3737 return eventResult; | 3803 return eventResult; |
| 3738 } | 3804 } |
| 3739 | 3805 |
| 3740 WebInputEventResult EventHandler::handleTouchEvent(const PlatformTouchEvent& eve
nt) | 3806 WebInputEventResult EventHandler::handleTouchEvent(const PlatformTouchEvent& eve
nt) |
| 3741 { | 3807 { |
| 3742 TRACE_EVENT0("blink", "EventHandler::handleTouchEvent"); | 3808 TRACE_EVENT0("blink", "EventHandler::handleTouchEvent"); |
| 3743 | 3809 |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4015 PlatformEvent::Modifiers EventHandler::accessKeyModifiers() | 4081 PlatformEvent::Modifiers EventHandler::accessKeyModifiers() |
| 4016 { | 4082 { |
| 4017 #if OS(MACOSX) | 4083 #if OS(MACOSX) |
| 4018 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo
rmEvent::AltKey); | 4084 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo
rmEvent::AltKey); |
| 4019 #else | 4085 #else |
| 4020 return PlatformEvent::AltKey; | 4086 return PlatformEvent::AltKey; |
| 4021 #endif | 4087 #endif |
| 4022 } | 4088 } |
| 4023 | 4089 |
| 4024 } // namespace blink | 4090 } // namespace blink |
| OLD | NEW |