mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
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:
parent
c3352661fc
commit
fb0460d033
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user