Added patch for mozilla#1144745 - HiDPI Gtk3 fixes

This commit is contained in:
Martin Stransky 2015-05-13 10:33:21 +02:00
parent ebc526234b
commit 92ebef22ab
5 changed files with 376 additions and 13 deletions

View File

@ -1,12 +0,0 @@
diff -up firefox-32.0.1/mozilla-release/modules/libpref/src/init/all.js.old firefox-32.0.1/mozilla-release/modules/libpref/src/init/all.js
--- firefox-32.0.1/mozilla-release/modules/libpref/init/all.js.old 2014-09-12 00:25:45.000000000 +0200
+++ firefox-32.0.1/mozilla-release/modules/libpref/init/all.js 2014-09-16 14:27:52.447743192 +0200
@@ -844,7 +844,7 @@ pref("javascript.options.strict",
#ifdef DEBUG
pref("javascript.options.strict.debug", true);
#endif
-pref("javascript.options.baselinejit", true);
+pref("javascript.options.baselinejit", false);
pref("javascript.options.ion", true);
pref("javascript.options.asmjs", true);
pref("javascript.options.native_regexp", true);

View File

@ -107,7 +107,7 @@
Summary: Mozilla Firefox Web browser Summary: Mozilla Firefox Web browser
Name: firefox Name: firefox
Version: 38.0 Version: 38.0
Release: 4%{?pre_tag}%{?dist} Release: 5%{?pre_tag}%{?dist}
URL: http://www.mozilla.org/projects/firefox/ URL: http://www.mozilla.org/projects/firefox/
License: MPLv1.1 or GPLv2+ or LGPLv2+ License: MPLv1.1 or GPLv2+ or LGPLv2+
Group: Applications/Internet Group: Applications/Internet
@ -155,6 +155,9 @@ Patch412: mozilla-1073117-no-gap-tab.patch
Patch414: mozilla-1143686.patch Patch414: mozilla-1143686.patch
Patch415: mozilla-1144643.patch Patch415: mozilla-1144643.patch
Patch416: mozilla-1161056.patch Patch416: mozilla-1161056.patch
Patch417: mozilla-1144745-1.patch
Patch418: mozilla-1144745-2.patch
Patch419: mozilla-1144745-3.patch
# Fix Skia Neon stuff on AArch64 # Fix Skia Neon stuff on AArch64
Patch500: aarch64-fix-skia.patch Patch500: aarch64-fix-skia.patch
@ -311,6 +314,9 @@ cd %{tarballdir}
%patch414 -p1 -b .1143686 %patch414 -p1 -b .1143686
%patch415 -p1 -b .1144643 %patch415 -p1 -b .1144643
%patch416 -p1 -b .1161056 %patch416 -p1 -b .1161056
%patch417 -p1 -b .1144745-1
%patch418 -p1 -b .1144745-2
%patch419 -p1 -b .1144745-3
%endif %endif
%patch500 -p1 %patch500 -p1
@ -808,6 +814,9 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
#--------------------------------------------------------------------- #---------------------------------------------------------------------
%changelog %changelog
* Wed May 13 2015 Martin Stransky <stransky@redhat.com> - 38.0-5
- Added patch for mozilla#1144745 - HiDPI Gtk3 fixes
* Mon May 11 2015 Martin Stransky <stransky@redhat.com> - 38.0-4 * Mon May 11 2015 Martin Stransky <stransky@redhat.com> - 38.0-4
- Update to 38.0 Build 3 - Update to 38.0 Build 3
- Added fix for rhbz#1219542 - Added fix for rhbz#1219542

150
mozilla-1144745-1.patch Normal file
View File

@ -0,0 +1,150 @@
diff -up mozilla-release/widget/gtk/nsNativeThemeGTK.cpp.1144745-1 mozilla-release/widget/gtk/nsNativeThemeGTK.cpp
--- mozilla-release/widget/gtk/nsNativeThemeGTK.cpp.1144745-1 2015-05-13 10:25:28.638492635 +0200
+++ mozilla-release/widget/gtk/nsNativeThemeGTK.cpp 2015-05-13 10:28:41.438095846 +0200
@@ -32,6 +32,7 @@
#include "gfxPlatformGtk.h"
#include "gfxGdkNativeRenderer.h"
#include <algorithm>
+#include <dlfcn.h>
using namespace mozilla;
using namespace mozilla::gfx;
@@ -88,6 +89,24 @@ nsNativeThemeGTK::RefreshWidgetWindow(ns
vm->InvalidateAllViews();
}
+gint
+nsNativeThemeGTK::GdkScaleFactor()
+{
+#if (MOZ_WIDGET_GTK >= 3)
+ // Since GDK 3.10
+ static auto sGdkScreenGetMonitorScaleFactorPtr = (gint (*)(GdkScreen*, gint))
+ dlsym(RTLD_DEFAULT, "gdk_screen_get_monitor_scale_factor");
+ if (sGdkScreenGetMonitorScaleFactorPtr) {
+ // FIXME: In the future, we'll want to fix this for GTK on Wayland which
+ // supports a variable scale factor per display.
+ GdkScreen *screen = gdk_screen_get_default();
+ return sGdkScreenGetMonitorScaleFactorPtr(screen, 0);
+ }
+#endif
+ return 1;
+}
+
+
static bool IsFrameContentNodeInNamespace(nsIFrame *aFrame, uint32_t aNamespace)
{
nsIContent *content = aFrame ? aFrame->GetContent() : nullptr;
@@ -711,10 +730,10 @@ nsNativeThemeGTK::GetExtraSizeForWidget(
switch (aWidgetType) {
case NS_THEME_SCROLLBAR_THUMB_VERTICAL:
aExtra->top = aExtra->bottom = 1;
- return true;
+ break;
case NS_THEME_SCROLLBAR_THUMB_HORIZONTAL:
aExtra->left = aExtra->right = 1;
- return true;
+ break;
// Include the indicator spacing (the padding around the control).
case NS_THEME_CHECKBOX:
@@ -732,7 +751,7 @@ nsNativeThemeGTK::GetExtraSizeForWidget(
aExtra->right = indicator_spacing;
aExtra->bottom = indicator_spacing;
aExtra->left = indicator_spacing;
- return true;
+ break;
}
case NS_THEME_BUTTON :
{
@@ -745,7 +764,7 @@ nsNativeThemeGTK::GetExtraSizeForWidget(
aExtra->right = right;
aExtra->bottom = bottom;
aExtra->left = left;
- return true;
+ break;
}
}
case NS_THEME_FOCUS_OUTLINE:
@@ -753,7 +772,7 @@ nsNativeThemeGTK::GetExtraSizeForWidget(
moz_gtk_get_focus_outline_size(&aExtra->left, &aExtra->top);
aExtra->right = aExtra->left;
aExtra->bottom = aExtra->top;
- return true;
+ break;
}
case NS_THEME_TAB :
{
@@ -777,6 +796,11 @@ nsNativeThemeGTK::GetExtraSizeForWidget(
default:
return false;
}
+ aExtra->top *= GdkScaleFactor();
+ aExtra->right *= GdkScaleFactor();
+ aExtra->bottom *= GdkScaleFactor();
+ aExtra->left *= GdkScaleFactor();
+ return true;
}
NS_IMETHODIMP
@@ -803,6 +827,7 @@ nsNativeThemeGTK::DrawWidgetBackground(n
gfxRect rect = presContext->AppUnitsToGfxUnits(aRect);
gfxRect dirtyRect = presContext->AppUnitsToGfxUnits(aDirtyRect);
+ gint scaleFactor = GdkScaleFactor();
// Align to device pixels where sensible
// to provide crisper and faster drawing.
@@ -840,8 +865,10 @@ nsNativeThemeGTK::DrawWidgetBackground(n
// gdk rectangles are wrt the drawing rect.
- GdkRectangle gdk_rect = {-drawingRect.x, -drawingRect.y,
- widgetRect.width, widgetRect.height};
+ GdkRectangle gdk_rect = {-drawingRect.x/scaleFactor,
+ -drawingRect.y/scaleFactor,
+ widgetRect.width/scaleFactor,
+ widgetRect.height/scaleFactor};
// translate everything so (0,0) is the top left of the drawingRect
gfxContextAutoSaveRestore autoSR(ctx);
@@ -850,6 +877,7 @@ nsNativeThemeGTK::DrawWidgetBackground(n
tm = ctx->CurrentMatrix();
}
tm.Translate(rect.TopLeft() + gfxPoint(drawingRect.x, drawingRect.y));
+ tm.Scale(scaleFactor, scaleFactor); // Draw in GDK coords
ctx->SetMatrix(tm);
NS_ASSERTION(!IsWidgetTypeDisabled(mDisabledWidgetTypes, aWidgetType),
@@ -1038,6 +1066,11 @@ nsNativeThemeGTK::GetWidgetPadding(nsDev
aResult->left += horizontal_padding;
aResult->right += horizontal_padding;
+ aResult->top *= GdkScaleFactor();
+ aResult->right *= GdkScaleFactor();
+ aResult->bottom *= GdkScaleFactor();
+ aResult->left *= GdkScaleFactor();
+
return true;
}
}
@@ -1298,6 +1331,9 @@ nsNativeThemeGTK::GetMinimumWidgetSize(n
}
break;
}
+
+ *aResult = *aResult * GdkScaleFactor();
+
return NS_OK;
}
diff -up mozilla-release/widget/gtk/nsNativeThemeGTK.h.1144745-1 mozilla-release/widget/gtk/nsNativeThemeGTK.h
--- mozilla-release/widget/gtk/nsNativeThemeGTK.h.1144745-1 2015-05-08 18:55:27.000000000 +0200
+++ mozilla-release/widget/gtk/nsNativeThemeGTK.h 2015-05-13 10:25:28.642492647 +0200
@@ -81,6 +81,7 @@ private:
nsIntMargin* aExtra);
void RefreshWidgetWindow(nsIFrame* aFrame);
+ gint GdkScaleFactor();
uint8_t mDisabledWidgetTypes[32];
uint8_t mSafeWidgetStates[1024]; // 256 widgets * 32 bits per widget

185
mozilla-1144745-2.patch Normal file
View File

@ -0,0 +1,185 @@
diff -up mozilla-release/widget/gtk/nsLookAndFeel.cpp.1144745-2 mozilla-release/widget/gtk/nsLookAndFeel.cpp
--- mozilla-release/widget/gtk/nsLookAndFeel.cpp.1144745-2 2015-05-13 10:30:08.204367309 +0200
+++ mozilla-release/widget/gtk/nsLookAndFeel.cpp 2015-05-13 10:30:08.208367321 +0200
@@ -18,6 +18,7 @@
#include <fontconfig/fontconfig.h>
#include "gfxPlatformGtk.h"
+#include "nsScreenGtk.h"
#include "gtkdrawing.h"
#include "nsStyleConsts.h"
@@ -742,12 +743,7 @@ GetSystemFontInfo(GtkWidget *aWidget,
// Scale fonts up on HiDPI displays.
// This would be done automatically with cairo, but we manually manage
// the display scale for platform consistency.
- static auto sGdkScreenGetMonitorScaleFactorPtr = (gint (*)(GdkScreen*,gint))
- dlsym(RTLD_DEFAULT, "gdk_screen_get_monitor_scale_factor");
- if (sGdkScreenGetMonitorScaleFactorPtr) {
- GdkScreen *screen = gdk_screen_get_default();
- size *= (*sGdkScreenGetMonitorScaleFactorPtr)(screen, 0);
- }
+ size *= nsScreenGtk::GetGtkMonitorScaleFactor();
// |size| is now pixels
diff -up mozilla-release/widget/gtk/nsNativeThemeGTK.cpp.1144745-2 mozilla-release/widget/gtk/nsNativeThemeGTK.cpp
--- mozilla-release/widget/gtk/nsNativeThemeGTK.cpp.1144745-2 2015-05-13 10:30:08.206367315 +0200
+++ mozilla-release/widget/gtk/nsNativeThemeGTK.cpp 2015-05-13 10:30:46.966488584 +0200
@@ -6,6 +6,7 @@
#include "nsNativeThemeGTK.h"
#include "nsThemeConstants.h"
#include "gtkdrawing.h"
+#include "nsScreenGtk.h"
#include "nsIObserverService.h"
#include "nsIServiceManager.h"
@@ -89,23 +90,6 @@ nsNativeThemeGTK::RefreshWidgetWindow(ns
vm->InvalidateAllViews();
}
-gint
-nsNativeThemeGTK::GdkScaleFactor()
-{
-#if (MOZ_WIDGET_GTK >= 3)
- // Since GDK 3.10
- static auto sGdkScreenGetMonitorScaleFactorPtr = (gint (*)(GdkScreen*, gint))
- dlsym(RTLD_DEFAULT, "gdk_screen_get_monitor_scale_factor");
- if (sGdkScreenGetMonitorScaleFactorPtr) {
- // FIXME: In the future, we'll want to fix this for GTK on Wayland which
- // supports a variable scale factor per display.
- GdkScreen *screen = gdk_screen_get_default();
- return sGdkScreenGetMonitorScaleFactorPtr(screen, 0);
- }
-#endif
- return 1;
-}
-
static bool IsFrameContentNodeInNamespace(nsIFrame *aFrame, uint32_t aNamespace)
{
@@ -796,10 +780,11 @@ nsNativeThemeGTK::GetExtraSizeForWidget(
default:
return false;
}
- aExtra->top *= GdkScaleFactor();
- aExtra->right *= GdkScaleFactor();
- aExtra->bottom *= GdkScaleFactor();
- aExtra->left *= GdkScaleFactor();
+ gint scale = nsScreenGtk::GetGtkMonitorScaleFactor();
+ aExtra->top *= scale;
+ aExtra->right *= scale;
+ aExtra->bottom *= scale;
+ aExtra->left *= scale;
return true;
}
@@ -827,7 +812,7 @@ nsNativeThemeGTK::DrawWidgetBackground(n
gfxRect rect = presContext->AppUnitsToGfxUnits(aRect);
gfxRect dirtyRect = presContext->AppUnitsToGfxUnits(aDirtyRect);
- gint scaleFactor = GdkScaleFactor();
+ gint scaleFactor = nsScreenGtk::GetGtkMonitorScaleFactor();
// Align to device pixels where sensible
// to provide crisper and faster drawing.
@@ -1066,10 +1051,11 @@ nsNativeThemeGTK::GetWidgetPadding(nsDev
aResult->left += horizontal_padding;
aResult->right += horizontal_padding;
- aResult->top *= GdkScaleFactor();
- aResult->right *= GdkScaleFactor();
- aResult->bottom *= GdkScaleFactor();
- aResult->left *= GdkScaleFactor();
+ gint scale = nsScreenGtk::GetGtkMonitorScaleFactor();
+ aResult->top *= scale;
+ aResult->right *= scale;
+ aResult->bottom *= scale;
+ aResult->left *= scale;
return true;
}
@@ -1332,7 +1318,7 @@ nsNativeThemeGTK::GetMinimumWidgetSize(n
break;
}
- *aResult = *aResult * GdkScaleFactor();
+ *aResult = *aResult * nsScreenGtk::GetGtkMonitorScaleFactor();
return NS_OK;
}
diff -up mozilla-release/widget/gtk/nsNativeThemeGTK.h.1144745-2 mozilla-release/widget/gtk/nsNativeThemeGTK.h
--- mozilla-release/widget/gtk/nsNativeThemeGTK.h.1144745-2 2015-05-13 10:30:08.206367315 +0200
+++ mozilla-release/widget/gtk/nsNativeThemeGTK.h 2015-05-13 10:30:08.209367325 +0200
@@ -81,7 +81,6 @@ private:
nsIntMargin* aExtra);
void RefreshWidgetWindow(nsIFrame* aFrame);
- gint GdkScaleFactor();
uint8_t mDisabledWidgetTypes[32];
uint8_t mSafeWidgetStates[1024]; // 256 widgets * 32 bits per widget
diff -up mozilla-release/widget/gtk/nsScreenGtk.cpp.1144745-2 mozilla-release/widget/gtk/nsScreenGtk.cpp
--- mozilla-release/widget/gtk/nsScreenGtk.cpp.1144745-2 2015-05-08 18:55:27.000000000 +0200
+++ mozilla-release/widget/gtk/nsScreenGtk.cpp 2015-05-13 10:30:08.209367325 +0200
@@ -63,6 +63,23 @@ nsScreenGtk :: GetAvailRect(int32_t *out
} // GetAvailRect
+gint
+nsScreenGtk :: GetGtkMonitorScaleFactor()
+{
+#if (MOZ_WIDGET_GTK >= 3)
+ // Since GDK 3.10
+ static auto sGdkScreenGetMonitorScaleFactorPtr = (gint (*)(GdkScreen*, gint))
+ dlsym(RTLD_DEFAULT, "gdk_screen_get_monitor_scale_factor");
+ if (sGdkScreenGetMonitorScaleFactorPtr) {
+ // FIXME: In the future, we'll want to fix this for GTK on Wayland which
+ // supports a variable scale factor per display.
+ GdkScreen *screen = gdk_screen_get_default();
+ return sGdkScreenGetMonitorScaleFactorPtr(screen, 0);
+ }
+#endif
+ return 1;
+}
+
double
nsScreenGtk :: GetDPIScale()
{
@@ -127,20 +144,9 @@ nsScreenGtk :: GetColorDepth(int32_t *aC
void
nsScreenGtk :: Init (GdkWindow *aRootWindow)
{
- gint width = gdk_screen_width();
- gint height = gdk_screen_height();
-
- // Since GDK 3.10
- static auto sGdkScreenGetMonitorScaleFactorPtr = (gint (*)(GdkScreen*, gint))
- dlsym(RTLD_DEFAULT, "gdk_screen_get_monitor_scale_factor");
- if (sGdkScreenGetMonitorScaleFactorPtr) {
- // FIXME: In the future, we'll want to fix this for GTK on Wayland which
- // supports a variable scale factor per display.
- GdkScreen *screen = gdk_window_get_screen(aRootWindow);
- gint scale = sGdkScreenGetMonitorScaleFactorPtr(screen, 0);
- width *= scale;
- height *= scale;
- }
+ gint scale = nsScreenGtk::GetGtkMonitorScaleFactor();
+ gint width = gdk_screen_width()*scale;
+ gint height = gdk_screen_height()*scale;
// We listen for configure events on the root window to pick up
// changes to this rect. We could listen for "size_changed" signals
diff -up mozilla-release/widget/gtk/nsScreenGtk.h.1144745-2 mozilla-release/widget/gtk/nsScreenGtk.h
--- mozilla-release/widget/gtk/nsScreenGtk.h.1144745-2 2015-05-08 18:55:27.000000000 +0200
+++ mozilla-release/widget/gtk/nsScreenGtk.h 2015-05-13 10:30:08.209367325 +0200
@@ -43,7 +43,8 @@ public:
void Init(XineramaScreenInfo *aScreenInfo);
#endif /* MOZ_X11 */
- static double GetDPIScale();
+ static gint GetGtkMonitorScaleFactor();
+ static double GetDPIScale();
private:
uint32_t mScreenNum;

31
mozilla-1144745-3.patch Normal file
View File

@ -0,0 +1,31 @@
# HG changeset patch
# User Martin Stransky <stransky@redhat.com>
# Parent e0299ad29b855f798ee5db8257cbb459894c1b29
Bug 1144745 - scale border returned by GetWidgetBorder(), r=?karlt
diff --git a/widget/gtk/nsNativeThemeGTK.cpp b/widget/gtk/nsNativeThemeGTK.cpp
--- a/widget/gtk/nsNativeThemeGTK.cpp
+++ b/widget/gtk/nsNativeThemeGTK.cpp
@@ -990,16 +990,22 @@ nsNativeThemeGTK::GetWidgetBorder(nsDevi
if (GetGtkWidgetAndState(aWidgetType, aFrame, gtkWidgetType, nullptr,
nullptr)) {
moz_gtk_get_widget_border(gtkWidgetType, &aResult->left, &aResult->top,
&aResult->right, &aResult->bottom, direction,
IsFrameContentNodeInNamespace(aFrame, kNameSpaceID_XHTML));
}
}
}
+
+ gint scale = nsScreenGtk::GetGtkMonitorScaleFactor();
+ aResult->top *= scale;
+ aResult->right *= scale;
+ aResult->bottom *= scale;
+ aResult->left *= scale;
return NS_OK;
}
bool
nsNativeThemeGTK::GetWidgetPadding(nsDeviceContext* aContext,
nsIFrame* aFrame, uint8_t aWidgetType,
nsIntMargin* aResult)
{