Bug 1476221 - Expose the offset of the visual viewport relative to the layout viewport to chrome JS code via nsIDOMWindowUtils. r=mstange

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Botond Ballo 2018-09-20 19:31:03 +00:00
parent c5f9b83562
commit 08d328e92e
2 changed files with 27 additions and 0 deletions

View File

@ -1624,6 +1624,26 @@ nsDOMWindowUtils::GetScrollXYFloat(bool aFlushLayout, float* aScrollX, float* aS
return NS_OK;
}
NS_IMETHODIMP
nsDOMWindowUtils::GetVisualViewportOffsetRelativeToLayoutViewport(float* aOffsetX, float* aOffsetY)
{
*aOffsetX = 0;
*aOffsetY = 0;
nsCOMPtr<nsIDocument> doc = GetDocument();
NS_ENSURE_STATE(doc);
nsIPresShell* presShell = doc->GetShell();
NS_ENSURE_TRUE(presShell, NS_ERROR_NOT_AVAILABLE);
nsPoint offset = presShell->GetVisualViewportOffsetRelativeToLayoutViewport();
*aOffsetX = nsPresContext::AppUnitsToFloatCSSPixels(offset.x);
*aOffsetY = nsPresContext::AppUnitsToFloatCSSPixels(offset.y);
return NS_OK;
}
NS_IMETHODIMP
nsDOMWindowUtils::GetScrollbarSize(bool aFlushLayout, int32_t* aWidth,
int32_t* aHeight)

View File

@ -844,6 +844,13 @@ interface nsIDOMWindowUtils : nsISupports {
*/
DOMRect getBoundsWithoutFlushing(in Element aElement);
/**
* Returns the offset of the window's visual viewport relative to the
* layout viewport.
*/
void getVisualViewportOffsetRelativeToLayoutViewport(out float aOffsetX,
out float aOffsetY);
const long FLUSH_NONE = -1;
const long FLUSH_STYLE = 0;
const long FLUSH_LAYOUT = 1;