mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 06:11:37 +00:00
Bug 1477610 - Flush layout when reporting the visual viewport size via the Visual Viewport API. r=hiro
Differential Revision: https://phabricator.services.mozilla.com/D29089 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
936ebd1f3a
commit
9ec620930d
@ -13,6 +13,7 @@
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsPresContext.h"
|
||||
#include "nsRefreshDriver.h"
|
||||
#include "DocumentInlines.h"
|
||||
|
||||
#define VVP_LOG(...)
|
||||
// #define VVP_LOG(...) printf_stderr("VVP: " __VA_ARGS__)
|
||||
@ -60,6 +61,14 @@ void VisualViewport::GetEventTargetParent(EventChainPreVisitor& aVisitor) {
|
||||
CSSSize VisualViewport::VisualViewportSize() const {
|
||||
CSSSize size = CSSSize(0, 0);
|
||||
|
||||
// Flush layout, as that may affect the answer below (e.g. scrollbars
|
||||
// may have appeared, decreasing the available viewport size).
|
||||
RefPtr<const VisualViewport> kungFuDeathGrip(this);
|
||||
if (Document* doc = GetDocument()) {
|
||||
doc->FlushPendingNotifications(FlushType::Layout);
|
||||
}
|
||||
|
||||
// Fetch the pres shell after the layout flush, as it might have destroyed it.
|
||||
if (PresShell* presShell = GetPresShell()) {
|
||||
if (presShell->IsVisualViewportSizeSet()) {
|
||||
size = CSSRect::FromAppUnits(presShell->GetVisualViewportSize());
|
||||
@ -121,7 +130,7 @@ double VisualViewport::OffsetTop() const {
|
||||
return PageTop() - LayoutViewportOffset().Y();
|
||||
}
|
||||
|
||||
PresShell* VisualViewport::GetPresShell() const {
|
||||
Document* VisualViewport::GetDocument() const {
|
||||
nsCOMPtr<nsPIDOMWindowInner> window = GetOwner();
|
||||
if (!window) {
|
||||
return nullptr;
|
||||
@ -132,16 +141,17 @@ PresShell* VisualViewport::GetPresShell() const {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return docShell->GetPresShell();
|
||||
return docShell->GetDocument();
|
||||
}
|
||||
|
||||
PresShell* VisualViewport::GetPresShell() const {
|
||||
RefPtr<Document> document = GetDocument();
|
||||
return document ? document->GetPresShell() : nullptr;
|
||||
}
|
||||
|
||||
nsPresContext* VisualViewport::GetPresContext() const {
|
||||
PresShell* presShell = GetPresShell();
|
||||
if (!presShell) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return presShell->GetPresContext();
|
||||
RefPtr<Document> document = GetDocument();
|
||||
return document ? document->GetPresContext() : nullptr;
|
||||
}
|
||||
|
||||
/* ================= Resize event handling ================= */
|
||||
|
@ -28,8 +28,8 @@ class VisualViewport final : public mozilla::DOMEventTargetHelper {
|
||||
double OffsetTop() const;
|
||||
double PageLeft() const;
|
||||
double PageTop() const;
|
||||
double Width() const;
|
||||
double Height() const;
|
||||
MOZ_CAN_RUN_SCRIPT double Width() const;
|
||||
MOZ_CAN_RUN_SCRIPT double Height() const;
|
||||
double Scale() const;
|
||||
IMPL_EVENT_HANDLER(resize)
|
||||
IMPL_EVENT_HANDLER(scroll)
|
||||
@ -88,9 +88,10 @@ class VisualViewport final : public mozilla::DOMEventTargetHelper {
|
||||
private:
|
||||
virtual ~VisualViewport();
|
||||
|
||||
CSSSize VisualViewportSize() const;
|
||||
MOZ_CAN_RUN_SCRIPT CSSSize VisualViewportSize() const;
|
||||
CSSPoint VisualViewportOffset() const;
|
||||
CSSPoint LayoutViewportOffset() const;
|
||||
Document* GetDocument() const;
|
||||
PresShell* GetPresShell() const;
|
||||
nsPresContext* GetPresContext() const;
|
||||
|
||||
|
@ -1,10 +0,0 @@
|
||||
[viewport-read-size-causes-layout.html]
|
||||
[Untitled]
|
||||
expected: FAIL
|
||||
|
||||
[viewport-read-size-causes-layout]
|
||||
expected:
|
||||
if (os == "android") and not e10s: PASS
|
||||
if (os == "android") and e10s: PASS
|
||||
FAIL
|
||||
|
@ -1,10 +0,0 @@
|
||||
[viewport-read-size-in-iframe-causes-layout.html]
|
||||
[Untitled]
|
||||
expected: FAIL
|
||||
|
||||
[viewport-read-size-in-iframe-causes-layout]
|
||||
expected:
|
||||
if (os == "android") and not e10s: PASS
|
||||
if (os == "android") and e10s: PASS
|
||||
FAIL
|
||||
|
@ -1,15 +0,0 @@
|
||||
[viewport-scrollbars-cause-resize.html]
|
||||
[Viewport: Scrollbars Cause Resize]
|
||||
expected:
|
||||
if (os == "android") and not e10s: PASS
|
||||
FAIL
|
||||
|
||||
[view size reflects appearance of classic scrollbars]
|
||||
expected:
|
||||
if (os == "android") and not e10s: PASS
|
||||
if (os == "android") and e10s: PASS
|
||||
FAIL
|
||||
|
||||
[Resize event was fired at window.visualViewport if, and only if, scrollbars are classic (i.e. affect flow)]
|
||||
disabled: Bug 1515043
|
||||
|
@ -1,7 +0,0 @@
|
||||
[viewport-unscaled-size.html]
|
||||
[visualViewport.width should exclude scrollbar.]
|
||||
expected:
|
||||
if (os == "android") and not e10s: PASS
|
||||
if (os == "android") and e10s: PASS
|
||||
FAIL
|
||||
|
Loading…
Reference in New Issue
Block a user