| 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/FrameHost.h" | |
| 12 #include "core/frame/FrameView.h" | 11 #include "core/frame/FrameView.h" |
| 13 #include "core/html/HTMLFrameOwnerElement.h" | 12 #include "core/html/HTMLFrameOwnerElement.h" |
| 14 #include "core/input/EventHandler.h" | 13 #include "core/input/EventHandler.h" |
| 15 #include "core/input/EventHandlingUtil.h" | 14 #include "core/input/EventHandlingUtil.h" |
| 16 #include "core/layout/LayoutBlock.h" | 15 #include "core/layout/LayoutBlock.h" |
| 17 #include "core/layout/LayoutPart.h" | 16 #include "core/layout/LayoutPart.h" |
| 18 #include "core/layout/api/LayoutViewItem.h" | 17 #include "core/layout/api/LayoutViewItem.h" |
| 19 #include "core/loader/DocumentLoader.h" | 18 #include "core/loader/DocumentLoader.h" |
| 20 #include "core/page/AutoscrollController.h" | 19 #include "core/page/AutoscrollController.h" |
| 21 #include "core/page/Page.h" | 20 #include "core/page/Page.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 47 visitor->trace(m_scrollbarHandlingScrollGesture); | 46 visitor->trace(m_scrollbarHandlingScrollGesture); |
| 48 visitor->trace(m_resizeScrollableArea); | 47 visitor->trace(m_resizeScrollableArea); |
| 49 } | 48 } |
| 50 | 49 |
| 51 void ScrollManager::clearGestureScrollState() { | 50 void ScrollManager::clearGestureScrollState() { |
| 52 m_scrollGestureHandlingNode = nullptr; | 51 m_scrollGestureHandlingNode = nullptr; |
| 53 m_previousGestureScrolledElement = nullptr; | 52 m_previousGestureScrolledElement = nullptr; |
| 54 m_deltaConsumedForScrollSequence = false; | 53 m_deltaConsumedForScrollSequence = false; |
| 55 m_currentScrollChain.clear(); | 54 m_currentScrollChain.clear(); |
| 56 | 55 |
| 57 if (FrameHost* host = frameHost()) { | 56 if (Page* page = m_frame->page()) { |
| 58 bool resetX = true; | 57 bool resetX = true; |
| 59 bool resetY = true; | 58 bool resetY = true; |
| 60 host->overscrollController().resetAccumulated(resetX, resetY); | 59 page->overscrollController().resetAccumulated(resetX, resetY); |
| 61 } | 60 } |
| 62 } | 61 } |
| 63 | 62 |
| 64 void ScrollManager::stopAutoscroll() { | 63 void ScrollManager::stopAutoscroll() { |
| 65 if (AutoscrollController* controller = autoscrollController()) | 64 if (AutoscrollController* controller = autoscrollController()) |
| 66 controller->stopAutoscroll(); | 65 controller->stopAutoscroll(); |
| 67 } | 66 } |
| 68 | 67 |
| 69 bool ScrollManager::middleClickAutoscrollInProgress() const { | 68 bool ScrollManager::middleClickAutoscrollInProgress() const { |
| 70 return autoscrollController() && | 69 return autoscrollController() && |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 m_previousGestureScrolledElement = | 301 m_previousGestureScrolledElement = |
| 303 scrollState->currentNativeScrollingElement(); | 302 scrollState->currentNativeScrollingElement(); |
| 304 m_deltaConsumedForScrollSequence = | 303 m_deltaConsumedForScrollSequence = |
| 305 scrollState->deltaConsumedForScrollSequence(); | 304 scrollState->deltaConsumedForScrollSequence(); |
| 306 | 305 |
| 307 bool didScrollX = scrollState->deltaX() != delta.width(); | 306 bool didScrollX = scrollState->deltaX() != delta.width(); |
| 308 bool didScrollY = scrollState->deltaY() != delta.height(); | 307 bool didScrollY = scrollState->deltaY() != delta.height(); |
| 309 | 308 |
| 310 if ((!m_previousGestureScrolledElement || | 309 if ((!m_previousGestureScrolledElement || |
| 311 !isViewportScrollingElement(*m_previousGestureScrolledElement)) && | 310 !isViewportScrollingElement(*m_previousGestureScrolledElement)) && |
| 312 frameHost()) | 311 page()) |
| 313 frameHost()->overscrollController().resetAccumulated(didScrollX, | 312 page()->overscrollController().resetAccumulated(didScrollX, didScrollY); |
| 314 didScrollY); | |
| 315 | 313 |
| 316 if (didScrollX || didScrollY) { | 314 if (didScrollX || didScrollY) { |
| 317 setFrameWasScrolledByUser(); | 315 setFrameWasScrolledByUser(); |
| 318 return WebInputEventResult::HandledSystem; | 316 return WebInputEventResult::HandledSystem; |
| 319 } | 317 } |
| 320 | 318 |
| 321 return WebInputEventResult::NotHandled; | 319 return WebInputEventResult::NotHandled; |
| 322 } | 320 } |
| 323 | 321 |
| 324 WebInputEventResult ScrollManager::handleGestureScrollEnd( | 322 WebInputEventResult ScrollManager::handleGestureScrollEnd( |
| (...skipping 13 matching lines...) Expand all Loading... |
| 338 scrollStateData->delta_consumed_for_scroll_sequence = | 336 scrollStateData->delta_consumed_for_scroll_sequence = |
| 339 m_deltaConsumedForScrollSequence; | 337 m_deltaConsumedForScrollSequence; |
| 340 ScrollState* scrollState = ScrollState::create(std::move(scrollStateData)); | 338 ScrollState* scrollState = ScrollState::create(std::move(scrollStateData)); |
| 341 customizedScroll(*node, *scrollState); | 339 customizedScroll(*node, *scrollState); |
| 342 } | 340 } |
| 343 | 341 |
| 344 clearGestureScrollState(); | 342 clearGestureScrollState(); |
| 345 return WebInputEventResult::NotHandled; | 343 return WebInputEventResult::NotHandled; |
| 346 } | 344 } |
| 347 | 345 |
| 348 FrameHost* ScrollManager::frameHost() const { | 346 Page* ScrollManager::page() const { |
| 349 if (!m_frame->page()) | 347 return m_frame->page(); |
| 350 return nullptr; | |
| 351 | |
| 352 return &m_frame->page()->frameHost(); | |
| 353 } | 348 } |
| 354 | 349 |
| 355 WebInputEventResult ScrollManager::passScrollGestureEvent( | 350 WebInputEventResult ScrollManager::passScrollGestureEvent( |
| 356 const WebGestureEvent& gestureEvent, | 351 const WebGestureEvent& gestureEvent, |
| 357 LayoutObject* layoutObject) { | 352 LayoutObject* layoutObject) { |
| 358 DCHECK(gestureEvent.isScrollEvent()); | 353 DCHECK(gestureEvent.isScrollEvent()); |
| 359 | 354 |
| 360 if (!m_lastGestureScrollOverFrameViewBase || !layoutObject || | 355 if (!m_lastGestureScrollOverFrameViewBase || !layoutObject || |
| 361 !layoutObject->isLayoutPart()) | 356 !layoutObject->isLayoutPart()) |
| 362 return WebInputEventResult::NotHandled; | 357 return WebInputEventResult::NotHandled; |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 if (scrollbar->gestureEvent(targetedEvent.event(), &shouldUpdateCapture)) { | 553 if (scrollbar->gestureEvent(targetedEvent.event(), &shouldUpdateCapture)) { |
| 559 if (shouldUpdateCapture) | 554 if (shouldUpdateCapture) |
| 560 m_scrollbarHandlingScrollGesture = scrollbar; | 555 m_scrollbarHandlingScrollGesture = scrollbar; |
| 561 return true; | 556 return true; |
| 562 } | 557 } |
| 563 } | 558 } |
| 564 return false; | 559 return false; |
| 565 } | 560 } |
| 566 | 561 |
| 567 } // namespace blink | 562 } // namespace blink |
| OLD | NEW |