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/dom/NodeComputedStyle.h" |
9 #include "core/events/GestureEvent.h" | 10 #include "core/events/GestureEvent.h" |
10 #include "core/frame/BrowserControls.h" | 11 #include "core/frame/BrowserControls.h" |
11 #include "core/frame/LocalFrameView.h" | 12 #include "core/frame/LocalFrameView.h" |
12 #include "core/html/HTMLFrameOwnerElement.h" | 13 #include "core/html/HTMLFrameOwnerElement.h" |
13 #include "core/input/EventHandler.h" | 14 #include "core/input/EventHandler.h" |
14 #include "core/input/EventHandlingUtil.h" | 15 #include "core/input/EventHandlingUtil.h" |
15 #include "core/layout/LayoutBlock.h" | 16 #include "core/layout/LayoutBlock.h" |
16 #include "core/layout/LayoutEmbeddedContent.h" | 17 #include "core/layout/LayoutEmbeddedContent.h" |
17 #include "core/layout/api/LayoutViewItem.h" | 18 #include "core/layout/api/LayoutViewItem.h" |
18 #include "core/loader/DocumentLoader.h" | 19 #include "core/loader/DocumentLoader.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 | 87 |
87 void ScrollManager::RecomputeScrollChain(const Node& start_node, | 88 void ScrollManager::RecomputeScrollChain(const Node& start_node, |
88 const ScrollState& scroll_state, | 89 const ScrollState& scroll_state, |
89 std::deque<int>& scroll_chain) { | 90 std::deque<int>& scroll_chain) { |
90 DCHECK(!scroll_chain.size()); | 91 DCHECK(!scroll_chain.size()); |
91 scroll_chain.clear(); | 92 scroll_chain.clear(); |
92 | 93 |
93 DCHECK(start_node.GetLayoutObject()); | 94 DCHECK(start_node.GetLayoutObject()); |
94 LayoutBox* cur_box = start_node.GetLayoutObject()->EnclosingBox(); | 95 LayoutBox* cur_box = start_node.GetLayoutObject()->EnclosingBox(); |
95 Element* document_element = frame_->GetDocument()->documentElement(); | 96 Element* document_element = frame_->GetDocument()->documentElement(); |
| 97 bool x_dominated = |
| 98 std::abs(scroll_state.deltaXHint()) > std::abs(scroll_state.deltaYHint()); |
96 | 99 |
97 // Scrolling propagates along the containing block chain and ends at the | 100 // Scrolling propagates along the containing block chain and ends at the |
98 // RootScroller element. The RootScroller element will have a custom | 101 // RootScroller element. The RootScroller element will have a custom |
99 // applyScroll callback that scrolls the frame or element. | 102 // applyScroll callback that scrolls the frame or element. |
100 while (cur_box) { | 103 while (cur_box) { |
101 Node* cur_node = cur_box->GetNode(); | 104 Node* cur_node = cur_box->GetNode(); |
102 Element* cur_element = nullptr; | 105 Element* cur_element = nullptr; |
103 | 106 |
104 // FIXME: this should reject more elements, as part of crbug.com/410974. | 107 // FIXME: this should reject more elements, as part of crbug.com/410974. |
105 if (cur_node && cur_node->IsElementNode()) { | 108 if (cur_node && cur_node->IsElementNode()) { |
106 cur_element = ToElement(cur_node); | 109 cur_element = ToElement(cur_node); |
107 } else if (cur_node && cur_node->IsDocumentNode()) { | 110 } else if (cur_node && cur_node->IsDocumentNode()) { |
108 // In normal circumastances, the documentElement will be the root | 111 // In normal circumastances, the documentElement will be the root |
109 // scroller but the documentElement itself isn't a containing block, | 112 // scroller but the documentElement itself isn't a containing block, |
110 // that'll be the document node rather than the element. | 113 // that'll be the document node rather than the element. |
111 cur_element = document_element; | 114 cur_element = document_element; |
112 } | 115 } |
113 | 116 |
114 if (cur_element) { | 117 if (cur_element) { |
115 if (CanScroll(scroll_state, *cur_element)) | 118 if (CanScroll(scroll_state, *cur_element)) |
116 scroll_chain.push_front(DOMNodeIds::IdForNode(cur_element)); | 119 scroll_chain.push_front(DOMNodeIds::IdForNode(cur_element)); |
117 if (IsViewportScrollingElement(*cur_element) || | 120 if (IsViewportScrollingElement(*cur_element) || |
118 cur_element == document_element) | 121 cur_element == document_element) |
119 break; | 122 break; |
| 123 |
| 124 if ((x_dominated && |
| 125 cur_element->GetComputedStyle()->ScrollBoundaryBehaviorX() != |
| 126 EScrollBoundaryBehavior::kAuto) || |
| 127 (!x_dominated && |
| 128 cur_element->GetComputedStyle()->ScrollBoundaryBehaviorY() != |
| 129 EScrollBoundaryBehavior::kAuto)) |
| 130 break; |
120 } | 131 } |
121 | 132 |
122 cur_box = cur_box->ContainingBlock(); | 133 cur_box = cur_box->ContainingBlock(); |
123 } | 134 } |
124 } | 135 } |
125 | 136 |
126 bool ScrollManager::CanScroll(const ScrollState& scroll_state, | 137 bool ScrollManager::CanScroll(const ScrollState& scroll_state, |
127 const Element& current_element) { | 138 const Element& current_element) { |
128 const double delta_x = scroll_state.isBeginning() ? scroll_state.deltaXHint() | 139 const double delta_x = scroll_state.isBeginning() ? scroll_state.deltaXHint() |
129 : scroll_state.deltaX(); | 140 : scroll_state.deltaX(); |
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
706 &should_update_capture)) { | 717 &should_update_capture)) { |
707 if (should_update_capture) | 718 if (should_update_capture) |
708 scrollbar_handling_scroll_gesture_ = scrollbar; | 719 scrollbar_handling_scroll_gesture_ = scrollbar; |
709 return true; | 720 return true; |
710 } | 721 } |
711 } | 722 } |
712 return false; | 723 return false; |
713 } | 724 } |
714 | 725 |
715 } // namespace blink | 726 } // namespace blink |
OLD | NEW |