mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 19:35:51 +00:00
Bug 1369627 - Part 2: Send DimensionInfo down to the content process synchronously when creating a new window, r=smaug
MozReview-Commit-ID: GlzJ491RLUE
This commit is contained in:
parent
f9f7306ed3
commit
b24cba603e
@ -855,6 +855,7 @@ ContentChild::ProvideWindowCommon(TabChild* aTabOpener,
|
||||
uint64_t layersId = 0;
|
||||
CompositorOptions compositorOptions;
|
||||
uint32_t maxTouchPoints = 0;
|
||||
DimensionInfo dimensionInfo;
|
||||
|
||||
if (aIframeMoz) {
|
||||
MOZ_ASSERT(aTabOpener);
|
||||
@ -893,7 +894,8 @@ ContentChild::ProvideWindowCommon(TabChild* aTabOpener,
|
||||
&textureFactoryIdentifier,
|
||||
&layersId,
|
||||
&compositorOptions,
|
||||
&maxTouchPoints)) {
|
||||
&maxTouchPoints,
|
||||
&dimensionInfo)) {
|
||||
PRenderFrameChild::Send__delete__(renderFrame);
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
@ -942,6 +944,8 @@ ContentChild::ProvideWindowCommon(TabChild* aTabOpener,
|
||||
newChild->DoFakeShow(textureFactoryIdentifier, layersId, compositorOptions,
|
||||
renderFrame, showInfo);
|
||||
|
||||
newChild->RecvUpdateDimensions(dimensionInfo);
|
||||
|
||||
for (size_t i = 0; i < frameScripts.Length(); i++) {
|
||||
FrameScriptInfo& info = frameScripts[i];
|
||||
if (!newChild->RecvLoadRemoteScript(info.url(), info.runInGlobalScope())) {
|
||||
|
@ -4637,7 +4637,8 @@ ContentParent::RecvCreateWindow(PBrowserParent* aThisTab,
|
||||
TextureFactoryIdentifier* aTextureFactoryIdentifier,
|
||||
uint64_t* aLayersId,
|
||||
CompositorOptions* aCompositorOptions,
|
||||
uint32_t* aMaxTouchPoints)
|
||||
uint32_t* aMaxTouchPoints,
|
||||
DimensionInfo* aDimensions)
|
||||
{
|
||||
// We always expect to open a new window here. If we don't, it's an error.
|
||||
*aWindowIsNew = true;
|
||||
@ -4694,6 +4695,9 @@ ContentParent::RecvCreateWindow(PBrowserParent* aThisTab,
|
||||
nsCOMPtr<nsIWidget> widget = newTab->GetWidget();
|
||||
*aMaxTouchPoints = widget ? widget->GetMaxTouchPoints() : 0;
|
||||
|
||||
// NOTE: widget must be set for this to return a meaningful value.
|
||||
*aDimensions = widget ? newTab->GetDimensionInfo() : DimensionInfo();
|
||||
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
|
@ -543,7 +543,8 @@ public:
|
||||
layers::TextureFactoryIdentifier* aTextureFactoryIdentifier,
|
||||
uint64_t* aLayersId,
|
||||
mozilla::layers::CompositorOptions* aCompositorOptions,
|
||||
uint32_t* aMaxTouchPoints) override;
|
||||
uint32_t* aMaxTouchPoints,
|
||||
DimensionInfo* aDimensions) override;
|
||||
|
||||
virtual mozilla::ipc::IPCResult RecvCreateWindowInDifferentProcess(
|
||||
PBrowserParent* aThisTab,
|
||||
|
@ -18,6 +18,10 @@ using LayoutDeviceIntRect from "Units.h";
|
||||
using DesktopIntRect from "Units.h";
|
||||
using DesktopToLayoutDeviceScale from "Units.h";
|
||||
using CSSToLayoutDeviceScale from "Units.h";
|
||||
using CSSRect from "Units.h";
|
||||
using CSSSize from "Units.h";
|
||||
using mozilla::LayoutDeviceIntPoint from "Units.h";
|
||||
using mozilla::dom::ScreenOrientationInternal from "mozilla/dom/ScreenOrientation.h";
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
@ -83,5 +87,14 @@ struct ScreenDetails {
|
||||
CSSToLayoutDeviceScale defaultCSSScaleFactor;
|
||||
};
|
||||
|
||||
struct DimensionInfo
|
||||
{
|
||||
CSSRect rect;
|
||||
CSSSize size;
|
||||
ScreenOrientationInternal orientation;
|
||||
LayoutDeviceIntPoint clientOffset;
|
||||
LayoutDeviceIntPoint chromeDisp;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
@ -35,8 +35,6 @@ include "mozilla/layers/LayersMessageUtils.h";
|
||||
using class IPC::Principal from "mozilla/dom/PermissionMessageUtils.h";
|
||||
using class mozilla::gfx::Matrix from "mozilla/gfx/Matrix.h";
|
||||
using struct gfxSize from "gfxPoint.h";
|
||||
using CSSRect from "Units.h";
|
||||
using CSSSize from "Units.h";
|
||||
using mozilla::LayoutDeviceIntPoint from "Units.h";
|
||||
using mozilla::LayoutDevicePoint from "Units.h";
|
||||
using mozilla::ScreenIntPoint from "Units.h";
|
||||
@ -66,7 +64,6 @@ using class mozilla::WidgetSelectionEvent from "ipc/nsGUIEventIPC.h";
|
||||
using class mozilla::WidgetTouchEvent from "ipc/nsGUIEventIPC.h";
|
||||
using class mozilla::WidgetPluginEvent from "ipc/nsGUIEventIPC.h";
|
||||
using struct mozilla::dom::RemoteDOMEvent from "mozilla/dom/TabMessageUtils.h";
|
||||
using mozilla::dom::ScreenOrientationInternal from "mozilla/dom/ScreenOrientation.h";
|
||||
using struct mozilla::layers::TextureFactoryIdentifier from "mozilla/layers/CompositorTypes.h";
|
||||
using mozilla::layers::CompositorOptions from "mozilla/layers/CompositorOptions.h";
|
||||
using mozilla::CSSToScreenScale from "Units.h";
|
||||
@ -639,10 +636,7 @@ child:
|
||||
|
||||
async LoadURL(nsCString uri, ShowInfo info);
|
||||
|
||||
async UpdateDimensions(CSSRect rect, CSSSize size,
|
||||
ScreenOrientationInternal orientation,
|
||||
LayoutDeviceIntPoint clientOffset,
|
||||
LayoutDeviceIntPoint chromeDisp) compressall;
|
||||
async UpdateDimensions(DimensionInfo dimensions) compressall;
|
||||
|
||||
async SizeModeChanged(nsSizeMode sizeMode);
|
||||
|
||||
|
@ -1002,7 +1002,8 @@ parent:
|
||||
TextureFactoryIdentifier textureFactoryIdentifier,
|
||||
uint64_t layersId,
|
||||
CompositorOptions compositorOptions,
|
||||
uint32_t maxTouchPoints);
|
||||
uint32_t maxTouchPoints,
|
||||
DimensionInfo dimensions);
|
||||
|
||||
async CreateWindowInDifferentProcess(
|
||||
PBrowser aThisTab,
|
||||
|
@ -1219,22 +1219,21 @@ TabChild::RecvInitRendering(const TextureFactoryIdentifier& aTextureFactoryIdent
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult
|
||||
TabChild::RecvUpdateDimensions(const CSSRect& rect, const CSSSize& size,
|
||||
const ScreenOrientationInternal& orientation,
|
||||
const LayoutDeviceIntPoint& clientOffset,
|
||||
const LayoutDeviceIntPoint& chromeDisp)
|
||||
TabChild::RecvUpdateDimensions(const DimensionInfo& aDimensionInfo)
|
||||
{
|
||||
if (!mRemoteFrame) {
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mUnscaledOuterRect = rect;
|
||||
mClientOffset = clientOffset;
|
||||
mChromeDisp = chromeDisp;
|
||||
mUnscaledOuterRect = aDimensionInfo.rect();
|
||||
mClientOffset = aDimensionInfo.clientOffset();
|
||||
mChromeDisp = aDimensionInfo.chromeDisp();
|
||||
|
||||
mOrientation = orientation;
|
||||
SetUnscaledInnerSize(size);
|
||||
if (!mHasValidInnerSize && size.width != 0 && size.height != 0) {
|
||||
mOrientation = aDimensionInfo.orientation();
|
||||
SetUnscaledInnerSize(aDimensionInfo.size());
|
||||
if (!mHasValidInnerSize &&
|
||||
aDimensionInfo.size().width != 0 &&
|
||||
aDimensionInfo.size().height != 0) {
|
||||
mHasValidInnerSize = true;
|
||||
}
|
||||
|
||||
@ -1248,8 +1247,8 @@ TabChild::RecvUpdateDimensions(const CSSRect& rect, const CSSSize& size,
|
||||
baseWin->SetPositionAndSize(0, 0, screenSize.width, screenSize.height,
|
||||
nsIBaseWindow::eRepaint);
|
||||
|
||||
mPuppetWidget->Resize(screenRect.x + clientOffset.x + chromeDisp.x,
|
||||
screenRect.y + clientOffset.y + chromeDisp.y,
|
||||
mPuppetWidget->Resize(screenRect.x + mClientOffset.x + mChromeDisp.x,
|
||||
screenRect.y + mClientOffset.y + mChromeDisp.y,
|
||||
screenSize.width, screenSize.height, true);
|
||||
|
||||
return IPC_OK();
|
||||
|
@ -350,11 +350,7 @@ public:
|
||||
PRenderFrameChild* aRenderFrame) override;
|
||||
|
||||
virtual mozilla::ipc::IPCResult
|
||||
RecvUpdateDimensions(const CSSRect& aRect,
|
||||
const CSSSize& aSize,
|
||||
const ScreenOrientationInternal& aOrientation,
|
||||
const LayoutDeviceIntPoint& aClientOffset,
|
||||
const LayoutDeviceIntPoint& aChromeDisp) override;
|
||||
RecvUpdateDimensions(const mozilla::dom::DimensionInfo& aDimensionInfo) override;
|
||||
virtual mozilla::ipc::IPCResult
|
||||
RecvSizeModeChanged(const nsSizeMode& aSizeMode) override;
|
||||
|
||||
|
@ -737,22 +737,31 @@ TabParent::UpdateDimensions(const nsIntRect& rect, const ScreenIntSize& size)
|
||||
mClientOffset = clientOffset;
|
||||
mChromeOffset = chromeOffset;
|
||||
|
||||
CSSToLayoutDeviceScale widgetScale = widget->GetDefaultScale();
|
||||
|
||||
LayoutDeviceIntRect devicePixelRect =
|
||||
ViewAs<LayoutDevicePixel>(mRect,
|
||||
PixelCastJustification::LayoutDeviceIsScreenForTabDims);
|
||||
LayoutDeviceIntSize devicePixelSize =
|
||||
ViewAs<LayoutDevicePixel>(mDimensions,
|
||||
PixelCastJustification::LayoutDeviceIsScreenForTabDims);
|
||||
|
||||
CSSRect unscaledRect = devicePixelRect / widgetScale;
|
||||
CSSSize unscaledSize = devicePixelSize / widgetScale;
|
||||
Unused << SendUpdateDimensions(unscaledRect, unscaledSize,
|
||||
orientation, clientOffset, chromeOffset);
|
||||
Unused << SendUpdateDimensions(GetDimensionInfo());
|
||||
}
|
||||
}
|
||||
|
||||
DimensionInfo
|
||||
TabParent::GetDimensionInfo()
|
||||
{
|
||||
nsCOMPtr<nsIWidget> widget = GetWidget();
|
||||
MOZ_ASSERT(widget);
|
||||
CSSToLayoutDeviceScale widgetScale = widget->GetDefaultScale();
|
||||
|
||||
LayoutDeviceIntRect devicePixelRect =
|
||||
ViewAs<LayoutDevicePixel>(mRect,
|
||||
PixelCastJustification::LayoutDeviceIsScreenForTabDims);
|
||||
LayoutDeviceIntSize devicePixelSize =
|
||||
ViewAs<LayoutDevicePixel>(mDimensions,
|
||||
PixelCastJustification::LayoutDeviceIsScreenForTabDims);
|
||||
|
||||
CSSRect unscaledRect = devicePixelRect / widgetScale;
|
||||
CSSSize unscaledSize = devicePixelSize / widgetScale;
|
||||
DimensionInfo di(unscaledRect, unscaledSize, mOrientation,
|
||||
mClientOffset, mChromeOffset);
|
||||
return di;
|
||||
}
|
||||
|
||||
void
|
||||
TabParent::SizeModeChanged(const nsSizeMode& aSizeMode)
|
||||
{
|
||||
|
@ -362,6 +362,8 @@ public:
|
||||
|
||||
void UpdateDimensions(const nsIntRect& aRect, const ScreenIntSize& aSize);
|
||||
|
||||
DimensionInfo GetDimensionInfo();
|
||||
|
||||
void SizeModeChanged(const nsSizeMode& aSizeMode);
|
||||
|
||||
void UIResolutionChanged();
|
||||
|
@ -382,6 +382,7 @@ public:
|
||||
}
|
||||
|
||||
WidgetEvent(const WidgetEvent& aOther)
|
||||
: WidgetEventTime()
|
||||
{
|
||||
MOZ_COUNT_CTOR(WidgetEvent);
|
||||
*this = aOther;
|
||||
|
Loading…
Reference in New Issue
Block a user