Bug 1498812 - Part 10: Return whether SetVisualViewportOffset was a no-op. r=botond

So that the caller doesn't have to retrieve and compare the previous viewport
offset himself.

Differential Revision: https://phabricator.services.mozilla.com/D15785

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jan Henning 2019-01-11 19:50:17 +00:00
Родитель 70dd21256f
Коммит 0ce3612dce
2 изменённых файлов: 8 добавлений и 2 удалений

Просмотреть файл

@ -10091,17 +10091,20 @@ void nsIPresShell::SetVisualViewportSize(nscoord aWidth, nscoord aHeight) {
} }
} }
void nsIPresShell::SetVisualViewportOffset( bool nsIPresShell::SetVisualViewportOffset(
const nsPoint& aScrollOffset, const nsPoint& aPrevLayoutScrollPos) { const nsPoint& aScrollOffset, const nsPoint& aPrevLayoutScrollPos) {
bool didChange = false;
if (mVisualViewportOffset != aScrollOffset) { if (mVisualViewportOffset != aScrollOffset) {
nsPoint prevOffset = mVisualViewportOffset; nsPoint prevOffset = mVisualViewportOffset;
mVisualViewportOffset = aScrollOffset; mVisualViewportOffset = aScrollOffset;
didChange = true;
if (auto* window = nsGlobalWindowInner::Cast(mDocument->GetInnerWindow())) { if (auto* window = nsGlobalWindowInner::Cast(mDocument->GetInnerWindow())) {
window->VisualViewport()->PostScrollEvent(prevOffset, window->VisualViewport()->PostScrollEvent(prevOffset,
aPrevLayoutScrollPos); aPrevLayoutScrollPos);
} }
} }
return didChange;
} }
nsPoint nsIPresShell::GetVisualViewportOffsetRelativeToLayoutViewport() const { nsPoint nsIPresShell::GetVisualViewportOffsetRelativeToLayoutViewport() const {

Просмотреть файл

@ -1650,7 +1650,10 @@ class nsIPresShell : public nsStubDocumentObserver {
return mVisualViewportSize; return mVisualViewportSize;
} }
void SetVisualViewportOffset(const nsPoint& aScrollOffset, /**
* The return value indicates whether the offset actually changed.
*/
bool SetVisualViewportOffset(const nsPoint& aScrollOffset,
const nsPoint& aPrevLayoutScrollPos); const nsPoint& aPrevLayoutScrollPos);
nsPoint GetVisualViewportOffset() const { return mVisualViewportOffset; } nsPoint GetVisualViewportOffset() const { return mVisualViewportOffset; }