Skip to content

Commit

Permalink
Backed out changeset 3bc82182725e (bug 1493081) for android bustages.…
Browse files Browse the repository at this point in the history
… CLOSED TREE
  • Loading branch information
nbeleuzu committed Oct 9, 2018
1 parent a1df8ac commit 6f7c4e2
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 48 deletions.
4 changes: 2 additions & 2 deletions view/nsView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ void nsView::DoResetWidgetBounds(bool aMoveOnly,
// Stash a copy of these and use them so we can handle this being deleted (say
// from sync painting/flushing from Show/Move/Resize on the widget).
LayoutDeviceIntRect newBounds;
RefPtr<nsDeviceContext> dx = mViewManager->GetDeviceContext();

nsWindowType type = widget->WindowType();

Expand Down Expand Up @@ -359,8 +360,7 @@ void nsView::DoResetWidgetBounds(bool aMoveOnly,
// because of the potential for device-pixel coordinate spaces for mixed
// hidpi/lodpi screens to overlap each other and result in bad placement
// (bug 814434).

DesktopToLayoutDeviceScale scale = widget->GetDesktopToDeviceScaleByScreen();
DesktopToLayoutDeviceScale scale = dx->GetDesktopToDeviceScale();

DesktopRect deskRect = newBounds / scale;
if (changedPos) {
Expand Down
32 changes: 0 additions & 32 deletions widget/gtk/nsWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@

#if defined(MOZ_WAYLAND)
#include <gdk/gdkwayland.h>
#include "nsView.h"
#endif

#include "nsGkAtoms.h"
Expand Down Expand Up @@ -842,37 +841,6 @@ nsWindow::GetDesktopToDeviceScale()
return DesktopToLayoutDeviceScale(1.0);
}

DesktopToLayoutDeviceScale
nsWindow::GetDesktopToDeviceScaleByScreen()
{
#ifdef MOZ_WAYLAND
GdkDisplay* gdkDisplay = gdk_display_get_default();
// In Wayland there's no way to get absolute position of the window and use it to
// determine the screen factor of the monitor on which the window is placed.
// The window is notified of the current scale factor but not at this point,
// so the GdkScaleFactor can return wrong value which can lead to wrong popup
// placement.
// We need to use parent's window scale factor for the new one.
if (GDK_IS_WAYLAND_DISPLAY(gdkDisplay)) {
nsView* view = nsView::GetViewFor(this);
if (view) {
nsView* parentView = view->GetParent();
if (parentView) {
nsIWidget* parentWidget = parentView->GetNearestWidget(nullptr);
if (parentWidget) {
return DesktopToLayoutDeviceScale(parentWidget->RoundsWidgetCoordinatesTo());
} else {
NS_WARNING("Widget has no parent");
}
}
} else {
NS_WARNING("Cannot find widget view");
}
}
#endif
return nsBaseWidget::GetDesktopToDeviceScale();
}

void
nsWindow::SetParent(nsIWidget *aNewParent)
{
Expand Down
1 change: 0 additions & 1 deletion widget/gtk/nsWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ class nsWindow final : public nsBaseWidget
virtual float GetDPI() override;
virtual double GetDefaultScaleInternal() override;
mozilla::DesktopToLayoutDeviceScale GetDesktopToDeviceScale() override;
mozilla::DesktopToLayoutDeviceScale GetDesktopToDeviceScaleByScreen() override;
virtual void SetParent(nsIWidget* aNewParent) override;
virtual void SetModal(bool aModal) override;
virtual bool IsVisible() const override;
Expand Down
6 changes: 0 additions & 6 deletions widget/nsBaseWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
#include "nsIWidgetListener.h"
#include "nsPIDOMWindow.h"
#include "nsWeakReference.h"
#include "nsView.h"
#include "nsViewManager.h"
#include <algorithm>

#if defined(XP_WIN)
Expand Down Expand Up @@ -240,10 +238,6 @@ class nsBaseWidget : public nsIWidget, public nsSupportsWeakReference
mozilla::DesktopToLayoutDeviceScale GetDesktopToDeviceScale() override {
return mozilla::DesktopToLayoutDeviceScale(1.0);
}
mozilla::DesktopToLayoutDeviceScale GetDesktopToDeviceScaleByScreen() override {
return (nsView::GetViewFor(this)->GetViewManager()->GetDeviceContext())->GetDesktopToDeviceScale();
}

virtual void ConstrainPosition(bool aAllowSlop,
int32_t *aX,
int32_t *aY) override {}
Expand Down
7 changes: 0 additions & 7 deletions widget/nsIWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -577,13 +577,6 @@ class nsIWidget : public nsISupports
*/
virtual mozilla::DesktopToLayoutDeviceScale GetDesktopToDeviceScale() = 0;

/**
* Return the scaling factor between device pixels and the platform-
* dependent "desktop pixels" by looking up the screen by the position
* of the widget.
*/
virtual mozilla::DesktopToLayoutDeviceScale GetDesktopToDeviceScaleByScreen() = 0;

/**
* Return the default scale factor for the window. This is the
* default number of device pixels per CSS pixel to use. This should
Expand Down

0 comments on commit 6f7c4e2

Please sign in to comment.