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

Unified Diff: third_party/WebKit/Source/core/input/ScrollManager.cpp

Issue 2773893003: Record size of scroller that user scrolls (Closed)
Patch Set: nit 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/input/ScrollManager.cpp
diff --git a/third_party/WebKit/Source/core/input/ScrollManager.cpp b/third_party/WebKit/Source/core/input/ScrollManager.cpp
index 054ae1c88a7b9b2f249509bea336ec83810a4b02..5d0ce699cbed9f15e6f011f7f10fb1df39b3a57a 100644
--- a/third_party/WebKit/Source/core/input/ScrollManager.cpp
+++ b/third_party/WebKit/Source/core/input/ScrollManager.cpp
@@ -24,6 +24,7 @@
#include "core/paint/PaintLayer.h"
#include "platform/Histogram.h"
#include "platform/RuntimeEnabledFeatures.h"
+#include "platform/scroll/ScrollerSizeMetrics.h"
#include "platform/wtf/PtrUtil.h"
namespace blink {
@@ -197,16 +198,20 @@ void ScrollManager::CustomizedScroll(const Node& start_node,
scroll_state.distributeToScrollChainDescendant();
}
-uint32_t ScrollManager::ComputeNonCompositedMainThreadScrollingReasons() {
+void ScrollManager::ComputeScrollRelatedMetrics(
+ uint32_t* non_composited_main_thread_scrolling_reasons,
+ int* scroller_size) {
// When scrolling on the main thread, the scrollableArea may or may not be
// composited. Either way, we have recorded either the reasons stored in
// its layer or the reason NonFastScrollableRegion from the compositor
// side. Here we record scrolls that occurred on main thread due to a
// non-composited scroller.
- if (!scroll_gesture_handling_node_->GetLayoutObject() || !frame_->View())
- return 0;
+ if (!scroll_gesture_handling_node_->GetLayoutObject())
+ return;
- uint32_t non_composited_main_thread_scrolling_reasons = 0;
+ // When recording the size of the scroller, we only need to record the
+ // fisrt scrollable area that we find during the walk up.
flackr 2017/04/21 00:56:35 nit: s/fisrt/first
yigu 2017/04/21 12:20:33 Done.
+ bool set_scroller_size = false;
for (auto* cur_box =
scroll_gesture_handling_node_->GetLayoutObject()->EnclosingBox();
@@ -216,43 +221,65 @@ uint32_t ScrollManager::ComputeNonCompositedMainThreadScrollingReasons() {
if (!scrollable_area || !scrollable_area->ScrollsOverflow())
continue;
+ if (!set_scroller_size && !cur_box->Layer()->IsRootLayer()) {
+ *scroller_size = scrollable_area->VisibleContentRect().Width() *
+ scrollable_area->VisibleContentRect().Height();
+ set_scroller_size = true;
+ }
+
DCHECK(!scrollable_area->UsesCompositedScrolling() ||
!scrollable_area->GetNonCompositedMainThreadScrollingReasons());
- non_composited_main_thread_scrolling_reasons |=
+ *non_composited_main_thread_scrolling_reasons |=
scrollable_area->GetNonCompositedMainThreadScrollingReasons();
}
-
- return non_composited_main_thread_scrolling_reasons;
}
-void ScrollManager::RecordNonCompositedMainThreadScrollingReasons(
- const WebGestureDevice device) {
+void ScrollManager::RecordScrollRelatedMetrics(const WebGestureDevice device) {
if (device != kWebGestureDeviceTouchpad &&
device != kWebGestureDeviceTouchscreen) {
return;
}
- uint32_t reasons = ComputeNonCompositedMainThreadScrollingReasons();
- if (!reasons)
- return;
- DCHECK(MainThreadScrollingReason::HasNonCompositedScrollReasons(reasons));
-
- uint32_t main_thread_scrolling_reason_enum_max =
- MainThreadScrollingReason::kMainThreadScrollingReasonCount + 1;
- for (uint32_t i = MainThreadScrollingReason::kNonCompositedReasonsFirst;
- i <= MainThreadScrollingReason::kNonCompositedReasonsLast; ++i) {
- unsigned val = 1 << i;
- if (reasons & val) {
- if (device == kWebGestureDeviceTouchscreen) {
- DEFINE_STATIC_LOCAL(EnumerationHistogram, touch_histogram,
- ("Renderer4.MainThreadGestureScrollReason",
- main_thread_scrolling_reason_enum_max));
- touch_histogram.Count(i + 1);
- } else {
- DEFINE_STATIC_LOCAL(EnumerationHistogram, wheel_histogram,
- ("Renderer4.MainThreadWheelScrollReason",
- main_thread_scrolling_reason_enum_max));
- wheel_histogram.Count(i + 1);
+ int scroller_size = 0;
+ uint32_t non_composited_main_thread_scrolling_reasons = 0;
+ ComputeScrollRelatedMetrics(&non_composited_main_thread_scrolling_reasons,
+ &scroller_size);
+ if (scroller_size > 0) {
flackr 2017/04/21 00:56:35 Nit: While clearly a silly case, you might miss a
yigu 2017/04/21 12:20:33 Done.
+ if (device == kWebGestureDeviceTouchpad) {
+ DEFINE_STATIC_LOCAL(
+ CustomCountHistogram, size_histogram_wheel,
+ ("Event.Scroll.ScrollerSize.OnScroll_Wheel", 1,
+ kScrollerSizeLargestBucket, kScrollerSizeBucketCount));
+ size_histogram_wheel.Count(scroller_size);
+ } else {
+ DEFINE_STATIC_LOCAL(
+ CustomCountHistogram, size_histogram_touch,
+ ("Event.Scroll.ScrollerSize.OnScroll_Touch", 1,
+ kScrollerSizeLargestBucket, kScrollerSizeBucketCount));
+ size_histogram_touch.Count(scroller_size);
+ }
+ }
+
+ if (non_composited_main_thread_scrolling_reasons) {
+ DCHECK(MainThreadScrollingReason::HasNonCompositedScrollReasons(
+ non_composited_main_thread_scrolling_reasons));
+ uint32_t main_thread_scrolling_reason_enum_max =
+ MainThreadScrollingReason::kMainThreadScrollingReasonCount + 1;
+ for (uint32_t i = MainThreadScrollingReason::kNonCompositedReasonsFirst;
+ i <= MainThreadScrollingReason::kNonCompositedReasonsLast; ++i) {
+ unsigned val = 1 << i;
+ if (non_composited_main_thread_scrolling_reasons & val) {
+ if (device == kWebGestureDeviceTouchscreen) {
+ DEFINE_STATIC_LOCAL(EnumerationHistogram, touch_histogram,
+ ("Renderer4.MainThreadGestureScrollReason",
+ main_thread_scrolling_reason_enum_max));
+ touch_histogram.Count(i + 1);
+ } else {
+ DEFINE_STATIC_LOCAL(EnumerationHistogram, wheel_histogram,
+ ("Renderer4.MainThreadWheelScrollReason",
+ main_thread_scrolling_reason_enum_max));
+ wheel_histogram.Count(i + 1);
+ }
}
}
}
@@ -283,7 +310,7 @@ WebInputEventResult ScrollManager::HandleGestureScrollBegin(
PassScrollGestureEvent(gesture_event,
scroll_gesture_handling_node_->GetLayoutObject());
- RecordNonCompositedMainThreadScrollingReasons(gesture_event.source_device);
+ RecordScrollRelatedMetrics(gesture_event.source_device);
current_scroll_chain_.clear();
std::unique_ptr<ScrollStateData> scroll_state_data =

Powered by Google App Engine
This is Rietveld 408576698