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
This commit is contained in:
Ryan Hunt 2019-06-19 18:20:52 +00:00
parent 3e07310481
commit 116f9c9f98
5 changed files with 19 additions and 5 deletions

View File

@ -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() {

View File

@ -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);

View File

@ -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();

View File

@ -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) {

View File

@ -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;