From 116f9c9f98665e28ea50eb3012041e98bd1e8f00 Mon Sep 17 00:00:00 2001 From: Ryan Hunt Date: Wed, 19 Jun 2019 18:20:52 +0000 Subject: [PATCH] Bug 1559518 - Use LayoutDevicePixel for BrowserChild visible rect and composition size. r=kats App units of a remote browser element in the parent process are different from app units inside the remote content in the child process. We should apply the appropriate conversions by exposing the relevant data as LayoutDevicePixel. Differential Revision: https://phabricator.services.mozilla.com/D35334 --HG-- extra : moz-landing-system : lando --- dom/ipc/BrowserChild.cpp | 8 +++++--- dom/ipc/BrowserChild.h | 2 +- layout/base/nsLayoutUtils.cpp | 5 ++++- widget/PuppetWidget.cpp | 7 +++++++ widget/PuppetWidget.h | 2 ++ 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/dom/ipc/BrowserChild.cpp b/dom/ipc/BrowserChild.cpp index 4ccb040cac34..0480087ab328 100644 --- a/dom/ipc/BrowserChild.cpp +++ b/dom/ipc/BrowserChild.cpp @@ -3332,14 +3332,16 @@ ScreenIntSize BrowserChild::GetInnerSize() { innerSize, PixelCastJustification::LayoutDeviceIsScreenForTabDims); }; -nsRect BrowserChild::GetVisibleRect() { +LayoutDeviceIntRect BrowserChild::GetVisibleRect() { + CSSRect visibleRect; if (mIsTopLevel) { // We are conservative about visible rects for top-level browsers to avoid // artifacts when resizing - return nsRect(nsPoint(), CSSPixel::ToAppUnits(mUnscaledInnerSize)); + visibleRect = CSSRect(CSSPoint(), mUnscaledInnerSize); } else { - return mEffectsInfo.mVisibleRect; + visibleRect = CSSPixel::FromAppUnits(mEffectsInfo.mVisibleRect); } + return RoundedToInt(visibleRect * mPuppetWidget->GetDefaultScale()); } ScreenIntRect BrowserChild::GetOuterRect() { diff --git a/dom/ipc/BrowserChild.h b/dom/ipc/BrowserChild.h index 64a30d25a585..f55f45e87846 100644 --- a/dom/ipc/BrowserChild.h +++ b/dom/ipc/BrowserChild.h @@ -549,7 +549,7 @@ class BrowserChild final : public nsMessageManagerScriptExecutor, ScreenIntSize GetInnerSize(); - nsRect GetVisibleRect(); + LayoutDeviceIntRect GetVisibleRect(); // Call RecvShow(nsIntSize(0, 0)) and block future calls to RecvShow(). void DoFakeShow(const ShowInfo& aShowInfo); diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index 2fcec216032f..0c2a4d249f1d 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -3792,8 +3792,11 @@ nsresult nsLayoutUtils::PaintFrame(gfxContext* aRenderingContext, // If we are in a remote browser, then apply clipping from ancestor browsers if (BrowserChild* browserChild = BrowserChild::GetFrom(presShell)) { + LayoutDeviceIntRect unscaledVisibleRect = browserChild->GetVisibleRect(); + CSSRect visibleRect = + unscaledVisibleRect / presContext->CSSToDevPixelScale(); rootVisualOverflow.IntersectRect(rootVisualOverflow, - browserChild->GetVisibleRect()); + CSSPixel::ToAppUnits(visibleRect)); } nsIFrame* rootScrollFrame = presShell->GetRootScrollFrame(); diff --git a/widget/PuppetWidget.cpp b/widget/PuppetWidget.cpp index 5a7f448d31eb..6573c1406725 100644 --- a/widget/PuppetWidget.cpp +++ b/widget/PuppetWidget.cpp @@ -1158,6 +1158,13 @@ LayoutDeviceIntRect PuppetWidget::GetScreenBounds() { return LayoutDeviceIntRect(WidgetToScreenOffset(), mBounds.Size()); } +LayoutDeviceIntSize PuppetWidget::GetCompositionSize() { + if (!mBrowserChild) { + return nsBaseWidget::GetCompositionSize(); + } + return mBrowserChild->GetVisibleRect().Size(); +} + uint32_t PuppetWidget::GetMaxTouchPoints() const { uint32_t maxTouchPoints = 0; if (mBrowserChild) { diff --git a/widget/PuppetWidget.h b/widget/PuppetWidget.h index 85a3862783a7..a05a069703af 100644 --- a/widget/PuppetWidget.h +++ b/widget/PuppetWidget.h @@ -242,6 +242,8 @@ class PuppetWidget : public nsBaseWidget, virtual LayoutDeviceIntRect GetScreenBounds() override; + virtual LayoutDeviceIntSize GetCompositionSize() override; + virtual MOZ_MUST_USE nsresult StartPluginIME( const mozilla::WidgetKeyboardEvent& aKeyboardEvent, int32_t aPanelX, int32_t aPanelY, nsString& aCommitted) override;