Skip to content

Commit

Permalink
Bug 1875011 - Rename GetScrollPositionCSSPixels to GetRoundedScrollPo…
Browse files Browse the repository at this point in the history
…sitionCSSPixels. r=botond

Differential Revision: https://phabricator.services.mozilla.com/D198766
  • Loading branch information
hiikezoe committed Jan 17, 2024
1 parent 6e30d94 commit 0fcc489
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 17 deletions.
10 changes: 5 additions & 5 deletions dom/base/Element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ void Element::Scroll(double aXScroll, double aYScroll) {
void Element::Scroll(const ScrollToOptions& aOptions) {
nsIScrollableFrame* sf = GetScrollFrame();
if (sf) {
CSSIntPoint scrollPos = sf->GetScrollPositionCSSPixels();
CSSIntPoint scrollPos = sf->GetRoundedScrollPositionCSSPixels();
if (aOptions.mLeft.WasPassed()) {
scrollPos.x = static_cast<int32_t>(
mozilla::ToZeroIfNonfinite(aOptions.mLeft.Value()));
Expand Down Expand Up @@ -874,7 +874,7 @@ void Element::ScrollBy(const ScrollToOptions& aOptions) {

int32_t Element::ScrollTop() {
nsIScrollableFrame* sf = GetScrollFrame();
return sf ? sf->GetScrollPositionCSSPixels().y.value : 0;
return sf ? sf->GetRoundedScrollPositionCSSPixels().y.value : 0;
}

void Element::SetScrollTop(int32_t aScrollTop) {
Expand All @@ -892,14 +892,14 @@ void Element::SetScrollTop(int32_t aScrollTop) {
sf->IsSmoothScroll() ? ScrollMode::SmoothMsd : ScrollMode::Instant;

sf->ScrollToCSSPixels(
CSSIntPoint(sf->GetScrollPositionCSSPixels().x, aScrollTop),
CSSIntPoint(sf->GetRoundedScrollPositionCSSPixels().x, aScrollTop),
scrollMode);
}
}

int32_t Element::ScrollLeft() {
nsIScrollableFrame* sf = GetScrollFrame();
return sf ? sf->GetScrollPositionCSSPixels().x.value : 0;
return sf ? sf->GetRoundedScrollPositionCSSPixels().x.value : 0;
}

void Element::SetScrollLeft(int32_t aScrollLeft) {
Expand All @@ -912,7 +912,7 @@ void Element::SetScrollLeft(int32_t aScrollLeft) {
sf->IsSmoothScroll() ? ScrollMode::SmoothMsd : ScrollMode::Instant;

sf->ScrollToCSSPixels(
CSSIntPoint(aScrollLeft, sf->GetScrollPositionCSSPixels().y),
CSSIntPoint(aScrollLeft, sf->GetRoundedScrollPositionCSSPixels().y),
scrollMode);
}
}
Expand Down
2 changes: 1 addition & 1 deletion dom/base/nsGlobalWindowInner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3827,7 +3827,7 @@ void nsGlobalWindowInner::ScrollTo(const ScrollToOptions& aOptions) {
nsIScrollableFrame* sf = GetScrollFrame();

if (sf) {
CSSIntPoint scrollPos = sf->GetScrollPositionCSSPixels();
CSSIntPoint scrollPos = sf->GetRoundedScrollPositionCSSPixels();
if (aOptions.mLeft.WasPassed()) {
scrollPos.x = static_cast<int32_t>(
mozilla::ToZeroIfNonfinite(aOptions.mLeft.Value()));
Expand Down
6 changes: 3 additions & 3 deletions layout/generic/nsGfxScrollFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2384,7 +2384,7 @@ void nsHTMLScrollFrame::ScrollToInternal(

void nsHTMLScrollFrame::ScrollToCSSPixels(const CSSIntPoint& aScrollPosition,
ScrollMode aMode) {
CSSIntPoint currentCSSPixels = GetScrollPositionCSSPixels();
CSSIntPoint currentCSSPixels = GetRoundedScrollPositionCSSPixels();
// Transmogrify this scroll to a relative one if there's any on-going
// animation in APZ triggered by __user__.
// Bug 1740164: We will apply it for cases there's no animation in APZ.
Expand Down Expand Up @@ -2446,7 +2446,7 @@ void nsHTMLScrollFrame::ScrollToCSSPixelsForApz(
// 'this' might be destroyed here
}

CSSIntPoint nsHTMLScrollFrame::GetScrollPositionCSSPixels() {
CSSIntPoint nsHTMLScrollFrame::GetRoundedScrollPositionCSSPixels() {
return CSSIntPoint::FromAppUnitsRounded(GetScrollPosition());
}

Expand Down Expand Up @@ -5006,7 +5006,7 @@ void nsHTMLScrollFrame::ScrollByCSSPixelsInternal(const CSSIntPoint& aDelta,
// the previous scrolling operation, but there may be some edge cases where
// the current position in CSS pixels differs from the given position, the
// cases should be fixed in bug 1556685.
CSSIntPoint currentCSSPixels = GetScrollPositionCSSPixels();
CSSIntPoint currentCSSPixels = GetRoundedScrollPositionCSSPixels();
nsPoint pt = CSSPoint::ToAppUnits(currentCSSPixels + aDelta);

nscoord halfPixel = nsPresContext::CSSPixelsToAppUnits(0.5f);
Expand Down
3 changes: 2 additions & 1 deletion layout/generic/nsGfxScrollFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,8 @@ class nsHTMLScrollFrame : public nsContainerFrame,
/**
* @note This method might destroy the frame, pres shell and other objects.
*/
CSSIntPoint GetScrollPositionCSSPixels() final;
CSSIntPoint GetRoundedScrollPositionCSSPixels() final;

/**
* @note This method might destroy the frame, pres shell and other objects.
*/
Expand Down
14 changes: 7 additions & 7 deletions layout/generic/nsIScrollableFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,21 +262,21 @@ class nsIScrollableFrame : public nsIScrollbarMediator {
* aScrollPosition.x/y is different from the current CSS pixel position,
* makes sure we only move in the direction given by the difference.
*
* When aMode is SMOOTH, INSTANT, or NORMAL, GetScrollPositionCSSPixels (the
* scroll position after rounding to CSS pixels) will be exactly
* When aMode is SMOOTH, INSTANT, or NORMAL, GetRoundedScrollPositionCSSPixels
* (the scroll position after rounding to CSS pixels) will be exactly
* aScrollPosition at the end of the scroll animation.
*
* When aMode is SMOOTH_MSD, intermediate animation frames may be outside the
* range and / or moving in any direction; GetScrollPositionCSSPixels will be
* exactly aScrollPosition at the end of the scroll animation unless the
* SMOOTH_MSD animation is interrupted.
* range and / or moving in any direction; GetRoundedScrollPositionCSSPixels
* will be exactly aScrollPosition at the end of the scroll animation unless
* the SMOOTH_MSD animation is interrupted.
*/
virtual void ScrollToCSSPixels(const CSSIntPoint& aScrollPosition,
ScrollMode aMode = ScrollMode::Instant) = 0;
/**
* @note This method might destroy the frame, pres shell and other objects.
* Scrolls to a particular position in float CSS pixels.
* This does not guarantee that GetScrollPositionCSSPixels equals
* This does not guarantee that GetRoundedScrollPositionCSSPixels equals
* aScrollPosition afterward. It tries to scroll as close to
* aScrollPosition as possible while scrolling by an integer
* number of layer pixels (so the operation is fast and looks clean).
Expand All @@ -289,7 +289,7 @@ class nsIScrollableFrame : public nsIScrollbarMediator {
* Returns the scroll position in integer CSS pixels, rounded to the nearest
* pixel.
*/
virtual CSSIntPoint GetScrollPositionCSSPixels() = 0;
virtual CSSIntPoint GetRoundedScrollPositionCSSPixels() = 0;
/**
* @note This method might destroy the frame, pres shell and other objects.
* Modifies the current scroll position by aDelta units given by aUnit,
Expand Down

0 comments on commit 0fcc489

Please sign in to comment.