Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2008, The Android Open Source Project | 2 * Copyright 2008, The Android Open Source Project |
| 3 * Copyright (C) 2012 Research In Motion Limited. All rights reserved. | 3 * Copyright (C) 2012 Research In Motion Limited. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above copyright | 10 * * Redistributions in binary form must reproduce the above copyright |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 */ | 25 */ |
| 26 | 26 |
| 27 #include "core/events/TouchEvent.h" | 27 #include "core/events/TouchEvent.h" |
| 28 | 28 |
| 29 #include "bindings/core/v8/DOMWrapperWorld.h" | 29 #include "bindings/core/v8/DOMWrapperWorld.h" |
| 30 #include "bindings/core/v8/ScriptState.h" | 30 #include "bindings/core/v8/ScriptState.h" |
| 31 #include "core/EventTypeNames.h" | |
| 31 #include "core/events/EventDispatcher.h" | 32 #include "core/events/EventDispatcher.h" |
| 32 #include "core/frame/FrameConsole.h" | 33 #include "core/frame/FrameConsole.h" |
| 34 #include "core/frame/FrameView.h" | |
| 33 #include "core/frame/LocalDOMWindow.h" | 35 #include "core/frame/LocalDOMWindow.h" |
| 36 #include "core/html/HTMLElement.h" | |
|
tdresser
2016/04/07 12:22:07
Is this used?
dtapuska
2016/04/19 17:54:46
Done.
| |
| 34 #include "core/inspector/ConsoleMessage.h" | 37 #include "core/inspector/ConsoleMessage.h" |
| 38 #include "platform/Histogram.h" | |
| 35 | 39 |
| 36 namespace blink { | 40 namespace blink { |
| 37 | 41 |
| 42 namespace { | |
| 43 | |
| 44 const size_t kRootScrollerOffset = 4; | |
|
tdresser
2016/04/07 12:22:07
Add a comment indicating what these are offsets in
dtapuska
2016/04/19 17:54:46
Done.
| |
| 45 const size_t kScrollableDocumentOffset = 2; | |
| 46 const size_t kHandledOffset = 1; | |
| 47 | |
| 48 enum ListenerHistogram { | |
| 49 NonRootScrollerNonScrollableNotHandled, // Non-root-scroller, non-scrollable document, not handled. | |
| 50 NonRootScrollerNonScrollableHandled, // Non-root-scroller, non-scrollable do cument, handled application. | |
| 51 NonRootScrollerScrollableDocumentNotHandled, // Non-root-scroller, scrollabl e document, not handled. | |
| 52 NonRootScrollerScrollableDocumentHandled, // Non-root-scroller, scrollable d ocument, handled application. | |
| 53 RootScrollerNonScrollableNotHandled, // Root-scroller, non-scrollable docume nt, not handled. | |
| 54 RootScrollerNonScrollableHandled, // Root-scroller, non-scrollable document, handled. | |
| 55 RootScrollerScrollableDocumentNotHandled, // Root-scroller, scrollable docum ent, not handled. | |
| 56 RootScrollerScrollableDocumentHandled, // Root-scroller, scrollable document , handled. | |
| 57 ListenerHistogramMax, | |
| 58 }; | |
| 59 | |
| 60 ListenerHistogram toListenerHistogramValue(const Node& node, DispatchEventResult dispatchResult) | |
| 61 { | |
| 62 int result = 0; | |
| 63 if (node.isDocumentNode() || static_cast<Node*>(node.document().documentElem ent()) == &node || static_cast<Node*>(node.document().body()) == &node) { | |
|
tdresser
2016/04/07 12:22:08
We need to check |window| too, don't we?
Add a co
dtapuska
2016/04/19 17:54:47
Done.
| |
| 64 result += kRootScrollerOffset; | |
| 65 } | |
| 66 FrameView* view = node.document().view(); | |
| 67 if (view && view->isScrollable()) | |
| 68 result += kScrollableDocumentOffset; | |
| 69 | |
| 70 if (dispatchResult != DispatchEventResult::NotCanceled) { | |
|
tdresser
2016/04/07 12:22:07
Let's be consistent about whether or not we use {}
dtapuska
2016/04/19 17:54:46
Done.
| |
| 71 result += kHandledOffset; | |
| 72 } | |
| 73 return (ListenerHistogram)result; | |
|
tdresser
2016/04/07 12:22:08
static_cast
dtapuska
2016/04/19 17:54:47
Done.
| |
| 74 } | |
| 75 | |
| 76 } // namespace | |
| 77 | |
| 38 TouchEvent::TouchEvent() | 78 TouchEvent::TouchEvent() |
| 39 { | 79 { |
| 40 } | 80 } |
| 41 | 81 |
| 42 TouchEvent::TouchEvent(TouchList* touches, TouchList* targetTouches, | 82 TouchEvent::TouchEvent(TouchList* touches, TouchList* targetTouches, |
| 43 TouchList* changedTouches, const AtomicString& type, | 83 TouchList* changedTouches, const AtomicString& type, |
| 44 AbstractView* view, | 84 AbstractView* view, |
| 45 PlatformEvent::Modifiers modifiers, bool cancelable, bool causesScrollingIfU ncanceled, | 85 PlatformEvent::Modifiers modifiers, bool cancelable, bool causesScrollingIfU ncanceled, bool firstTouchMoveAfterTouchStart, |
| 46 double platformTimeStamp) | 86 double platformTimeStamp) |
| 47 // Pass a sourceCapabilities including the ability to fire touchevents when creating this touchevent, which is always created from input device capabilities from EventHandler. | 87 // Pass a sourceCapabilities including the ability to fire touchevents when creating this touchevent, which is always created from input device capabilities from EventHandler. |
| 48 : UIEventWithKeyState(type, true, cancelable, view, 0, modifiers, platformTi meStamp, InputDeviceCapabilities::firesTouchEventsSourceCapabilities()), | 88 : UIEventWithKeyState(type, true, cancelable, view, 0, modifiers, platformTi meStamp, InputDeviceCapabilities::firesTouchEventsSourceCapabilities()) |
| 49 m_touches(touches), m_targetTouches(targetTouches), m_changedTouches(changed Touches), m_causesScrollingIfUncanceled(causesScrollingIfUncanceled) | 89 , m_touches(touches) |
| 90 , m_targetTouches(targetTouches) | |
| 91 , m_changedTouches(changedTouches) | |
| 92 , m_causesScrollingIfUncanceled(causesScrollingIfUncanceled) | |
| 93 , m_firstTouchMoveAfterTouchStart(firstTouchMoveAfterTouchStart) | |
| 50 { | 94 { |
| 51 } | 95 } |
| 52 | 96 |
| 53 TouchEvent::TouchEvent(const AtomicString& type, const TouchEventInit& initializ er) | 97 TouchEvent::TouchEvent(const AtomicString& type, const TouchEventInit& initializ er) |
| 54 : UIEventWithKeyState(type, initializer) | 98 : UIEventWithKeyState(type, initializer) |
| 55 , m_touches(TouchList::create(initializer.touches())) | 99 , m_touches(TouchList::create(initializer.touches())) |
| 56 , m_targetTouches(TouchList::create(initializer.targetTouches())) | 100 , m_targetTouches(TouchList::create(initializer.targetTouches())) |
| 57 , m_changedTouches(TouchList::create(initializer.changedTouches())) | 101 , m_changedTouches(TouchList::create(initializer.changedTouches())) |
| 58 { | 102 { |
| 59 } | 103 } |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 { | 176 { |
| 133 } | 177 } |
| 134 | 178 |
| 135 TouchEvent& TouchEventDispatchMediator::event() const | 179 TouchEvent& TouchEventDispatchMediator::event() const |
| 136 { | 180 { |
| 137 return toTouchEvent(EventDispatchMediator::event()); | 181 return toTouchEvent(EventDispatchMediator::event()); |
| 138 } | 182 } |
| 139 | 183 |
| 140 DispatchEventResult TouchEventDispatchMediator::dispatchEvent(EventDispatcher& d ispatcher) const | 184 DispatchEventResult TouchEventDispatchMediator::dispatchEvent(EventDispatcher& d ispatcher) const |
| 141 { | 185 { |
| 142 event().eventPath().adjustForTouchEvent(event()); | 186 TouchEvent& touchEvent = event(); |
| 143 return dispatcher.dispatch(); | 187 touchEvent.eventPath().adjustForTouchEvent(touchEvent); |
| 188 DispatchEventResult result = dispatcher.dispatch(); | |
| 189 | |
| 190 // Only report for top level documents with a single touch on | |
| 191 // touch-start or the first touch-move. | |
| 192 if (touchEvent.cancelable() && touchEvent.touches() && touchEvent.touches()- >length() == 1 && !dispatcher.node().document().ownerElement() && (touchEvent.ty pe() == EventTypeNames::touchstart || (touchEvent.type() == EventTypeNames::touc hmove && touchEvent.firstTouchMoveAfterTouchStart()))) { | |
|
tdresser
2016/04/07 12:22:08
This condition is pretty illegible. Maybe split th
dtapuska
2016/04/19 17:54:47
Done.
| |
| 193 DEFINE_STATIC_LOCAL(EnumerationHistogram, rootDocumentListenerHistogram, ("Event.Listeners.TouchBlockingOnRootElements", ListenerHistogramMax)); | |
| 194 rootDocumentListenerHistogram.count(toListenerHistogramValue(dispatcher. node(), result)); | |
| 195 } | |
| 196 return result; | |
| 144 } | 197 } |
| 145 | 198 |
| 146 } // namespace blink | 199 } // namespace blink |
| OLD | NEW |