Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 6f7c4e2

Browse files
committed
Backed out changeset 3bc82182725e (bug 1493081) for android bustages. CLOSED TREE
1 parent a1df8ac commit 6f7c4e2

5 files changed

Lines changed: 2 additions & 48 deletions

File tree

view/nsView.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ void nsView::DoResetWidgetBounds(bool aMoveOnly,
320320
// Stash a copy of these and use them so we can handle this being deleted (say
321321
// from sync painting/flushing from Show/Move/Resize on the widget).
322322
LayoutDeviceIntRect newBounds;
323+
RefPtr<nsDeviceContext> dx = mViewManager->GetDeviceContext();
323324

324325
nsWindowType type = widget->WindowType();
325326

@@ -359,8 +360,7 @@ void nsView::DoResetWidgetBounds(bool aMoveOnly,
359360
// because of the potential for device-pixel coordinate spaces for mixed
360361
// hidpi/lodpi screens to overlap each other and result in bad placement
361362
// (bug 814434).
362-
363-
DesktopToLayoutDeviceScale scale = widget->GetDesktopToDeviceScaleByScreen();
363+
DesktopToLayoutDeviceScale scale = dx->GetDesktopToDeviceScale();
364364

365365
DesktopRect deskRect = newBounds / scale;
366366
if (changedPos) {

widget/gtk/nsWindow.cpp

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757

5858
#if defined(MOZ_WAYLAND)
5959
#include <gdk/gdkwayland.h>
60-
#include "nsView.h"
6160
#endif
6261

6362
#include "nsGkAtoms.h"
@@ -842,37 +841,6 @@ nsWindow::GetDesktopToDeviceScale()
842841
return DesktopToLayoutDeviceScale(1.0);
843842
}
844843

845-
DesktopToLayoutDeviceScale
846-
nsWindow::GetDesktopToDeviceScaleByScreen()
847-
{
848-
#ifdef MOZ_WAYLAND
849-
GdkDisplay* gdkDisplay = gdk_display_get_default();
850-
// In Wayland there's no way to get absolute position of the window and use it to
851-
// determine the screen factor of the monitor on which the window is placed.
852-
// The window is notified of the current scale factor but not at this point,
853-
// so the GdkScaleFactor can return wrong value which can lead to wrong popup
854-
// placement.
855-
// We need to use parent's window scale factor for the new one.
856-
if (GDK_IS_WAYLAND_DISPLAY(gdkDisplay)) {
857-
nsView* view = nsView::GetViewFor(this);
858-
if (view) {
859-
nsView* parentView = view->GetParent();
860-
if (parentView) {
861-
nsIWidget* parentWidget = parentView->GetNearestWidget(nullptr);
862-
if (parentWidget) {
863-
return DesktopToLayoutDeviceScale(parentWidget->RoundsWidgetCoordinatesTo());
864-
} else {
865-
NS_WARNING("Widget has no parent");
866-
}
867-
}
868-
} else {
869-
NS_WARNING("Cannot find widget view");
870-
}
871-
}
872-
#endif
873-
return nsBaseWidget::GetDesktopToDeviceScale();
874-
}
875-
876844
void
877845
nsWindow::SetParent(nsIWidget *aNewParent)
878846
{

widget/gtk/nsWindow.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ class nsWindow final : public nsBaseWidget
125125
virtual float GetDPI() override;
126126
virtual double GetDefaultScaleInternal() override;
127127
mozilla::DesktopToLayoutDeviceScale GetDesktopToDeviceScale() override;
128-
mozilla::DesktopToLayoutDeviceScale GetDesktopToDeviceScaleByScreen() override;
129128
virtual void SetParent(nsIWidget* aNewParent) override;
130129
virtual void SetModal(bool aModal) override;
131130
virtual bool IsVisible() const override;

widget/nsBaseWidget.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
#include "nsIWidgetListener.h"
2525
#include "nsPIDOMWindow.h"
2626
#include "nsWeakReference.h"
27-
#include "nsView.h"
28-
#include "nsViewManager.h"
2927
#include <algorithm>
3028

3129
#if defined(XP_WIN)
@@ -240,10 +238,6 @@ class nsBaseWidget : public nsIWidget, public nsSupportsWeakReference
240238
mozilla::DesktopToLayoutDeviceScale GetDesktopToDeviceScale() override {
241239
return mozilla::DesktopToLayoutDeviceScale(1.0);
242240
}
243-
mozilla::DesktopToLayoutDeviceScale GetDesktopToDeviceScaleByScreen() override {
244-
return (nsView::GetViewFor(this)->GetViewManager()->GetDeviceContext())->GetDesktopToDeviceScale();
245-
}
246-
247241
virtual void ConstrainPosition(bool aAllowSlop,
248242
int32_t *aX,
249243
int32_t *aY) override {}

widget/nsIWidget.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -577,13 +577,6 @@ class nsIWidget : public nsISupports
577577
*/
578578
virtual mozilla::DesktopToLayoutDeviceScale GetDesktopToDeviceScale() = 0;
579579

580-
/**
581-
* Return the scaling factor between device pixels and the platform-
582-
* dependent "desktop pixels" by looking up the screen by the position
583-
* of the widget.
584-
*/
585-
virtual mozilla::DesktopToLayoutDeviceScale GetDesktopToDeviceScaleByScreen() = 0;
586-
587580
/**
588581
* Return the default scale factor for the window. This is the
589582
* default number of device pixels per CSS pixel to use. This should

0 commit comments

Comments
 (0)