Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(680)

Side by Side Diff: third_party/WebKit/Source/core/input/ScrollManager.cpp

Issue 2816973002: Revert of Move logic of recording main thread scrolling reasons from cc to blink::ScrollManager (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
26 #include "platform/RuntimeEnabledFeatures.h" 25 #include "platform/RuntimeEnabledFeatures.h"
27 #include "wtf/PtrUtil.h" 26 #include "wtf/PtrUtil.h"
28 27
29 namespace blink { 28 namespace blink {
30 29
31 ScrollManager::ScrollManager(LocalFrame& frame) : frame_(frame) { 30 ScrollManager::ScrollManager(LocalFrame& frame) : frame_(frame) {
32 Clear(); 31 Clear();
33 } 32 }
34 33
35 void ScrollManager::Clear() { 34 void ScrollManager::Clear() {
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 if (scroll_state.deltaX() || scroll_state.deltaY()) 189 if (scroll_state.deltaX() || scroll_state.deltaY())
191 frame_->GetDocument()->UpdateStyleAndLayoutIgnorePendingStylesheets(); 190 frame_->GetDocument()->UpdateStyleAndLayoutIgnorePendingStylesheets();
192 191
193 if (current_scroll_chain_.empty()) 192 if (current_scroll_chain_.empty())
194 RecomputeScrollChain(start_node, current_scroll_chain_); 193 RecomputeScrollChain(start_node, current_scroll_chain_);
195 scroll_state.SetScrollChain(current_scroll_chain_); 194 scroll_state.SetScrollChain(current_scroll_chain_);
196 195
197 scroll_state.distributeToScrollChainDescendant(); 196 scroll_state.distributeToScrollChainDescendant();
198 } 197 }
199 198
200 uint32_t ScrollManager::ComputeNonCompositedMainThreadScrollingReasons() {
201 // When scrolling on the main thread, the scrollableArea may or may not be
202 // composited. Either way, we have recorded either the reasons stored in
203 // its layer or the reason NonFastScrollableRegion from the compositor
204 // side. Here we record scrolls that occurred on main thread due to a
205 // non-composited scroller.
206 if (!scroll_gesture_handling_node_->GetLayoutObject() || !frame_->View())
207 return 0;
208
209 uint32_t non_composited_main_thread_scrolling_reasons = 0;
210
211 for (auto* cur_box =
212 scroll_gesture_handling_node_->GetLayoutObject()->EnclosingBox();
213 cur_box; cur_box = cur_box->ContainingBlock()) {
214 PaintLayerScrollableArea* scrollable_area = cur_box->GetScrollableArea();
215
216 if (!scrollable_area || !scrollable_area->ScrollsOverflow())
217 continue;
218
219 DCHECK(!scrollable_area->UsesCompositedScrolling() ||
220 !scrollable_area->GetNonCompositedMainThreadScrollingReasons());
221 non_composited_main_thread_scrolling_reasons |=
222 scrollable_area->GetNonCompositedMainThreadScrollingReasons();
223 }
224
225 return non_composited_main_thread_scrolling_reasons;
226 }
227
228 void ScrollManager::RecordNonCompositedMainThreadScrollingReasons(
229 const WebGestureDevice device) {
230 if (device != kWebGestureDeviceTouchpad &&
231 device != kWebGestureDeviceTouchscreen) {
232 return;
233 }
234
235 uint32_t reasons = ComputeNonCompositedMainThreadScrollingReasons();
236 if (!reasons)
237 return;
238 DCHECK(MainThreadScrollingReason::HasNonCompositedScrollReasons(reasons));
239
240 uint32_t main_thread_scrolling_reason_enum_max =
241 MainThreadScrollingReason::kMainThreadScrollingReasonCount + 1;
242 for (uint32_t i = MainThreadScrollingReason::kNonCompositedReasonsFirst;
243 i <= MainThreadScrollingReason::kNonCompositedReasonsLast; ++i) {
244 unsigned val = 1 << i;
245 if (reasons & val) {
246 if (device == kWebGestureDeviceTouchscreen) {
247 DEFINE_STATIC_LOCAL(EnumerationHistogram, touch_histogram,
248 ("Renderer4.MainThreadGestureScrollReason",
249 main_thread_scrolling_reason_enum_max));
250 touch_histogram.Count(i + 1);
251 } else {
252 DEFINE_STATIC_LOCAL(EnumerationHistogram, wheel_histogram,
253 ("Renderer4.MainThreadWheelScrollReason",
254 main_thread_scrolling_reason_enum_max));
255 wheel_histogram.Count(i + 1);
256 }
257 }
258 }
259 }
260
261 WebInputEventResult ScrollManager::HandleGestureScrollBegin( 199 WebInputEventResult ScrollManager::HandleGestureScrollBegin(
262 const WebGestureEvent& gesture_event) { 200 const WebGestureEvent& gesture_event) {
263 Document* document = frame_->GetDocument(); 201 Document* document = frame_->GetDocument();
264 202
265 if (document->GetLayoutViewItem().IsNull()) 203 if (document->GetLayoutViewItem().IsNull())
266 return WebInputEventResult::kNotHandled; 204 return WebInputEventResult::kNotHandled;
267 205
268 // If there's no layoutObject on the node, send the event to the nearest 206 // If there's no layoutObject on the node, send the event to the nearest
269 // ancestor with a layoutObject. Needed for <option> and <optgroup> elements 207 // ancestor with a layoutObject. Needed for <option> and <optgroup> elements
270 // so we can touch scroll <select>s 208 // so we can touch scroll <select>s
271 while (scroll_gesture_handling_node_ && 209 while (scroll_gesture_handling_node_ &&
272 !scroll_gesture_handling_node_->GetLayoutObject()) 210 !scroll_gesture_handling_node_->GetLayoutObject())
273 scroll_gesture_handling_node_ = 211 scroll_gesture_handling_node_ =
274 scroll_gesture_handling_node_->ParentOrShadowHostNode(); 212 scroll_gesture_handling_node_->ParentOrShadowHostNode();
275 213
276 if (!scroll_gesture_handling_node_) 214 if (!scroll_gesture_handling_node_)
277 scroll_gesture_handling_node_ = frame_->GetDocument()->documentElement(); 215 scroll_gesture_handling_node_ = frame_->GetDocument()->documentElement();
278 216
279 if (!scroll_gesture_handling_node_ || 217 if (!scroll_gesture_handling_node_ ||
280 !scroll_gesture_handling_node_->GetLayoutObject()) 218 !scroll_gesture_handling_node_->GetLayoutObject())
281 return WebInputEventResult::kNotHandled; 219 return WebInputEventResult::kNotHandled;
282 220
283 PassScrollGestureEvent(gesture_event, 221 PassScrollGestureEvent(gesture_event,
284 scroll_gesture_handling_node_->GetLayoutObject()); 222 scroll_gesture_handling_node_->GetLayoutObject());
285 223
286 RecordNonCompositedMainThreadScrollingReasons(gesture_event.source_device);
287
288 current_scroll_chain_.clear(); 224 current_scroll_chain_.clear();
289 std::unique_ptr<ScrollStateData> scroll_state_data = 225 std::unique_ptr<ScrollStateData> scroll_state_data =
290 WTF::MakeUnique<ScrollStateData>(); 226 WTF::MakeUnique<ScrollStateData>();
291 IntPoint position = FlooredIntPoint(gesture_event.PositionInRootFrame()); 227 IntPoint position = FlooredIntPoint(gesture_event.PositionInRootFrame());
292 scroll_state_data->position_x = position.X(); 228 scroll_state_data->position_x = position.X();
293 scroll_state_data->position_y = position.Y(); 229 scroll_state_data->position_y = position.Y();
294 scroll_state_data->is_beginning = true; 230 scroll_state_data->is_beginning = true;
295 scroll_state_data->from_user_input = true; 231 scroll_state_data->from_user_input = true;
296 scroll_state_data->is_direct_manipulation = 232 scroll_state_data->is_direct_manipulation =
297 gesture_event.source_device == kWebGestureDeviceTouchscreen; 233 gesture_event.source_device == kWebGestureDeviceTouchscreen;
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 &should_update_capture)) { 566 &should_update_capture)) {
631 if (should_update_capture) 567 if (should_update_capture)
632 scrollbar_handling_scroll_gesture_ = scrollbar; 568 scrollbar_handling_scroll_gesture_ = scrollbar;
633 return true; 569 return true;
634 } 570 }
635 } 571 }
636 return false; 572 return false;
637 } 573 }
638 574
639 } // namespace blink 575 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/input/ScrollManager.h ('k') | third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698