Bug 1478776 - Part 9: Helper function for layout viewport scroll position in PresShell. r=botond

This changes the semantics of the relative visual viewport offset calculation in
the PresShell slightly, in that a missing root scroll frame will no longer
force the relative offset to zero, even if the visual viewport itself has a non-
zero scroll position [1].
On the other hand, the visual viewport's own relative offset calculations
already work that way today, in that layout and visual viewport scroll positions
are retrieved separately and then subtracted from one another regardless of
whether those values are actually valid or merely a fallback because the
PresShell/scroll frame weren't available.

[1] Though I'm not sure under what circumstances this could really be relevant.

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jan Henning 2018-12-20 21:35:55 +00:00
Родитель c3352661fc
Коммит fb0460d033
3 изменённых файлов: 9 добавлений и 7 удалений

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

@ -87,12 +87,8 @@ CSSPoint VisualViewport::VisualViewportOffset() const {
CSSPoint VisualViewport::LayoutViewportOffset() const {
CSSPoint offset = CSSPoint(0, 0);
nsIPresShell* presShell = GetPresShell();
if (presShell) {
nsIScrollableFrame* sf = presShell->GetRootScrollFrameAsScrollable();
if (sf) {
offset = CSSPoint::FromAppUnits(sf->GetScrollPosition());
}
if (nsIPresShell* presShell = GetPresShell()) {
offset = CSSPoint::FromAppUnits(presShell->GetLayoutViewportOffset());
}
return offset;
}

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

@ -10054,9 +10054,13 @@ void nsIPresShell::SetVisualViewportOffset(const nsPoint& aScrollOffset,
}
nsPoint nsIPresShell::GetVisualViewportOffsetRelativeToLayoutViewport() const {
return GetVisualViewportOffset() - GetLayoutViewportOffset();
}
nsPoint nsIPresShell::GetLayoutViewportOffset() const {
nsPoint result;
if (nsIScrollableFrame* sf = GetRootScrollFrameAsScrollable()) {
result = GetVisualViewportOffset() - sf->GetScrollPosition();
result = sf->GetScrollPosition();
}
return result;
}

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

@ -1654,6 +1654,8 @@ class nsIPresShell : public nsStubDocumentObserver {
nsPoint GetVisualViewportOffsetRelativeToLayoutViewport() const;
nsPoint GetLayoutViewportOffset() const;
virtual void WindowSizeMoveDone() = 0;
virtual void SysColorChanged() = 0;
virtual void ThemeChanged() = 0;