mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
Bug 1871760 - Revert bug 1856088. r=botond
Two test cases attached in bug 1856088 now work with the previous commit and work without `MergeableAbsolute`. Differential Revision: https://phabricator.services.mozilla.com/D199841
This commit is contained in:
parent
5345093b90
commit
0d84054136
@ -147,12 +147,10 @@ CSSSize FrameMetrics::CalculateCompositedSizeInCssPixels(
|
||||
return aCompositionBounds.Size() / aZoom;
|
||||
}
|
||||
|
||||
std::pair<bool, CSSPoint> FrameMetrics::ApplyAbsoluteScrollUpdateFrom(
|
||||
const ScrollPositionUpdate& aUpdate) {
|
||||
CSSPoint oldVisualOffset = GetVisualScrollOffset();
|
||||
bool FrameMetrics::ApplyScrollUpdateFrom(const ScrollPositionUpdate& aUpdate) {
|
||||
// In applying a main-thread scroll update, try to preserve the relative
|
||||
// offset between the visual and layout viewports.
|
||||
CSSPoint relativeOffset = oldVisualOffset - GetLayoutScrollOffset();
|
||||
CSSPoint relativeOffset = GetVisualScrollOffset() - GetLayoutScrollOffset();
|
||||
MOZ_ASSERT(IsRootContent() || relativeOffset == CSSPoint());
|
||||
// We need to set the two offsets together, otherwise a subsequent
|
||||
// RecalculateLayoutViewportOffset() could see divergent layout and
|
||||
@ -160,7 +158,7 @@ std::pair<bool, CSSPoint> FrameMetrics::ApplyAbsoluteScrollUpdateFrom(
|
||||
bool offsetChanged = SetLayoutScrollOffset(aUpdate.GetDestination());
|
||||
offsetChanged |=
|
||||
ClampAndSetVisualScrollOffset(aUpdate.GetDestination() + relativeOffset);
|
||||
return {offsetChanged, GetVisualScrollOffset() - oldVisualOffset};
|
||||
return offsetChanged;
|
||||
}
|
||||
|
||||
CSSPoint FrameMetrics::ApplyRelativeScrollUpdateFrom(
|
||||
|
@ -243,11 +243,9 @@ struct FrameMetrics {
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns true if the layout scroll offset or visual scroll offset changed
|
||||
* and returns the visual scroll offset change delta.
|
||||
* Returns true if the layout scroll offset or visual scroll offset changed.
|
||||
*/
|
||||
std::pair<bool, CSSPoint> ApplyAbsoluteScrollUpdateFrom(
|
||||
const ScrollPositionUpdate& aUpdate);
|
||||
bool ApplyScrollUpdateFrom(const ScrollPositionUpdate& aUpdate);
|
||||
|
||||
/**
|
||||
* Applies the relative scroll offset update contained in aOther to the
|
||||
|
@ -5732,20 +5732,11 @@ void AsyncPanZoomController::NotifyLayersUpdated(
|
||||
relativeDelta =
|
||||
Some(Metrics().ApplyPureRelativeScrollUpdateFrom(scrollUpdate));
|
||||
Metrics().RecalculateLayoutViewportOffset();
|
||||
} else if (scrollUpdate.GetType() == ScrollUpdateType::MergeableAbsolute) {
|
||||
APZC_LOG("%p mergeable updating scroll offset from %s to %s\n", this,
|
||||
ToString(Metrics().GetVisualScrollOffset()).c_str(),
|
||||
ToString(scrollUpdate.GetDestination()).c_str());
|
||||
relativeDelta =
|
||||
Some(Metrics().ApplyAbsoluteScrollUpdateFrom(scrollUpdate).second);
|
||||
Metrics().RecalculateLayoutViewportOffset();
|
||||
scrollOffsetUpdated = true;
|
||||
} else {
|
||||
APZC_LOG("%p updating scroll offset from %s to %s\n", this,
|
||||
ToString(Metrics().GetVisualScrollOffset()).c_str(),
|
||||
ToString(scrollUpdate.GetDestination()).c_str());
|
||||
auto [offsetChanged, _] =
|
||||
Metrics().ApplyAbsoluteScrollUpdateFrom(scrollUpdate);
|
||||
bool offsetChanged = Metrics().ApplyScrollUpdateFrom(scrollUpdate);
|
||||
Metrics().RecalculateLayoutViewportOffset();
|
||||
|
||||
if (offsetChanged || scrollUpdate.GetMode() != ScrollMode::Instant ||
|
||||
|
@ -520,7 +520,7 @@ template <>
|
||||
struct ParamTraits<mozilla::ScrollUpdateType>
|
||||
: public ContiguousEnumSerializerInclusive<
|
||||
mozilla::ScrollUpdateType, mozilla::ScrollUpdateType::Absolute,
|
||||
mozilla::ScrollUpdateType::MergeableAbsolute> {};
|
||||
mozilla::ScrollUpdateType::PureRelative> {};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::ScrollMode>
|
||||
|
@ -539,11 +539,8 @@ void ScrollAnchorContainer::ApplyAdjustments() {
|
||||
MOZ_RELEASE_ASSERT(!mApplyingAnchorAdjustment);
|
||||
// We should use AutoRestore here, but that doesn't work with bitfields
|
||||
mApplyingAnchorAdjustment = true;
|
||||
Frame()->ScrollToInternal(
|
||||
Frame()->GetScrollPosition() + physicalAdjustment, ScrollMode::Instant,
|
||||
StaticPrefs::layout_css_scroll_anchoring_absolute_update()
|
||||
? ScrollOrigin::AnchorAdjustment
|
||||
: ScrollOrigin::Relative);
|
||||
Frame()->ScrollToInternal(Frame()->GetScrollPosition() + physicalAdjustment,
|
||||
ScrollMode::Instant, ScrollOrigin::Relative);
|
||||
mApplyingAnchorAdjustment = false;
|
||||
|
||||
if (Frame()->mIsRoot) {
|
||||
|
@ -33,8 +33,6 @@ enum class ScrollOrigin : uint8_t {
|
||||
// The scroll came from an attempt by the main thread to re-clamp the scroll
|
||||
// position after a reflow.
|
||||
Clamp,
|
||||
// The scroll came from a scroll adjustment triggered by scroll anchoring.
|
||||
AnchorAdjustment,
|
||||
|
||||
// The following scroll origins also are associated with prefs of the form
|
||||
// general.smoothScroll.<origin>(.*)
|
||||
|
@ -93,20 +93,6 @@ ScrollPositionUpdate ScrollPositionUpdate::NewPureRelativeScroll(
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*static*/
|
||||
ScrollPositionUpdate ScrollPositionUpdate::NewMergeableScroll(
|
||||
ScrollOrigin aOrigin, nsPoint aDestination) {
|
||||
MOZ_ASSERT(aOrigin == ScrollOrigin::AnchorAdjustment);
|
||||
|
||||
ScrollPositionUpdate ret;
|
||||
ret.mScrollGeneration = sGenerationCounter.NewMainThreadGeneration();
|
||||
ret.mType = ScrollUpdateType::MergeableAbsolute;
|
||||
ret.mScrollMode = ScrollMode::Instant;
|
||||
ret.mScrollOrigin = aOrigin;
|
||||
ret.mDestination = CSSPoint::FromAppUnits(aDestination);
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool ScrollPositionUpdate::operator==(
|
||||
const ScrollPositionUpdate& aOther) const {
|
||||
// instances are immutable, and all the fields are set when the generation
|
||||
@ -126,7 +112,6 @@ ScrollOrigin ScrollPositionUpdate::GetOrigin() const { return mScrollOrigin; }
|
||||
|
||||
CSSPoint ScrollPositionUpdate::GetDestination() const {
|
||||
MOZ_ASSERT(mType == ScrollUpdateType::Absolute ||
|
||||
mType == ScrollUpdateType::MergeableAbsolute ||
|
||||
mType == ScrollUpdateType::Relative);
|
||||
return mDestination;
|
||||
}
|
||||
|
@ -34,9 +34,6 @@ enum class ScrollUpdateType {
|
||||
// The delta should be applied to whatever the current scroll position is
|
||||
// on the receiver side.
|
||||
PureRelative,
|
||||
// Similar to |Absolute|, but even if there's an active async scroll animation
|
||||
// the position update will NOT cancel the async scroll animation.
|
||||
MergeableAbsolute,
|
||||
};
|
||||
|
||||
enum class ScrollTriggeredByScript : bool { No, Yes };
|
||||
@ -86,9 +83,6 @@ class ScrollPositionUpdate {
|
||||
ScrollMode aMode,
|
||||
const nsPoint& aDelta);
|
||||
|
||||
static ScrollPositionUpdate NewMergeableScroll(ScrollOrigin aOrigin,
|
||||
nsPoint aDestination);
|
||||
|
||||
bool operator==(const ScrollPositionUpdate& aOther) const;
|
||||
|
||||
MainThreadScrollGeneration GetGeneration() const;
|
||||
|
@ -2245,12 +2245,7 @@ void nsHTMLScrollFrame::AsyncScroll::InitSmoothScroll(
|
||||
case ScrollOrigin::Apz:
|
||||
// Likewise we should never get APZ-triggered scrolls here, and if that
|
||||
// changes something is likely broken somewhere.
|
||||
MOZ_ASSERT_UNREACHABLE(
|
||||
"APZ scroll position updates should never be smooth");
|
||||
break;
|
||||
case ScrollOrigin::AnchorAdjustment:
|
||||
MOZ_ASSERT_UNREACHABLE(
|
||||
"scroll anchor adjustments should never be smooth");
|
||||
MOZ_ASSERT(false);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -3026,7 +3021,6 @@ void nsHTMLScrollFrame::ScrollToImpl(
|
||||
(mLastScrollOrigin != ScrollOrigin::None &&
|
||||
mLastScrollOrigin != ScrollOrigin::NotSpecified &&
|
||||
mLastScrollOrigin != ScrollOrigin::Relative &&
|
||||
mLastScrollOrigin != ScrollOrigin::AnchorAdjustment &&
|
||||
mLastScrollOrigin != ScrollOrigin::Apz)) {
|
||||
aOrigin = ScrollOrigin::Other;
|
||||
}
|
||||
@ -3170,9 +3164,6 @@ void nsHTMLScrollFrame::ScrollToImpl(
|
||||
AppendScrollUpdate(
|
||||
ScrollPositionUpdate::NewRelativeScroll(mApzScrollPos, pt));
|
||||
mApzScrollPos = pt;
|
||||
} else if (aOrigin == ScrollOrigin::AnchorAdjustment) {
|
||||
AppendScrollUpdate(ScrollPositionUpdate::NewMergeableScroll(aOrigin, pt));
|
||||
mApzScrollPos = pt;
|
||||
} else if (aOrigin != ScrollOrigin::Apz) {
|
||||
AppendScrollUpdate(ScrollPositionUpdate::NewScroll(mLastScrollOrigin, pt));
|
||||
}
|
||||
|
@ -9223,12 +9223,6 @@
|
||||
value: true
|
||||
mirror: always
|
||||
|
||||
# Handle scroll-anchoring adjustments as absolute scroll position updates.
|
||||
- name: layout.css.scroll-anchoring.absolute-update
|
||||
type: bool
|
||||
value: true
|
||||
mirror: always
|
||||
|
||||
# Are shared memory User Agent style sheets enabled?
|
||||
- name: layout.css.shared-memory-ua-sheets.enabled
|
||||
type: bool
|
||||
|
Loading…
Reference in New Issue
Block a user