mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-01 22:07:41 +00:00
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:
parent
c5f9b83562
commit
08d328e92e
@ -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)
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user