0

Remove ui::ScrollGranularity::kScrollByPercentage

The CL deletes ui::ScrollGranularity::kScrollByPercentage, related code
and the runtime PercentBasedScrolling feature flag.

ScrollUtils::ResolveScrollPercentageToPixels is kept since it is used
for scroll by page wheel scroll which happens on the compositor thread.

Bug: 359747082
Change-Id: I7eaa5b9e516a52a48c26112b49258052bb639ffa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6033599
Reviewed-by: Rahul Arakeri <arakeri@microsoft.com>
Reviewed-by: Robert Flack <flackr@chromium.org>
Reviewed-by: Olga Gerchikov <gerchiko@microsoft.com>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Yaroslav Shalivskyy <yshalivskyy@microsoft.com>
Cr-Commit-Position: refs/heads/main@{#1387160}
This commit is contained in:
Yaroslav Shalivskyy
2024-11-23 00:15:54 +00:00
committed by Chromium LUCI CQ
parent 00ac3868ea
commit f90b4aa1a1
17 changed files with 38 additions and 194 deletions

@@ -1494,13 +1494,6 @@ gfx::Vector2dF InputHandler::ResolveScrollGranularityToPixels(
gfx::Vector2dF pixel_delta = scroll_delta; gfx::Vector2dF pixel_delta = scroll_delta;
if (granularity == ui::ScrollGranularity::kScrollByPage) { if (granularity == ui::ScrollGranularity::kScrollByPage) {
// Page should use a percentage of the scroller so change the parameters
// and let the percentage case below resolve it.
granularity = ui::ScrollGranularity::kScrollByPercentage;
pixel_delta.Scale(kMinFractionToStepWhenPaging);
}
if (granularity == ui::ScrollGranularity::kScrollByPercentage) {
gfx::SizeF scroller_size = gfx::SizeF(scroll_node.container_bounds); gfx::SizeF scroller_size = gfx::SizeF(scroll_node.container_bounds);
gfx::SizeF viewport_size(compositor_delegate_->VisualDeviceViewportSize()); gfx::SizeF viewport_size(compositor_delegate_->VisualDeviceViewportSize());
@@ -1512,6 +1505,7 @@ gfx::Vector2dF InputHandler::ResolveScrollGranularityToPixels(
// enabled, `DeviceScaleFactor()` returns 1). // enabled, `DeviceScaleFactor()` returns 1).
viewport_size.InvScale(compositor_delegate_->DeviceScaleFactor()); viewport_size.InvScale(compositor_delegate_->DeviceScaleFactor());
pixel_delta.Scale(kMinFractionToStepWhenPaging);
pixel_delta = ScrollUtils::ResolveScrollPercentageToPixels( pixel_delta = ScrollUtils::ResolveScrollPercentageToPixels(
pixel_delta, scroller_size, viewport_size); pixel_delta, scroller_size, viewport_size);
} }

@@ -17,16 +17,14 @@ namespace cc {
static constexpr int kPixelsPerLineStep = 40; static constexpr int kPixelsPerLineStep = 40;
static constexpr float kMinFractionToStepWhenPaging = 0.875f; static constexpr float kMinFractionToStepWhenPaging = 0.875f;
// Each directional scroll for percentage-based units should scroll 1/8th of
// the scrollable area.
static constexpr float kPercentDeltaForDirectionalScroll = 0.125f;
// Class for scroll helper methods in cc and blink. // Class for scroll helper methods in cc and blink.
class CC_EXPORT ScrollUtils { class CC_EXPORT ScrollUtils {
public: public:
// Transforms a |scroll_delta| in percent units to pixel units based in its // Transforms a |scroll_delta| in percent units to pixel units based on its
// |scroller_size|. Limits it by a maximum of 12.5% of |viewport_size| to // scroller_size and viewport_size. Inputs and output must be in physical
// avoid too large deltas. Inputs and output must be in physical pixels. // pixels. Currently used for converting kScrollByPage wheel scrolls
// (available on some platforms and can be enabled via the OS setting) that
// are handled on the compositor thread to pixel units.
static gfx::Vector2dF ResolveScrollPercentageToPixels( static gfx::Vector2dF ResolveScrollPercentageToPixels(
const gfx::Vector2dF& scroll_delta, const gfx::Vector2dF& scroll_delta,
const gfx::SizeF& scroller_size, const gfx::SizeF& scroller_size,

@@ -157,9 +157,7 @@ void MouseWheelEventQueue::ProcessMouseWheelAck(
event_sent_for_gesture_ack_->event.delta_units == event_sent_for_gesture_ack_->event.delta_units ==
ui::ScrollGranularity::kScrollByPrecisePixel || ui::ScrollGranularity::kScrollByPrecisePixel ||
event_sent_for_gesture_ack_->event.delta_units == event_sent_for_gesture_ack_->event.delta_units ==
ui::ScrollGranularity::kScrollByPixel || ui::ScrollGranularity::kScrollByPixel);
event_sent_for_gesture_ack_->event.delta_units ==
ui::ScrollGranularity::kScrollByPercentage);
scroll_update.data.scroll_update.delta_units = scroll_update.data.scroll_update.delta_units =
event_sent_for_gesture_ack_->event.delta_units; event_sent_for_gesture_ack_->event.delta_units;

@@ -67,28 +67,7 @@ void SyntheticGestureTargetBase::DispatchInputEventToPlatform(
LOG(WARNING) << "Mouse wheel position is not within content bounds."; LOG(WARNING) << "Mouse wheel position is not within content bounds.";
return; return;
} }
if (web_wheel.delta_units != ui::ScrollGranularity::kScrollByPercentage) DispatchWebMouseWheelEventToPlatform(web_wheel, latency_info);
DispatchWebMouseWheelEventToPlatform(web_wheel, latency_info);
else {
// Percentage-based mouse wheel scrolls are implemented in the UI layer by
// converting a native event's wheel tick amount to a percentage and
// setting that directly on WebMouseWheelEvent (i.e. it does not read the
// ui::MouseWheelEvent). However, when dispatching a synthetic
// ui::MouseWheelEvent, the created WebMouseWheelEvent will copy values
// from the ui::MouseWheelEvent. ui::MouseWheelEvent does
// not have a float value for delta, so that codepath ends up truncating.
// So instead, dispatch the WebMouseWheelEvent directly through the
// RenderWidgetHostInputEventRouter attached to the RenderWidgetHostImpl.
DCHECK(host_->delegate());
DCHECK(host_->delegate()->IsWidgetForPrimaryMainFrame(host_));
DCHECK(host_->delegate()->GetInputEventRouter());
std::unique_ptr<WebInputEvent> wheel_evt_ptr = web_wheel.Clone();
host_->delegate()->GetInputEventRouter()->RouteMouseWheelEvent(
host_->GetView(),
static_cast<WebMouseWheelEvent*>(wheel_evt_ptr.get()), latency_info);
}
} else if (WebInputEvent::IsMouseEventType(event.GetType())) { } else if (WebInputEvent::IsMouseEventType(event.GetType())) {
const WebMouseEvent& web_mouse = const WebMouseEvent& web_mouse =
static_cast<const WebMouseEvent&>(event); static_cast<const WebMouseEvent&>(event);

@@ -262,8 +262,6 @@ void SetRuntimeFeaturesFromChromiumFeatures() {
raw_ref(features::kNotificationContentImage), kSetOnlyIfOverridden}, raw_ref(features::kNotificationContentImage), kSetOnlyIfOverridden},
{wf::EnablePaymentApp, raw_ref(features::kServiceWorkerPaymentApps)}, {wf::EnablePaymentApp, raw_ref(features::kServiceWorkerPaymentApps)},
{wf::EnablePaymentRequest, raw_ref(features::kWebPayments)}, {wf::EnablePaymentRequest, raw_ref(features::kWebPayments)},
{wf::EnablePercentBasedScrolling,
raw_ref(features::kWindowsScrollingPersonality)},
{wf::EnablePeriodicBackgroundSync, {wf::EnablePeriodicBackgroundSync,
raw_ref(features::kPeriodicBackgroundSync)}, raw_ref(features::kPeriodicBackgroundSync)},
{wf::EnablePushMessagingSubscriptionChange, {wf::EnablePushMessagingSubscriptionChange,

@@ -398,16 +398,11 @@ void SyntheticSmoothMoveGesture::ComputeNextMoveSegment() {
DCHECK_LT(current_move_segment_, static_cast<int>(params().distances.size())); DCHECK_LT(current_move_segment_, static_cast<int>(params().distances.size()));
// Percentage based scrolls do not require velocity and are delivered in a // Percentage based scrolls do not require velocity and are delivered in a
// single segment. No need to compute another segment // single segment. No need to compute another segment
if (params().granularity == ui::ScrollGranularity::kScrollByPercentage) { const auto duration =
current_move_segment_start_time_ = current_move_segment_stop_time_; base::Seconds(double{params().distances[current_move_segment_].Length()} /
} else { params().speed_in_pixels_s);
const auto duration = base::Seconds( current_move_segment_start_time_ = current_move_segment_stop_time_;
double{params().distances[current_move_segment_].Length()} / current_move_segment_stop_time_ = current_move_segment_start_time_ + duration;
params().speed_in_pixels_s);
current_move_segment_start_time_ = current_move_segment_stop_time_;
current_move_segment_stop_time_ =
current_move_segment_start_time_ + duration;
}
} }
base::TimeTicks SyntheticSmoothMoveGesture::ClampTimestamp( base::TimeTicks SyntheticSmoothMoveGesture::ClampTimestamp(

@@ -126,31 +126,17 @@ ui::ScrollInputType WebGestureEvent::GetScrollInputType() const {
} }
float WebGestureEvent::DeltaXInRootFrame() const { float WebGestureEvent::DeltaXInRootFrame() const {
float delta_x = (type_ == WebInputEvent::Type::kGestureScrollBegin) const float delta_x = (type_ == WebInputEvent::Type::kGestureScrollBegin)
? data.scroll_begin.delta_x_hint ? data.scroll_begin.delta_x_hint
: data.scroll_update.delta_x; : data.scroll_update.delta_x;
return delta_x / frame_scale_;
bool is_percent = (type_ == WebInputEvent::Type::kGestureScrollBegin)
? data.scroll_begin.delta_hint_units ==
ui::ScrollGranularity::kScrollByPercentage
: data.scroll_update.delta_units ==
ui::ScrollGranularity::kScrollByPercentage;
return is_percent ? delta_x : delta_x / frame_scale_;
} }
float WebGestureEvent::DeltaYInRootFrame() const { float WebGestureEvent::DeltaYInRootFrame() const {
float delta_y = (type_ == WebInputEvent::Type::kGestureScrollBegin) const float delta_y = (type_ == WebInputEvent::Type::kGestureScrollBegin)
? data.scroll_begin.delta_y_hint ? data.scroll_begin.delta_y_hint
: data.scroll_update.delta_y; : data.scroll_update.delta_y;
return delta_y / frame_scale_;
bool is_percent = (type_ == WebInputEvent::Type::kGestureScrollBegin)
? data.scroll_begin.delta_hint_units ==
ui::ScrollGranularity::kScrollByPercentage
: data.scroll_update.delta_units ==
ui::ScrollGranularity::kScrollByPercentage;
return is_percent ? delta_y : delta_y / frame_scale_;
} }
ui::ScrollGranularity WebGestureEvent::DeltaUnits() const { ui::ScrollGranularity WebGestureEvent::DeltaUnits() const {
@@ -234,18 +220,12 @@ void WebGestureEvent::FlattenTransform() {
if (frame_scale_ != 1) { if (frame_scale_ != 1) {
switch (type_) { switch (type_) {
case WebInputEvent::Type::kGestureScrollBegin: case WebInputEvent::Type::kGestureScrollBegin:
if (data.scroll_begin.delta_hint_units != data.scroll_begin.delta_x_hint /= frame_scale_;
ui::ScrollGranularity::kScrollByPercentage) { data.scroll_begin.delta_y_hint /= frame_scale_;
data.scroll_begin.delta_x_hint /= frame_scale_;
data.scroll_begin.delta_y_hint /= frame_scale_;
}
break; break;
case WebInputEvent::Type::kGestureScrollUpdate: case WebInputEvent::Type::kGestureScrollUpdate:
if (data.scroll_update.delta_units != data.scroll_update.delta_x /= frame_scale_;
ui::ScrollGranularity::kScrollByPercentage) { data.scroll_update.delta_y /= frame_scale_;
data.scroll_update.delta_x /= frame_scale_;
data.scroll_update.delta_y /= frame_scale_;
}
break; break;
case WebInputEvent::Type::kGestureTwoFingerTap: case WebInputEvent::Type::kGestureTwoFingerTap:
data.two_finger_tap.first_finger_width /= frame_scale_; data.two_finger_tap.first_finger_width /= frame_scale_;

@@ -21,23 +21,6 @@
namespace blink { namespace blink {
namespace {
gfx::Vector2dF ResolveMouseWheelPercentToWheelDelta(
const WebMouseWheelEvent& event) {
DCHECK(event.delta_units == ui::ScrollGranularity::kScrollByPercentage);
// TODO (dlibby): OS scroll settings need to be factored into this.
// Note that this value is negative because we're converting from wheel
// ticks to wheel delta pixel. Wheel ticks are negative for scrolling down,
// but the delta must be positive.
constexpr float percent_mouse_wheel_ticks_multiplier = -100.f;
return gfx::Vector2dF(
event.wheel_ticks_x * percent_mouse_wheel_ticks_multiplier,
event.wheel_ticks_y * percent_mouse_wheel_ticks_multiplier);
}
} // namespace
MouseWheelEventManager::MouseWheelEventManager(LocalFrame& frame, MouseWheelEventManager::MouseWheelEventManager(LocalFrame& frame,
ScrollManager& scroll_manager) ScrollManager& scroll_manager)
: frame_(frame), wheel_target_(nullptr), scroll_manager_(scroll_manager) {} : frame_(frame), wheel_target_(nullptr), scroll_manager_(scroll_manager) {}
@@ -106,12 +89,7 @@ WebInputEventResult MouseWheelEventManager::HandleWheelEvent(
if (wheel_target_) { if (wheel_target_) {
WheelEvent* dom_event = WheelEvent* dom_event =
(event.delta_units == ui::ScrollGranularity::kScrollByPercentage) WheelEvent::Create(event, *wheel_target_->GetDocument().domWindow());
? WheelEvent::Create(event,
ResolveMouseWheelPercentToWheelDelta(event),
*wheel_target_->GetDocument().domWindow())
: WheelEvent::Create(event,
*wheel_target_->GetDocument().domWindow());
// The event handler might remove |wheel_target_| from DOM so we should get // The event handler might remove |wheel_target_| from DOM so we should get
// this value now (see https://crbug.com/857013). // this value now (see https://crbug.com/857013).

@@ -221,20 +221,15 @@ bool ScrollManager::LogicalScroll(mojom::blink::ScrollDirection direction,
ScrollableArea* scrollable_area = ScrollableArea::GetForScrolling(box); ScrollableArea* scrollable_area = ScrollableArea::GetForScrolling(box);
DCHECK(scrollable_area); DCHECK(scrollable_area);
ScrollOffset delta = ScrollOffset delta = ToScrollDelta(physical_direction, 1);
ToScrollDelta(physical_direction,
ScrollableArea::DirectionBasedScrollDelta(granularity));
delta.Scale(scrollable_area->ScrollStep(granularity, kHorizontalScrollbar), delta.Scale(scrollable_area->ScrollStep(granularity, kHorizontalScrollbar),
scrollable_area->ScrollStep(granularity, kVerticalScrollbar)); scrollable_area->ScrollStep(granularity, kVerticalScrollbar));
// Pressing the arrow key is considered as a scroll with intended direction // Pressing the arrow key is considered as a scroll with intended direction
// only (this results in kScrollByLine or kScrollByPercentage, depending on // only. Pressing the PgUp/PgDn key is considered as a scroll with intended
// REF::PercentBasedScrollingEnabled). Pressing the PgUp/PgDn key is // direction and end position. Pressing the Home/End key is considered as a
// considered as a scroll with intended direction and end position. Pressing // scroll with intended end position only.
// the Home/End key is considered as a scroll with intended end position
// only.
switch (granularity) { switch (granularity) {
case ui::ScrollGranularity::kScrollByLine: case ui::ScrollGranularity::kScrollByLine: {
case ui::ScrollGranularity::kScrollByPercentage: {
if (scrollable_area->SnapForDirection(delta)) if (scrollable_area->SnapForDirection(delta))
return true; return true;
break; break;
@@ -297,10 +292,7 @@ bool ScrollManager::LogicalScroll(mojom::blink::ScrollDirection direction,
&(frame_->GetEventHandler().GetKeyboardEventManager())), &(frame_->GetEventHandler().GetKeyboardEventManager())),
scrolling_via_key)); scrolling_via_key));
ScrollResult result = scrollable_area->UserScroll( ScrollResult result = scrollable_area->UserScroll(
granularity, granularity, ToScrollDelta(physical_direction, 1), std::move(callback));
ToScrollDelta(physical_direction,
ScrollableArea::DirectionBasedScrollDelta(granularity)),
std::move(callback));
if (result.DidScroll()) if (result.DidScroll())
return true; return true;

@@ -92,14 +92,6 @@ int ScrollableArea::MaxOverlapBetweenPages() const {
return GetPageScrollbarTheme().MaxOverlapBetweenPages(); return GetPageScrollbarTheme().MaxOverlapBetweenPages();
} }
// static
float ScrollableArea::DirectionBasedScrollDelta(
ui::ScrollGranularity granularity) {
return (granularity == ui::ScrollGranularity::kScrollByPercentage)
? cc::kPercentDeltaForDirectionalScroll
: 1;
}
// static // static
mojom::blink::ScrollBehavior ScrollableArea::DetermineScrollBehavior( mojom::blink::ScrollBehavior ScrollableArea::DetermineScrollBehavior(
mojom::blink::ScrollBehavior behavior_from_param, mojom::blink::ScrollBehavior behavior_from_param,
@@ -203,8 +195,6 @@ float ScrollableArea::ScrollStep(ui::ScrollGranularity granularity,
case ui::ScrollGranularity::kScrollByPixel: case ui::ScrollGranularity::kScrollByPixel:
case ui::ScrollGranularity::kScrollByPrecisePixel: case ui::ScrollGranularity::kScrollByPrecisePixel:
return PixelStep(orientation); return PixelStep(orientation);
case ui::ScrollGranularity::kScrollByPercentage:
return PercentageStep(orientation);
default: default:
NOTREACHED(); NOTREACHED();
} }
@@ -215,25 +205,6 @@ ScrollOffset ScrollableArea::ResolveScrollDelta(
const ScrollOffset& delta) { const ScrollOffset& delta) {
gfx::SizeF step(ScrollStep(granularity, kHorizontalScrollbar), gfx::SizeF step(ScrollStep(granularity, kHorizontalScrollbar),
ScrollStep(granularity, kVerticalScrollbar)); ScrollStep(granularity, kVerticalScrollbar));
if (granularity == ui::ScrollGranularity::kScrollByPercentage) {
LocalFrame* local_frame = GetLayoutBox()->GetFrame();
DCHECK(local_frame);
gfx::SizeF viewport(local_frame->GetPage()->GetVisualViewport().Size());
// Convert to screen coordinates (physical pixels).
float page_scale_factor = local_frame->GetPage()->PageScaleFactor();
step.Scale(page_scale_factor);
gfx::Vector2dF pixel_delta =
cc::ScrollUtils::ResolveScrollPercentageToPixels(delta, step, viewport);
// Rescale back to rootframe coordinates.
pixel_delta.Scale(1 / page_scale_factor);
return pixel_delta;
}
return gfx::ScaleVector2d(delta, step.width(), step.height()); return gfx::ScaleVector2d(delta, step.width(), step.height());
} }
@@ -1159,14 +1130,6 @@ float ScrollableArea::PixelStep(ScrollbarOrientation) const {
return 1; return 1;
} }
float ScrollableArea::PercentageStep(ScrollbarOrientation orientation) const {
int percent_basis =
(orientation == ScrollbarOrientation::kHorizontalScrollbar)
? VisibleWidth()
: VisibleHeight();
return static_cast<float>(percent_basis);
}
int ScrollableArea::VerticalScrollbarWidth( int ScrollableArea::VerticalScrollbarWidth(
OverlayScrollbarClipBehavior behavior) const { OverlayScrollbarClipBehavior behavior) const {
DCHECK_EQ(behavior, kIgnoreOverlayScrollbarSize); DCHECK_EQ(behavior, kIgnoreOverlayScrollbarSize);

@@ -109,10 +109,6 @@ class CORE_EXPORT ScrollableArea : public GarbageCollectedMixin {
static float MinFractionToStepWhenPaging(); static float MinFractionToStepWhenPaging();
int MaxOverlapBetweenPages() const; int MaxOverlapBetweenPages() const;
// Returns the amount of delta, in |granularity| units, for a direction-based
// (i.e. keyboard or scrollbar arrow) scroll.
static float DirectionBasedScrollDelta(ui::ScrollGranularity granularity);
// Convert a non-finite scroll value (Infinity, -Infinity, NaN) to 0 as // Convert a non-finite scroll value (Infinity, -Infinity, NaN) to 0 as
// per https://drafts.csswg.org/cssom-view/#normalize-non-finite-values. // per https://drafts.csswg.org/cssom-view/#normalize-non-finite-values.
static float NormalizeNonFiniteScroll(float value) { static float NormalizeNonFiniteScroll(float value) {
@@ -691,12 +687,6 @@ class CORE_EXPORT ScrollableArea : public GarbageCollectedMixin {
virtual int DocumentStep(ScrollbarOrientation) const; virtual int DocumentStep(ScrollbarOrientation) const;
virtual float PixelStep(ScrollbarOrientation) const; virtual float PixelStep(ScrollbarOrientation) const;
// This returns the amount a percent-based delta should be resolved against;
// which is the visible height of the scroller. This value is eventually
// used to scroll the incoming scroll delta, where a scroll delta of 1
// represents one hundred percent.
float PercentageStep(ScrollbarOrientation) const;
// Returns true if a snap point was found. // Returns true if a snap point was found.
bool PerformSnapping( bool PerformSnapping(
const cc::SnapSelectionStrategy& strategy, const cc::SnapSelectionStrategy& strategy,

@@ -620,10 +620,9 @@ void Scrollbar::MouseDown(const WebMouseEvent& evt) {
void Scrollbar::InjectScrollGestureForPressedPart( void Scrollbar::InjectScrollGestureForPressedPart(
WebInputEvent::Type gesture_type) { WebInputEvent::Type gesture_type) {
ui::ScrollGranularity granularity = PressedPartScrollGranularity(); const ui::ScrollGranularity granularity = PressedPartScrollGranularity();
ScrollOffset delta = const ScrollOffset delta =
ToScrollDelta(PressedPartScrollDirectionPhysical(), ToScrollDelta(PressedPartScrollDirectionPhysical(), 1);
ScrollableArea::DirectionBasedScrollDelta(granularity));
InjectScrollGesture(gesture_type, delta, granularity); InjectScrollGesture(gesture_type, delta, granularity);
} }

@@ -3218,12 +3218,6 @@
status: "experimental", status: "experimental",
base_feature: "none", base_feature: "none",
}, },
{
name: "PercentBasedScrolling",
base_feature: "none",
public: true,
settable_from_internals: true,
},
{ {
name: "PerformanceManagerInstrumentation", name: "PerformanceManagerInstrumentation",
base_feature: "none", base_feature: "none",

@@ -626,7 +626,6 @@ _CONFIG = [
'cc::kManipulationInfoTouch', 'cc::kManipulationInfoTouch',
'cc::kManipulationInfoWheel', 'cc::kManipulationInfoWheel',
'cc::kMinFractionToStepWhenPaging', 'cc::kMinFractionToStepWhenPaging',
'cc::kPercentDeltaForDirectionalScroll',
'cc::kPixelsPerLineStep', 'cc::kPixelsPerLineStep',
'cc::MainThreadScrollingReason', 'cc::MainThreadScrollingReason',
'cc::ManipulationInfo', 'cc::ManipulationInfo',

@@ -29,10 +29,6 @@ struct GestureEventData;
struct GestureEventDetails; struct GestureEventDetails;
class MotionEvent; class MotionEvent;
// The scroll percentage per mousewheel tick. Used to determine scroll delta
// if percent based scrolling is enabled.
const float kScrollPercentPerLineOrChar = 0.05f;
blink::WebTouchEvent CreateWebTouchEventFromMotionEvent( blink::WebTouchEvent CreateWebTouchEventFromMotionEvent(
const MotionEvent& event, const MotionEvent& event,
bool may_cause_scrolling, bool may_cause_scrolling,

@@ -35,12 +35,12 @@ TEST(BlinkEventUtilTest, NoScalingWith1DSF) {
EXPECT_TRUE(ScaleWebInputEvent(event, 2.f)); EXPECT_TRUE(ScaleWebInputEvent(event, 2.f));
} }
void RunTest(ui::ScrollGranularity granularity) { TEST(BlinkEventUtilTest, NonPaginatedWebMouseWheelEvent) {
blink::WebMouseWheelEvent event( blink::WebMouseWheelEvent event(
blink::WebInputEvent::Type::kMouseWheel, blink::WebInputEvent::Type::kMouseWheel,
blink::WebInputEvent::kNoModifiers, blink::WebInputEvent::kNoModifiers,
blink::WebInputEvent::GetStaticTimeStampForTests()); blink::WebInputEvent::GetStaticTimeStampForTests());
event.delta_units = granularity; event.delta_units = ui::ScrollGranularity::kScrollByPixel;
event.delta_x = 1.f; event.delta_x = 1.f;
event.delta_y = 1.f; event.delta_y = 1.f;
event.wheel_ticks_x = 1.f; event.wheel_ticks_x = 1.f;
@@ -56,14 +56,6 @@ void RunTest(ui::ScrollGranularity granularity) {
EXPECT_EQ(2.f, mouseWheelEvent->wheel_ticks_y); EXPECT_EQ(2.f, mouseWheelEvent->wheel_ticks_y);
} }
TEST(BlinkEventUtilTest, NonPaginatedWebMouseWheelEvent) {
RunTest(ui::ScrollGranularity::kScrollByPixel);
}
TEST(BlinkEventUtilTest, NonPaginatedWebMouseWheelEventPercentBased) {
RunTest(ui::ScrollGranularity::kScrollByPercentage);
}
TEST(BlinkEventUtilTest, PaginatedWebMouseWheelEvent) { TEST(BlinkEventUtilTest, PaginatedWebMouseWheelEvent) {
blink::WebMouseWheelEvent event( blink::WebMouseWheelEvent event(
blink::WebInputEvent::Type::kMouseWheel, blink::WebInputEvent::Type::kMouseWheel,

@@ -16,8 +16,7 @@ enum class ScrollGranularity : uint8_t {
kScrollByLine, kScrollByLine,
kScrollByPage, kScrollByPage,
kScrollByDocument, kScrollByDocument,
kScrollByPercentage, kMaxValue = kScrollByDocument
kMaxValue = kScrollByPercentage
}; };
} // namespace ui } // namespace ui