Backed out changeset cf44885dc2ac (bug 1431337) for failing mochitest browser chrome at browser/base/content/test/performance/browser_startup_images.js on a CLOSED TREE
authorAndreea Pavel <apavel@mozilla.com>
Thu, 15 Feb 2018 16:03:40 +0200
changeset 404023 3ffcad22d632d1cd97285b3a54cb469227bd1df1
parent 404022 58d315ce1f1b2a855174a4e309afa1f3f6578569
child 404024 c25eaa199ff8899cd4eec799bf1624b07705c372
push id99924
push userebalazs@mozilla.com
push dateThu, 15 Feb 2018 20:43:51 +0000
treeherdermozilla-inbound@a7d2a49f46fb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1431337
milestone60.0a1
backs outcf44885dc2aca866ed9345b28337d146b02e1371
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset cf44885dc2ac (bug 1431337) for failing mochitest browser chrome at browser/base/content/test/performance/browser_startup_images.js on a CLOSED TREE
widget/gtk/WindowSurfaceWayland.cpp
widget/gtk/WindowSurfaceWayland.h
widget/gtk/nsLookAndFeel.cpp
widget/gtk/nsNativeThemeGTK.cpp
widget/gtk/nsNativeThemeGTK.h
widget/gtk/nsWindow.cpp
--- a/widget/gtk/WindowSurfaceWayland.cpp
+++ b/widget/gtk/WindowSurfaceWayland.cpp
@@ -588,41 +588,28 @@ WindowSurfaceWayland::~WindowSurfaceWayl
       NewRunnableFunction("WaylandDisplayRelease",
                           &WaylandDisplayRelease,
                           mWaylandDisplay->GetDisplay()));
   } else {
     WaylandDisplayRelease(mWaylandDisplay->GetDisplay());
   }
 }
 
-void
-WindowSurfaceWayland::UpdateScaleFactor()
-{
-  wl_surface* waylandSurface = mWindow->GetWaylandSurface();
-  if (waylandSurface) {
-    wl_surface_set_buffer_scale(waylandSurface, mWindow->GdkScaleFactor());
-  }
-}
-
 WindowBackBuffer*
 WindowSurfaceWayland::GetBufferToDraw(int aWidth, int aHeight)
 {
   if (!mFrontBuffer) {
     mFrontBuffer = new WindowBackBuffer(mWaylandDisplay, aWidth, aHeight);
     mBackBuffer = new WindowBackBuffer(mWaylandDisplay, aWidth, aHeight);
-    UpdateScaleFactor();
     return mFrontBuffer;
   }
 
   if (!mFrontBuffer->IsAttached()) {
     if (!mFrontBuffer->IsMatchingSize(aWidth, aHeight)) {
       mFrontBuffer->Resize(aWidth, aHeight);
-      // There's a chance that scale factor has been changed
-      // when buffer size changed
-      UpdateScaleFactor();
     }
     return mFrontBuffer;
   }
 
   // Front buffer is used by compositor, draw to back buffer
   if (mBackBuffer->IsAttached()) {
     NS_WARNING("No drawing buffer available");
     return nullptr;
@@ -643,17 +630,16 @@ WindowSurfaceWayland::GetBufferToDraw(in
     // When buffer switches we need to damage whole screen
     // (https://bugzilla.redhat.com/show_bug.cgi?id=1418260)
     mFullScreenDamage = true;
   } else {
     // Former buffer has different size from the new request. Only resize
     // the new buffer and leave gecko to render new whole content.
     mFrontBuffer->Resize(aWidth, aHeight);
   }
-  UpdateScaleFactor();
 
   return mFrontBuffer;
 }
 
 already_AddRefed<gfx::DrawTarget>
 WindowSurfaceWayland::Lock(const LayoutDeviceIntRegion& aRegion)
 {
   MOZ_ASSERT(mIsMainThread == NS_IsMainThread());
@@ -710,16 +696,20 @@ WindowSurfaceWayland::Commit(const Layou
       // Delete frame callback connected to obsoleted wl_surface.
       wl_callback_destroy(mFrameCallback);
     }
 
     mFrameCallback = wl_surface_frame(waylandSurface);
     wl_callback_add_listener(mFrameCallback, &frame_listener, this);
     mFrameCallbackSurface = waylandSurface;
 
+    // Let the wayland know of the current scaling factor for the hdpi
+    // displays
+    wl_surface_set_buffer_scale(waylandSurface, mWindow->GdkScaleFactor());
+
     // There's no pending frame callback so we can draw immediately
     // and create frame callback for possible subsequent drawing.
     mFrontBuffer->Attach(waylandSurface);
     mDelayedCommit = false;
   }
 }
 
 void
--- a/widget/gtk/WindowSurfaceWayland.h
+++ b/widget/gtk/WindowSurfaceWayland.h
@@ -108,17 +108,16 @@ public:
   ~WindowSurfaceWayland();
 
   already_AddRefed<gfx::DrawTarget> Lock(const LayoutDeviceIntRegion& aRegion) override;
   void                      Commit(const LayoutDeviceIntRegion& aInvalidRegion) final override;
   void                      FrameCallbackHandler();
 
 private:
   WindowBackBuffer*         GetBufferToDraw(int aWidth, int aHeight);
-  void                      UpdateScaleFactor();
 
   // TODO: Do we need to hold a reference to nsWindow object?
   nsWindow*                 mWindow;
   nsWaylandDisplay*         mWaylandDisplay;
   WindowBackBuffer*         mFrontBuffer;
   WindowBackBuffer*         mBackBuffer;
   wl_callback*              mFrameCallback;
   wl_surface*               mFrameCallbackSurface;
--- a/widget/gtk/nsLookAndFeel.cpp
+++ b/widget/gtk/nsLookAndFeel.cpp
@@ -732,47 +732,51 @@ GetSystemFontInfo(GtkStyleContext *aStyl
     float size = float(pango_font_description_get_size(desc)) / PANGO_SCALE;
 
     // |size| is now either pixels or pango-points (not Mozilla-points!)
 
     if (!pango_font_description_get_size_is_absolute(desc)) {
         // |size| is in pango-points, so convert to pixels.
         size *= float(gfxPlatformGtk::GetFontScaleDPI()) / POINTS_PER_INCH_FLOAT;
     }
-    // |size| is now pixels but not scaled for the hidpi displays,
-    // this needs to be done in GetFontImpl where the aDevPixPerCSSPixel
-    // parameter is provided.
+
+    // Scale fonts up on HiDPI displays.
+    // This would be done automatically with cairo, but we manually manage
+    // the display scale for platform consistency.
+    size *= mozilla::widget::ScreenHelperGTK::GetGTKMonitorScaleFactor();
+
+    // |size| is now pixels
 
     aFontStyle->size = size;
 
     pango_font_description_free(desc);
 }
 
 bool
 nsLookAndFeel::GetFontImpl(FontID aID, nsString& aFontName,
                            gfxFontStyle& aFontStyle,
                            float aDevPixPerCSSPixel)
 {
   switch (aID) {
     case eFont_Menu:         // css2
     case eFont_PullDownMenu: // css3
       aFontName = mMenuFontName;
       aFontStyle = mMenuFontStyle;
-      break;
+      return true;
 
     case eFont_Field:        // css3
     case eFont_List:         // css3
       aFontName = mFieldFontName;
       aFontStyle = mFieldFontStyle;
-      break;
+      return true;
 
     case eFont_Button:       // css3
       aFontName = mButtonFontName;
       aFontStyle = mButtonFontStyle;
-      break;
+      return true;
 
     case eFont_Caption:      // css2
     case eFont_Icon:         // css2
     case eFont_MessageBox:   // css2
     case eFont_SmallCaption: // css2
     case eFont_StatusBar:    // css2
     case eFont_Window:       // css3
     case eFont_Document:     // css3
@@ -780,28 +784,18 @@ nsLookAndFeel::GetFontImpl(FontID aID, n
     case eFont_Desktop:      // css3
     case eFont_Info:         // css3
     case eFont_Dialog:       // css3
     case eFont_Tooltips:     // moz
     case eFont_Widget:       // moz
     default:
       aFontName = mDefaultFontName;
       aFontStyle = mDefaultFontStyle;
-      break;
+      return true;
   }
-  // Scale the font for the current monitor
-  double scaleFactor = nsIWidget::DefaultScaleOverride();
-  if (scaleFactor > 0) {
-    aFontStyle.size *= aDevPixPerCSSPixel;
-  } else {
-    // Remove effect of font scale because it has been already applied in
-    // GetSystemFontInfo
-    aFontStyle.size *= aDevPixPerCSSPixel / gfxPlatformGtk::GetFontScaleFactor();
-  }
-  return true;
 }
 
 void
 nsLookAndFeel::EnsureInit()
 {
     GdkColor colorValue;
     GdkColor *colorValuePtr;
 
--- a/widget/gtk/nsNativeThemeGTK.cpp
+++ b/widget/gtk/nsNativeThemeGTK.cpp
@@ -32,17 +32,16 @@
 #include <gtk/gtkx.h>
 
 #include "gfxContext.h"
 #include "gfxPlatformGtk.h"
 #include "gfxGdkNativeRenderer.h"
 #include "mozilla/gfx/BorrowedContext.h"
 #include "mozilla/gfx/HelpersCairo.h"
 #include "mozilla/gfx/PathHelpers.h"
-#include "mozilla/Preferences.h"
 
 #ifdef MOZ_X11
 #  ifdef CAIRO_HAS_XLIB_SURFACE
 #    include "cairo-xlib.h"
 #  endif
 #  ifdef CAIRO_HAS_XLIB_XRENDER_SURFACE
 #    include "cairo-xlib-xrender.h"
 #  endif
@@ -55,39 +54,16 @@ using namespace mozilla;
 using namespace mozilla::gfx;
 using namespace mozilla::widget;
 
 NS_IMPL_ISUPPORTS_INHERITED(nsNativeThemeGTK, nsNativeTheme, nsITheme,
                                                              nsIObserver)
 
 static int gLastGdkError;
 
-// Return scale factor of the monitor where the window is located
-// by the most part or layout.css.devPixelsPerPx pref if set to > 0.
-static inline gint
-GetMonitorScaleFactor(nsIFrame* aFrame)
-{
-  // When the layout.css.devPixelsPerPx is set the scale can be < 1,
-  // the real monitor scale cannot go under 1.
-  double scale = nsIWidget::DefaultScaleOverride();
-  if (scale <= 0) {
-    nsIWidget* rootWidget = aFrame->PresContext()->GetRootWidget();
-    if (rootWidget) {
-        // We need to use GetDefaultScale() despite it returns monitor scale
-        // factor multiplied by font scale factor because it is the only scale
-        // updated in nsPuppetWidget.
-        // Since we don't want to apply font scale factor for UI elements
-        // (because GTK does not do so) we need to remove that from returned value.
-        return rootWidget->GetDefaultScale().scale / gfxPlatformGtk::GetFontScaleFactor();
-    }
-  }
-  // We cannot return zero scale because that would lead to divide by zero
-  return (scale < 1) ? 1 : int(round(scale));
-}
-
 nsNativeThemeGTK::nsNativeThemeGTK()
 {
   if (moz_gtk_init() != MOZ_GTK_SUCCESS) {
     memset(mDisabledWidgetTypes, 0xff, sizeof(mDisabledWidgetTypes));
     return;
   }
 
   // We have to call moz_gtk_shutdown before the event loop stops running.
@@ -1064,17 +1040,17 @@ nsNativeThemeGTK::GetExtraSizeForWidget(
       } else {
         aExtra->bottom = extra;
       }
       return false;
     }
   default:
     return false;
   }
-  gint scale = GetMonitorScaleFactor(aFrame);
+  gint scale = ScreenHelperGTK::GetGTKMonitorScaleFactor();
   aExtra->top *= scale;
   aExtra->right *= scale;
   aExtra->bottom *= scale;
   aExtra->left *= scale;
   return true;
 }
 
 NS_IMETHODIMP
@@ -1092,17 +1068,17 @@ nsNativeThemeGTK::DrawWidgetBackground(g
                             &flags))
     return NS_OK;
 
   gfxContext* ctx = aContext;
   nsPresContext *presContext = aFrame->PresContext();
 
   gfxRect rect = presContext->AppUnitsToGfxUnits(aRect);
   gfxRect dirtyRect = presContext->AppUnitsToGfxUnits(aDirtyRect);
-  gint scaleFactor = GetMonitorScaleFactor(aFrame);
+  gint scaleFactor = ScreenHelperGTK::GetGTKMonitorScaleFactor();
 
   // Align to device pixels where sensible
   // to provide crisper and faster drawing.
   // Don't snap if it's a non-unit scale factor. We're going to have to take
   // slow paths then in any case.
   bool snapped = ctx->UserToDevicePixelSnapped(rect);
   if (snapped) {
     // Leave rect in device coords but make dirtyRect consistent.
@@ -1338,17 +1314,17 @@ nsNativeThemeGTK::GetWidgetBorder(nsDevi
       break;
     MOZ_FALLTHROUGH;
   default:
     {
       GetCachedWidgetBorder(aFrame, aWidgetType, direction, aResult);
     }
   }
 
-  gint scale = GetMonitorScaleFactor(aFrame);
+  gint scale = ScreenHelperGTK::GetGTKMonitorScaleFactor();
   aResult->top *= scale;
   aResult->right *= scale;
   aResult->bottom *= scale;
   aResult->left *= scale;
   return NS_OK;
 }
 
 bool
@@ -1396,17 +1372,17 @@ nsNativeThemeGTK::GetWidgetPadding(nsDev
         if (aWidgetType == NS_THEME_MENUITEM)
           moz_gtk_menuitem_get_horizontal_padding(&horizontal_padding);
         else
           moz_gtk_checkmenuitem_get_horizontal_padding(&horizontal_padding);
 
         aResult->left += horizontal_padding;
         aResult->right += horizontal_padding;
 
-        gint scale = GetMonitorScaleFactor(aFrame);
+        gint scale = ScreenHelperGTK::GetGTKMonitorScaleFactor();
         aResult->top *= scale;
         aResult->right *= scale;
         aResult->bottom *= scale;
         aResult->left *= scale;
 
         return true;
       }
   }
@@ -1645,17 +1621,18 @@ nsNativeThemeGTK::GetMinimumWidgetSize(n
         moz_gtk_get_arrow_size(MOZ_GTK_DROPDOWN,
                                &aResult->width, &aResult->height);
       }
       // else the minimum size is missing consideration of container
       // descendants; the value returned here will not be helpful, but the
       // box model may consider border and padding with child minimum sizes.
 
       nsIntMargin border;
-      GetCachedWidgetBorder(aFrame, aWidgetType, GetTextDirection(aFrame), &border);
+      nsNativeThemeGTK::GetWidgetBorder(aFrame->PresContext()->DeviceContext(),
+                                        aFrame, aWidgetType, &border);
       aResult->width += border.left + border.right;
       aResult->height += border.top + border.bottom;
     }
     break;
 #ifdef MOZ_WIDGET_GTK
   case NS_THEME_NUMBER_INPUT:
   case NS_THEME_TEXTFIELD:
     {
@@ -1697,17 +1674,17 @@ nsNativeThemeGTK::GetMinimumWidgetSize(n
 
       moz_gtk_get_treeview_expander_size(&expander_size);
       aResult->width = aResult->height = expander_size;
       *aIsOverridable = false;
     }
     break;
   }
 
-  *aResult = *aResult * GetMonitorScaleFactor(aFrame);
+  *aResult = *aResult * ScreenHelperGTK::GetGTKMonitorScaleFactor();
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsNativeThemeGTK::WidgetStateChanged(nsIFrame* aFrame, uint8_t aWidgetType,
                                      nsAtom* aAttribute, bool* aShouldRepaint,
                                      const nsAttrValue* aOldValue)
--- a/widget/gtk/nsNativeThemeGTK.h
+++ b/widget/gtk/nsNativeThemeGTK.h
@@ -71,16 +71,17 @@ public:
   NS_IMETHOD_(bool) WidgetIsContainer(uint8_t aWidgetType) override;
 
   NS_IMETHOD_(bool) ThemeDrawsFocusForWidget(uint8_t aWidgetType) override;
 
   virtual bool ThemeNeedsComboboxDropmarker() override;
 
   virtual Transparency GetWidgetTransparency(nsIFrame* aFrame,
                                              uint8_t aWidgetType) override;
+
   nsNativeThemeGTK();
 
 protected:
   virtual ~nsNativeThemeGTK();
 
 private:
   GtkTextDirection GetTextDirection(nsIFrame* aFrame);
   gint GetTabMarginPixels(nsIFrame* aFrame);
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -5926,17 +5926,16 @@ widget_composited_changed_cb (GtkWidget*
 
 static void
 scale_changed_cb (GtkWidget* widget, GParamSpec* aPSpec, gpointer aPointer)
 {
     RefPtr<nsWindow> window = get_window_for_gtk_widget(widget);
     if (!window) {
       return;
     }
-    // This eventually propagate new scale to the PuppetWidgets
     window->OnDPIChanged();
 
     // configure_event is already fired before scale-factor signal,
     // but size-allocate isn't fired by changing scale
     GtkAllocation allocation;
     gtk_widget_get_allocation(widget, &allocation);
     window->OnSizeAllocate(&allocation);
 }