ScrollbarController cleanup.
This CL optimizes hit testing on pointerdown. Previously, 2 hit tests were performed for a pointerdown on a composited scrollbar. With this change, we now do only 1. Please see the bug for more details. Bug: 40160629 Change-Id: Ia71343f12e56dfe8ad70c9e36208e29b04376868 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5273278 Commit-Queue: Rahul Arakeri <arakeri@microsoft.com> Reviewed-by: Robert Flack <flackr@chromium.org> Cr-Commit-Position: refs/heads/main@{#1257041}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
d9d0bd8afb
commit
312b5137b7
@ -547,7 +547,7 @@ InputHandlerPointerResult InputHandler::MouseMoveAt(
|
||||
}
|
||||
|
||||
PointerResultType InputHandler::HitTest(const gfx::PointF& viewport_point) {
|
||||
return scrollbar_controller_->HitTest(viewport_point);
|
||||
return scrollbar_controller_->HitTest(viewport_point).type;
|
||||
}
|
||||
|
||||
InputHandlerPointerResult InputHandler::MouseDown(
|
||||
|
@ -58,6 +58,13 @@ enum class ScrollBeginThreadState {
|
||||
kMaxValue = kScrollingOnMain,
|
||||
};
|
||||
|
||||
struct CC_EXPORT PointerHitTestResult {
|
||||
PointerHitTestResult() = default;
|
||||
|
||||
PointerResultType type = PointerResultType::kUnhandled;
|
||||
raw_ptr<const LayerImpl> layer_impl = nullptr;
|
||||
};
|
||||
|
||||
struct CC_EXPORT InputHandlerPointerResult {
|
||||
InputHandlerPointerResult() = default;
|
||||
// Tells what type of processing occurred in the input handler as a result of
|
||||
|
@ -51,7 +51,7 @@ ScrollbarLayerImplBase* ScrollbarController::ScrollbarLayer() const {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PointerResultType ScrollbarController::HitTest(
|
||||
PointerHitTestResult ScrollbarController::HitTest(
|
||||
const gfx::PointF position_in_widget) const {
|
||||
// If a non-custom scrollbar layer was not found, we return early as there is
|
||||
// no point in setting additional state in the ScrollbarController. Return an
|
||||
@ -59,16 +59,20 @@ PointerResultType ScrollbarController::HitTest(
|
||||
// to InputHandlerProxy::RouteToTypeSpecificHandler, the pointer event gets
|
||||
// passed on to the main thread.
|
||||
const LayerImpl* layer_impl = GetLayerHitByPoint(position_in_widget);
|
||||
PointerHitTestResult result;
|
||||
|
||||
if (!(layer_impl && layer_impl->IsScrollbarLayer()))
|
||||
return PointerResultType::kUnhandled;
|
||||
return result;
|
||||
|
||||
// If the scrollbar layer has faded out (eg: Overlay scrollbars), don't
|
||||
// initiate a scroll.
|
||||
const ScrollbarLayerImplBase* scrollbar = ToScrollbarLayer(layer_impl);
|
||||
if (scrollbar->OverlayScrollbarOpacity() == 0.f)
|
||||
return PointerResultType::kUnhandled;
|
||||
return result;
|
||||
|
||||
return PointerResultType::kScrollbarScroll;
|
||||
result.type = PointerResultType::kScrollbarScroll;
|
||||
result.layer_impl = layer_impl;
|
||||
return result;
|
||||
}
|
||||
|
||||
// Performs hit test and prepares scroll deltas that will be used by GSB and
|
||||
@ -76,13 +80,15 @@ PointerResultType ScrollbarController::HitTest(
|
||||
InputHandlerPointerResult ScrollbarController::HandlePointerDown(
|
||||
const gfx::PointF position_in_widget,
|
||||
bool jump_key_modifier) {
|
||||
if (HitTest(position_in_widget) != PointerResultType::kScrollbarScroll)
|
||||
PointerHitTestResult hit_test_result = HitTest(position_in_widget);
|
||||
if (hit_test_result.type != PointerResultType::kScrollbarScroll) {
|
||||
return InputHandlerPointerResult();
|
||||
}
|
||||
|
||||
// TODO(arakeri): GetLayerHitByPoint should ideally be called only once per
|
||||
// pointerdown. This needs to be optimized. See crbug.com/1156922.
|
||||
const ScrollbarLayerImplBase* scrollbar =
|
||||
ToScrollbarLayer(GetLayerHitByPoint(position_in_widget));
|
||||
ToScrollbarLayer(hit_test_result.layer_impl);
|
||||
captured_scrollbar_metadata_ = CapturedScrollbarMetadata();
|
||||
captured_scrollbar_metadata_->scroll_element_id =
|
||||
scrollbar->scroll_element_id();
|
||||
|
@ -157,7 +157,7 @@ class CC_EXPORT ScrollbarController {
|
||||
ScrollbarLayerImplBase* ScrollbarLayer() const;
|
||||
void WillBeginImplFrame();
|
||||
void ResetState();
|
||||
PointerResultType HitTest(const gfx::PointF position_in_widget) const;
|
||||
PointerHitTestResult HitTest(const gfx::PointF position_in_widget) const;
|
||||
|
||||
private:
|
||||
FRIEND_TEST_ALL_PREFIXES(LayerTreeHostImplTest, ThumbDragAfterJumpClick);
|
||||
|
Reference in New Issue
Block a user