зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1498812 - Part 1: Add helper method for directly retrieving the visual viewport's position. r=botond
Mainly required for testing. Differential Revision: https://phabricator.services.mozilla.com/D15683 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
d59bf80ea2
Коммит
2f5820064c
|
@ -1431,6 +1431,25 @@ nsDOMWindowUtils::GetVisualViewportOffsetRelativeToLayoutViewport(
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMWindowUtils::GetVisualViewportOffset(int32_t* aOffsetX,
|
||||
int32_t* aOffsetY) {
|
||||
*aOffsetX = 0;
|
||||
*aOffsetY = 0;
|
||||
|
||||
nsCOMPtr<Document> doc = GetDocument();
|
||||
NS_ENSURE_STATE(doc);
|
||||
|
||||
nsIPresShell* presShell = doc->GetShell();
|
||||
NS_ENSURE_TRUE(presShell, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
nsPoint offset = presShell->GetVisualViewportOffset();
|
||||
*aOffsetX = nsPresContext::AppUnitsToIntCSSPixels(offset.x);
|
||||
*aOffsetY = nsPresContext::AppUnitsToIntCSSPixels(offset.y);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMWindowUtils::GetScrollbarSize(bool aFlushLayout, int32_t* aWidth,
|
||||
int32_t* aHeight) {
|
||||
|
|
|
@ -848,6 +848,11 @@ interface nsIDOMWindowUtils : nsISupports {
|
|||
void getVisualViewportOffsetRelativeToLayoutViewport(out float aOffsetX,
|
||||
out float aOffsetY);
|
||||
|
||||
/**
|
||||
* Returns the scroll position of the window's visual viewport.
|
||||
*/
|
||||
void getVisualViewportOffset(out long aOffsetX, out long aOffsetY);
|
||||
|
||||
const long FLUSH_NONE = -1;
|
||||
const long FLUSH_STYLE = 0;
|
||||
const long FLUSH_LAYOUT = 1;
|
||||
|
|
Загрузка…
Ссылка в новой задаче