Bug 1550800 - Make PuppetWidget::WidgetToScreenOffset work in out-of-process iframes. r=hsivonen,emilio

A mochitest for this change will be landed in bug 1614268 which needs
a work to make Element.focus() work in OOP iframes (bug 1556627).

Differential Revision: https://phabricator.services.mozilla.com/D62191

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Hiroyuki Ikezoe 2020-02-12 01:44:28 +00:00
parent 796e6049b6
commit 48f45a3d02
2 changed files with 13 additions and 3 deletions

View File

@ -1140,6 +1140,14 @@ LayoutDeviceIntPoint PuppetWidget::GetChromeOffset() {
return GetOwningBrowserChild()->GetChromeOffset();
}
LayoutDeviceIntPoint PuppetWidget::WidgetToScreenOffset() {
auto positionRalativeToWindow =
WidgetToTopLevelWidgetTransform().TransformPoint(LayoutDevicePoint());
return GetWindowPosition() +
LayoutDeviceIntPoint::Round(positionRalativeToWindow);
}
LayoutDeviceIntPoint PuppetWidget::GetWindowPosition() {
if (!GetOwningBrowserChild()) {
return LayoutDeviceIntPoint();

View File

@ -132,9 +132,7 @@ class PuppetWidget : public nsBaseWidget,
virtual mozilla::LayoutDeviceToLayoutDeviceMatrix4x4
WidgetToTopLevelWidgetTransform() override;
virtual LayoutDeviceIntPoint WidgetToScreenOffset() override {
return GetWindowPosition() + GetChromeOffset();
}
virtual LayoutDeviceIntPoint WidgetToScreenOffset() override;
virtual LayoutDeviceIntPoint TopLevelWidgetToScreenOffset() override {
return GetWindowPosition();
@ -235,6 +233,10 @@ class PuppetWidget : public nsBaseWidget,
nsIntSize GetScreenDimensions();
// Get the offset to the chrome of the window that this tab belongs to.
//
// NOTE: In OOP iframes this value is zero. You should use
// WidgetToTopLevelWidgetTransform instead which is already including the
// chrome offset.
LayoutDeviceIntPoint GetChromeOffset();
// Get the screen position of the application window.