Bug 1507279 - Expose the visual scrolling mechanism to internal JS users. r=kats

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Botond Ballo 2019-01-10 20:59:21 +00:00
Родитель 2d2fffe3ea
Коммит 6790cc7377
2 изменённых файлов: 30 добавлений и 0 удалений

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

@ -1396,6 +1396,23 @@ nsDOMWindowUtils::GetScrollXYFloat(bool aFlushLayout, float* aScrollX,
return NS_OK;
}
NS_IMETHODIMP
nsDOMWindowUtils::ScrollToVisual(float aOffsetX, float aOffsetY) {
nsCOMPtr<Document> doc = GetDocument();
NS_ENSURE_STATE(doc);
nsPresContext* presContext = doc->GetPresContext();
NS_ENSURE_TRUE(presContext, NS_ERROR_NOT_AVAILABLE);
// This should only be called on the root content document.
NS_ENSURE_TRUE(presContext->IsRootContentDocument(), NS_ERROR_INVALID_ARG);
presContext->PresShell()->SetPendingVisualViewportOffset(
Some(CSSPoint::ToAppUnits(CSSPoint(aOffsetX, aOffsetY))));
return NS_OK;
}
NS_IMETHODIMP
nsDOMWindowUtils::GetVisualViewportOffsetRelativeToLayoutViewport(
float* aOffsetX, float* aOffsetY) {

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

@ -828,6 +828,19 @@ interface nsIDOMWindowUtils : nsISupports {
*/
DOMRect getBoundsWithoutFlushing(in Element aElement);
/**
* Scroll the visual viewport to the given coordinates, relative to the
* document origin.
* Only applicable to the window associated with the root content document.
* Note: this does not take effect right away. Rather, the visual scroll
* request is sent to APZ with the next transaction, and will be
* reflected in the main thread with the subsequent APZ repaint request.
* Please see the caveats mentioned at nsIPresShell::
* SetPendingVisualViewportOffset(), and request APZ review if adding a new
* call to this.
*/
void scrollToVisual(in float aOffsetX, in float aOffsetY);
/**
* Returns the offset of the window's visual viewport relative to the
* layout viewport.