mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 968991 - Only initialize the root metrics after getting both before-first-paint and the mInnerSize dimensions. r=botond
This commit is contained in:
parent
ded53c42ba
commit
af2350f8ba
@ -316,6 +316,32 @@ TabChild::HandleEvent(nsIDOMEvent* aEvent)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
TabChild::InitializeRootMetrics()
|
||||
{
|
||||
// Calculate a really simple resolution that we probably won't
|
||||
// be keeping, as well as putting the scroll offset back to
|
||||
// the top-left of the page.
|
||||
mLastRootMetrics.mViewport = CSSRect(CSSPoint(), kDefaultViewportSize);
|
||||
mLastRootMetrics.mCompositionBounds = ScreenIntRect(ScreenIntPoint(), mInnerSize);
|
||||
mLastRootMetrics.mZoom = mLastRootMetrics.CalculateIntrinsicScale();
|
||||
mLastRootMetrics.mDevPixelsPerCSSPixel = mWidget->GetDefaultScale();
|
||||
// We use ScreenToLayerScale(1) below in order to turn the
|
||||
// async zoom amount into the gecko zoom amount.
|
||||
mLastRootMetrics.mCumulativeResolution =
|
||||
mLastRootMetrics.mZoom / mLastRootMetrics.mDevPixelsPerCSSPixel * ScreenToLayerScale(1);
|
||||
// This is the root layer, so the cumulative resolution is the same
|
||||
// as the resolution.
|
||||
mLastRootMetrics.mResolution = mLastRootMetrics.mCumulativeResolution / LayoutDeviceToParentLayerScale(1);
|
||||
mLastRootMetrics.mScrollOffset = CSSPoint(0, 0);
|
||||
}
|
||||
|
||||
bool
|
||||
TabChild::HasValidInnerSize()
|
||||
{
|
||||
return (mInnerSize.width != 0) && (mInnerSize.height != 0);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TabChild::Observe(nsISupports *aSubject,
|
||||
const char *aTopic,
|
||||
@ -352,29 +378,19 @@ TabChild::Observe(nsISupports *aSubject,
|
||||
// page.
|
||||
SetCSSViewport(kDefaultViewportSize);
|
||||
|
||||
// Calculate a really simple resolution that we probably won't
|
||||
// be keeping, as well as putting the scroll offset back to
|
||||
// the top-left of the page.
|
||||
mLastRootMetrics.mViewport = CSSRect(CSSPoint(), kDefaultViewportSize);
|
||||
mLastRootMetrics.mCompositionBounds = ScreenIntRect(ScreenIntPoint(), mInnerSize);
|
||||
mLastRootMetrics.mZoom = mLastRootMetrics.CalculateIntrinsicScale();
|
||||
mLastRootMetrics.mDevPixelsPerCSSPixel = mWidget->GetDefaultScale();
|
||||
// We use ScreenToLayerScale(1) below in order to turn the
|
||||
// async zoom amount into the gecko zoom amount.
|
||||
mLastRootMetrics.mCumulativeResolution =
|
||||
mLastRootMetrics.mZoom / mLastRootMetrics.mDevPixelsPerCSSPixel * ScreenToLayerScale(1);
|
||||
// This is the root layer, so the cumulative resolution is the same
|
||||
// as the resolution.
|
||||
mLastRootMetrics.mResolution = mLastRootMetrics.mCumulativeResolution / LayoutDeviceToParentLayerScale(1);
|
||||
mLastRootMetrics.mScrollOffset = CSSPoint(0, 0);
|
||||
|
||||
// In some cases before-first-paint gets called before
|
||||
// RecvUpdateDimensions is called and therefore before we have an
|
||||
// mInnerSize value set. In such cases defer initializing the viewport
|
||||
// until we we get an inner size.
|
||||
if (HasValidInnerSize()) {
|
||||
InitializeRootMetrics();
|
||||
utils->SetResolution(mLastRootMetrics.mResolution.scale,
|
||||
mLastRootMetrics.mResolution.scale);
|
||||
|
||||
HandlePossibleViewportChange();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -1458,6 +1474,9 @@ TabChild::RecvUpdateDimensions(const nsRect& rect, const nsIntSize& size, const
|
||||
mOuterRect.width = rect.width;
|
||||
mOuterRect.height = rect.height;
|
||||
|
||||
bool initialSizing = !HasValidInnerSize()
|
||||
&& (size.width != 0 && size.height != 0);
|
||||
|
||||
mOrientation = orientation;
|
||||
mInnerSize = ScreenIntSize::FromUnknownSize(
|
||||
gfx::IntSize(size.width, size.height));
|
||||
@ -1468,6 +1487,14 @@ TabChild::RecvUpdateDimensions(const nsRect& rect, const nsIntSize& size, const
|
||||
baseWin->SetPositionAndSize(0, 0, size.width, size.height,
|
||||
true);
|
||||
|
||||
if (initialSizing && mContentDocumentIsDisplayed) {
|
||||
// If this is the first time we're getting a valid mInnerSize, and the
|
||||
// before-first-paint event has already been handled, then we need to set
|
||||
// up our default viewport here. See the corresponding call to
|
||||
// InitializeRootMetrics in the before-first-paint handler.
|
||||
InitializeRootMetrics();
|
||||
}
|
||||
|
||||
HandlePossibleViewportChange();
|
||||
|
||||
return true;
|
||||
|
@ -411,6 +411,9 @@ private:
|
||||
|
||||
nsresult Init();
|
||||
|
||||
void InitializeRootMetrics();
|
||||
bool HasValidInnerSize();
|
||||
|
||||
// Notify others that our TabContext has been updated. (At the moment, this
|
||||
// sets the appropriate app-id and is-browser flags on our docshell.)
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user