Bug 1507279 - Expose the visual scrolling mechanism to internal JS users. r=kats
Differential Revision: https://phabricator.services.mozilla.com/D16142
This commit is contained in:
@@ -1396,6 +1396,23 @@ nsDOMWindowUtils::GetScrollXYFloat(bool aFlushLayout, float* aScrollX,
|
|||||||
return NS_OK;
|
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
|
NS_IMETHODIMP
|
||||||
nsDOMWindowUtils::GetVisualViewportOffsetRelativeToLayoutViewport(
|
nsDOMWindowUtils::GetVisualViewportOffsetRelativeToLayoutViewport(
|
||||||
float* aOffsetX, float* aOffsetY) {
|
float* aOffsetX, float* aOffsetY) {
|
||||||
|
|||||||
@@ -828,6 +828,19 @@ interface nsIDOMWindowUtils : nsISupports {
|
|||||||
*/
|
*/
|
||||||
DOMRect getBoundsWithoutFlushing(in Element aElement);
|
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
|
* Returns the offset of the window's visual viewport relative to the
|
||||||
* layout viewport.
|
* layout viewport.
|
||||||
|
|||||||
Reference in New Issue
Block a user