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:
Jan Henning 2019-01-11 19:49:39 +00:00
Родитель d59bf80ea2
Коммит 2f5820064c
2 изменённых файлов: 24 добавлений и 0 удалений

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

@ -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;