Chromium Code Reviews| 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/ScrollManager.h" | 5 #include "core/input/ScrollManager.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include "core/dom/DOMNodeIds.h" | 8 #include "core/dom/DOMNodeIds.h" |
| 9 #include "core/events/GestureEvent.h" | 9 #include "core/events/GestureEvent.h" |
| 10 #include "core/frame/BrowserControls.h" | 10 #include "core/frame/BrowserControls.h" |
| 11 #include "core/frame/FrameView.h" | 11 #include "core/frame/FrameView.h" |
| 12 #include "core/html/HTMLFrameOwnerElement.h" | 12 #include "core/html/HTMLFrameOwnerElement.h" |
| 13 #include "core/input/EventHandler.h" | 13 #include "core/input/EventHandler.h" |
| 14 #include "core/input/EventHandlingUtil.h" | 14 #include "core/input/EventHandlingUtil.h" |
| 15 #include "core/layout/LayoutBlock.h" | 15 #include "core/layout/LayoutBlock.h" |
| 16 #include "core/layout/LayoutPart.h" | 16 #include "core/layout/LayoutPart.h" |
| 17 #include "core/layout/api/LayoutViewItem.h" | 17 #include "core/layout/api/LayoutViewItem.h" |
| 18 #include "core/loader/DocumentLoader.h" | 18 #include "core/loader/DocumentLoader.h" |
| 19 #include "core/page/AutoscrollController.h" | 19 #include "core/page/AutoscrollController.h" |
| 20 #include "core/page/Page.h" | 20 #include "core/page/Page.h" |
| 21 #include "core/page/scrolling/OverscrollController.h" | 21 #include "core/page/scrolling/OverscrollController.h" |
| 22 #include "core/page/scrolling/RootScrollerController.h" | 22 #include "core/page/scrolling/RootScrollerController.h" |
| 23 #include "core/page/scrolling/ScrollState.h" | 23 #include "core/page/scrolling/ScrollState.h" |
| 24 #include "core/paint/PaintLayer.h" | 24 #include "core/paint/PaintLayer.h" |
| 25 #include "platform/Histogram.h" | |
| 25 #include "platform/RuntimeEnabledFeatures.h" | 26 #include "platform/RuntimeEnabledFeatures.h" |
| 27 #include "platform/scroll/ScrollerSize.h" | |
| 26 #include "wtf/PtrUtil.h" | 28 #include "wtf/PtrUtil.h" |
| 27 | 29 |
| 28 namespace blink { | 30 namespace blink { |
| 29 | 31 |
| 30 ScrollManager::ScrollManager(LocalFrame& frame) : m_frame(frame) { | 32 ScrollManager::ScrollManager(LocalFrame& frame) : m_frame(frame) { |
| 31 clear(); | 33 clear(); |
| 32 } | 34 } |
| 33 | 35 |
| 34 void ScrollManager::clear() { | 36 void ScrollManager::clear() { |
| 35 m_lastGestureScrollOverFrameViewBase = false; | 37 m_lastGestureScrollOverFrameViewBase = false; |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 214 if (!m_scrollGestureHandlingNode) | 216 if (!m_scrollGestureHandlingNode) |
| 215 m_scrollGestureHandlingNode = m_frame->document()->documentElement(); | 217 m_scrollGestureHandlingNode = m_frame->document()->documentElement(); |
| 216 | 218 |
| 217 if (!m_scrollGestureHandlingNode || | 219 if (!m_scrollGestureHandlingNode || |
| 218 !m_scrollGestureHandlingNode->layoutObject()) | 220 !m_scrollGestureHandlingNode->layoutObject()) |
| 219 return WebInputEventResult::NotHandled; | 221 return WebInputEventResult::NotHandled; |
| 220 | 222 |
| 221 passScrollGestureEvent(gestureEvent, | 223 passScrollGestureEvent(gestureEvent, |
| 222 m_scrollGestureHandlingNode->layoutObject()); | 224 m_scrollGestureHandlingNode->layoutObject()); |
| 223 | 225 |
| 226 if (m_scrollGestureHandlingNode->layoutObject() && | |
| 227 (gestureEvent.sourceDevice == WebGestureDeviceTouchpad || | |
| 228 gestureEvent.sourceDevice == WebGestureDeviceTouchscreen)) { | |
| 229 recordScrollerSize(*(m_scrollGestureHandlingNode->layoutObject()), | |
| 230 gestureEvent.sourceDevice); | |
| 231 } | |
| 232 | |
| 224 m_currentScrollChain.clear(); | 233 m_currentScrollChain.clear(); |
| 225 std::unique_ptr<ScrollStateData> scrollStateData = | 234 std::unique_ptr<ScrollStateData> scrollStateData = |
| 226 WTF::makeUnique<ScrollStateData>(); | 235 WTF::makeUnique<ScrollStateData>(); |
| 227 IntPoint position = flooredIntPoint(gestureEvent.positionInRootFrame()); | 236 IntPoint position = flooredIntPoint(gestureEvent.positionInRootFrame()); |
| 228 scrollStateData->position_x = position.x(); | 237 scrollStateData->position_x = position.x(); |
| 229 scrollStateData->position_y = position.y(); | 238 scrollStateData->position_y = position.y(); |
| 230 scrollStateData->is_beginning = true; | 239 scrollStateData->is_beginning = true; |
| 231 scrollStateData->from_user_input = true; | 240 scrollStateData->from_user_input = true; |
| 232 scrollStateData->is_direct_manipulation = | 241 scrollStateData->is_direct_manipulation = |
| 233 gestureEvent.sourceDevice == WebGestureDeviceTouchscreen; | 242 gestureEvent.sourceDevice == WebGestureDeviceTouchscreen; |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 559 bool shouldUpdateCapture = false; | 568 bool shouldUpdateCapture = false; |
| 560 if (scrollbar->gestureEvent(targetedEvent.event(), &shouldUpdateCapture)) { | 569 if (scrollbar->gestureEvent(targetedEvent.event(), &shouldUpdateCapture)) { |
| 561 if (shouldUpdateCapture) | 570 if (shouldUpdateCapture) |
| 562 m_scrollbarHandlingScrollGesture = scrollbar; | 571 m_scrollbarHandlingScrollGesture = scrollbar; |
| 563 return true; | 572 return true; |
| 564 } | 573 } |
| 565 } | 574 } |
| 566 return false; | 575 return false; |
| 567 } | 576 } |
| 568 | 577 |
| 578 void ScrollManager::recordScrollerSize(const LayoutObject& layoutObject, | |
| 579 const WebGestureDevice device) { | |
| 580 if (!layoutObject.enclosingLayer()) | |
|
flackr
2017/04/12 15:31:04
I'm confused, is the scroll gesture handling node
| |
| 581 return; | |
| 582 | |
| 583 if (device == WebGestureDeviceTouchpad) { | |
| 584 DEFINE_STATIC_LOCAL(CustomCountHistogram, sizeHistogramWheel, | |
| 585 ("Event.Scroll.ScrollerSize.OnScroll_Wheel", 1, | |
| 586 kMaxScrollerSize, kBucketNum)); | |
| 587 sizeHistogramWheel.count( | |
| 588 layoutObject.enclosingLayer()->visualRect().width().toInt() * | |
|
bokan
2017/03/31 20:23:50
I think this misses a few edge cases. For starters
bokan
2017/03/31 20:24:45
I think this is probably the reason your frame scr
yigu
2017/03/31 20:38:32
We basically don't care about the main scroller as
bokan
2017/04/04 15:25:45
If we don't care about the viewport, we should avo
| |
| 589 layoutObject.enclosingLayer()->visualRect().height().toInt()); | |
| 590 } else { | |
| 591 DEFINE_STATIC_LOCAL(CustomCountHistogram, sizeHistogramTouch, | |
| 592 ("Event.Scroll.ScrollerSize.OnScroll_Touch", 1, | |
| 593 kMaxScrollerSize, kBucketNum)); | |
| 594 sizeHistogramTouch.count( | |
| 595 layoutObject.enclosingLayer()->visualRect().width().toInt() * | |
| 596 layoutObject.enclosingLayer()->visualRect().height().toInt()); | |
| 597 } | |
| 598 } | |
| 599 | |
| 569 } // namespace blink | 600 } // namespace blink |
| OLD | NEW |