зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1675949 - Use a non-fixed value for pixel deltas. r=masayuki
Your call if you think this is worth it. Might need some test adjustments. Differential Revision: https://phabricator.services.mozilla.com/D107199
This commit is contained in:
Родитель
a7a3f7d10e
Коммит
e1a48f33c9
|
@ -2373,18 +2373,9 @@ void EventStateManager::DispatchLegacyMouseScrollEvents(
|
|||
|
||||
// Ignore mouse wheel transaction for computing legacy mouse wheel
|
||||
// events' delta value.
|
||||
nsIFrame* scrollFrame = ComputeScrollTargetAndMayAdjustWheelEvent(
|
||||
aTargetFrame, aEvent, COMPUTE_LEGACY_MOUSE_SCROLL_EVENT_TARGET);
|
||||
|
||||
nsIScrollableFrame* scrollTarget = do_QueryFrame(scrollFrame);
|
||||
nsPresContext* pc =
|
||||
scrollFrame ? scrollFrame->PresContext() : aTargetFrame->PresContext();
|
||||
|
||||
// DOM event's delta vales are computed from CSS pixels.
|
||||
nsSize scrollAmount = GetScrollAmount(pc, aEvent, scrollTarget);
|
||||
nsIntSize scrollAmountInCSSPixels(
|
||||
nsPresContext::AppUnitsToIntCSSPixels(scrollAmount.width),
|
||||
nsPresContext::AppUnitsToIntCSSPixels(scrollAmount.height));
|
||||
auto scrollAmountInCSSPixels =
|
||||
CSSIntSize::FromAppUnits(aEvent->mScrollAmount);
|
||||
|
||||
// XXX We don't deal with fractional amount in legacy event, though the
|
||||
// default action handler (DoScrollText()) deals with it.
|
||||
|
@ -5937,6 +5928,15 @@ void EventStateManager::DeltaAccumulator::InitLineOrPageDelta(
|
|||
mHandlingDeltaMode = aEvent->mDeltaMode;
|
||||
mIsNoLineOrPageDeltaDevice = aEvent->mIsNoLineOrPageDelta;
|
||||
|
||||
{
|
||||
nsIFrame* frame = aESM->ComputeScrollTarget(
|
||||
aTargetFrame, aEvent, COMPUTE_LEGACY_MOUSE_SCROLL_EVENT_TARGET);
|
||||
nsPresContext* pc =
|
||||
frame ? frame->PresContext() : aTargetFrame->PresContext();
|
||||
nsIScrollableFrame* scrollTarget = do_QueryFrame(frame);
|
||||
aEvent->mScrollAmount = aESM->GetScrollAmount(pc, aEvent, scrollTarget);
|
||||
}
|
||||
|
||||
// If it's handling neither a device that does not provide line or page deltas
|
||||
// nor delta values multiplied by prefs, we must not modify lineOrPageDelta
|
||||
// values.
|
||||
|
@ -5969,15 +5969,8 @@ void EventStateManager::DeltaAccumulator::InitLineOrPageDelta(
|
|||
// eMouseScrollEventClass (DOMMouseScroll) but not be used for scrolling
|
||||
// of default action. The transaction should be used only for the default
|
||||
// action.
|
||||
nsIFrame* frame = aESM->ComputeScrollTarget(
|
||||
aTargetFrame, aEvent, COMPUTE_LEGACY_MOUSE_SCROLL_EVENT_TARGET);
|
||||
nsPresContext* pc =
|
||||
frame ? frame->PresContext() : aTargetFrame->PresContext();
|
||||
nsIScrollableFrame* scrollTarget = do_QueryFrame(frame);
|
||||
nsSize scrollAmount = aESM->GetScrollAmount(pc, aEvent, scrollTarget);
|
||||
nsIntSize scrollAmountInCSSPixels(
|
||||
nsPresContext::AppUnitsToIntCSSPixels(scrollAmount.width),
|
||||
nsPresContext::AppUnitsToIntCSSPixels(scrollAmount.height));
|
||||
auto scrollAmountInCSSPixels =
|
||||
CSSIntSize::FromAppUnits(aEvent->mScrollAmount);
|
||||
|
||||
aEvent->mLineOrPageDeltaX = RoundDown(mX) / scrollAmountInCSSPixels.width;
|
||||
aEvent->mLineOrPageDeltaY = RoundDown(mY) / scrollAmountInCSSPixels.height;
|
||||
|
|
|
@ -61,7 +61,8 @@ void WheelEvent::InitWheelEvent(
|
|||
}
|
||||
|
||||
double WheelEvent::ToWebExposedDelta(const WidgetWheelEvent& aWidgetEvent,
|
||||
double aDelta, CallerType aCallerType) {
|
||||
double aDelta, nscoord aLineOrPageAmount,
|
||||
CallerType aCallerType) {
|
||||
if (aCallerType != CallerType::System) {
|
||||
if (mDeltaModeCheckingState == DeltaModeCheckingState::Unknown) {
|
||||
mDeltaModeCheckingState = DeltaModeCheckingState::Unchecked;
|
||||
|
@ -69,9 +70,7 @@ double WheelEvent::ToWebExposedDelta(const WidgetWheelEvent& aWidgetEvent,
|
|||
if (mDeltaModeCheckingState == DeltaModeCheckingState::Unchecked &&
|
||||
aWidgetEvent.mDeltaMode == WheelEvent_Binding::DOM_DELTA_LINE &&
|
||||
StaticPrefs::dom_event_wheel_deltaMode_lines_disabled()) {
|
||||
// TODO(emilio, bug 1675949): Consider not using a fixed multiplier here?
|
||||
return aDelta *
|
||||
StaticPrefs::dom_event_wheel_deltaMode_lines_to_pixel_scale();
|
||||
return aDelta * CSSPixel::FromAppUnits(aLineOrPageAmount);
|
||||
}
|
||||
}
|
||||
if (!mAppUnitsPerDevPixel) {
|
||||
|
@ -82,17 +81,21 @@ double WheelEvent::ToWebExposedDelta(const WidgetWheelEvent& aWidgetEvent,
|
|||
|
||||
double WheelEvent::DeltaX(CallerType aCallerType) {
|
||||
WidgetWheelEvent* ev = mEvent->AsWheelEvent();
|
||||
return ToWebExposedDelta(*ev, ev->mDeltaX, aCallerType);
|
||||
return ToWebExposedDelta(*ev, ev->mDeltaX, ev->mScrollAmount.width,
|
||||
aCallerType);
|
||||
}
|
||||
|
||||
double WheelEvent::DeltaY(CallerType aCallerType) {
|
||||
WidgetWheelEvent* ev = mEvent->AsWheelEvent();
|
||||
return ToWebExposedDelta(*ev, ev->mDeltaY, aCallerType);
|
||||
return ToWebExposedDelta(*ev, ev->mDeltaY, ev->mScrollAmount.height,
|
||||
aCallerType);
|
||||
}
|
||||
|
||||
double WheelEvent::DeltaZ(CallerType aCallerType) {
|
||||
WidgetWheelEvent* ev = mEvent->AsWheelEvent();
|
||||
return ToWebExposedDelta(*ev, ev->mDeltaZ, aCallerType);
|
||||
// XXX Unclear what scroll amount we should use for deltaZ...
|
||||
auto amount = std::max(ev->mScrollAmount.width, ev->mScrollAmount.height);
|
||||
return ToWebExposedDelta(*ev, ev->mDeltaZ, amount, aCallerType);
|
||||
}
|
||||
|
||||
uint32_t WheelEvent::DeltaMode(CallerType aCallerType) {
|
||||
|
|
|
@ -49,7 +49,8 @@ class WheelEvent : public MouseEvent {
|
|||
protected:
|
||||
~WheelEvent() = default;
|
||||
|
||||
double ToWebExposedDelta(const WidgetWheelEvent&, double aDelta, CallerType);
|
||||
double ToWebExposedDelta(const WidgetWheelEvent&, double aDelta,
|
||||
nscoord aLineOrPageAmount, CallerType);
|
||||
|
||||
private:
|
||||
int32_t mAppUnitsPerDevPixel;
|
||||
|
|
|
@ -2503,9 +2503,9 @@ function* testContinuousTrustedEvents()
|
|||
wheel: {
|
||||
expected: true, preventDefault: false,
|
||||
skipDeltaModeCheck: true,
|
||||
deltaX: SpecialPowers.getIntPref("dom.event.wheel-deltaMode-lines-to-pixel-scale"),
|
||||
deltaY: SpecialPowers.getIntPref("dom.event.wheel-deltaMode-lines-to-pixel-scale"),
|
||||
deltaZ: SpecialPowers.getIntPref("dom.event.wheel-deltaMode-lines-to-pixel-scale"),
|
||||
deltaX: gHorizontalLine,
|
||||
deltaY: gLineHeight,
|
||||
deltaZ: Math.max(gHorizontalLine, gLineHeight),
|
||||
},
|
||||
DOMMouseScroll: {
|
||||
horizontal: { expected: true, preventDefault: false, detail: 1 },
|
||||
|
|
|
@ -1780,15 +1780,6 @@
|
|||
value: false
|
||||
mirror: always
|
||||
|
||||
# When dom.event.wheel-deltaMode-lines.disabled is true, this is the lines to
|
||||
# pixels multiplier that gets used.
|
||||
#
|
||||
# The value here is taken from PIXELS_PER_LINE_SCALE from pdf.js.
|
||||
- name: dom.event.wheel-deltaMode-lines-to-pixel-scale
|
||||
type: uint32_t
|
||||
value: 30
|
||||
mirror: always
|
||||
|
||||
#if defined(XP_MACOSX)
|
||||
# Whether to disable treating ctrl click as right click
|
||||
- name: dom.event.treat_ctrl_click_as_right_click.disabled
|
||||
|
|
|
@ -513,6 +513,12 @@ class WidgetWheelEvent : public WidgetMouseEventBase {
|
|||
double mDeltaY;
|
||||
double mDeltaZ;
|
||||
|
||||
// The amount of scrolling per line or page, without accounting for mouse
|
||||
// wheel transactions etc.
|
||||
//
|
||||
// Computed by EventStateManager::DeltaAccumulator::InitLineOrPageDelta.
|
||||
nsSize mScrollAmount;
|
||||
|
||||
// overflowed delta values for scroll, these values are set by
|
||||
// EventStateManger. If the default action of the wheel event isn't scroll,
|
||||
// these values are always zero. Otherwise, remaining delta values which are
|
||||
|
@ -609,6 +615,7 @@ class WidgetWheelEvent : public WidgetMouseEventBase {
|
|||
mDeltaY = aEvent.mDeltaY;
|
||||
mDeltaZ = aEvent.mDeltaZ;
|
||||
mDeltaMode = aEvent.mDeltaMode;
|
||||
mScrollAmount = aEvent.mScrollAmount;
|
||||
mCustomizedByUserPrefs = aEvent.mCustomizedByUserPrefs;
|
||||
mMayHaveMomentum = aEvent.mMayHaveMomentum;
|
||||
mIsMomentum = aEvent.mIsMomentum;
|
||||
|
|
Загрузка…
Ссылка в новой задаче