Chromium Code Reviews| 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 80 #include "core/page/DragState.h" | 80 #include "core/page/DragState.h" |
| 81 #include "core/page/FocusController.h" | 81 #include "core/page/FocusController.h" |
| 82 #include "core/page/FrameTree.h" | 82 #include "core/page/FrameTree.h" |
| 83 #include "core/page/Page.h" | 83 #include "core/page/Page.h" |
| 84 #include "core/page/SpatialNavigation.h" | 84 #include "core/page/SpatialNavigation.h" |
| 85 #include "core/page/TouchAdjustment.h" | 85 #include "core/page/TouchAdjustment.h" |
| 86 #include "core/page/scrolling/ScrollState.h" | 86 #include "core/page/scrolling/ScrollState.h" |
| 87 #include "core/paint/PaintLayer.h" | 87 #include "core/paint/PaintLayer.h" |
| 88 #include "core/style/ComputedStyle.h" | 88 #include "core/style/ComputedStyle.h" |
| 89 #include "core/svg/SVGDocumentExtensions.h" | 89 #include "core/svg/SVGDocumentExtensions.h" |
| 90 #include "platform/Histogram.h" | |
| 90 #include "platform/PlatformGestureEvent.h" | 91 #include "platform/PlatformGestureEvent.h" |
| 91 #include "platform/PlatformKeyboardEvent.h" | 92 #include "platform/PlatformKeyboardEvent.h" |
| 92 #include "platform/PlatformTouchEvent.h" | 93 #include "platform/PlatformTouchEvent.h" |
| 93 #include "platform/PlatformWheelEvent.h" | 94 #include "platform/PlatformWheelEvent.h" |
| 94 #include "platform/RuntimeEnabledFeatures.h" | 95 #include "platform/RuntimeEnabledFeatures.h" |
| 95 #include "platform/TraceEvent.h" | 96 #include "platform/TraceEvent.h" |
| 96 #include "platform/WindowsKeyboardCodes.h" | 97 #include "platform/WindowsKeyboardCodes.h" |
| 97 #include "platform/geometry/FloatPoint.h" | 98 #include "platform/geometry/FloatPoint.h" |
| 98 #include "platform/graphics/Image.h" | 99 #include "platform/graphics/Image.h" |
| 99 #include "platform/heap/Handle.h" | 100 #include "platform/heap/Handle.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 200 curBox = curBox->containingBlock(); | 201 curBox = curBox->containingBlock(); |
| 201 } | 202 } |
| 202 // TODO(tdresser): this should sometimes be excluded, as part of crbug.com/4 10974. | 203 // TODO(tdresser): this should sometimes be excluded, as part of crbug.com/4 10974. |
| 203 // We need to ensure that the scrollingElement is always part of | 204 // We need to ensure that the scrollingElement is always part of |
| 204 // the scroll chain. In quirks mode, when the scrollingElement is | 205 // the scroll chain. In quirks mode, when the scrollingElement is |
| 205 // the body, some elements may use the documentElement as their | 206 // the body, some elements may use the documentElement as their |
| 206 // containingBlock, so we ensure the scrollingElement is added | 207 // containingBlock, so we ensure the scrollingElement is added |
| 207 // here. | 208 // here. |
| 208 scrollChain.push_front(DOMNodeIds::idForNode(frame.document()->scrollingElem ent())); | 209 scrollChain.push_front(DOMNodeIds::idForNode(frame.document()->scrollingElem ent())); |
| 209 } | 210 } |
| 210 | 211 |
|
tdresser
2016/04/19 20:49:58
Could we factor all this logic out into a separate
dtapuska
2016/04/21 01:18:49
I think this is all going to change when Navid lan
| |
| 212 // These offsets change indicies into the ListenerHistogram | |
| 213 // enumeration. The addition of a series of offsets then | |
| 214 // produces the resulting ListenerHistogram value. | |
| 215 const size_t kTouchTargetHistogramRootScrollerOffset = 4; | |
| 216 const size_t kTouchTargetHistogramScrollableDocumentOffset = 2; | |
| 217 const size_t kTouchTargetHistogramHandledOffset = 1; | |
| 218 | |
| 219 enum TouchTargetAndDispatchResultTypeHistogram { | |
|
tdresser
2016/04/19 20:49:58
I don't think we need "Histogram" in the type here
dtapuska
2016/04/21 01:18:49
Done.
| |
| 220 NonRootScrollerNonScrollableNotHandled, // Non-root-scroller, non-scrollable document, not handled. | |
| 221 NonRootScrollerNonScrollableHandled, // Non-root-scroller, non-scrollable do cument, handled application. | |
| 222 NonRootScrollerScrollableDocumentNotHandled, // Non-root-scroller, scrollabl e document, not handled. | |
| 223 NonRootScrollerScrollableDocumentHandled, // Non-root-scroller, scrollable d ocument, handled application. | |
| 224 RootScrollerNonScrollableNotHandled, // Root-scroller, non-scrollable docume nt, not handled. | |
| 225 RootScrollerNonScrollableHandled, // Root-scroller, non-scrollable document, handled. | |
| 226 RootScrollerScrollableDocumentNotHandled, // Root-scroller, scrollable docum ent, not handled. | |
| 227 RootScrollerScrollableDocumentHandled, // Root-scroller, scrollable document , handled. | |
| 228 ListenerHistogramMax, | |
| 229 }; | |
| 230 | |
| 231 TouchTargetAndDispatchResultTypeHistogram toTouchTargetHistogramValue(EventTarge t* eventTarget, DispatchEventResult dispatchResult) | |
| 232 { | |
| 233 int result = 0; | |
| 234 Document* document = nullptr; | |
| 235 | |
| 236 if (const LocalDOMWindow* domWindow = eventTarget->toDOMWindow()) { | |
| 237 // Treat the window as a root scroller as well. | |
| 238 document = domWindow->document(); | |
| 239 result += kTouchTargetHistogramRootScrollerOffset; | |
| 240 } else if (Node* node = eventTarget->toNode()) { | |
| 241 // Report if the target node is the document or body. | |
| 242 if (node->isDocumentNode() || static_cast<Node*>(node->document().docume ntElement()) == node || static_cast<Node*>(node->document().body()) == node) { | |
| 243 result += kTouchTargetHistogramRootScrollerOffset; | |
| 244 } | |
| 245 document = &node->document(); | |
| 246 } | |
| 247 | |
| 248 if (document) { | |
| 249 FrameView* view = document->view(); | |
| 250 if (view && view->isScrollable()) | |
| 251 result += kTouchTargetHistogramScrollableDocumentOffset; | |
| 252 } | |
| 253 | |
| 254 if (dispatchResult != DispatchEventResult::NotCanceled) | |
| 255 result += kTouchTargetHistogramHandledOffset; | |
| 256 return static_cast<TouchTargetAndDispatchResultTypeHistogram>(result); | |
| 257 } | |
| 258 | |
| 211 } // namespace | 259 } // namespace |
| 212 | 260 |
| 213 using namespace HTMLNames; | 261 using namespace HTMLNames; |
| 214 | 262 |
| 215 // The link drag hysteresis is much larger than the others because there | 263 // The link drag hysteresis is much larger than the others because there |
| 216 // needs to be enough space to cancel the link press without starting a link dra g, | 264 // needs to be enough space to cancel the link press without starting a link dra g, |
| 217 // and because dragging links is rare. | 265 // and because dragging links is rare. |
| 218 static const int LinkDragHysteresis = 40; | 266 static const int LinkDragHysteresis = 40; |
| 219 static const int ImageDragHysteresis = 5; | 267 static const int ImageDragHysteresis = 5; |
| 220 static const int TextDragHysteresis = 3; | 268 static const int TextDragHysteresis = 3; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 285 , m_mousePositionIsUnknown(true) | 333 , m_mousePositionIsUnknown(true) |
| 286 , m_mouseDownTimestamp(0) | 334 , m_mouseDownTimestamp(0) |
| 287 , m_touchPressed(false) | 335 , m_touchPressed(false) |
| 288 , m_inPointerCanceledState(false) | 336 , m_inPointerCanceledState(false) |
| 289 , m_scrollGestureHandlingNode(nullptr) | 337 , m_scrollGestureHandlingNode(nullptr) |
| 290 , m_lastGestureScrollOverWidget(false) | 338 , m_lastGestureScrollOverWidget(false) |
| 291 , m_longTapShouldInvokeContextMenu(false) | 339 , m_longTapShouldInvokeContextMenu(false) |
| 292 , m_activeIntervalTimer(this, &EventHandler::activeIntervalTimerFired) | 340 , m_activeIntervalTimer(this, &EventHandler::activeIntervalTimerFired) |
| 293 , m_lastShowPressTimestamp(0) | 341 , m_lastShowPressTimestamp(0) |
| 294 , m_deltaConsumedForScrollSequence(false) | 342 , m_deltaConsumedForScrollSequence(false) |
| 343 , m_waitingForFirstTouchMove(false) | |
| 295 { | 344 { |
| 296 } | 345 } |
| 297 | 346 |
| 298 EventHandler::~EventHandler() | 347 EventHandler::~EventHandler() |
| 299 { | 348 { |
| 300 ASSERT(!m_fakeMouseMoveEventTimer.isActive()); | 349 ASSERT(!m_fakeMouseMoveEventTimer.isActive()); |
| 301 } | 350 } |
| 302 | 351 |
| 303 DEFINE_TRACE(EventHandler) | 352 DEFINE_TRACE(EventHandler) |
| 304 { | 353 { |
| (...skipping 3466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3771 using EventTargetSet = HeapHashSet<Member<EventTarget>>; | 3820 using EventTargetSet = HeapHashSet<Member<EventTarget>>; |
| 3772 // Set of targets involved in m_touches. | 3821 // Set of targets involved in m_touches. |
| 3773 EventTargetSet m_targets; | 3822 EventTargetSet m_targets; |
| 3774 }; | 3823 }; |
| 3775 | 3824 |
| 3776 } // namespace | 3825 } // namespace |
| 3777 | 3826 |
| 3778 WebInputEventResult EventHandler::dispatchTouchEvents(const PlatformTouchEvent& event, | 3827 WebInputEventResult EventHandler::dispatchTouchEvents(const PlatformTouchEvent& event, |
| 3779 HeapVector<TouchInfo>& touchInfos, bool freshTouchEvents, bool allTouchRelea sed) | 3828 HeapVector<TouchInfo>& touchInfos, bool freshTouchEvents, bool allTouchRelea sed) |
| 3780 { | 3829 { |
| 3830 bool touchStartOrFirstTouchMove = false; | |
| 3831 if (event.type() == PlatformEvent::TouchStart) { | |
| 3832 m_waitingForFirstTouchMove = true; | |
| 3833 touchStartOrFirstTouchMove = true; | |
| 3834 } else if (event.type() == PlatformEvent::TouchMove) { | |
| 3835 touchStartOrFirstTouchMove = m_waitingForFirstTouchMove; | |
| 3836 m_waitingForFirstTouchMove = false; | |
| 3837 } | |
| 3838 | |
| 3781 // Build up the lists to use for the 'touches', 'targetTouches' and | 3839 // Build up the lists to use for the 'touches', 'targetTouches' and |
| 3782 // 'changedTouches' attributes in the JS event. See | 3840 // 'changedTouches' attributes in the JS event. See |
| 3783 // http://www.w3.org/TR/touch-events/#touchevent-interface for how these | 3841 // http://www.w3.org/TR/touch-events/#touchevent-interface for how these |
| 3784 // lists fit together. | 3842 // lists fit together. |
| 3785 | 3843 |
| 3786 // Holds the complete set of touches on the screen. | 3844 // Holds the complete set of touches on the screen. |
| 3787 TouchList* touches = TouchList::create(); | 3845 TouchList* touches = TouchList::create(); |
| 3788 | 3846 |
| 3789 // A different view on the 'touches' list above, filtered and grouped by | 3847 // A different view on the 'touches' list above, filtered and grouped by |
| 3790 // event target. Used for the 'targetTouches' list in the JS event. | 3848 // event target. Used for the 'targetTouches' list in the JS event. |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3857 continue; | 3915 continue; |
| 3858 | 3916 |
| 3859 const AtomicString& eventName(touchEventNameForTouchPointState(static_ca st<PlatformTouchPoint::TouchState>(state))); | 3917 const AtomicString& eventName(touchEventNameForTouchPointState(static_ca st<PlatformTouchPoint::TouchState>(state))); |
| 3860 for (const auto& eventTarget : changedTouches[state].m_targets) { | 3918 for (const auto& eventTarget : changedTouches[state].m_targets) { |
| 3861 EventTarget* touchEventTarget = eventTarget; | 3919 EventTarget* touchEventTarget = eventTarget; |
| 3862 TouchEvent* touchEvent = TouchEvent::create( | 3920 TouchEvent* touchEvent = TouchEvent::create( |
| 3863 touches, touchesByTarget.get(touchEventTarget), changedTouches[s tate].m_touches.get(), | 3921 touches, touchesByTarget.get(touchEventTarget), changedTouches[s tate].m_touches.get(), |
| 3864 eventName, touchEventTarget->toNode()->document().domWindow(), | 3922 eventName, touchEventTarget->toNode()->document().domWindow(), |
| 3865 event.getModifiers(), event.cancelable(), event.causesScrollingI fUncanceled(), event.timestamp()); | 3923 event.getModifiers(), event.cancelable(), event.causesScrollingI fUncanceled(), event.timestamp()); |
| 3866 | 3924 |
| 3867 eventResult = mergeEventResult(eventResult, toWebInputEventResult(to uchEventTarget->dispatchEvent(touchEvent))); | 3925 DispatchEventResult domDispatchResult = touchEventTarget->dispatchEv ent(touchEvent); |
| 3926 | |
| 3927 // Only report for top level documents with a single touch on | |
| 3928 // touch-start or the first touch-move. | |
| 3929 if (touchStartOrFirstTouchMove && touchInfos.size() == 1 && event.ca ncelable() && !m_frame->document()->ownerElement()) { | |
| 3930 DEFINE_STATIC_LOCAL(EnumerationHistogram, rootDocumentListenerHi stogram, ("Event.Touch.TargetAndDispatchResult", ListenerHistogramMax)); | |
| 3931 rootDocumentListenerHistogram.count(toTouchTargetHistogramValue( eventTarget, domDispatchResult)); | |
| 3932 } | |
| 3933 eventResult = mergeEventResult(eventResult, toWebInputEventResult(do mDispatchResult)); | |
| 3868 } | 3934 } |
| 3869 } | 3935 } |
| 3870 | 3936 |
| 3871 return eventResult; | 3937 return eventResult; |
| 3872 } | 3938 } |
| 3873 | 3939 |
| 3874 WebInputEventResult EventHandler::handleTouchEvent(const PlatformTouchEvent& eve nt) | 3940 WebInputEventResult EventHandler::handleTouchEvent(const PlatformTouchEvent& eve nt) |
| 3875 { | 3941 { |
| 3876 TRACE_EVENT0("blink", "EventHandler::handleTouchEvent"); | 3942 TRACE_EVENT0("blink", "EventHandler::handleTouchEvent"); |
| 3877 | 3943 |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4149 PlatformEvent::Modifiers EventHandler::accessKeyModifiers() | 4215 PlatformEvent::Modifiers EventHandler::accessKeyModifiers() |
| 4150 { | 4216 { |
| 4151 #if OS(MACOSX) | 4217 #if OS(MACOSX) |
| 4152 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo rmEvent::AltKey); | 4218 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo rmEvent::AltKey); |
| 4153 #else | 4219 #else |
| 4154 return PlatformEvent::AltKey; | 4220 return PlatformEvent::AltKey; |
| 4155 #endif | 4221 #endif |
| 4156 } | 4222 } |
| 4157 | 4223 |
| 4158 } // namespace blink | 4224 } // namespace blink |
| OLD | NEW |