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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 78 #include "core/page/AutoscrollController.h" | 78 #include "core/page/AutoscrollController.h" |
| 79 #include "core/page/ChromeClient.h" | 79 #include "core/page/ChromeClient.h" |
| 80 #include "core/page/DragController.h" | 80 #include "core/page/DragController.h" |
| 81 #include "core/page/DragState.h" | 81 #include "core/page/DragState.h" |
| 82 #include "core/page/FocusController.h" | 82 #include "core/page/FocusController.h" |
| 83 #include "core/page/FrameTree.h" | 83 #include "core/page/FrameTree.h" |
| 84 #include "core/page/Page.h" | 84 #include "core/page/Page.h" |
| 85 #include "core/page/SpatialNavigation.h" | 85 #include "core/page/SpatialNavigation.h" |
| 86 #include "core/page/TouchAdjustment.h" | 86 #include "core/page/TouchAdjustment.h" |
| 87 #include "core/page/scrolling/OverscrollController.h" | 87 #include "core/page/scrolling/OverscrollController.h" |
| 88 #include "core/page/scrolling/RootScroller.h" | |
| 88 #include "core/page/scrolling/ScrollState.h" | 89 #include "core/page/scrolling/ScrollState.h" |
| 89 #include "core/paint/PaintLayer.h" | 90 #include "core/paint/PaintLayer.h" |
| 90 #include "core/style/ComputedStyle.h" | 91 #include "core/style/ComputedStyle.h" |
| 91 #include "core/svg/SVGDocumentExtensions.h" | 92 #include "core/svg/SVGDocumentExtensions.h" |
| 92 #include "platform/Histogram.h" | 93 #include "platform/Histogram.h" |
| 93 #include "platform/PlatformGestureEvent.h" | 94 #include "platform/PlatformGestureEvent.h" |
| 94 #include "platform/PlatformKeyboardEvent.h" | 95 #include "platform/PlatformKeyboardEvent.h" |
| 95 #include "platform/PlatformTouchEvent.h" | 96 #include "platform/PlatformTouchEvent.h" |
| 96 #include "platform/PlatformWheelEvent.h" | 97 #include "platform/PlatformWheelEvent.h" |
| 97 #include "platform/RuntimeEnabledFeatures.h" | 98 #include "platform/RuntimeEnabledFeatures.h" |
| (...skipping 2413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2511 if (m_frame->isMainFrame()) | 2512 if (m_frame->isMainFrame()) |
| 2512 m_frame->host()->topControls().scrollBegin(); | 2513 m_frame->host()->topControls().scrollBegin(); |
| 2513 } | 2514 } |
| 2514 return WebInputEventResult::HandledSystem; | 2515 return WebInputEventResult::HandledSystem; |
| 2515 } | 2516 } |
| 2516 | 2517 |
| 2517 bool EventHandler::isRootScroller(const Node& node) const | 2518 bool EventHandler::isRootScroller(const Node& node) const |
| 2518 { | 2519 { |
| 2519 // The root scroller is the one Element on the page designated to perform | 2520 // The root scroller is the one Element on the page designated to perform |
| 2520 // "viewport actions" like top controls movement and overscroll glow. | 2521 // "viewport actions" like top controls movement and overscroll glow. |
| 2521 | 2522 if (!node.isElementNode() || !frameHost() || !frameHost()->rootScroller()) |
| 2522 if (!node.isElementNode() || node.document().ownerElement()) | |
| 2523 return false; | 2523 return false; |
| 2524 | 2524 |
| 2525 return node.document().rootScroller() == toElement(&node); | 2525 return frameHost()->rootScroller()->get() == toElement(&node); |
| 2526 } | 2526 } |
| 2527 | 2527 |
| 2528 WebInputEventResult EventHandler::handleGestureScrollUpdate(const PlatformGestur eEvent& gestureEvent) | 2528 WebInputEventResult EventHandler::handleGestureScrollUpdate(const PlatformGestur eEvent& gestureEvent) |
| 2529 { | 2529 { |
| 2530 ASSERT(gestureEvent.type() == PlatformEvent::GestureScrollUpdate); | 2530 ASSERT(gestureEvent.type() == PlatformEvent::GestureScrollUpdate); |
| 2531 | 2531 |
| 2532 // Negate the deltas since the gesture event stores finger movement and | 2532 // Negate the deltas since the gesture event stores finger movement and |
| 2533 // scrolling occurs in the direction opposite the finger's movement | 2533 // scrolling occurs in the direction opposite the finger's movement |
| 2534 // direction. e.g. Finger moving up has negative event delta but causes the | 2534 // direction. e.g. Finger moving up has negative event delta but causes the |
| 2535 // page to scroll down causing positive scroll delta. | 2535 // page to scroll down causing positive scroll delta. |
| (...skipping 1331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3867 EventTarget* touchEventTarget = eventTarget; | 3867 EventTarget* touchEventTarget = eventTarget; |
| 3868 TouchEvent* touchEvent = TouchEvent::create( | 3868 TouchEvent* touchEvent = TouchEvent::create( |
| 3869 touches, touchesByTarget.get(touchEventTarget), changedTouches[s tate].m_touches.get(), | 3869 touches, touchesByTarget.get(touchEventTarget), changedTouches[s tate].m_touches.get(), |
| 3870 eventName, touchEventTarget->toNode()->document().domWindow(), | 3870 eventName, touchEventTarget->toNode()->document().domWindow(), |
| 3871 event.getModifiers(), event.cancelable(), event.causesScrollingI fUncanceled(), event.timestamp()); | 3871 event.getModifiers(), event.cancelable(), event.causesScrollingI fUncanceled(), event.timestamp()); |
| 3872 | 3872 |
| 3873 DispatchEventResult domDispatchResult = touchEventTarget->dispatchEv ent(touchEvent); | 3873 DispatchEventResult domDispatchResult = touchEventTarget->dispatchEv ent(touchEvent); |
| 3874 | 3874 |
| 3875 // Only report for top level documents with a single touch on | 3875 // Only report for top level documents with a single touch on |
| 3876 // touch-start or the first touch-move. | 3876 // touch-start or the first touch-move. |
| 3877 if (touchStartOrFirstTouchMove && touchInfos.size() == 1 && event.ca ncelable() && !m_frame->document()->ownerElement()) { | 3877 if (touchStartOrFirstTouchMove && touchInfos.size() == 1 && event.ca ncelable() && m_frame->isMainFrame()) { |
| 3878 DEFINE_STATIC_LOCAL(EnumerationHistogram, rootDocumentListenerHi stogram, ("Event.Touch.TargetAndDispatchResult", TouchTargetAndDispatchResultTyp eMax)); | 3878 DEFINE_STATIC_LOCAL(EnumerationHistogram, rootDocumentListenerHi stogram, ("Event.Touch.TargetAndDispatchResult", TouchTargetAndDispatchResultTyp eMax)); |
| 3879 rootDocumentListenerHistogram.count(toTouchTargetHistogramValue( eventTarget, domDispatchResult)); | 3879 rootDocumentListenerHistogram.count(toTouchTargetHistogramValue( eventTarget, domDispatchResult)); |
| 3880 | 3880 |
| 3881 // Count the handled touch starts and first touch moves before a nd after the page is fully loaded respectively. | 3881 // Count the handled touch starts and first touch moves before a nd after the page is fully loaded respectively. |
| 3882 if (m_frame->document()->isLoadCompleted()) { | 3882 if (m_frame->document()->isLoadCompleted()) { |
| 3883 DEFINE_STATIC_LOCAL(EnumerationHistogram, touchDispositionsA fterPageLoadHistogram, ("Event.Touch.TouchDispositionsAfterPageLoad", TouchEvent DispatchResultTypeMax)); | 3883 DEFINE_STATIC_LOCAL(EnumerationHistogram, touchDispositionsA fterPageLoadHistogram, ("Event.Touch.TouchDispositionsAfterPageLoad", TouchEvent DispatchResultTypeMax)); |
| 3884 touchDispositionsAfterPageLoadHistogram.count((domDispatchRe sult != DispatchEventResult::NotCanceled) ? HandledTouches : UnhandledTouches); | 3884 touchDispositionsAfterPageLoadHistogram.count((domDispatchRe sult != DispatchEventResult::NotCanceled) ? HandledTouches : UnhandledTouches); |
| 3885 } else { | 3885 } else { |
| 3886 DEFINE_STATIC_LOCAL(EnumerationHistogram, touchDispositionsB eforePageLoadHistogram, ("Event.Touch.TouchDispositionsBeforePageLoad", TouchEve ntDispatchResultTypeMax)); | 3886 DEFINE_STATIC_LOCAL(EnumerationHistogram, touchDispositionsB eforePageLoadHistogram, ("Event.Touch.TouchDispositionsBeforePageLoad", TouchEve ntDispatchResultTypeMax)); |
| 3887 touchDispositionsBeforePageLoadHistogram.count((domDispatchR esult != DispatchEventResult::NotCanceled) ? HandledTouches : UnhandledTouches); | 3887 touchDispositionsBeforePageLoadHistogram.count((domDispatchR esult != DispatchEventResult::NotCanceled) ? HandledTouches : UnhandledTouches); |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4169 } | 4169 } |
| 4170 | 4170 |
| 4171 FrameHost* EventHandler::frameHost() | 4171 FrameHost* EventHandler::frameHost() |
| 4172 { | 4172 { |
| 4173 if (!m_frame->page()) | 4173 if (!m_frame->page()) |
| 4174 return nullptr; | 4174 return nullptr; |
| 4175 | 4175 |
| 4176 return &m_frame->page()->frameHost(); | 4176 return &m_frame->page()->frameHost(); |
| 4177 } | 4177 } |
| 4178 | 4178 |
| 4179 const FrameHost* EventHandler::frameHost() const | |
| 4180 { | |
| 4181 if (!m_frame->page()) | |
| 4182 return nullptr; | |
| 4183 | |
| 4184 return &m_frame->page()->frameHost(); | |
|
dcheng
2016/05/03 18:47:40
We don't really go for const-correctness elsewhere
bokan
2016/05/03 21:41:04
IMO, that's something we should be working towards
dcheng
2016/05/07 06:09:07
Do we have any instances of this pattern anywhere
| |
| 4185 } | |
| 4186 | |
| 4179 } // namespace blink | 4187 } // namespace blink |
| OLD | NEW |