Bug 1509575 - Make nsIPresShell::mVisualViewportOffset a Maybe so we can tell if it's ever been set. r=kats
This allows us to e.g. avoid sending a value that's (0,0) because it hasn't been set yet in a visual scroll update. Depends on D16346 Differential Revision: https://phabricator.services.mozilla.com/D16477
This commit is contained in:
@@ -10102,9 +10102,9 @@ void nsIPresShell::SetVisualViewportSize(nscoord aWidth, nscoord aHeight) {
|
|||||||
bool nsIPresShell::SetVisualViewportOffset(
|
bool nsIPresShell::SetVisualViewportOffset(
|
||||||
const nsPoint& aScrollOffset, const nsPoint& aPrevLayoutScrollPos) {
|
const nsPoint& aScrollOffset, const nsPoint& aPrevLayoutScrollPos) {
|
||||||
bool didChange = false;
|
bool didChange = false;
|
||||||
if (mVisualViewportOffset != aScrollOffset) {
|
if (GetVisualViewportOffset() != aScrollOffset) {
|
||||||
nsPoint prevOffset = mVisualViewportOffset;
|
nsPoint prevOffset = GetVisualViewportOffset();
|
||||||
mVisualViewportOffset = aScrollOffset;
|
mVisualViewportOffset = Some(aScrollOffset);
|
||||||
didChange = true;
|
didChange = true;
|
||||||
|
|
||||||
if (auto* window = nsGlobalWindowInner::Cast(mDocument->GetInnerWindow())) {
|
if (auto* window = nsGlobalWindowInner::Cast(mDocument->GetInnerWindow())) {
|
||||||
|
|||||||
@@ -1658,7 +1658,12 @@ class nsIPresShell : public nsStubDocumentObserver {
|
|||||||
bool SetVisualViewportOffset(const nsPoint& aScrollOffset,
|
bool SetVisualViewportOffset(const nsPoint& aScrollOffset,
|
||||||
const nsPoint& aPrevLayoutScrollPos);
|
const nsPoint& aPrevLayoutScrollPos);
|
||||||
|
|
||||||
nsPoint GetVisualViewportOffset() const { return mVisualViewportOffset; }
|
nsPoint GetVisualViewportOffset() const {
|
||||||
|
return mVisualViewportOffset.valueOr(nsPoint());
|
||||||
|
}
|
||||||
|
bool IsVisualViewportOffsetSet() const {
|
||||||
|
return mVisualViewportOffset.isSome();
|
||||||
|
}
|
||||||
|
|
||||||
nsPoint GetVisualViewportOffsetRelativeToLayoutViewport() const;
|
nsPoint GetVisualViewportOffsetRelativeToLayoutViewport() const;
|
||||||
|
|
||||||
@@ -1769,7 +1774,7 @@ class nsIPresShell : public nsStubDocumentObserver {
|
|||||||
|
|
||||||
nsSize mVisualViewportSize;
|
nsSize mVisualViewportSize;
|
||||||
|
|
||||||
nsPoint mVisualViewportOffset;
|
mozilla::Maybe<nsPoint> mVisualViewportOffset;
|
||||||
|
|
||||||
// A pending visual scroll offset that we will ask APZ to scroll to
|
// A pending visual scroll offset that we will ask APZ to scroll to
|
||||||
// during the next transaction. Cleared when we send the transaction.
|
// during the next transaction. Cleared when we send the transaction.
|
||||||
|
|||||||
Reference in New Issue
Block a user