Bug 1185747 part 3 - Rip out code to explicitly override the CSS viewport. r=tn
This commit is contained in:
@@ -299,25 +299,6 @@ nsDOMWindowUtils::UpdateLayerTree()
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsDOMWindowUtils::SetCSSViewport(float aWidthPx, float aHeightPx)
|
|
||||||
{
|
|
||||||
MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome());
|
|
||||||
|
|
||||||
if (!(aWidthPx >= 0.0 && aHeightPx >= 0.0)) {
|
|
||||||
return NS_ERROR_ILLEGAL_VALUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsIPresShell* presShell = GetPresShell();
|
|
||||||
if (!presShell) {
|
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsLayoutUtils::SetCSSViewport(presShell, CSSSize(aWidthPx, aHeightPx));
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsDOMWindowUtils::GetViewportInfo(uint32_t aDisplayWidth,
|
nsDOMWindowUtils::GetViewportInfo(uint32_t aDisplayWidth,
|
||||||
uint32_t aDisplayHeight,
|
uint32_t aDisplayHeight,
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ interface nsIJSRAIIHelper;
|
|||||||
interface nsIContentPermissionRequest;
|
interface nsIContentPermissionRequest;
|
||||||
interface nsIObserver;
|
interface nsIObserver;
|
||||||
|
|
||||||
[scriptable, uuid(6ddc9a79-18cd-4dbc-9975-68928e6c9857)]
|
[scriptable, uuid(a30a95ac-3b95-4251-88dc-8efa89ba9f9c)]
|
||||||
interface nsIDOMWindowUtils : nsISupports {
|
interface nsIDOMWindowUtils : nsISupports {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -106,15 +106,6 @@ interface nsIDOMWindowUtils : nsISupports {
|
|||||||
*/
|
*/
|
||||||
void updateLayerTree();
|
void updateLayerTree();
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the CSS viewport to be |widthPx| x |heightPx| in units of CSS
|
|
||||||
* pixels, regardless of the size of the enclosing widget/view.
|
|
||||||
* This will trigger reflow.
|
|
||||||
*
|
|
||||||
* The caller of this method must have chrome privileges.
|
|
||||||
*/
|
|
||||||
void setCSSViewport(in float aWidthPx, in float aHeightPx);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Information retrieved from the <meta name="viewport"> tag.
|
* Information retrieved from the <meta name="viewport"> tag.
|
||||||
* See nsContentUtils::GetViewportInfo for more information.
|
* See nsContentUtils::GetViewportInfo for more information.
|
||||||
|
|||||||
@@ -139,10 +139,10 @@ typedef struct CapturingContentInfo {
|
|||||||
mozilla::StaticRefPtr<nsIContent> mContent;
|
mozilla::StaticRefPtr<nsIContent> mContent;
|
||||||
} CapturingContentInfo;
|
} CapturingContentInfo;
|
||||||
|
|
||||||
// 4f512d0b-c58c-4fc9-ae42-8aa6d992e7ae
|
// b07c5323-3061-4ca9-95ed-84cccbffadac
|
||||||
#define NS_IPRESSHELL_IID \
|
#define NS_IPRESSHELL_IID \
|
||||||
{ 0x4f512d0b, 0xc58c, 0x4fc9, \
|
{ 0xb07c5323, 0x3061, 0x4ca9, \
|
||||||
{ 0xae, 0x42, 0x8a, 0xa6, 0xd9, 0x92, 0xe7, 0xae } }
|
{ 0x95, 0xed, 0x84, 0xcc, 0xcb, 0xff, 0xad, 0xac } }
|
||||||
|
|
||||||
// debug VerifyReflow flags
|
// debug VerifyReflow flags
|
||||||
#define VERIFY_REFLOW_ON 0x01
|
#define VERIFY_REFLOW_ON 0x01
|
||||||
@@ -404,12 +404,6 @@ public:
|
|||||||
* coordinates for aWidth and aHeight must be in standard nscoord's.
|
* coordinates for aWidth and aHeight must be in standard nscoord's.
|
||||||
*/
|
*/
|
||||||
virtual nsresult ResizeReflow(nscoord aWidth, nscoord aHeight) = 0;
|
virtual nsresult ResizeReflow(nscoord aWidth, nscoord aHeight) = 0;
|
||||||
/**
|
|
||||||
* Reflow, and also change presshell state so as to only permit
|
|
||||||
* reflowing off calls to ResizeReflowOverride() in the future.
|
|
||||||
* ResizeReflow() calls are ignored after ResizeReflowOverride().
|
|
||||||
*/
|
|
||||||
virtual nsresult ResizeReflowOverride(nscoord aWidth, nscoord aHeight) = 0;
|
|
||||||
/**
|
/**
|
||||||
* Do the same thing as ResizeReflow but even if ResizeReflowOverride was
|
* Do the same thing as ResizeReflow but even if ResizeReflowOverride was
|
||||||
* called previously.
|
* called previously.
|
||||||
|
|||||||
@@ -8267,17 +8267,6 @@ nsLayoutUtils::SetScrollPositionClampingScrollPortSize(nsIPresShell* aPresShell,
|
|||||||
MaybeReflowForInflationScreenSizeChange(presContext);
|
MaybeReflowForInflationScreenSizeChange(presContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ void
|
|
||||||
nsLayoutUtils::SetCSSViewport(nsIPresShell* aPresShell, CSSSize aSize)
|
|
||||||
{
|
|
||||||
MOZ_ASSERT(aSize.width >= 0.0 && aSize.height >= 0.0);
|
|
||||||
|
|
||||||
nscoord width = nsPresContext::CSSPixelsToAppUnits(aSize.width);
|
|
||||||
nscoord height = nsPresContext::CSSPixelsToAppUnits(aSize.height);
|
|
||||||
|
|
||||||
aPresShell->ResizeReflowOverride(width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* static */ FrameMetrics
|
/* static */ FrameMetrics
|
||||||
nsLayoutUtils::ComputeFrameMetrics(nsIFrame* aForFrame,
|
nsLayoutUtils::ComputeFrameMetrics(nsIFrame* aForFrame,
|
||||||
nsIFrame* aScrollFrame,
|
nsIFrame* aScrollFrame,
|
||||||
|
|||||||
@@ -2680,12 +2680,6 @@ public:
|
|||||||
static void SetScrollPositionClampingScrollPortSize(nsIPresShell* aPresShell,
|
static void SetScrollPositionClampingScrollPortSize(nsIPresShell* aPresShell,
|
||||||
CSSSize aSize);
|
CSSSize aSize);
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the CSS viewport to the given size
|
|
||||||
* (see nsIDOMWindowUtils.setCSSViewport).
|
|
||||||
*/
|
|
||||||
static void SetCSSViewport(nsIPresShell* aPresShell, CSSSize aSize);
|
|
||||||
|
|
||||||
static FrameMetrics ComputeFrameMetrics(nsIFrame* aForFrame,
|
static FrameMetrics ComputeFrameMetrics(nsIFrame* aForFrame,
|
||||||
nsIFrame* aScrollFrame,
|
nsIFrame* aScrollFrame,
|
||||||
nsIContent* aContent,
|
nsIContent* aContent,
|
||||||
|
|||||||
@@ -784,7 +784,6 @@ PresShell::PresShell()
|
|||||||
#endif
|
#endif
|
||||||
mRenderFlags = 0;
|
mRenderFlags = 0;
|
||||||
mResolution = 1.0;
|
mResolution = 1.0;
|
||||||
mViewportOverridden = false;
|
|
||||||
|
|
||||||
mScrollPositionClampingScrollPortSizeSet = false;
|
mScrollPositionClampingScrollPortSizeSet = false;
|
||||||
|
|
||||||
@@ -1766,35 +1765,9 @@ PresShell::AsyncResizeEventCallback(nsITimer* aTimer, void* aPresShell)
|
|||||||
static_cast<PresShell*>(aPresShell)->FireResizeEvent();
|
static_cast<PresShell*>(aPresShell)->FireResizeEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
|
||||||
PresShell::ResizeReflowOverride(nscoord aWidth, nscoord aHeight)
|
|
||||||
{
|
|
||||||
mViewportOverridden = true;
|
|
||||||
|
|
||||||
if (mMobileViewportManager) {
|
|
||||||
// Once the viewport is explicitly overridden, we don't need the
|
|
||||||
// MobileViewportManager any more (in this presShell at least). Destroying
|
|
||||||
// it simplifies things because then it can maintain an invariant that any
|
|
||||||
// time it gets a meta-viewport change (for example) it knows it must
|
|
||||||
// recompute the CSS viewport and do a reflow. If we didn't destroy it here
|
|
||||||
// then there would be times where a meta-viewport change would have no
|
|
||||||
// effect.
|
|
||||||
mMobileViewportManager->Destroy();
|
|
||||||
mMobileViewportManager = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ResizeReflowIgnoreOverride(aWidth, aHeight);
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
PresShell::ResizeReflow(nscoord aWidth, nscoord aHeight)
|
PresShell::ResizeReflow(nscoord aWidth, nscoord aHeight)
|
||||||
{
|
{
|
||||||
if (mViewportOverridden) {
|
|
||||||
// The viewport has been overridden, and this reflow request
|
|
||||||
// didn't ask to ignore the override. Pretend it didn't happen.
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mZoomConstraintsClient) {
|
if (mZoomConstraintsClient) {
|
||||||
// If we have a ZoomConstraintsClient and the available screen area
|
// If we have a ZoomConstraintsClient and the available screen area
|
||||||
// changed, then we might need to disable double-tap-to-zoom, so notify
|
// changed, then we might need to disable double-tap-to-zoom, so notify
|
||||||
|
|||||||
@@ -105,7 +105,6 @@ public:
|
|||||||
virtual void EndObservingDocument() override;
|
virtual void EndObservingDocument() override;
|
||||||
virtual nsresult Initialize(nscoord aWidth, nscoord aHeight) override;
|
virtual nsresult Initialize(nscoord aWidth, nscoord aHeight) override;
|
||||||
virtual nsresult ResizeReflow(nscoord aWidth, nscoord aHeight) override;
|
virtual nsresult ResizeReflow(nscoord aWidth, nscoord aHeight) override;
|
||||||
virtual nsresult ResizeReflowOverride(nscoord aWidth, nscoord aHeight) override;
|
|
||||||
virtual nsresult ResizeReflowIgnoreOverride(nscoord aWidth, nscoord aHeight) override;
|
virtual nsresult ResizeReflowIgnoreOverride(nscoord aWidth, nscoord aHeight) override;
|
||||||
virtual nsIPageSequenceFrame* GetPageSequenceFrame() const override;
|
virtual nsIPageSequenceFrame* GetPageSequenceFrame() const override;
|
||||||
virtual nsCanvasFrame* GetCanvasFrame() const override;
|
virtual nsCanvasFrame* GetCanvasFrame() const override;
|
||||||
@@ -359,7 +358,7 @@ public:
|
|||||||
virtual nsresult SetIsActive(bool aIsActive) override;
|
virtual nsresult SetIsActive(bool aIsActive) override;
|
||||||
|
|
||||||
virtual bool GetIsViewportOverridden() override {
|
virtual bool GetIsViewportOverridden() override {
|
||||||
return mViewportOverridden || (mMobileViewportManager != nullptr);
|
return (mMobileViewportManager != nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool IsLayoutFlushObserver() override
|
virtual bool IsLayoutFlushObserver() override
|
||||||
@@ -861,7 +860,6 @@ protected:
|
|||||||
bool mDocumentLoading : 1;
|
bool mDocumentLoading : 1;
|
||||||
bool mIgnoreFrameDestruction : 1;
|
bool mIgnoreFrameDestruction : 1;
|
||||||
bool mHaveShutDown : 1;
|
bool mHaveShutDown : 1;
|
||||||
bool mViewportOverridden : 1;
|
|
||||||
bool mLastRootReflowHadUnconstrainedBSize : 1;
|
bool mLastRootReflowHadUnconstrainedBSize : 1;
|
||||||
bool mNoDelayedMouseEvents : 1;
|
bool mNoDelayedMouseEvents : 1;
|
||||||
bool mNoDelayedKeyEvents : 1;
|
bool mNoDelayedKeyEvents : 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user