From 20d7a16e95888dccd3853f3b031b1ae04dd07916 Mon Sep 17 00:00:00 2001 From: Martin Stransky Date: Fri, 3 Mar 2017 14:35:44 +0100 Subject: [PATCH] Update to 52.0 (B2) --- .gitignore | 2 + firefox-build-prbool.patch | 42 +- firefox-ppc64le.patch | 28 - firefox.spec | 19 +- mozilla-1319374.patch | 174 --- mozilla-1321579.patch | 39 - mozilla-build-arm.patch | 35 +- sources | 4 +- widget-rebase.patch | 2123 ++++-------------------------------- 9 files changed, 290 insertions(+), 2176 deletions(-) delete mode 100644 firefox-ppc64le.patch delete mode 100644 mozilla-1319374.patch delete mode 100644 mozilla-1321579.patch diff --git a/.gitignore b/.gitignore index 34ce82e..df1803f 100644 --- a/.gitignore +++ b/.gitignore @@ -224,3 +224,5 @@ firefox-3.6.4.source.tar.bz2 /firefox-51.0.1.source.tar.xz /firefox-langpacks-51.0.1-20170125.tar.xz /firefox-langpacks-51.0.1-20170126.tar.xz +/firefox-52.0.source.tar.xz +/firefox-langpacks-52.0-20170303.tar.xz diff --git a/firefox-build-prbool.patch b/firefox-build-prbool.patch index 67443c3..f271631 100644 --- a/firefox-build-prbool.patch +++ b/firefox-build-prbool.patch @@ -1,28 +1,17 @@ -diff -up firefox-48.0/dom/u2f/U2F.cpp.prbool firefox-48.0/dom/u2f/U2F.cpp ---- firefox-48.0/dom/u2f/U2F.cpp.prbool 2016-07-26 12:27:56.903381382 +0200 -+++ firefox-48.0/dom/u2f/U2F.cpp 2016-07-26 12:28:08.924399413 +0200 +diff -up firefox-52.0/dom/u2f/U2F.cpp.prbool firefox-52.0/dom/u2f/U2F.cpp +--- firefox-52.0/dom/u2f/U2F.cpp.prbool 2017-03-03 13:42:22.613691228 +0100 ++++ firefox-52.0/dom/u2f/U2F.cpp 2017-03-03 13:48:20.864647727 +0100 @@ -4,6 +4,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include "prtypes.h" #include "hasht.h" + #include "mozilla/dom/CallbackFunction.h" #include "mozilla/dom/ContentChild.h" - #include "mozilla/dom/CryptoBuffer.h" -diff -up firefox-48.0/security/certverifier/OCSPCache.h.prbool firefox-48.0/security/certverifier/OCSPCache.h ---- firefox-48.0/security/certverifier/OCSPCache.h.prbool 2016-05-12 19:13:32.000000000 +0200 -+++ firefox-48.0/security/certverifier/OCSPCache.h 2016-07-26 12:26:56.366290580 +0200 -@@ -25,6 +25,7 @@ - #ifndef mozilla_psm_OCSPCache_h - #define mozilla_psm_OCSPCache_h - -+#include "prtypes.h" - #include "hasht.h" - #include "mozilla/Mutex.h" - #include "mozilla/Vector.h" -diff -up firefox-51.0/security/certverifier/CTLogVerifier.cpp.old firefox-51.0/security/certverifier/CTLogVerifier.cpp ---- firefox-51.0/security/certverifier/CTLogVerifier.cpp.old 2017-01-18 13:03:34.758386735 +0100 -+++ firefox-51.0/security/certverifier/CTLogVerifier.cpp 2017-01-18 13:03:38.753367776 +0100 +diff -up firefox-52.0/security/certverifier/CTLogVerifier.cpp.prbool firefox-52.0/security/certverifier/CTLogVerifier.cpp +--- firefox-52.0/security/certverifier/CTLogVerifier.cpp.prbool 2017-01-16 17:16:51.000000000 +0100 ++++ firefox-52.0/security/certverifier/CTLogVerifier.cpp 2017-03-03 13:42:22.613691228 +0100 @@ -7,6 +7,7 @@ #include "CTLogVerifier.h" @@ -31,9 +20,9 @@ diff -up firefox-51.0/security/certverifier/CTLogVerifier.cpp.old firefox-51.0/s #include "hasht.h" #include "mozilla/ArrayUtils.h" #include "mozilla/Assertions.h" -diff -up firefox-51.0/security/certverifier/CTObjectsExtractor.cpp.old firefox-51.0/security/certverifier/CTObjectsExtractor.cpp ---- firefox-51.0/security/certverifier/CTObjectsExtractor.cpp.old 2017-01-18 13:01:57.629847680 +0100 -+++ firefox-51.0/security/certverifier/CTObjectsExtractor.cpp 2017-01-18 13:02:01.892827449 +0100 +diff -up firefox-52.0/security/certverifier/CTObjectsExtractor.cpp.prbool firefox-52.0/security/certverifier/CTObjectsExtractor.cpp +--- firefox-52.0/security/certverifier/CTObjectsExtractor.cpp.prbool 2017-01-16 17:16:51.000000000 +0100 ++++ firefox-52.0/security/certverifier/CTObjectsExtractor.cpp 2017-03-03 13:42:22.613691228 +0100 @@ -6,6 +6,7 @@ #include "CTObjectsExtractor.h" @@ -42,3 +31,14 @@ diff -up firefox-51.0/security/certverifier/CTObjectsExtractor.cpp.old firefox-5 #include "hasht.h" #include "mozilla/Assertions.h" #include "mozilla/Casting.h" +diff -up firefox-52.0/security/certverifier/OCSPCache.h.prbool firefox-52.0/security/certverifier/OCSPCache.h +--- firefox-52.0/security/certverifier/OCSPCache.h.prbool 2017-02-27 17:11:06.000000000 +0100 ++++ firefox-52.0/security/certverifier/OCSPCache.h 2017-03-03 13:42:22.613691228 +0100 +@@ -25,6 +25,7 @@ + #ifndef mozilla_psm_OCSPCache_h + #define mozilla_psm_OCSPCache_h + ++#include "prtypes.h" + #include "hasht.h" + #include "mozilla/Mutex.h" + #include "mozilla/Vector.h" diff --git a/firefox-ppc64le.patch b/firefox-ppc64le.patch deleted file mode 100644 index 9f74819..0000000 --- a/firefox-ppc64le.patch +++ /dev/null @@ -1,28 +0,0 @@ -diff -up firefox-36.0/mozilla-release/gfx/skia/trunk/include/core/SkPreConfig.h.ppc64le firefox-36.0/mozilla-release/gfx/skia/trunk/include/core/SkPreConfig.h ---- firefox-36.0/mozilla-release/gfx/skia/skia/include/core/SkPreConfig.h.ppc64le 2015-02-20 03:01:40.000000000 +0100 -+++ firefox-36.0/mozilla-release/gfx/skia/skia/include/core/SkPreConfig.h 2015-03-06 15:52:58.298050379 +0100 -@@ -90,6 +90,13 @@ - #endif - - ////////////////////////////////////////////////////////////////////// -+#if !defined(SK_CPU_BENDIAN) && !defined(SK_CPU_LENDIAN) -+ #if defined(__BIG_ENDIAN__) -+ #define SK_CPU_BENDIAN -+ #elif defined(__LITTLE_ENDIAN__) -+ #define SK_CPU_LENDIAN -+ #endif -+#endif - - #if !defined(SK_CPU_BENDIAN) && !defined(SK_CPU_LENDIAN) - #if defined(__sparc) || defined(__sparc__) || \ -diff -up firefox-36.0/mozilla-release/js/src/jsdtoa.cpp.ppc64le firefox-36.0/mozilla-release/js/src/jsdtoa.cpp ---- firefox-36.0/mozilla-release/js/src/jsdtoa.cpp.ppc64le 2015-02-20 03:01:49.000000000 +0100 -+++ firefox-36.0/mozilla-release/js/src/jsdtoa.cpp 2015-03-06 15:54:38.348048226 +0100 -@@ -52,6 +52,7 @@ static inline void dtoa_free(void* p) { - #define MALLOC dtoa_malloc - #define FREE dtoa_free - #include "dtoa.c" -+#undef CONST - - /* Mapping of JSDToStrMode -> js_dtoa mode */ - static const uint8_t dtoaModes[] = { diff --git a/firefox.spec b/firefox.spec index e503593..57569f6 100644 --- a/firefox.spec +++ b/firefox.spec @@ -1,6 +1,3 @@ -# Temporary disabled due to js crash -#ExcludeArch: armv7hl - # Use system nspr/nss? %define system_nss 1 @@ -96,14 +93,14 @@ Summary: Mozilla Firefox Web browser Name: firefox -Version: 51.0.1 -Release: 11%{?pre_tag}%{?dist} +Version: 52.0 +Release: 1%{?pre_tag}%{?dist} URL: https://www.mozilla.org/firefox/ License: MPLv1.1 or GPLv2+ or LGPLv2+ Group: Applications/Internet Source0: https://archive.mozilla.org/pub/firefox/releases/%{version}%{?pre_version}/source/firefox-%{version}%{?pre_version}.source.tar.xz %if %{build_langpacks} -Source1: firefox-langpacks-%{version}%{?pre_version}-20170126.tar.xz +Source1: firefox-langpacks-%{version}%{?pre_version}-20170303.tar.xz %endif Source10: firefox-mozconfig Source12: firefox-redhat-default-prefs.js @@ -121,7 +118,6 @@ Patch18: xulrunner-24.0-jemalloc-ppc.patch # workaround linking issue on s390 (JSContext::updateMallocCounter(size_t) not found) Patch19: xulrunner-24.0-s390-inlines.patch Patch20: firefox-build-prbool.patch -Patch21: firefox-ppc64le.patch Patch24: firefox-debug.patch Patch25: rhbz-1219542-s390-build.patch @@ -150,8 +146,6 @@ Patch406: mozilla-256180.patch # Rebase Gtk3 widget code to latest trunk to # fix various rendering problems Patch407: widget-rebase.patch -Patch408: mozilla-1319374.patch -Patch409: mozilla-1321579.patch # Debian patches Patch500: mozilla-440908.patch @@ -280,7 +274,6 @@ cd %{tarballdir} %patch18 -p1 -b .jemalloc-ppc %patch19 -p2 -b .s390-inlines %patch20 -p1 -b .prbool -%patch21 -p2 -b .ppc64le %patch24 -p1 -b .debug %ifarch s390 %patch25 -p1 -b .rhbz-1219542-s390 @@ -309,9 +302,6 @@ cd %{tarballdir} # Rebase Gtk3 widget code to latest trunk to # fix various rendering problems %patch407 -p1 -b .widget-rebase -# ppc64 build fix -%patch408 -p1 -b .1319374 -%patch409 -p1 -b .1321579 # Debian extension patch %patch500 -p1 -b .440908 @@ -815,6 +805,9 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || : #--------------------------------------------------------------------- %changelog +* Fri Mar 3 2017 Martin Stransky - 52.0-1 +- Update to 52.0 (B2) + * Thu Mar 02 2017 Kai Engert - 51.0.1-11 - Enable upstream fix for rhbz#1400293 mozbz#1324096 on F26 and Rawhide. Keep the old workaround on F24/F25, required base packages aren't diff --git a/mozilla-1319374.patch b/mozilla-1319374.patch deleted file mode 100644 index 1dec744..0000000 --- a/mozilla-1319374.patch +++ /dev/null @@ -1,174 +0,0 @@ -diff -up firefox-51.0/gfx/2d/BorrowedContext.h.1319374 firefox-51.0/gfx/2d/BorrowedContext.h ---- firefox-51.0/gfx/2d/BorrowedContext.h.1319374 2017-01-16 17:16:49.000000000 +0100 -+++ firefox-51.0/gfx/2d/BorrowedContext.h 2017-01-20 12:17:56.589954310 +0100 -@@ -195,8 +195,18 @@ public: - - CGContextRef cg; - private: -+#ifdef USE_SKIA - static CGContextRef BorrowCGContextFromDrawTarget(DrawTarget *aDT); - static void ReturnCGContextToDrawTarget(DrawTarget *aDT, CGContextRef cg); -+#else -+ static CGContextRef BorrowCGContextFromDrawTarget(DrawTarget *aDT) { -+ MOZ_CRASH("Not supported without Skia"); -+ } -+ -+ static void ReturnCGContextToDrawTarget(DrawTarget *aDT, CGContextRef cg) { -+ MOZ_CRASH("not supported without Skia"); -+ } -+#endif - DrawTarget *mDT; - }; - #endif -diff -up firefox-51.0/gfx/layers/composite/LayerManagerComposite.cpp.1319374 firefox-51.0/gfx/layers/composite/LayerManagerComposite.cpp ---- firefox-51.0/gfx/layers/composite/LayerManagerComposite.cpp.1319374 2017-01-16 17:16:50.000000000 +0100 -+++ firefox-51.0/gfx/layers/composite/LayerManagerComposite.cpp 2017-01-20 12:27:01.818193768 +0100 -@@ -12,7 +12,6 @@ - #include "CompositableHost.h" // for CompositableHost - #include "ContainerLayerComposite.h" // for ContainerLayerComposite, etc - #include "FPSCounter.h" // for FPSState, FPSCounter --#include "PaintCounter.h" // For PaintCounter - #include "FrameMetrics.h" // for FrameMetrics - #include "GeckoProfiler.h" // for profiler_set_frame_number, etc - #include "ImageLayerComposite.h" // for ImageLayerComposite -@@ -72,6 +71,9 @@ - #include "TextRenderer.h" // for TextRenderer - #include "mozilla/layers/CompositorBridgeParent.h" - #include "TreeTraversal.h" // for ForEachNode -+#ifdef USE_SKIA -+#include "PaintCounter.h" // For PaintCounter -+#endif - - class gfxContext; - -@@ -133,6 +135,10 @@ LayerManagerComposite::LayerManagerCompo - { - mTextRenderer = new TextRenderer(aCompositor); - MOZ_ASSERT(aCompositor); -+ -+#ifdef USE_SKIA -+ mPaintCounter = nullptr; -+#endif - } - - LayerManagerComposite::~LayerManagerComposite() -@@ -151,8 +157,11 @@ LayerManagerComposite::Destroy() - } - mRoot = nullptr; - mClonedLayerTreeProperties = nullptr; -- mPaintCounter = nullptr; - mDestroyed = true; -+ -+#ifdef USE_SKIA -+ mPaintCounter = nullptr; -+#endif - } - } - -@@ -564,7 +573,6 @@ LayerManagerComposite::InvalidateDebugOv - bool drawFps = gfxPrefs::LayersDrawFPS(); - bool drawFrameCounter = gfxPrefs::DrawFrameCounter(); - bool drawFrameColorBars = gfxPrefs::CompositorDrawColorBars(); -- bool drawPaintTimes = gfxPrefs::AlwaysPaint(); - - if (drawFps || drawFrameCounter) { - aInvalidRegion.Or(aInvalidRegion, nsIntRect(0, 0, 256, 256)); -@@ -572,11 +580,16 @@ LayerManagerComposite::InvalidateDebugOv - if (drawFrameColorBars) { - aInvalidRegion.Or(aInvalidRegion, nsIntRect(0, 0, 10, aBounds.height)); - } -+ -+#ifdef USE_SKIA -+ bool drawPaintTimes = gfxPrefs::AlwaysPaint(); - if (drawPaintTimes) { - aInvalidRegion.Or(aInvalidRegion, nsIntRect(PaintCounter::GetPaintRect())); - } -+#endif - } - -+#ifdef USE_SKIA - void - LayerManagerComposite::DrawPaintTimes(Compositor* aCompositor) - { -@@ -587,6 +600,7 @@ LayerManagerComposite::DrawPaintTimes(Co - TimeDuration compositeTime = TimeStamp::Now() - mRenderStartTime; - mPaintCounter->Draw(aCompositor, mLastPaintTime, compositeTime); - } -+#endif - - static uint16_t sFrameCount = 0; - void -@@ -595,7 +609,6 @@ LayerManagerComposite::RenderDebugOverla - bool drawFps = gfxPrefs::LayersDrawFPS(); - bool drawFrameCounter = gfxPrefs::DrawFrameCounter(); - bool drawFrameColorBars = gfxPrefs::CompositorDrawColorBars(); -- bool drawPaintTimes = gfxPrefs::AlwaysPaint(); - - TimeStamp now = TimeStamp::Now(); - -@@ -736,9 +749,12 @@ LayerManagerComposite::RenderDebugOverla - sFrameCount++; - } - -+#ifdef USE_SKIA -+ bool drawPaintTimes = gfxPrefs::AlwaysPaint(); - if (drawPaintTimes) { - DrawPaintTimes(mCompositor); - } -+#endif - } - - RefPtr -diff -up firefox-51.0/gfx/layers/composite/LayerManagerComposite.h.1319374 firefox-51.0/gfx/layers/composite/LayerManagerComposite.h ---- firefox-51.0/gfx/layers/composite/LayerManagerComposite.h.1319374 2017-01-16 17:16:50.000000000 +0100 -+++ firefox-51.0/gfx/layers/composite/LayerManagerComposite.h 2017-01-20 12:17:56.589954310 +0100 -@@ -331,11 +331,6 @@ private: - #endif - - /** -- * Render paint and composite times above the frame. -- */ -- void DrawPaintTimes(Compositor* aCompositor); -- -- /** - * We need to know our invalid region before we're ready to render. - */ - void InvalidateDebugOverlay(nsIntRegion& aInvalidRegion, const gfx::IntRect& aBounds); -@@ -391,9 +386,16 @@ private: - bool mLastFrameMissedHWC; - - bool mWindowOverlayChanged; -- RefPtr mPaintCounter; - TimeDuration mLastPaintTime; - TimeStamp mRenderStartTime; -+ -+#ifdef USE_SKIA -+ /** -+ * Render paint and composite times above the frame. -+ */ -+ void DrawPaintTimes(Compositor* aCompositor); -+ RefPtr mPaintCounter; -+#endif - }; - - /** -diff -up firefox-51.0/gfx/layers/moz.build.1319374 firefox-51.0/gfx/layers/moz.build ---- firefox-51.0/gfx/layers/moz.build.1319374 2017-01-16 17:16:50.000000000 +0100 -+++ firefox-51.0/gfx/layers/moz.build 2017-01-20 12:17:56.589954310 +0100 -@@ -340,7 +340,6 @@ UNIFIED_SOURCES += [ - 'composite/ImageHost.cpp', - 'composite/ImageLayerComposite.cpp', - 'composite/LayerManagerComposite.cpp', -- 'composite/PaintCounter.cpp', - 'composite/PaintedLayerComposite.cpp', - 'composite/TextRenderer.cpp', - 'composite/TextureHost.cpp', -@@ -485,3 +484,8 @@ LOCAL_INCLUDES += CONFIG['SKIA_INCLUDES' - - if CONFIG['GNU_CXX']: - CXXFLAGS += ['-Wno-error=shadow'] -+ -+if CONFIG['MOZ_ENABLE_SKIA']: -+ UNIFIED_SOURCES += [ -+ 'composite/PaintCounter.cpp', -+ ] diff --git a/mozilla-1321579.patch b/mozilla-1321579.patch deleted file mode 100644 index 4dd2a76..0000000 --- a/mozilla-1321579.patch +++ /dev/null @@ -1,39 +0,0 @@ -diff --git a/build/autoconf/compiler-opts.m4 b/build/autoconf/compiler-opts.m4 ---- a/build/autoconf/compiler-opts.m4 -+++ b/build/autoconf/compiler-opts.m4 -@@ -173,16 +173,34 @@ AC_SUBST([LD_IS_BFD]) - - if test "$GNU_CC"; then - if test -z "$DEVELOPER_OPTIONS"; then - CFLAGS="$CFLAGS -ffunction-sections -fdata-sections" - CXXFLAGS="$CXXFLAGS -ffunction-sections -fdata-sections" - fi - CFLAGS="$CFLAGS -fno-math-errno" - CXXFLAGS="$CXXFLAGS -fno-exceptions -fno-math-errno" -+ -+ if test -z "$CLANG_CC"; then -+ case "$CC_VERSION" in -+ 4.*) -+ ;; -+ *) -+ # Lifetime Dead Store Elimination level 2 (default in GCC6+) breaks Gecko. -+ # Ideally, we'd use -flifetime-dse=1, but that means we'd forcefully -+ # enable it on optimization levels where it would otherwise not be enabled. -+ # So we disable it entirely. But since that would mean inconsistency with -+ # GCC5, which has level 1 depending on optimization level, disable it on -+ # GCC5 as well, because better safe than sorry. -+ # Add it first so that a mozconfig can override by setting CFLAGS/CXXFLAGS. -+ CFLAGS="-fno-lifetime-dse $CFLAGS" -+ CXXFLAGS="-fno-lifetime-dse $CXXFLAGS" -+ ;; -+ esac -+ fi - fi - - dnl ======================================================== - dnl = Identical Code Folding - dnl ======================================================== - - MOZ_ARG_DISABLE_BOOL(icf, - [ --disable-icf Disable Identical Code Folding], - diff --git a/mozilla-build-arm.patch b/mozilla-build-arm.patch index fd54f93..1e1e57c 100644 --- a/mozilla-build-arm.patch +++ b/mozilla-build-arm.patch @@ -1,6 +1,20 @@ -diff -up firefox-46.0/media/webrtc/trunk/webrtc/build/common.gypi.arm firefox-46.0/media/webrtc/trunk/webrtc/build/common.gypi ---- firefox-46.0/media/webrtc/trunk/webrtc/build/common.gypi.arm 2016-04-25 12:03:12.486027089 +0200 -+++ firefox-46.0/media/webrtc/trunk/webrtc/build/common.gypi 2016-04-25 12:05:55.714644873 +0200 +diff -up firefox-52.0/gfx/skia/skia/include/core/SkPreConfig.h.arm firefox-52.0/gfx/skia/skia/include/core/SkPreConfig.h +--- firefox-52.0/gfx/skia/skia/include/core/SkPreConfig.h.arm 2017-03-03 13:53:52.480754536 +0100 ++++ firefox-52.0/gfx/skia/skia/include/core/SkPreConfig.h 2017-03-03 13:56:01.476018102 +0100 +@@ -203,6 +203,10 @@ + #define SK_ARM_HAS_CRC32 + #endif + ++#if defined(__aarch64__) ++ #undef SK_ARM_HAS_NEON ++#endif ++ + ////////////////////////////////////////////////////////////////////// + + #if !defined(SKIA_IMPLEMENTATION) +diff -up firefox-52.0/media/webrtc/trunk/webrtc/build/common.gypi.arm firefox-52.0/media/webrtc/trunk/webrtc/build/common.gypi +--- firefox-52.0/media/webrtc/trunk/webrtc/build/common.gypi.arm 2016-09-05 22:12:57.000000000 +0200 ++++ firefox-52.0/media/webrtc/trunk/webrtc/build/common.gypi 2017-03-03 13:53:52.480754536 +0100 @@ -312,20 +312,6 @@ 'defines': [ 'WEBRTC_ARCH_ARM', @@ -22,18 +36,3 @@ diff -up firefox-46.0/media/webrtc/trunk/webrtc/build/common.gypi.arm firefox-46 }], ['os_bsd==1', { 'defines': [ -diff -up firefox-51.0/gfx/skia/skia/include/core/SkPreConfig.h.old firefox-51.0/gfx/skia/skia/include/core/SkPreConfig.h ---- firefox-51.0/gfx/skia/skia/include/core/SkPreConfig.h.old 2017-01-20 10:22:48.921666380 +0100 -+++ firefox-51.0/gfx/skia/skia/include/core/SkPreConfig.h 2017-01-20 10:23:23.600486691 +0100 -@@ -208,6 +208,10 @@ - #define SK_ARM_HAS_NEON - #endif - -+#if defined(__aarch64__) -+ #undef SK_ARM_HAS_NEON -+#endif -+ - ////////////////////////////////////////////////////////////////////// - - #if !defined(SKIA_IMPLEMENTATION) -diff -up firefox-51.0/media/webrtc/trunk/Makefile.old firefox-51.0/media/webrtc/trunk/Makefile diff --git a/sources b/sources index 0d52f80..4e3de8e 100644 --- a/sources +++ b/sources @@ -1,2 +1,2 @@ -SHA512 (firefox-langpacks-51.0.1-20170126.tar.xz) = 5c36e7ca9dad921a350495a550ba78f387a462408dcff170f8944eb98ef66ac0bbfbe546378836d77cfd56c16403ecd874ac7c15a83fa8bfa44d3271a8a31858 -SHA512 (firefox-51.0.1.source.tar.xz) = 556e31b717c0640ef5e181e00b9d2a6ea0ace7c16ae04333d0f2e9e120d0ab9efe82a4ca314ef43594c080523edf37953e65dbf694c7428be0a024f3719d8312 +SHA512 (firefox-52.0.source.tar.xz) = bffe5fd9eee240f252bf8a882c46f04551d21f6f58b8da68779cd106ed012ea77ee16bc287c847f8a7b959203c79f1b1d3f50151111f9610e1ca7a57c7b811f7 +SHA512 (firefox-langpacks-52.0-20170303.tar.xz) = c542fae511f35ed837f4a556fe5fe6aba936af7b2f2ba3f59aee1efdf68f4c8c31e6a53fc6bb806e0256f6a2ae00a5b4f98935243edbee40928bc25d6057e681 diff --git a/widget-rebase.patch b/widget-rebase.patch index bb39e24..f31b000 100644 --- a/widget-rebase.patch +++ b/widget-rebase.patch @@ -1,24 +1,7 @@ -diff -up firefox-51.0/widget/gtk/gtk3drawing.cpp.old firefox-51.0/widget/gtk/gtk3drawing.cpp ---- firefox-51.0/widget/gtk/gtk3drawing.cpp.old 2017-01-18 16:24:56.375732107 +0100 -+++ firefox-51.0/widget/gtk/gtk3drawing.cpp 2017-01-10 11:28:15.000000000 +0100 -@@ -18,16 +18,6 @@ - - #include - --static GtkWidget* gProtoLayout; --static GtkWidget* gComboBoxWidget; --static GtkWidget* gComboBoxButtonWidget; --static GtkWidget* gComboBoxArrowWidget; --static GtkWidget* gComboBoxSeparatorWidget; --static GtkWidget* gComboBoxEntryWidget; --static GtkWidget* gComboBoxEntryTextareaWidget; --static GtkWidget* gComboBoxEntryButtonWidget; --static GtkWidget* gComboBoxEntryArrowWidget; -- - static style_prop_t style_prop_func; - static gboolean have_arrow_scaling; - static gboolean checkbox_check_state; -@@ -46,6 +36,10 @@ static gboolean is_initialized; +diff -up firefox-52.0/widget/gtk/gtk3drawing.cpp.widget-rebase firefox-52.0/widget/gtk/gtk3drawing.cpp +--- firefox-52.0/widget/gtk/gtk3drawing.cpp.widget-rebase 2017-02-27 17:11:05.000000000 +0100 ++++ firefox-52.0/widget/gtk/gtk3drawing.cpp 2017-03-03 14:28:39.000000000 +0100 +@@ -36,6 +36,10 @@ static gboolean is_initialized; static gint moz_gtk_get_tab_thickness(GtkStyleContext *style); @@ -26,251 +9,10 @@ diff -up firefox-51.0/widget/gtk/gtk3drawing.cpp.old firefox-51.0/widget/gtk/gtk +moz_gtk_menu_item_paint(WidgetNodeType widget, cairo_t *cr, GdkRectangle* rect, + GtkWidgetState* state, GtkTextDirection direction); + - static GtkStateFlags - GetStateFlagsFromGtkWidgetState(GtkWidgetState* state) - { -@@ -79,212 +73,6 @@ moz_gtk_enable_style_props(style_prop_t - return MOZ_GTK_SUCCESS; - } - --static gint --setup_widget_prototype(GtkWidget* widget) --{ -- if (!gProtoLayout) { -- gProtoLayout = GetWidget(MOZ_GTK_WINDOW_CONTAINER); -- } -- gtk_container_add(GTK_CONTAINER(gProtoLayout), widget); -- return MOZ_GTK_SUCCESS; --} -- --/* We need to have pointers to the inner widgets (button, separator, arrow) -- * of the ComboBox to get the correct rendering from theme engines which -- * special cases their look. Since the inner layout can change, we ask GTK -- * to NULL our pointers when they are about to become invalid because the -- * corresponding widgets don't exist anymore. It's the role of -- * g_object_add_weak_pointer(). -- * Note that if we don't find the inner widgets (which shouldn't happen), we -- * fallback to use generic "non-inner" widgets, and they don't need that kind -- * of weak pointer since they are explicit children of gProtoLayout and as -- * such GTK holds a strong reference to them. */ --static void --moz_gtk_get_combo_box_inner_button(GtkWidget *widget, gpointer client_data) --{ -- if (GTK_IS_TOGGLE_BUTTON(widget)) { -- gComboBoxButtonWidget = widget; -- g_object_add_weak_pointer(G_OBJECT(widget), -- (gpointer *) &gComboBoxButtonWidget); -- gtk_widget_realize(widget); -- } --} -- --static void --moz_gtk_get_combo_box_button_inner_widgets(GtkWidget *widget, -- gpointer client_data) --{ -- if (GTK_IS_SEPARATOR(widget)) { -- gComboBoxSeparatorWidget = widget; -- g_object_add_weak_pointer(G_OBJECT(widget), -- (gpointer *) &gComboBoxSeparatorWidget); -- } else if (GTK_IS_ARROW(widget)) { -- gComboBoxArrowWidget = widget; -- g_object_add_weak_pointer(G_OBJECT(widget), -- (gpointer *) &gComboBoxArrowWidget); -- } else -- return; -- gtk_widget_realize(widget); --} -- --static gint --ensure_combo_box_widgets() --{ -- GtkWidget* buttonChild; -- -- if (gComboBoxButtonWidget && gComboBoxArrowWidget) -- return MOZ_GTK_SUCCESS; -- -- /* Create a ComboBox if needed */ -- if (!gComboBoxWidget) { -- gComboBoxWidget = gtk_combo_box_new(); -- setup_widget_prototype(gComboBoxWidget); -- } -- -- /* Get its inner Button */ -- gtk_container_forall(GTK_CONTAINER(gComboBoxWidget), -- moz_gtk_get_combo_box_inner_button, -- NULL); -- -- if (gComboBoxButtonWidget) { -- /* Get the widgets inside the Button */ -- buttonChild = gtk_bin_get_child(GTK_BIN(gComboBoxButtonWidget)); -- if (GTK_IS_BOX(buttonChild)) { -- /* appears-as-list = FALSE, cell-view = TRUE; the button -- * contains an hbox. This hbox is there because the ComboBox -- * needs to place a cell renderer, a separator, and an arrow in -- * the button when appears-as-list is FALSE. */ -- gtk_container_forall(GTK_CONTAINER(buttonChild), -- moz_gtk_get_combo_box_button_inner_widgets, -- NULL); -- } else if(GTK_IS_ARROW(buttonChild)) { -- /* appears-as-list = TRUE, or cell-view = FALSE; -- * the button only contains an arrow */ -- gComboBoxArrowWidget = buttonChild; -- g_object_add_weak_pointer(G_OBJECT(buttonChild), (gpointer *) -- &gComboBoxArrowWidget); -- gtk_widget_realize(gComboBoxArrowWidget); -- } -- } else { -- /* Shouldn't be reached with current internal gtk implementation; we -- * use a generic toggle button as last resort fallback to avoid -- * crashing. */ -- gComboBoxButtonWidget = GetWidget(MOZ_GTK_TOGGLE_BUTTON); -- } -- -- if (!gComboBoxArrowWidget) { -- /* Shouldn't be reached with current internal gtk implementation; -- * we gButtonArrowWidget as last resort fallback to avoid -- * crashing. */ -- gComboBoxArrowWidget = GetWidget(MOZ_GTK_BUTTON_ARROW); -- } -- -- /* We don't test the validity of gComboBoxSeparatorWidget since there -- * is none when "appears-as-list" = TRUE or "cell-view" = FALSE; if it -- * is invalid we just won't paint it. */ -- -- return MOZ_GTK_SUCCESS; --} -- --/* We need to have pointers to the inner widgets (entry, button, arrow) of -- * the ComboBoxEntry to get the correct rendering from theme engines which -- * special cases their look. Since the inner layout can change, we ask GTK -- * to NULL our pointers when they are about to become invalid because the -- * corresponding widgets don't exist anymore. It's the role of -- * g_object_add_weak_pointer(). -- * Note that if we don't find the inner widgets (which shouldn't happen), we -- * fallback to use generic "non-inner" widgets, and they don't need that kind -- * of weak pointer since they are explicit children of gProtoLayout and as -- * such GTK holds a strong reference to them. */ --static void --moz_gtk_get_combo_box_entry_inner_widgets(GtkWidget *widget, -- gpointer client_data) --{ -- if (GTK_IS_TOGGLE_BUTTON(widget)) { -- gComboBoxEntryButtonWidget = widget; -- g_object_add_weak_pointer(G_OBJECT(widget), -- (gpointer *) &gComboBoxEntryButtonWidget); -- } else if (GTK_IS_ENTRY(widget)) { -- gComboBoxEntryTextareaWidget = widget; -- g_object_add_weak_pointer(G_OBJECT(widget), -- (gpointer *) &gComboBoxEntryTextareaWidget); -- } else -- return; -- gtk_widget_realize(widget); --} -- --static void --moz_gtk_get_combo_box_entry_arrow(GtkWidget *widget, gpointer client_data) --{ -- if (GTK_IS_ARROW(widget)) { -- gComboBoxEntryArrowWidget = widget; -- g_object_add_weak_pointer(G_OBJECT(widget), -- (gpointer *) &gComboBoxEntryArrowWidget); -- gtk_widget_realize(widget); -- } --} -- --static gint --ensure_combo_box_entry_widgets() --{ -- GtkWidget* buttonChild; -- -- if (gComboBoxEntryTextareaWidget && -- gComboBoxEntryButtonWidget && -- gComboBoxEntryArrowWidget) -- return MOZ_GTK_SUCCESS; -- -- /* Create a ComboBoxEntry if needed */ -- if (!gComboBoxEntryWidget) { -- gComboBoxEntryWidget = gtk_combo_box_new_with_entry(); -- setup_widget_prototype(gComboBoxEntryWidget); -- } -- -- /* Get its inner Entry and Button */ -- gtk_container_forall(GTK_CONTAINER(gComboBoxEntryWidget), -- moz_gtk_get_combo_box_entry_inner_widgets, -- NULL); -- -- if (!gComboBoxEntryTextareaWidget) { -- gComboBoxEntryTextareaWidget = GetWidget(MOZ_GTK_ENTRY); -- } -- -- if (gComboBoxEntryButtonWidget) { -- /* Get the Arrow inside the Button */ -- buttonChild = gtk_bin_get_child(GTK_BIN(gComboBoxEntryButtonWidget)); -- if (GTK_IS_BOX(buttonChild)) { -- /* appears-as-list = FALSE, cell-view = TRUE; the button -- * contains an hbox. This hbox is there because the ComboBox -- * needs to place a cell renderer, a separator, and an arrow in -- * the button when appears-as-list is FALSE. */ -- gtk_container_forall(GTK_CONTAINER(buttonChild), -- moz_gtk_get_combo_box_entry_arrow, -- NULL); -- } else if(GTK_IS_ARROW(buttonChild)) { -- /* appears-as-list = TRUE, or cell-view = FALSE; -- * the button only contains an arrow */ -- gComboBoxEntryArrowWidget = buttonChild; -- g_object_add_weak_pointer(G_OBJECT(buttonChild), (gpointer *) -- &gComboBoxEntryArrowWidget); -- gtk_widget_realize(gComboBoxEntryArrowWidget); -- } -- } else { -- /* Shouldn't be reached with current internal gtk implementation; -- * we use a generic toggle button as last resort fallback to avoid -- * crashing. */ -- gComboBoxEntryButtonWidget = GetWidget(MOZ_GTK_TOGGLE_BUTTON); -- } -- -- if (!gComboBoxEntryArrowWidget) { -- /* Shouldn't be reached with current internal gtk implementation; -- * we gButtonArrowWidget as last resort fallback to avoid -- * crashing. */ -- gComboBoxEntryArrowWidget = GetWidget(MOZ_GTK_BUTTON_ARROW); -- } -- -- return MOZ_GTK_SUCCESS; --} -- - gint - moz_gtk_init() - { -@@ -336,16 +124,24 @@ moz_gtk_radio_get_metrics(gint* indicato - return MOZ_GTK_SUCCESS; - } - --gint --moz_gtk_get_focus_outline_size(gint* focus_h_width, gint* focus_v_width) -+static gint -+moz_gtk_get_focus_outline_size(GtkStyleContext* style, -+ gint* focus_h_width, gint* focus_v_width) - { - GtkBorder border; - GtkBorder padding; -- GtkStyleContext *style = ClaimStyleContext(MOZ_GTK_ENTRY); - gtk_style_context_get_border(style, GTK_STATE_FLAG_NORMAL, &border); - gtk_style_context_get_padding(style, GTK_STATE_FLAG_NORMAL, &padding); - *focus_h_width = border.left + padding.left; - *focus_v_width = border.top + padding.top; -+ return MOZ_GTK_SUCCESS; -+} -+ -+gint -+moz_gtk_get_focus_outline_size(gint* focus_h_width, gint* focus_v_width) -+{ -+ GtkStyleContext *style = ClaimStyleContext(MOZ_GTK_ENTRY); -+ moz_gtk_get_focus_outline_size(style, focus_h_width, focus_v_width); - ReleaseStyleContext(style); - return MOZ_GTK_SUCCESS; - } -@@ -364,7 +160,7 @@ moz_gtk_menuitem_get_horizontal_padding( + // GetStateFlagsFromGtkWidgetState() can be safely used for the specific + // GtkWidgets that set both prelight and active flags. For other widgets, + // either the GtkStateFlags or Gecko's GtkWidgetState need to be carefully +@@ -167,7 +171,7 @@ moz_gtk_menuitem_get_horizontal_padding( gint moz_gtk_checkmenuitem_get_horizontal_padding(gint* horizontal_padding) { @@ -279,52 +21,32 @@ diff -up firefox-51.0/widget/gtk/gtk3drawing.cpp.old firefox-51.0/widget/gtk/gtk gtk_style_context_get_style(style, "horizontal-padding", horizontal_padding, nullptr); -@@ -636,8 +432,66 @@ calculate_arrow_rect(GtkWidget* arrow, G - return MOZ_GTK_SUCCESS; +@@ -463,7 +467,7 @@ moz_gtk_get_widget_min_size(WidgetNodeTy } -+void -+moz_gtk_get_widget_min_size(WidgetNodeType aGtkWidgetType, int* width, -+ int* height) -+{ -+ GtkStyleContext* style = ClaimStyleContext(aGtkWidgetType); -+ GtkStateFlags state_flags = gtk_style_context_get_state(style); -+ gtk_style_context_get(style, state_flags, -+ "min-height", height, -+ "min-width", width, -+ nullptr); -+ -+ GtkBorder border, padding, margin; -+ gtk_style_context_get_border(style, state_flags, &border); -+ gtk_style_context_get_padding(style, state_flags, &padding); -+ gtk_style_context_get_margin(style, state_flags, &margin); -+ ReleaseStyleContext(style); -+ -+ *width += border.left + border.right + margin.left + margin.right + -+ padding.left + padding.right; -+ *height += border.top + border.bottom + margin.top + margin.bottom + -+ padding.top + padding.bottom; -+} -+ -+static void + static void +-moz_gtk_rectangle_inset(GdkRectangle* rect, GtkBorder& aBorder) +Inset(GdkRectangle* rect, GtkBorder& aBorder) -+{ -+ MOZ_ASSERT(rect); -+ rect->x += aBorder.left; -+ rect->y += aBorder.top; -+ rect->width -= aBorder.left + aBorder.right; -+ rect->height -= aBorder.top + aBorder.bottom; -+} -+ + { + MOZ_ASSERT(rect); + rect->x += aBorder.left; +@@ -472,17 +476,29 @@ moz_gtk_rectangle_inset(GdkRectangle* re + rect->height -= aBorder.top + aBorder.bottom; + } + +-/* Subtracting margin is used to inset drawing of element which can have margins, +- * like scrollbar, scrollbar's trough, thumb and scrollbar's button */ +// Inset a rectangle by the margins specified in a style context. -+static void + static void +-moz_gtk_subtract_margin(GtkStyleContext* style, GdkRectangle* rect) +InsetByMargin(GdkRectangle* rect, GtkStyleContext* style) -+{ -+ MOZ_ASSERT(rect); -+ GtkBorder margin; -+ -+ gtk_style_context_get_margin(style, gtk_style_context_get_state(style), -+ &margin); + { + MOZ_ASSERT(rect); + GtkBorder margin; + + gtk_style_context_get_margin(style, gtk_style_context_get_state(style), + &margin); +- moz_gtk_rectangle_inset(rect, margin); + Inset(rect, margin); +} + @@ -339,238 +61,37 @@ diff -up firefox-51.0/widget/gtk/gtk3drawing.cpp.old firefox-51.0/widget/gtk/gtk + Inset(rect, padding); + gtk_style_context_get_border(style, state, &border); + Inset(rect, border); -+} -+ - static gint --moz_gtk_scrollbar_button_paint(cairo_t *cr, GdkRectangle* rect, -+moz_gtk_scrollbar_button_paint(cairo_t *cr, const GdkRectangle* aRect, - GtkWidgetState* state, - GtkScrollbarButtonFlags flags, - GtkTextDirection direction) -@@ -675,32 +529,38 @@ moz_gtk_scrollbar_button_paint(cairo_t * - gtk_style_context_add_class(style, GTK_STYLE_CLASS_TOP); - } - -- /* Scrollbar button has to be inset by trough_border because its DOM element -- * is filling width of vertical scrollbar's track (or height in case -- * of horizontal scrollbars). */ -- -- MozGtkScrollbarMetrics metrics; -- moz_gtk_get_scrollbar_metrics(&metrics); -- if (flags & MOZ_GTK_STEPPER_VERTICAL) { -- rect->x += metrics.trough_border; -- rect->width = metrics.slider_width; -+ GdkRectangle rect = *aRect; -+ if (gtk_check_version(3,20,0) == nullptr) { -+ // The "trough-border" is not used since GTK 3.20. The stepper margin -+ // box occupies the full width of the "contents" gadget content box. -+ InsetByMargin(&rect, style); - } else { -- rect->y += metrics.trough_border; -- rect->height = metrics.slider_width; -+ // Scrollbar button has to be inset by trough_border because its DOM -+ // element is filling width of vertical scrollbar's track (or height -+ // in case of horizontal scrollbars). -+ MozGtkScrollbarMetrics metrics; -+ moz_gtk_get_scrollbar_metrics(&metrics); -+ if (flags & MOZ_GTK_STEPPER_VERTICAL) { -+ rect.x += metrics.trough_border; -+ rect.width = metrics.slider_width; -+ } else { -+ rect.y += metrics.trough_border; -+ rect.height = metrics.slider_width; -+ } - } - -- gtk_render_background(style, cr, rect->x, rect->y, rect->width, rect->height); -- gtk_render_frame(style, cr, rect->x, rect->y, rect->width, rect->height); -+ gtk_render_background(style, cr, rect.x, rect.y, rect.width, rect.height); -+ gtk_render_frame(style, cr, rect.x, rect.y, rect.width, rect.height); - -- arrow_rect.width = rect->width / 2; -- arrow_rect.height = rect->height / 2; -+ arrow_rect.width = rect.width / 2; -+ arrow_rect.height = rect.height / 2; - - gfloat arrow_scaling; - gtk_style_context_get_style(style, "arrow-scaling", &arrow_scaling, NULL); - -- gdouble arrow_size = MIN(rect->width, rect->height) * arrow_scaling; -- arrow_rect.x = rect->x + (rect->width - arrow_size) / 2; -- arrow_rect.y = rect->y + (rect->height - arrow_size) / 2; -+ gdouble arrow_size = MIN(rect.width, rect.height) * arrow_scaling; -+ arrow_rect.x = rect.x + (rect.width - arrow_size) / 2; -+ arrow_rect.y = rect.y + (rect.height - arrow_size) / 2; - - if (state_flags & GTK_STATE_FLAG_ACTIVE) { - gtk_style_context_get_style(style, -@@ -742,19 +602,23 @@ moz_gtk_update_scrollbar_style(GtkStyleC - - static void - moz_gtk_draw_styled_frame(GtkStyleContext* style, cairo_t *cr, -- GdkRectangle* rect, bool drawFocus) -+ const GdkRectangle* aRect, bool drawFocus) - { -- gtk_render_background(style, cr, rect->x, rect->y, rect->width, rect->height); -- gtk_render_frame(style, cr, rect->x, rect->y, rect->width, rect->height); -+ GdkRectangle rect = *aRect; -+ if (gtk_check_version(3, 6, 0) == nullptr) { -+ InsetByMargin(&rect, style); -+ } -+ gtk_render_background(style, cr, rect.x, rect.y, rect.width, rect.height); -+ gtk_render_frame(style, cr, rect.x, rect.y, rect.width, rect.height); - if (drawFocus) { - gtk_render_focus(style, cr, -- rect->x, rect->y, rect->width, rect->height); -+ rect.x, rect.y, rect.width, rect.height); - } } static gint - moz_gtk_scrollbar_trough_paint(WidgetNodeType widget, -- cairo_t *cr, GdkRectangle* rect, -+ cairo_t *cr, const GdkRectangle* rect, - GtkWidgetState* state, - GtkScrollbarTrackFlags flags, - GtkTextDirection direction) -@@ -766,26 +630,28 @@ moz_gtk_scrollbar_trough_paint(WidgetNod - ReleaseStyleContext(style); - } - -- bool isHorizontal = (widget == MOZ_GTK_SCROLLBAR_HORIZONTAL); -- GtkStyleContext* style; -+ GtkStyleContext* style = ClaimStyleContext(widget, direction); -+ moz_gtk_draw_styled_frame(style, cr, rect, state->focused); -+ ReleaseStyleContext(style); - -- // Draw all child CSS Nodes for Gtk >= 3.20 -- if (gtk_check_version(3, 20, 0) == nullptr) { -- style = ClaimStyleContext(widget, direction); -- moz_gtk_update_scrollbar_style(style, widget, direction); -- moz_gtk_draw_styled_frame(style, cr, rect, state->focused); -- ReleaseStyleContext(style); -+ return MOZ_GTK_SUCCESS; -+} - -- style = ClaimStyleContext(isHorizontal ? -- MOZ_GTK_SCROLLBAR_CONTENTS_HORIZONTAL : -- MOZ_GTK_SCROLLBAR_CONTENTS_VERTICAL, -- direction); -- moz_gtk_draw_styled_frame(style, cr, rect, state->focused); -- ReleaseStyleContext(style); -- } -- style = ClaimStyleContext(isHorizontal ? -- MOZ_GTK_SCROLLBAR_TROUGH_HORIZONTAL : -- MOZ_GTK_SCROLLBAR_TROUGH_VERTICAL, -+static gint -+moz_gtk_scrollbar_paint(WidgetNodeType widget, -+ cairo_t *cr, const GdkRectangle* rect, -+ GtkWidgetState* state, -+ GtkTextDirection direction) -+{ -+ GtkStyleContext* style = ClaimStyleContext(widget, direction); -+ moz_gtk_update_scrollbar_style(style, widget, direction); -+ -+ moz_gtk_draw_styled_frame(style, cr, rect, state->focused); -+ -+ ReleaseStyleContext(style); -+ style = ClaimStyleContext((widget == MOZ_GTK_SCROLLBAR_HORIZONTAL) ? -+ MOZ_GTK_SCROLLBAR_CONTENTS_HORIZONTAL : -+ MOZ_GTK_SCROLLBAR_CONTENTS_VERTICAL, - direction); - moz_gtk_draw_styled_frame(style, cr, rect, state->focused); - ReleaseStyleContext(style); -@@ -795,21 +661,21 @@ moz_gtk_scrollbar_trough_paint(WidgetNod - - static gint - moz_gtk_scrollbar_thumb_paint(WidgetNodeType widget, -- cairo_t *cr, GdkRectangle* rect, -+ cairo_t *cr, const GdkRectangle* aRect, - GtkWidgetState* state, - GtkTextDirection direction) +@@ -528,7 +544,7 @@ moz_gtk_scrollbar_button_paint(cairo_t * + if (gtk_check_version(3,20,0) == nullptr) { + // The "trough-border" is not used since GTK 3.20. The stepper margin + // box occupies the full width of the "contents" gadget content box. +- moz_gtk_subtract_margin(style, &rect); ++ InsetByMargin(&rect, style); + } else { + // Scrollbar button has to be inset by trough_border because its DOM + // element is filling width of vertical scrollbar's track (or height +@@ -601,7 +617,7 @@ moz_gtk_draw_styled_frame(GtkStyleContex { - GtkStateFlags state_flags = GetStateFlagsFromGtkWidgetState(state); -- GtkBorder margin; + GdkRectangle rect = *aRect; + if (gtk_check_version(3, 6, 0) == nullptr) { +- moz_gtk_subtract_margin(style, &rect); ++ InsetByMargin(&rect, style); + } + gtk_render_background(style, cr, rect.x, rect.y, rect.width, rect.height); + gtk_render_frame(style, cr, rect.x, rect.y, rect.width, rect.height); +@@ -664,7 +680,7 @@ moz_gtk_scrollbar_thumb_paint(WidgetNode -+ GdkRectangle rect = *aRect; + GdkRectangle rect = *aRect; GtkStyleContext* style = ClaimStyleContext(widget, direction, state_flags); -- gtk_style_context_get_margin (style, state_flags, &margin); +- moz_gtk_subtract_margin(style, &rect); + InsetByMargin(&rect, style); gtk_render_slider(style, cr, -- rect->x + margin.left, -- rect->y + margin.top, -- rect->width - margin.left - margin.right, -- rect->height - margin.top - margin.bottom, -+ rect.x, -+ rect.y, -+ rect.width, -+ rect.height, - (widget == MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL) ? - GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL); - -@@ -980,65 +846,31 @@ moz_gtk_vpaned_paint(cairo_t *cr, GdkRec - static gint - moz_gtk_entry_paint(cairo_t *cr, GdkRectangle* rect, - GtkWidgetState* state, -- GtkWidget* widget, GtkTextDirection direction) -+ GtkStyleContext* style) - { - gint x = rect->x, y = rect->y, width = rect->width, height = rect->height; -- GtkStyleContext* style; - int draw_focus_outline_only = state->depressed; // NS_THEME_FOCUS_OUTLINE - -- gtk_widget_set_direction(widget, direction); -- -- style = gtk_widget_get_style_context(widget); -- - if (draw_focus_outline_only) { - // Inflate the given 'rect' with the focus outline size. - gint h, v; -- moz_gtk_get_focus_outline_size(&h, &v); -+ moz_gtk_get_focus_outline_size(style, &h, &v); - rect->x -= h; - rect->width += 2 * h; - rect->y -= v; - rect->height += 2 * v; - width = rect->width; - height = rect->height; -- } -- -- /* gtkentry.c uses two windows, one for the entire widget and one for the -- * text area inside it. The background of both windows is set to the "base" -- * color of the new state in gtk_entry_state_changed, but only the inner -- * textarea window uses gtk_paint_flat_box when exposed */ -- -- /* This gets us a lovely greyish disabledish look */ -- gtk_widget_set_sensitive(widget, !state->disabled); -- -- gtk_style_context_save(style); -- gtk_style_context_add_class(style, GTK_STYLE_CLASS_ENTRY); -- -- /* Now paint the shadow and focus border. -- * We do like in gtk_entry_draw_frame, we first draw the shadow, a tad -- * smaller when focused if the focus is not interior, then the focus. */ -- -- if (state->focused && !state->disabled) { -- /* This will get us the lit borders that focused textboxes enjoy on -- * some themes. */ -- gtk_style_context_set_state(style, GTK_STATE_FLAG_FOCUSED); -- } -- -- if (state->disabled) { -- gtk_style_context_set_state(style, GTK_STATE_FLAG_INSENSITIVE); -- } -- -- if (!draw_focus_outline_only) { -+ } else { - gtk_render_background(style, cr, x, y, width, height); - } - gtk_render_frame(style, cr, x, y, width, height); - -- gtk_style_context_restore(style); -- - return MOZ_GTK_SUCCESS; + rect.x, +@@ -865,7 +881,7 @@ moz_gtk_entry_paint(cairo_t *cr, GdkRect } static gint @@ -579,7 +100,7 @@ diff -up firefox-51.0/widget/gtk/gtk3drawing.cpp.old firefox-51.0/widget/gtk/gtk GtkWidgetState* state, GtkTextDirection direction) { -@@ -1046,24 +878,29 @@ moz_gtk_text_view_paint(cairo_t *cr, Gdk +@@ -882,24 +898,24 @@ moz_gtk_text_view_paint(cairo_t *cr, Gdk GtkStyleContext* style_frame = ClaimStyleContext(MOZ_GTK_SCROLLED_WINDOW, direction, state_flags); @@ -612,169 +133,60 @@ diff -up firefox-51.0/widget/gtk/gtk3drawing.cpp.old firefox-51.0/widget/gtk/gtk + // background behind the text. However, this is transparent in Ambiance + // for GTK 3.20, in which case the MOZ_GTK_TEXT_VIEW background is + // visible. -+ // Workaround for Bug 1328899 - We don't want "selected" background color -+ // for active view class here which is set by Ambiance theme. -+ if (state->focused && !state->disabled) { -+ state_flags = static_cast(GTK_STATE_FLAG_FOCUSED); -+ } + style = ClaimStyleContext(MOZ_GTK_TEXT_VIEW_TEXT, direction, state_flags); + gtk_render_background(style, cr, rect.x, rect.y, rect.width, rect.height); ReleaseStyleContext(style); return MOZ_GTK_SUCCESS; -@@ -1198,34 +1035,37 @@ moz_gtk_combo_box_paint(cairo_t *cr, Gdk - GtkStyleContext* style; - GtkRequisition arrow_req; - -- ensure_combo_box_widgets(); -+ GtkWidget* comboBoxButton = GetWidget(MOZ_GTK_COMBOBOX_BUTTON); -+ GtkWidget* comboBoxArrow = GetWidget(MOZ_GTK_COMBOBOX_ARROW); - - /* Also sets the direction on gComboBoxButtonWidget, which is then - * inherited by the separator and arrow */ - moz_gtk_button_paint(cr, rect, state, GTK_RELIEF_NORMAL, -- gComboBoxButtonWidget, direction); -+ comboBoxButton, direction); - -- calculate_button_inner_rect(gComboBoxButtonWidget, -- rect, &arrow_rect, direction); -+ calculate_button_inner_rect(comboBoxButton, rect, &arrow_rect, direction); - /* Now arrow_rect contains the inner rect ; we want to correct the width - * to what the arrow needs (see gtk_combo_box_size_allocate) */ -- gtk_widget_get_preferred_size(gComboBoxArrowWidget, NULL, &arrow_req); -+ gtk_widget_get_preferred_size(comboBoxArrow, NULL, &arrow_req); -+ - if (direction == GTK_TEXT_DIR_LTR) - arrow_rect.x += arrow_rect.width - arrow_req.width; - arrow_rect.width = arrow_req.width; - -- calculate_arrow_rect(gComboBoxArrowWidget, -+ calculate_arrow_rect(comboBoxArrow, - &arrow_rect, &real_arrow_rect, direction); - -- style = gtk_widget_get_style_context(gComboBoxArrowWidget); -+ style = ClaimStyleContext(MOZ_GTK_COMBOBOX_ARROW); - gtk_render_arrow(style, cr, ARROW_DOWN, - real_arrow_rect.x, real_arrow_rect.y, - real_arrow_rect.width); +@@ -1291,6 +1307,7 @@ moz_gtk_tooltip_paint(cairo_t *cr, const + GdkRectangle rect = *aRect; + gtk_render_background(style, cr, rect.x, rect.y, rect.width, rect.height); + gtk_render_frame(style, cr, rect.x, rect.y, rect.width, rect.height); + ReleaseStyleContext(style); - /* If there is no separator in the theme, there's nothing left to do. */ -- if (!gComboBoxSeparatorWidget) -+ GtkWidget* widget = GetWidget(MOZ_GTK_COMBOBOX_SEPARATOR); -+ if (!widget) - return MOZ_GTK_SUCCESS; -- style = gtk_widget_get_style_context(gComboBoxSeparatorWidget); -+ style = gtk_widget_get_style_context(widget); - gtk_style_context_get_style(style, - "wide-separators", &wide_separators, - "separator-width", &separator_width, -@@ -1309,15 +1149,14 @@ moz_gtk_combo_box_entry_button_paint(cai - GtkStateFlags state_flags = GetStateFlagsFromGtkWidgetState(state); - GtkStyleContext* style; - -- ensure_combo_box_entry_widgets(); -- -+ GtkWidget* comboBoxEntry = GetWidget(MOZ_GTK_COMBOBOX_ENTRY_BUTTON); - moz_gtk_button_paint(cr, rect, state, GTK_RELIEF_NORMAL, -- gComboBoxEntryButtonWidget, direction); -+ comboBoxEntry, direction); -+ calculate_button_inner_rect(comboBoxEntry, rect, &arrow_rect, direction); - -- calculate_button_inner_rect(gComboBoxEntryButtonWidget, -- rect, &arrow_rect, direction); - if (state_flags & GTK_STATE_FLAG_ACTIVE) { -- gtk_style_context_get_style(gtk_widget_get_style_context(gComboBoxEntryButtonWidget), -+ style = gtk_widget_get_style_context(comboBoxEntry); -+ gtk_style_context_get_style(style, - "child-displacement-x", &x_displacement, - "child-displacement-y", &y_displacement, - NULL); -@@ -1325,15 +1164,14 @@ moz_gtk_combo_box_entry_button_paint(cai - arrow_rect.y += y_displacement; - } - -- calculate_arrow_rect(gComboBoxEntryArrowWidget, -+ calculate_arrow_rect(GetWidget(MOZ_GTK_COMBOBOX_ENTRY_ARROW), - &arrow_rect, &real_arrow_rect, direction); - -- style = gtk_widget_get_style_context(gComboBoxEntryArrowWidget); -- -+ style = ClaimStyleContext(MOZ_GTK_COMBOBOX_ENTRY_ARROW); - gtk_render_arrow(style, cr, ARROW_DOWN, - real_arrow_rect.x, real_arrow_rect.y, - real_arrow_rect.width); -- -+ ReleaseStyleContext(style); - return MOZ_GTK_SUCCESS; - } - -@@ -1353,7 +1191,6 @@ moz_gtk_container_paint(cairo_t *cr, Gdk - } - - ReleaseStyleContext(style); -- - return MOZ_GTK_SUCCESS; - } - -@@ -1439,13 +1276,52 @@ moz_gtk_toolbar_separator_paint(cairo_t - } - - static gint --moz_gtk_tooltip_paint(cairo_t *cr, GdkRectangle* rect, -+moz_gtk_tooltip_paint(cairo_t *cr, const GdkRectangle* aRect, - GtkTextDirection direction) - { -+ // Tooltip widget is made in GTK3 as following tree: -+ // Tooltip window -+ // Horizontal Box -+ // Icon (not supported by Firefox) -+ // Label -+ // Each element can be fully styled by CSS of GTK theme. -+ // We have to draw all elements with appropriate offset and right dimensions. -+ -+ // Tooltip drawing - GtkStyleContext* style = ClaimStyleContext(MOZ_GTK_TOOLTIP, direction); -- gtk_render_background(style, cr, rect->x, rect->y, rect->width, rect->height); -- gtk_render_frame(style, cr, rect->x, rect->y, rect->width, rect->height); -- ReleaseStyleContext(style); -+ GdkRectangle rect = *aRect; -+ gtk_render_background(style, cr, rect.x, rect.y, rect.width, rect.height); -+ gtk_render_frame(style, cr, rect.x, rect.y, rect.width, rect.height); -+ ReleaseStyleContext(style); -+ -+ // Horizontal Box drawing -+ // -+ // The box element has hard-coded 6px margin-* GtkWidget properties, which -+ // are added between the window dimensions and the CSS margin box of the -+ // horizontal box. The frame of the tooltip window is drawn in the -+ // 6px margin. -+ // For drawing Horizontal Box we have to inset drawing area by that 6px -+ // plus its CSS margin. + // Horizontal Box drawing + // +@@ -1300,33 +1317,26 @@ moz_gtk_tooltip_paint(cairo_t *cr, const + // 6px margin. + // For drawing Horizontal Box we have to inset drawing area by that 6px + // plus its CSS margin. +- GtkStyleContext* boxStyle = +- CreateStyleForWidget(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0), style); + GtkStyleContext* boxStyle = ClaimStyleContext(MOZ_GTK_TOOLTIP_BOX, direction); -+ -+ rect.x += 6; -+ rect.y += 6; -+ rect.width -= 12; -+ rect.height -= 12; -+ + + rect.x += 6; + rect.y += 6; + rect.width -= 12; + rect.height -= 12; + +- moz_gtk_subtract_margin(boxStyle, &rect); + InsetByMargin(&rect, boxStyle); -+ gtk_render_background(boxStyle, cr, rect.x, rect.y, rect.width, rect.height); -+ gtk_render_frame(boxStyle, cr, rect.x, rect.y, rect.width, rect.height); -+ -+ // Label drawing + gtk_render_background(boxStyle, cr, rect.x, rect.y, rect.width, rect.height); + gtk_render_frame(boxStyle, cr, rect.x, rect.y, rect.width, rect.height); + + // Label drawing +- GtkBorder padding, border; +- gtk_style_context_get_padding(boxStyle, GTK_STATE_FLAG_NORMAL, &padding); +- moz_gtk_rectangle_inset(&rect, padding); +- gtk_style_context_get_border(boxStyle, GTK_STATE_FLAG_NORMAL, &border); +- moz_gtk_rectangle_inset(&rect, border); + InsetByBorderPadding(&rect, boxStyle); + ReleaseStyleContext(boxStyle); -+ -+ GtkStyleContext* labelStyle = + + GtkStyleContext* labelStyle = +- CreateStyleForWidget(gtk_label_new(nullptr), boxStyle); + ClaimStyleContext(MOZ_GTK_TOOLTIP_BOX_LABEL, direction); -+ moz_gtk_draw_styled_frame(labelStyle, cr, &rect, false); + moz_gtk_draw_styled_frame(labelStyle, cr, &rect, false); +- g_object_unref(labelStyle); + ReleaseStyleContext(labelStyle); -+ + +- g_object_unref(boxStyle); +- +- ReleaseStyleContext(style); return MOZ_GTK_SUCCESS; } -@@ -1454,17 +1330,9 @@ moz_gtk_resizer_paint(cairo_t *cr, GdkRe +@@ -1335,17 +1345,9 @@ moz_gtk_resizer_paint(cairo_t *cr, GdkRe GtkWidgetState* state, GtkTextDirection direction) { @@ -795,7 +207,7 @@ diff -up firefox-51.0/widget/gtk/gtk3drawing.cpp.old firefox-51.0/widget/gtk/gtk // Workaround unico not respecting the text direction for resizers. // See bug 1174248. -@@ -1511,17 +1379,8 @@ moz_gtk_progress_chunk_paint(cairo_t *cr +@@ -1392,17 +1394,8 @@ moz_gtk_progress_chunk_paint(cairo_t *cr GtkTextDirection direction, WidgetNodeType widget) { @@ -815,7 +227,7 @@ diff -up firefox-51.0/widget/gtk/gtk3drawing.cpp.old firefox-51.0/widget/gtk/gtk if (widget == MOZ_GTK_PROGRESS_CHUNK_INDETERMINATE || widget == MOZ_GTK_PROGRESS_CHUNK_VERTICAL_INDETERMINATE) { -@@ -1905,6 +1764,13 @@ static gint +@@ -1786,6 +1779,13 @@ static gint moz_gtk_menu_separator_paint(cairo_t *cr, GdkRectangle* rect, GtkTextDirection direction) { @@ -829,7 +241,7 @@ diff -up firefox-51.0/widget/gtk/gtk3drawing.cpp.old firefox-51.0/widget/gtk/gtk GtkStyleContext* style; gboolean wide_separators; gint separator_height; -@@ -1952,36 +1818,39 @@ moz_gtk_menu_item_paint(WidgetNodeType w +@@ -1833,36 +1833,39 @@ moz_gtk_menu_item_paint(WidgetNodeType w GtkWidgetState* state, GtkTextDirection direction) { gint x, y, w, h; @@ -893,7 +305,7 @@ diff -up firefox-51.0/widget/gtk/gtk3drawing.cpp.old firefox-51.0/widget/gtk/gtk return MOZ_GTK_SUCCESS; } -@@ -2001,16 +1870,16 @@ moz_gtk_menu_arrow_paint(cairo_t *cr, Gd +@@ -1882,16 +1885,16 @@ moz_gtk_menu_arrow_paint(cairo_t *cr, Gd return MOZ_GTK_SUCCESS; } @@ -915,7 +327,7 @@ diff -up firefox-51.0/widget/gtk/gtk3drawing.cpp.old firefox-51.0/widget/gtk/gtk gint indicator_size, horizontal_padding; gint x, y; -@@ -2020,35 +1889,44 @@ moz_gtk_check_menu_item_paint(cairo_t *c +@@ -1901,35 +1904,44 @@ moz_gtk_check_menu_item_paint(cairo_t *c state_flags = static_cast(state_flags|checkbox_check_state); } @@ -972,44 +384,7 @@ diff -up firefox-51.0/widget/gtk/gtk3drawing.cpp.old firefox-51.0/widget/gtk/gtk gtk_render_option(style, cr, x, y, indicator_size, indicator_size); } else { gtk_render_check(style, cr, x, y, indicator_size, indicator_size); -@@ -2074,6 +1952,20 @@ moz_gtk_info_bar_paint(cairo_t *cr, GdkR - } - - static void -+moz_gtk_add_style_margin(GtkStyleContext* style, -+ gint* left, gint* top, gint* right, gint* bottom) -+{ -+ GtkBorder margin; -+ -+ gtk_style_context_get_margin(style, GTK_STATE_FLAG_NORMAL, &margin); -+ -+ *left += margin.left; -+ *right += margin.right; -+ *top += margin.top; -+ *bottom += margin.bottom; -+} -+ -+static void - moz_gtk_add_style_border(GtkStyleContext* style, - gint* left, gint* top, gint* right, gint* bottom) - { -@@ -2101,6 +1993,15 @@ moz_gtk_add_style_padding(GtkStyleContex - *bottom += padding.bottom; - } - -+static void moz_gtk_add_margin_border_padding(GtkStyleContext *style, -+ gint* left, gint* top, -+ gint* right, gint* bottom) -+{ -+ moz_gtk_add_style_margin(style, left, top, right, bottom); -+ moz_gtk_add_style_border(style, left, top, right, bottom); -+ moz_gtk_add_style_padding(style, left, top, right, bottom); -+} -+ - gint - moz_gtk_get_widget_border(WidgetNodeType widget, gint* left, gint* top, - gint* right, gint* bottom, GtkTextDirection direction, -@@ -2129,9 +2030,6 @@ moz_gtk_get_widget_border(WidgetNodeType +@@ -2033,9 +2045,6 @@ moz_gtk_get_widget_border(WidgetNodeType if (widget == MOZ_GTK_TOOLBAR_BUTTON) gtk_style_context_restore(style); @@ -1019,67 +394,7 @@ diff -up firefox-51.0/widget/gtk/gtk3drawing.cpp.old firefox-51.0/widget/gtk/gtk moz_gtk_add_style_border(style, left, top, right, bottom); ReleaseStyleContext(style); -@@ -2179,12 +2077,10 @@ moz_gtk_get_widget_border(WidgetNodeType - w = GetWidget(MOZ_GTK_TREE_HEADER_SORTARROW); - break; - case MOZ_GTK_DROPDOWN_ENTRY: -- ensure_combo_box_entry_widgets(); -- w = gComboBoxEntryTextareaWidget; -+ w = GetWidget(MOZ_GTK_COMBOBOX_ENTRY_TEXTAREA); - break; - case MOZ_GTK_DROPDOWN_ARROW: -- ensure_combo_box_entry_widgets(); -- w = gComboBoxEntryButtonWidget; -+ w = GetWidget(MOZ_GTK_COMBOBOX_ENTRY_BUTTON); - break; - case MOZ_GTK_DROPDOWN: - { -@@ -2196,32 +2092,33 @@ moz_gtk_get_widget_border(WidgetNodeType - GtkRequisition arrow_req; - GtkBorder border; - -- ensure_combo_box_widgets(); -- -- *left = *top = *right = *bottom = -- gtk_container_get_border_width(GTK_CONTAINER(gComboBoxButtonWidget)); -- -- style = gtk_widget_get_style_context(gComboBoxButtonWidget); -- -+ *left = *top = *right = *bottom = -+ gtk_container_get_border_width(GTK_CONTAINER( -+ GetWidget(MOZ_GTK_COMBOBOX_BUTTON))); -+ style = ClaimStyleContext(MOZ_GTK_COMBOBOX_BUTTON); - moz_gtk_add_style_padding(style, left, top, right, bottom); - moz_gtk_add_style_border(style, left, top, right, bottom); -+ ReleaseStyleContext(style); - - /* If there is no separator, don't try to count its width. */ - separator_width = 0; -- if (gComboBoxSeparatorWidget) { -- style = gtk_widget_get_style_context(gComboBoxSeparatorWidget); -+ GtkWidget* comboBoxSeparator = GetWidget(MOZ_GTK_COMBOBOX_SEPARATOR); -+ if (comboBoxSeparator) { -+ style = gtk_widget_get_style_context(comboBoxSeparator); - gtk_style_context_get_style(style, - "wide-separators", &wide_separators, - "separator-width", &separator_width, - NULL); - - if (!wide_separators) { -- gtk_style_context_get_border(style, GTK_STATE_FLAG_NORMAL, &border); -+ gtk_style_context_get_border(style, GTK_STATE_FLAG_NORMAL, -+ &border); - separator_width = border.left; - } - } - -- gtk_widget_get_preferred_size(gComboBoxArrowWidget, NULL, &arrow_req); -+ gtk_widget_get_preferred_size(GetWidget(MOZ_GTK_COMBOBOX_ARROW), -+ NULL, &arrow_req); - - if (direction == GTK_TEXT_DIR_RTL) - *left += separator_width + arrow_req.width; -@@ -2271,12 +2168,15 @@ moz_gtk_get_widget_border(WidgetNodeType +@@ -2174,12 +2183,15 @@ moz_gtk_get_widget_border(WidgetNodeType { // Bug 1274143 for MOZ_GTK_MENUBARITEM WidgetNodeType type = @@ -1099,258 +414,106 @@ diff -up firefox-51.0/widget/gtk/gtk3drawing.cpp.old firefox-51.0/widget/gtk/gtk ReleaseStyleContext(style); return MOZ_GTK_SUCCESS; } -@@ -2285,12 +2185,81 @@ moz_gtk_get_widget_border(WidgetNodeType +@@ -2188,7 +2200,6 @@ moz_gtk_get_widget_border(WidgetNodeType break; case MOZ_GTK_TOOLTIP: { - style = ClaimStyleContext(MOZ_GTK_TOOLTIP); -- moz_gtk_add_style_border(style, left, top, right, bottom); -- moz_gtk_add_style_padding(style, left, top, right, bottom); -- ReleaseStyleContext(style); -+ // In GTK 3 there are 6 pixels of additional margin around the box. -+ // See details there: -+ // https://github.com/GNOME/gtk/blob/5ea69a136bd7e4970b3a800390e20314665aaed2/gtk/ui/gtktooltipwindow.ui#L11 -+ *left = *right = *top = *bottom = 6; -+ -+ // We also need to add margin/padding/borders from Tooltip content. -+ // Tooltip contains horizontal box, where icon and label is put. -+ // We ignore icon as long as we don't have support for it. + // In GTK 3 there are 6 pixels of additional margin around the box. + // See details there: + // https://github.com/GNOME/gtk/blob/5ea69a136bd7e4970b3a800390e20314665aaed2/gtk/ui/gtktooltipwindow.ui#L11 +@@ -2197,21 +2208,16 @@ moz_gtk_get_widget_border(WidgetNodeType + // We also need to add margin/padding/borders from Tooltip content. + // Tooltip contains horizontal box, where icon and label is put. + // We ignore icon as long as we don't have support for it. +- GtkStyleContext* boxStyle = +- CreateStyleForWidget(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0), +- style); + GtkStyleContext* boxStyle = ClaimStyleContext(MOZ_GTK_TOOLTIP_BOX); -+ moz_gtk_add_margin_border_padding(boxStyle, -+ left, top, right, bottom); + moz_gtk_add_margin_border_padding(boxStyle, + left, top, right, bottom); + ReleaseStyleContext(boxStyle); -+ + +- GtkStyleContext* labelStyle = +- CreateStyleForWidget(gtk_label_new(nullptr), boxStyle); + GtkStyleContext* labelStyle = ClaimStyleContext(MOZ_GTK_TOOLTIP_BOX_LABEL); -+ moz_gtk_add_margin_border_padding(labelStyle, -+ left, top, right, bottom); + moz_gtk_add_margin_border_padding(labelStyle, + left, top, right, bottom); + ReleaseStyleContext(labelStyle); -+ + +- g_object_unref(labelStyle); +- g_object_unref(boxStyle); +- +- ReleaseStyleContext(style); return MOZ_GTK_SUCCESS; } -+ case MOZ_GTK_SCROLLBAR_VERTICAL: -+ case MOZ_GTK_SCROLLBAR_TROUGH_HORIZONTAL: -+ { -+ if (gtk_check_version(3,20,0) == nullptr) { -+ style = ClaimStyleContext(widget); -+ moz_gtk_add_margin_border_padding(style, left, top, right, bottom); -+ ReleaseStyleContext(style); -+ if (widget == MOZ_GTK_SCROLLBAR_VERTICAL) { -+ style = ClaimStyleContext(MOZ_GTK_SCROLLBAR_CONTENTS_VERTICAL); -+ moz_gtk_add_margin_border_padding(style, left, top, right, bottom); -+ ReleaseStyleContext(style); -+ } -+ } else { -+ MozGtkScrollbarMetrics metrics; -+ moz_gtk_get_scrollbar_metrics(&metrics); -+ /* Top and bottom border for whole vertical scrollbar, top and bottom -+ * border for horizontal track - to correctly position thumb element */ -+ *top = *bottom = metrics.trough_border; -+ } -+ return MOZ_GTK_SUCCESS; -+ } -+ break; -+ -+ case MOZ_GTK_SCROLLBAR_HORIZONTAL: -+ case MOZ_GTK_SCROLLBAR_TROUGH_VERTICAL: -+ { -+ if (gtk_check_version(3,20,0) == nullptr) { -+ style = ClaimStyleContext(widget); -+ moz_gtk_add_margin_border_padding(style, left, top, right, bottom); -+ ReleaseStyleContext(style); -+ if (widget == MOZ_GTK_SCROLLBAR_HORIZONTAL) { -+ style = ClaimStyleContext(MOZ_GTK_SCROLLBAR_CONTENTS_HORIZONTAL); -+ moz_gtk_add_margin_border_padding(style, left, top, right, bottom); -+ ReleaseStyleContext(style); -+ } -+ } else { -+ MozGtkScrollbarMetrics metrics; -+ moz_gtk_get_scrollbar_metrics(&metrics); -+ *left = *right = metrics.trough_border; -+ } -+ return MOZ_GTK_SUCCESS; -+ } -+ break; -+ -+ case MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL: -+ case MOZ_GTK_SCROLLBAR_THUMB_VERTICAL: -+ { -+ if (gtk_check_version(3,20,0) == nullptr) { -+ style = ClaimStyleContext(widget); -+ moz_gtk_add_margin_border_padding(style, left, top, right, bottom); -+ ReleaseStyleContext(style); -+ } -+ return MOZ_GTK_SUCCESS; -+ } -+ break; - /* These widgets have no borders, since they are not containers. */ - case MOZ_GTK_CHECKBUTTON_LABEL: - case MOZ_GTK_RADIOBUTTON_LABEL: -@@ -2299,10 +2268,6 @@ moz_gtk_get_widget_border(WidgetNodeType - case MOZ_GTK_CHECKBUTTON: - case MOZ_GTK_RADIOBUTTON: - case MOZ_GTK_SCROLLBAR_BUTTON: -- case MOZ_GTK_SCROLLBAR_HORIZONTAL: -- case MOZ_GTK_SCROLLBAR_VERTICAL: -- case MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL: -- case MOZ_GTK_SCROLLBAR_THUMB_VERTICAL: - case MOZ_GTK_SCALE_THUMB_HORIZONTAL: - case MOZ_GTK_SCALE_THUMB_VERTICAL: - case MOZ_GTK_GRIPPER: -@@ -2390,9 +2355,9 @@ moz_gtk_get_combo_box_entry_button_size( - * as well as the minimum arrow size and its padding - * */ - GtkRequisition requisition; -- ensure_combo_box_entry_widgets(); - -- gtk_widget_get_preferred_size(gComboBoxEntryButtonWidget, NULL, &requisition); -+ gtk_widget_get_preferred_size(GetWidget(MOZ_GTK_COMBOBOX_ENTRY_BUTTON), -+ NULL, &requisition); - *width = requisition.width; - *height = requisition.height; - -@@ -2421,8 +2386,7 @@ moz_gtk_get_arrow_size(WidgetNodeType wi - GtkWidget* widget; - switch (widgetType) { - case MOZ_GTK_DROPDOWN: -- ensure_combo_box_widgets(); -- widget = gComboBoxArrowWidget; -+ widget = GetWidget(MOZ_GTK_COMBOBOX_ARROW); - break; - default: - widget = GetWidget(MOZ_GTK_BUTTON_ARROW); -@@ -2588,6 +2552,9 @@ moz_gtk_get_scalethumb_metrics(GtkOrient - gint - moz_gtk_get_scrollbar_metrics(MozGtkScrollbarMetrics *metrics) + case MOZ_GTK_SCROLLBAR_VERTICAL: +@@ -2500,11 +2506,11 @@ void + moz_gtk_get_scale_metrics(GtkOrientation orient, gint* scale_width, + gint* scale_height) { -+ // For Gtk >= 3.20 scrollbar metrics are ignored -+ MOZ_ASSERT(gtk_check_version(3, 20, 0) != nullptr); -+ - GtkStyleContext* style = ClaimStyleContext(MOZ_GTK_SCROLLBAR_VERTICAL); - gtk_style_context_get_style(style, - "slider_width", &metrics->slider_width, -@@ -2598,40 +2565,9 @@ moz_gtk_get_scrollbar_metrics(MozGtkScro - nullptr); - ReleaseStyleContext(style); - -- if(!gtk_check_version(3, 20, 0)) { -- style = ClaimStyleContext(MOZ_GTK_SCROLLBAR_THUMB_VERTICAL); -- gtk_style_context_get(style, gtk_style_context_get_state(style), -- "min-height", &metrics->min_slider_size, nullptr); -- ReleaseStyleContext(style); -- } +- WidgetNodeType widget = (orient == GTK_ORIENTATION_HORIZONTAL) ? +- MOZ_GTK_SCALE_HORIZONTAL : +- MOZ_GTK_SCALE_VERTICAL; - - return MOZ_GTK_SUCCESS; + if (gtk_check_version(3, 20, 0) != nullptr) { ++ WidgetNodeType widget = (orient == GTK_ORIENTATION_HORIZONTAL) ? ++ MOZ_GTK_SCALE_HORIZONTAL : ++ MOZ_GTK_SCALE_VERTICAL; ++ + gint thumb_length, thumb_height, trough_border; + moz_gtk_get_scalethumb_metrics(orient, &thumb_length, &thumb_height); + +@@ -2520,12 +2526,10 @@ moz_gtk_get_scale_metrics(GtkOrientation + } + ReleaseStyleContext(style); + } else { +- GtkStyleContext* style = ClaimStyleContext(widget); +- gtk_style_context_get(style, gtk_style_context_get_state(style), +- "min-width", scale_width, +- "min-height", scale_height, +- nullptr); +- ReleaseStyleContext(style); ++ WidgetNodeType widget = (orient == GTK_ORIENTATION_HORIZONTAL) ? ++ MOZ_GTK_SCALE_TROUGH_HORIZONTAL : ++ MOZ_GTK_SCALE_TROUGH_VERTICAL; ++ moz_gtk_get_widget_min_size(widget, scale_width, scale_height); + } } --gboolean --moz_gtk_images_in_menus() --{ -- gboolean result; -- GtkSettings* settings; -- -- settings = gtk_widget_get_settings(GetWidget(MOZ_GTK_IMAGEMENUITEM)); -- -- g_object_get(settings, "gtk-menu-images", &result, NULL); -- return result; --} -- --gboolean --moz_gtk_images_in_buttons() --{ -- gboolean result; -- GtkSettings* settings; -- -- settings = gtk_widget_get_settings(GetWidget(MOZ_GTK_BUTTON)); -- -- g_object_get(settings, "gtk-button-images", &result, NULL); -- return result; --} -- - /* cairo_t *cr argument has to be a system-cairo. */ - gint - moz_gtk_widget_paint(WidgetNodeType widget, cairo_t *cr, -@@ -2672,10 +2608,25 @@ moz_gtk_widget_paint(WidgetNodeType widg - break; - case MOZ_GTK_SCROLLBAR_HORIZONTAL: - case MOZ_GTK_SCROLLBAR_VERTICAL: -- return moz_gtk_scrollbar_trough_paint(widget, cr, rect, -- state, -- (GtkScrollbarTrackFlags) flags, -- direction); -+ if (gtk_check_version(3,20,0) == nullptr) { -+ return moz_gtk_scrollbar_paint(widget, cr, rect, state, direction); -+ } else { -+ WidgetNodeType trough_widget = (widget == MOZ_GTK_SCROLLBAR_HORIZONTAL) ? -+ MOZ_GTK_SCROLLBAR_TROUGH_HORIZONTAL : MOZ_GTK_SCROLLBAR_TROUGH_VERTICAL; -+ return moz_gtk_scrollbar_trough_paint(trough_widget, cr, rect, -+ state, -+ (GtkScrollbarTrackFlags) flags, -+ direction); -+ } -+ break; -+ case MOZ_GTK_SCROLLBAR_TROUGH_HORIZONTAL: -+ case MOZ_GTK_SCROLLBAR_TROUGH_VERTICAL: -+ if (gtk_check_version(3,20,0) == nullptr) { -+ return moz_gtk_scrollbar_trough_paint(widget, cr, rect, -+ state, -+ (GtkScrollbarTrackFlags) flags, -+ direction); -+ } - break; - case MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL: - case MOZ_GTK_SCROLLBAR_THUMB_VERTICAL: -@@ -2702,9 +2653,13 @@ moz_gtk_widget_paint(WidgetNodeType widg - state, direction); - break; - case MOZ_GTK_SPINBUTTON_ENTRY: -- // TODO - use MOZ_GTK_SPINBUTTON_ENTRY style directly -- return moz_gtk_entry_paint(cr, rect, state, -- GetWidget(MOZ_GTK_SPINBUTTON), direction); -+ { -+ GtkStyleContext* style = ClaimStyleContext(MOZ_GTK_SPINBUTTON_ENTRY, -+ direction, GetStateFlagsFromGtkWidgetState(state)); -+ gint ret = moz_gtk_entry_paint(cr, rect, state, style); -+ ReleaseStyleContext(style); -+ return ret; -+ } - break; - case MOZ_GTK_GRIPPER: - return moz_gtk_gripper_paint(cr, rect, state, -@@ -2729,9 +2684,13 @@ moz_gtk_widget_paint(WidgetNodeType widg - (GtkExpanderStyle) flags, direction); - break; - case MOZ_GTK_ENTRY: -- return moz_gtk_entry_paint(cr, rect, state, GetWidget(MOZ_GTK_ENTRY), -- direction); -- break; -+ { -+ GtkStyleContext* style = ClaimStyleContext(MOZ_GTK_ENTRY, -+ direction, GetStateFlagsFromGtkWidgetState(state)); -+ gint ret = moz_gtk_entry_paint(cr, rect, state, style); -+ ReleaseStyleContext(style); -+ return ret; -+ } - case MOZ_GTK_TEXT_VIEW: - return moz_gtk_text_view_paint(cr, rect, state, direction); - break; -@@ -2743,9 +2702,13 @@ moz_gtk_widget_paint(WidgetNodeType widg - state, flags, direction); - break; - case MOZ_GTK_DROPDOWN_ENTRY: -- ensure_combo_box_entry_widgets(); -- return moz_gtk_entry_paint(cr, rect, state, -- gComboBoxEntryTextareaWidget, direction); -+ { -+ GtkStyleContext* style = ClaimStyleContext(MOZ_GTK_COMBOBOX_ENTRY_TEXTAREA, -+ direction, GetStateFlagsFromGtkWidgetState(state)); -+ gint ret = moz_gtk_entry_paint(cr, rect, state, style); -+ ReleaseStyleContext(style); -+ return ret; -+ } - break; - case MOZ_GTK_CHECKBUTTON_CONTAINER: - case MOZ_GTK_RADIOBUTTON_CONTAINER: -@@ -2819,10 +2782,8 @@ moz_gtk_widget_paint(WidgetNodeType widg +@@ -2548,10 +2552,28 @@ moz_gtk_get_scalethumb_metrics(GtkOrient + MOZ_GTK_SCALE_THUMB_HORIZONTAL: + MOZ_GTK_SCALE_THUMB_VERTICAL; + GtkStyleContext* style = ClaimStyleContext(widget); +- gtk_style_context_get(style, gtk_style_context_get_state(style), +- "min-width", thumb_length, +- "min-height", thumb_height, ++ ++ gint min_width, min_height; ++ GtkStateFlags state = gtk_style_context_get_state(style); ++ gtk_style_context_get(style, state, ++ "min-width", &min_width, ++ "min-height", &min_height, + nullptr); ++ GtkBorder margin; ++ gtk_style_context_get_margin(style, state, &margin); ++ gint margin_width = margin.left + margin.right; ++ gint margin_height = margin.top + margin.bottom; ++ ++ // Negative margin of slider element also determines its minimal size ++ // so use bigger of those two values. ++ if (min_width < -margin_width) ++ min_width = -margin_width; ++ if (min_height < -margin_height) ++ min_height = -margin_height; ++ ++ *thumb_length = min_width; ++ *thumb_height = min_height; ++ + ReleaseStyleContext(style); + } + +@@ -2791,10 +2813,8 @@ moz_gtk_widget_paint(WidgetNodeType widg break; case MOZ_GTK_CHECKMENUITEM: case MOZ_GTK_RADIOMENUITEM: @@ -1363,26 +526,9 @@ diff -up firefox-51.0/widget/gtk/gtk3drawing.cpp.old firefox-51.0/widget/gtk/gtk break; case MOZ_GTK_SPLITTER_HORIZONTAL: return moz_gtk_vpaned_paint(cr, rect, state); -@@ -2870,16 +2831,6 @@ moz_gtk_shutdown() - /* This will destroy all of our widgets */ - ResetWidgetCache(); - -- gProtoLayout = NULL; -- gComboBoxWidget = NULL; -- gComboBoxButtonWidget = NULL; -- gComboBoxSeparatorWidget = NULL; -- gComboBoxArrowWidget = NULL; -- gComboBoxEntryWidget = NULL; -- gComboBoxEntryButtonWidget = NULL; -- gComboBoxEntryArrowWidget = NULL; -- gComboBoxEntryTextareaWidget = NULL; -- - is_initialized = FALSE; - - return MOZ_GTK_SUCCESS; -diff -up firefox-51.0/widget/gtk/gtkdrawing.h.old firefox-51.0/widget/gtk/gtkdrawing.h ---- firefox-51.0/widget/gtk/gtkdrawing.h.old 2017-01-16 17:16:53.000000000 +0100 -+++ firefox-51.0/widget/gtk/gtkdrawing.h 2017-01-06 10:20:43.000000000 +0100 +diff -up firefox-52.0/widget/gtk/gtkdrawing.h.widget-rebase firefox-52.0/widget/gtk/gtkdrawing.h +--- firefox-52.0/widget/gtk/gtkdrawing.h.widget-rebase 2017-02-27 17:11:05.000000000 +0100 ++++ firefox-52.0/widget/gtk/gtkdrawing.h 2017-02-06 13:31:12.000000000 +0100 @@ -145,8 +145,11 @@ typedef enum { MOZ_GTK_ENTRY, /* Paints a GtkExpander. */ @@ -1430,72 +576,10 @@ diff -up firefox-51.0/widget/gtk/gtkdrawing.h.old firefox-51.0/widget/gtk/gtkdra MOZ_GTK_MENUSEPARATOR, /* GtkVPaned base class */ MOZ_GTK_SPLITTER_HORIZONTAL, -@@ -230,6 +239,22 @@ typedef enum { - MOZ_GTK_WINDOW_CONTAINER, - /* Paints a GtkInfoBar, for notifications. */ - MOZ_GTK_INFO_BAR, -+ /* Used for widget tree construction. */ -+ MOZ_GTK_COMBOBOX, -+ /* Paints a GtkComboBox button widget. */ -+ MOZ_GTK_COMBOBOX_BUTTON, -+ /* Paints a GtkComboBox arrow widget. */ -+ MOZ_GTK_COMBOBOX_ARROW, -+ /* Paints a GtkComboBox separator widget. */ -+ MOZ_GTK_COMBOBOX_SEPARATOR, -+ /* Used for widget tree construction. */ -+ MOZ_GTK_COMBOBOX_ENTRY, -+ /* Paints a GtkComboBox entry widget. */ -+ MOZ_GTK_COMBOBOX_ENTRY_TEXTAREA, -+ /* Paints a GtkComboBox entry button widget. */ -+ MOZ_GTK_COMBOBOX_ENTRY_BUTTON, -+ /* Paints a GtkComboBox entry arrow widget. */ -+ MOZ_GTK_COMBOBOX_ENTRY_ARROW, - /* Used for scrolled window shell. */ - MOZ_GTK_SCROLLED_WINDOW, - -@@ -505,23 +530,18 @@ gint - moz_gtk_get_tab_thickness(WidgetNodeType aNodeType); - - /** -- * Get a boolean which indicates whether or not to use images in menus. -- * If TRUE, use images in menus. -- */ --gboolean moz_gtk_images_in_menus(void); -- --/** -- * Get a boolean which indicates whether or not to use images in buttons. -- * If TRUE, use images in buttons. -- */ --gboolean moz_gtk_images_in_buttons(void); -- --/** - * Get a boolean which indicates whether the theme draws scrollbar buttons. - * If TRUE, draw scrollbar buttons. - */ - gboolean moz_gtk_has_scrollbar_buttons(void); - -+/** -+ * Get minimum widget size as sum of margin, padding, border and min-width, -+ * min-height. -+ */ -+void moz_gtk_get_widget_min_size(WidgetNodeType aGtkWidgetType, int* width, -+ int* height); -+ - #if (MOZ_WIDGET_GTK == 2) - #ifdef __cplusplus - } -diff -up firefox-51.0/widget/gtk/mozgtk/mozgtk.c.old firefox-51.0/widget/gtk/mozgtk/mozgtk.c ---- firefox-51.0/widget/gtk/mozgtk/mozgtk.c.old 2017-01-18 16:26:11.416376760 +0100 -+++ firefox-51.0/widget/gtk/mozgtk/mozgtk.c 2016-12-21 13:10:28.000000000 +0100 -@@ -9,6 +9,7 @@ STUB(gdk_atom_name) - STUB(gdk_beep) - STUB(gdk_cairo_create) - STUB(gdk_color_free) -+STUB(gdk_color_parse) - STUB(gdk_cursor_new_for_display) - STUB(gdk_cursor_new_from_name) - STUB(gdk_cursor_new_from_pixbuf) -@@ -244,7 +245,6 @@ STUB(gtk_icon_theme_get_icon_sizes) +diff -up firefox-52.0/widget/gtk/mozgtk/mozgtk.c.widget-rebase firefox-52.0/widget/gtk/mozgtk/mozgtk.c +--- firefox-52.0/widget/gtk/mozgtk/mozgtk.c.widget-rebase 2017-02-27 17:11:05.000000000 +0100 ++++ firefox-52.0/widget/gtk/mozgtk/mozgtk.c 2017-03-03 14:27:02.817350951 +0100 +@@ -245,7 +245,6 @@ STUB(gtk_icon_theme_get_icon_sizes) STUB(gtk_icon_theme_lookup_by_gicon) STUB(gtk_icon_theme_lookup_icon) STUB(gtk_image_get_type) @@ -1503,38 +587,18 @@ diff -up firefox-51.0/widget/gtk/mozgtk/mozgtk.c.old firefox-51.0/widget/gtk/moz STUB(gtk_image_new) STUB(gtk_image_new_from_stock) STUB(gtk_image_set_from_pixbuf) -@@ -577,10 +577,10 @@ STUB(gtk_tree_view_column_get_button) - STUB(gtk_widget_get_preferred_size) - STUB(gtk_widget_get_state_flags) - STUB(gtk_widget_get_style_context) --STUB(gtk_widget_path_append_for_widget) - STUB(gtk_widget_path_append_type) - STUB(gtk_widget_path_copy) - STUB(gtk_widget_path_free) -+STUB(gtk_widget_path_iter_add_class) - STUB(gtk_widget_path_new) - STUB(gtk_widget_path_unref) - STUB(gtk_widget_set_visual) -@@ -612,6 +612,9 @@ STUB(gdkx_visual_get) - STUB(gtk_object_get_type) - #endif +diff -up firefox-52.0/widget/gtk/nsLookAndFeel.cpp.widget-rebase firefox-52.0/widget/gtk/nsLookAndFeel.cpp +--- firefox-52.0/widget/gtk/nsLookAndFeel.cpp.widget-rebase 2017-02-27 17:11:05.000000000 +0100 ++++ firefox-52.0/widget/gtk/nsLookAndFeel.cpp 2017-02-28 14:17:22.000000000 +0100 +@@ -24,6 +24,7 @@ + #include "nsStyleConsts.h" + #include "gfxFontConstants.h" + #include "WidgetUtils.h" ++#include "nsIXULRuntime.h" -+#ifndef GTK3_SYMBOLS -+// Only define the following workaround when using GTK3, which we detect -+// by checking if GTK3 stubs are not provided. - #include - // Bug 1271100 - // We need to trick system Cairo into not using the XShm extension due to -@@ -625,4 +628,5 @@ XShmQueryExtension(Display* aDisplay) - { - return False; - } -+#endif + #include -diff -up firefox-51.0/widget/gtk/nsLookAndFeel.cpp.old firefox-51.0/widget/gtk/nsLookAndFeel.cpp ---- firefox-51.0/widget/gtk/nsLookAndFeel.cpp.old 2017-01-18 16:25:23.072605687 +0100 -+++ firefox-51.0/widget/gtk/nsLookAndFeel.cpp 2017-01-06 10:20:43.000000000 +0100 -@@ -47,9 +47,6 @@ nsLookAndFeel::nsLookAndFeel() +@@ -47,9 +48,6 @@ nsLookAndFeel::nsLookAndFeel() : nsXPLookAndFeel(), #if (MOZ_WIDGET_GTK == 2) mStyle(nullptr), @@ -1544,7 +608,7 @@ diff -up firefox-51.0/widget/gtk/nsLookAndFeel.cpp.old firefox-51.0/widget/gtk/n #endif mDefaultFontCached(false), mButtonFontCached(false), mFieldFontCached(false), mMenuFontCached(false) -@@ -61,13 +58,27 @@ nsLookAndFeel::~nsLookAndFeel() +@@ -61,13 +59,27 @@ nsLookAndFeel::~nsLookAndFeel() { #if (MOZ_WIDGET_GTK == 2) g_object_unref(mStyle); @@ -1575,70 +639,7 @@ diff -up firefox-51.0/widget/gtk/nsLookAndFeel.cpp.old firefox-51.0/widget/gtk/n static void GetLightAndDarkness(const GdkRGBA& aColor, double* aLightness, double* aDarkness) -@@ -157,30 +168,55 @@ GetUnicoBorderGradientColors(GtkStyleCon - return result; - } - -- --static void -+// Sets |aLightColor| and |aDarkColor| to colors from |aContext|. Returns -+// true if |aContext| uses these colors to render a visible border. -+// If returning false, then the colors returned are a fallback from the -+// border-color value even though |aContext| does not use these colors to -+// render a border. -+static bool - GetBorderColors(GtkStyleContext* aContext, - GdkRGBA* aLightColor, GdkRGBA* aDarkColor) - { -- if (GetUnicoBorderGradientColors(aContext, aLightColor, aDarkColor)) -- return; -- -+ // Determine whether the border on this style context is visible. - GtkStateFlags state = gtk_style_context_get_state(aContext); -+ GtkBorderStyle borderStyle; -+ gtk_style_context_get(aContext, state, GTK_STYLE_PROPERTY_BORDER_STYLE, -+ &borderStyle, nullptr); -+ bool visible = borderStyle != GTK_BORDER_STYLE_NONE && -+ borderStyle != GTK_BORDER_STYLE_HIDDEN; -+ if (visible) { -+ // GTK has an initial value of zero for border-widths, and so themes -+ // need to explicitly set border-widths to make borders visible. -+ GtkBorder border; -+ gtk_style_context_get_border(aContext, GTK_STATE_FLAG_NORMAL, &border); -+ visible = border.top != 0 || border.right != 0 || -+ border.bottom != 0 || border.left != 0; -+ } -+ -+ if (visible && -+ GetUnicoBorderGradientColors(aContext, aLightColor, aDarkColor)) -+ return true; -+ -+ // The initial value for the border-color is the foreground color, and so -+ // this will usually return a color distinct from the background even if -+ // there is no visible border detected. - gtk_style_context_get_border_color(aContext, state, aDarkColor); - // TODO GTK3 - update aLightColor - // for GTK_BORDER_STYLE_INSET/OUTSET/GROVE/RIDGE border styles. - // https://bugzilla.mozilla.org/show_bug.cgi?id=978172#c25 - *aLightColor = *aDarkColor; -+ return visible; - } - --static void -+static bool - GetBorderColors(GtkStyleContext* aContext, - nscolor* aLightColor, nscolor* aDarkColor) - { - GdkRGBA lightColor, darkColor; -- GetBorderColors(aContext, &lightColor, &darkColor); -+ bool ret = GetBorderColors(aContext, &lightColor, &darkColor); - *aLightColor = GDK_RGBA_TO_NS_RGBA(lightColor); - *aDarkColor = GDK_RGBA_TO_NS_RGBA(darkColor); -+ return ret; - } - #endif - -@@ -352,30 +388,39 @@ nsLookAndFeel::NativeGetColor(ColorID aI +@@ -377,30 +389,39 @@ nsLookAndFeel::NativeGetColor(ColorID aI break; #else // css2 http://www.w3.org/TR/REC-CSS2/ui.html#system-colors @@ -1685,7 +686,7 @@ diff -up firefox-51.0/widget/gtk/nsLookAndFeel.cpp.old firefox-51.0/widget/gtk/n #endif case eColorID_infobackground: // tooltip background color -@@ -496,18 +541,24 @@ nsLookAndFeel::NativeGetColor(ColorID aI +@@ -521,18 +542,24 @@ nsLookAndFeel::NativeGetColor(ColorID aI case eColorID__moz_fieldtext: aColor = sMozFieldText; break; @@ -1715,20 +716,7 @@ diff -up firefox-51.0/widget/gtk/nsLookAndFeel.cpp.old firefox-51.0/widget/gtk/n case eColorID__moz_buttonhovertext: aColor = sButtonHoverText; break; -@@ -784,12 +835,6 @@ nsLookAndFeel::GetIntImpl(IntID aID, int - case eIntID_SpellCheckerUnderlineStyle: - aResult = NS_STYLE_TEXT_DECORATION_STYLE_WAVY; - break; -- case eIntID_ImagesInMenus: -- aResult = moz_gtk_images_in_menus(); -- break; -- case eIntID_ImagesInButtons: -- aResult = moz_gtk_images_in_buttons(); -- break; - case eIntID_MenuBarDrag: - aResult = sMenuSupportsDrag; - break; -@@ -1010,16 +1055,6 @@ nsLookAndFeel::GetFontImpl(FontID aID, n +@@ -1029,16 +1056,6 @@ nsLookAndFeel::GetFontImpl(FontID aID, n return true; } @@ -1745,7 +733,7 @@ diff -up firefox-51.0/widget/gtk/nsLookAndFeel.cpp.old firefox-51.0/widget/gtk/n void nsLookAndFeel::Init() { -@@ -1110,78 +1145,54 @@ nsLookAndFeel::Init() +@@ -1129,78 +1146,60 @@ nsLookAndFeel::Init() g_object_set(settings, dark_setting, FALSE, nullptr); } @@ -1757,7 +745,12 @@ diff -up firefox-51.0/widget/gtk/nsLookAndFeel.cpp.old firefox-51.0/widget/gtk/n - - mButtonStyle = create_context(path); - gtk_style_context_add_class(mButtonStyle, GTK_STYLE_CLASS_BUTTON); -- ++ if (!mozilla::BrowserTabsRemoteAutostart() || XRE_IsContentProcess()) { ++ // disable dark in main when e10s is disabled ++ // disable dark in web content ++ fprintf(stderr, "************** Dark theme disabled **********\n"); ++ } + // Scrollbar colors - style = create_context(path); - gtk_style_context_add_class(style, GTK_STYLE_CLASS_SCROLLBAR); @@ -1847,7 +840,7 @@ diff -up firefox-51.0/widget/gtk/nsLookAndFeel.cpp.old firefox-51.0/widget/gtk/n #endif // button styles -@@ -1192,9 +1203,6 @@ nsLookAndFeel::Init() +@@ -1211,9 +1210,6 @@ nsLookAndFeel::Init() GtkWidget *combobox = gtk_combo_box_new(); GtkWidget *comboboxLabel = gtk_label_new("M"); gtk_container_add(GTK_CONTAINER(combobox), comboboxLabel); @@ -1857,7 +850,7 @@ diff -up firefox-51.0/widget/gtk/nsLookAndFeel.cpp.old firefox-51.0/widget/gtk/n #endif GtkWidget *window = gtk_window_new(GTK_WINDOW_POPUP); GtkWidget *treeView = gtk_tree_view_new(); -@@ -1208,7 +1216,9 @@ nsLookAndFeel::Init() +@@ -1227,7 +1223,9 @@ nsLookAndFeel::Init() gtk_container_add(GTK_CONTAINER(parent), button); gtk_container_add(GTK_CONTAINER(parent), treeView); gtk_container_add(GTK_CONTAINER(parent), linkButton); @@ -1867,7 +860,7 @@ diff -up firefox-51.0/widget/gtk/nsLookAndFeel.cpp.old firefox-51.0/widget/gtk/n gtk_container_add(GTK_CONTAINER(parent), menuBar); gtk_menu_shell_append(GTK_MENU_SHELL(menuBar), menuBarItem); gtk_container_add(GTK_CONTAINER(window), parent); -@@ -1291,11 +1301,19 @@ nsLookAndFeel::Init() +@@ -1310,11 +1308,19 @@ nsLookAndFeel::Init() } #else // Text colors @@ -1892,7 +885,7 @@ diff -up firefox-51.0/widget/gtk/nsLookAndFeel.cpp.old firefox-51.0/widget/gtk/n gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color); sMozFieldText = GDK_RGBA_TO_NS_RGBA(color); -@@ -1308,26 +1326,34 @@ nsLookAndFeel::Init() +@@ -1327,26 +1333,34 @@ nsLookAndFeel::Init() static_cast(GTK_STATE_FLAG_FOCUSED|GTK_STATE_FLAG_SELECTED), &color); sTextSelectedText = GDK_RGBA_TO_NS_RGBA(color); @@ -1936,7 +929,7 @@ diff -up firefox-51.0/widget/gtk/nsLookAndFeel.cpp.old firefox-51.0/widget/gtk/n // GTK's guide to fancy odd row background colors: // 1) Check if a theme explicitly defines an odd row color -@@ -1335,7 +1361,7 @@ nsLookAndFeel::Init() +@@ -1354,7 +1368,7 @@ nsLookAndFeel::Init() // slightly by a hardcoded value (gtkstyle.c) // 3) If neither are defined, take the base background color and // darken that by a hardcoded value @@ -1945,32 +938,17 @@ diff -up firefox-51.0/widget/gtk/nsLookAndFeel.cpp.old firefox-51.0/widget/gtk/n // Get odd row background color gtk_style_context_save(style); -@@ -1343,12 +1369,21 @@ nsLookAndFeel::Init() +@@ -1362,8 +1376,7 @@ nsLookAndFeel::Init() gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, &color); sOddCellBackground = GDK_RGBA_TO_NS_RGBA(color); gtk_style_context_restore(style); +- +- gtk_widget_path_free(path); + ReleaseStyleContext(style); -- gtk_widget_path_free(path); -- -+ // GtkFrame has a "border" subnode on which Adwaita draws the border. -+ // Some themes do not draw on this node but draw a border on the widget -+ // root node, so check the root node if no border is found on the border -+ // node. - style = ClaimStyleContext(MOZ_GTK_FRAME_BORDER); -- GetBorderColors(style, &sFrameOuterLightBorder, &sFrameInnerDarkBorder); -+ bool themeUsesColors = -+ GetBorderColors(style, &sFrameOuterLightBorder, &sFrameInnerDarkBorder); - ReleaseStyleContext(style); -+ if (!themeUsesColors) { -+ style = ClaimStyleContext(MOZ_GTK_FRAME); -+ GetBorderColors(style, &sFrameOuterLightBorder, &sFrameInnerDarkBorder); -+ ReleaseStyleContext(style); -+ } - - // GtkInfoBar - // TODO - Use WidgetCache for it? -@@ -1419,12 +1454,6 @@ nsLookAndFeel::RefreshImpl() + // GtkFrame has a "border" subnode on which Adwaita draws the border. + // Some themes do not draw on this node but draw a border on the widget +@@ -1448,12 +1461,6 @@ nsLookAndFeel::RefreshImpl() #if (MOZ_WIDGET_GTK == 2) g_object_unref(mStyle); mStyle = nullptr; @@ -1983,583 +961,28 @@ diff -up firefox-51.0/widget/gtk/nsLookAndFeel.cpp.old firefox-51.0/widget/gtk/n #endif Init(); -diff -up firefox-51.0/widget/gtk/nsNativeThemeGTK.cpp.old firefox-51.0/widget/gtk/nsNativeThemeGTK.cpp ---- firefox-51.0/widget/gtk/nsNativeThemeGTK.cpp.old 2017-01-16 17:16:53.000000000 +0100 -+++ firefox-51.0/widget/gtk/nsNativeThemeGTK.cpp 2016-10-31 11:52:13.000000000 +0100 -@@ -149,19 +149,15 @@ static void SetWidgetStateSafe(uint8_t * - aSafeVector[key >> 3] |= (1 << (key & 7)); +diff -up firefox-52.0/widget/gtk/nsNativeThemeGTK.cpp.widget-rebase firefox-52.0/widget/gtk/nsNativeThemeGTK.cpp +diff -up firefox-52.0/widget/gtk/nsNativeThemeGTK.h.widget-rebase firefox-52.0/widget/gtk/nsNativeThemeGTK.h +diff -up firefox-52.0/widget/gtk/WidgetStyleCache.cpp.widget-rebase firefox-52.0/widget/gtk/WidgetStyleCache.cpp +--- firefox-52.0/widget/gtk/WidgetStyleCache.cpp.widget-rebase 2017-02-27 17:11:05.000000000 +0100 ++++ firefox-52.0/widget/gtk/WidgetStyleCache.cpp 2017-02-06 13:31:12.000000000 +0100 +@@ -434,15 +434,6 @@ CreateScrolledWindowWidget() } --static GtkTextDirection GetTextDirection(nsIFrame* aFrame) -+/* static */ GtkTextDirection -+nsNativeThemeGTK::GetTextDirection(nsIFrame* aFrame) - { -- if (!aFrame) -- return GTK_TEXT_DIR_NONE; -- -- switch (aFrame->StyleVisibility()->mDirection) { -- case NS_STYLE_DIRECTION_RTL: -- return GTK_TEXT_DIR_RTL; -- case NS_STYLE_DIRECTION_LTR: -- return GTK_TEXT_DIR_LTR; -- } -- -- return GTK_TEXT_DIR_NONE; -+ // IsFrameRTL() treats vertical-rl modes as right-to-left (in addition to -+ // horizontal text with direction=RTL), rather than just considering the -+ // text direction. GtkTextDirection does not have distinct values for -+ // vertical writing modes, but considering the block flow direction is -+ // important for resizers and scrollbar elements, at least. -+ return IsFrameRTL(aFrame) ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR; - } - - // Returns positive for negative margins (otherwise 0). -@@ -429,6 +425,20 @@ nsNativeThemeGTK::GetGtkWidgetAndState(u - else - *aWidgetFlags = 0; - break; -+ case NS_THEME_SCROLLBARTRACK_HORIZONTAL: -+ if (gtk_check_version(3,20,0) == nullptr) { -+ aGtkWidgetType = MOZ_GTK_SCROLLBAR_TROUGH_HORIZONTAL; -+ } else { -+ return false; -+ } -+ break; -+ case NS_THEME_SCROLLBARTRACK_VERTICAL: -+ if (gtk_check_version(3,20,0) == nullptr) { -+ aGtkWidgetType = MOZ_GTK_SCROLLBAR_TROUGH_VERTICAL; -+ } else { -+ return false; -+ } -+ break; - case NS_THEME_SCROLLBARTHUMB_VERTICAL: - aGtkWidgetType = MOZ_GTK_SCROLLBAR_THUMB_VERTICAL; - break; -@@ -1105,14 +1115,7 @@ nsNativeThemeGTK::DrawWidgetBackground(n - { - GtkWidgetState state; - WidgetNodeType gtkWidgetType; -- // For resizer drawing, we want IsFrameRTL, which treats vertical-rl modes -- // as right-to-left (in addition to horizontal text with direction=RTL), -- // rather than just considering the text direction. -- // This will make resizers on vertically-oriented elements render properly. -- GtkTextDirection direction = -- aWidgetType == NS_THEME_RESIZER -- ? (IsFrameRTL(aFrame) ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR) -- : GetTextDirection(aFrame); -+ GtkTextDirection direction = GetTextDirection(aFrame); - gint flags; - if (!GetGtkWidgetAndState(aWidgetType, aFrame, gtkWidgetType, &state, - &flags)) -@@ -1248,6 +1251,21 @@ nsNativeThemeGTK::DrawWidgetBackground(n - return NS_OK; - } - -+WidgetNodeType -+nsNativeThemeGTK::NativeThemeToGtkTheme(uint8_t aWidgetType, nsIFrame* aFrame) -+{ -+ WidgetNodeType gtkWidgetType; -+ gint unusedFlags; -+ -+ if (!GetGtkWidgetAndState(aWidgetType, aFrame, gtkWidgetType, nullptr, -+ &unusedFlags)) -+ { -+ MOZ_ASSERT_UNREACHABLE("Unknown native widget to gtk widget mapping"); -+ return MOZ_GTK_WINDOW; -+ } -+ return gtkWidgetType; -+} -+ - NS_IMETHODIMP - nsNativeThemeGTK::GetWidgetBorder(nsDeviceContext* aContext, nsIFrame* aFrame, - uint8_t aWidgetType, nsIntMargin* aResult) -@@ -1255,24 +1273,6 @@ nsNativeThemeGTK::GetWidgetBorder(nsDevi - GtkTextDirection direction = GetTextDirection(aFrame); - aResult->top = aResult->left = aResult->right = aResult->bottom = 0; - switch (aWidgetType) { -- case NS_THEME_SCROLLBAR_VERTICAL: -- case NS_THEME_SCROLLBARTRACK_HORIZONTAL: -- { -- MozGtkScrollbarMetrics metrics; -- moz_gtk_get_scrollbar_metrics(&metrics); -- /* Top and bottom border for whole vertical scrollbar, top and bottom -- * border for horizontal track - to correctly position thumb element */ -- aResult->top = aResult->bottom = metrics.trough_border; -- } -- break; -- case NS_THEME_SCROLLBAR_HORIZONTAL: -- case NS_THEME_SCROLLBARTRACK_VERTICAL: -- { -- MozGtkScrollbarMetrics metrics; -- moz_gtk_get_scrollbar_metrics(&metrics); -- aResult->left = aResult->right = metrics.trough_border; -- } -- break; - case NS_THEME_TOOLBOX: - // gtk has no toolbox equivalent. So, although we map toolbox to - // gtk's 'toolbar' for purposes of painting the widget background, -@@ -1312,8 +1312,9 @@ nsNativeThemeGTK::GetWidgetBorder(nsDevi - default: - { - WidgetNodeType gtkWidgetType; -+ gint unusedFlags; - if (GetGtkWidgetAndState(aWidgetType, aFrame, gtkWidgetType, nullptr, -- nullptr)) { -+ &unusedFlags)) { - moz_gtk_get_widget_border(gtkWidgetType, &aResult->left, &aResult->top, - &aResult->right, &aResult->bottom, direction, - IsFrameContentNodeInNamespace(aFrame, kNameSpaceID_XHTML)); -@@ -1426,22 +1427,33 @@ nsNativeThemeGTK::GetMinimumWidgetSize(n - case NS_THEME_SCROLLBARBUTTON_UP: - case NS_THEME_SCROLLBARBUTTON_DOWN: - { -- MozGtkScrollbarMetrics metrics; -- moz_gtk_get_scrollbar_metrics(&metrics); -+ if (gtk_check_version(3,20,0) == nullptr) { -+ moz_gtk_get_widget_min_size(MOZ_GTK_SCROLLBAR_BUTTON, -+ &(aResult->width), &(aResult->height)); -+ } else { -+ MozGtkScrollbarMetrics metrics; -+ moz_gtk_get_scrollbar_metrics(&metrics); -+ -+ aResult->width = metrics.slider_width; -+ aResult->height = metrics.stepper_size; -+ } - -- aResult->width = metrics.slider_width; -- aResult->height = metrics.stepper_size; - *aIsOverridable = false; - } - break; - case NS_THEME_SCROLLBARBUTTON_LEFT: - case NS_THEME_SCROLLBARBUTTON_RIGHT: - { -- MozGtkScrollbarMetrics metrics; -- moz_gtk_get_scrollbar_metrics(&metrics); -+ if (gtk_check_version(3,20,0) == nullptr) { -+ moz_gtk_get_widget_min_size(MOZ_GTK_SCROLLBAR_BUTTON, -+ &(aResult->width), &(aResult->height)); -+ } else { -+ MozGtkScrollbarMetrics metrics; -+ moz_gtk_get_scrollbar_metrics(&metrics); - -- aResult->width = metrics.stepper_size; -- aResult->height = metrics.slider_width; -+ aResult->width = metrics.stepper_size; -+ aResult->height = metrics.slider_width; -+ } - *aIsOverridable = false; - } - break; -@@ -1468,39 +1480,65 @@ nsNativeThemeGTK::GetMinimumWidgetSize(n - * the thumb isn't a direct child of the scrollbar, unlike the buttons - * or track. So add a minimum size to the track as well to prevent a - * 0-width scrollbar. */ -- MozGtkScrollbarMetrics metrics; -- moz_gtk_get_scrollbar_metrics(&metrics); -+ if (gtk_check_version(3,20,0) == nullptr) { -+ // Thumb min dimensions to start with -+ WidgetNodeType thumbType = aWidgetType == NS_THEME_SCROLLBAR_VERTICAL ? -+ MOZ_GTK_SCROLLBAR_THUMB_VERTICAL : MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL; -+ moz_gtk_get_widget_min_size(thumbType, &(aResult->width), &(aResult->height)); -+ -+ // Add scrollbar's borders -+ nsIntMargin border; -+ nsNativeThemeGTK::GetWidgetBorder(aFrame->PresContext()->DeviceContext(), -+ aFrame, aWidgetType, &border); -+ aResult->width += border.left + border.right; -+ aResult->height += border.top + border.bottom; -+ -+ // Add track's borders -+ uint8_t trackType = aWidgetType == NS_THEME_SCROLLBAR_VERTICAL ? -+ NS_THEME_SCROLLBARTRACK_VERTICAL : NS_THEME_SCROLLBARTRACK_HORIZONTAL; -+ nsNativeThemeGTK::GetWidgetBorder(aFrame->PresContext()->DeviceContext(), -+ aFrame, trackType, &border); -+ aResult->width += border.left + border.right; -+ aResult->height += border.top + border.bottom; -+ } else { -+ MozGtkScrollbarMetrics metrics; -+ moz_gtk_get_scrollbar_metrics(&metrics); - -- // Require room for the slider in the track if we don't have buttons. -- bool hasScrollbarButtons = moz_gtk_has_scrollbar_buttons(); -+ // Require room for the slider in the track if we don't have buttons. -+ bool hasScrollbarButtons = moz_gtk_has_scrollbar_buttons(); - -- if (aWidgetType == NS_THEME_SCROLLBAR_VERTICAL) { -- aResult->width = metrics.slider_width + 2 * metrics.trough_border; -- if (!hasScrollbarButtons) -- aResult->height = metrics.min_slider_size + 2 * metrics.trough_border; -- } else { -- aResult->height = metrics.slider_width + 2 * metrics.trough_border; -- if (!hasScrollbarButtons) -- aResult->width = metrics.min_slider_size + 2 * metrics.trough_border; -+ if (aWidgetType == NS_THEME_SCROLLBAR_VERTICAL) { -+ aResult->width = metrics.slider_width + 2 * metrics.trough_border; -+ if (!hasScrollbarButtons) -+ aResult->height = metrics.min_slider_size + 2 * metrics.trough_border; -+ } else { -+ aResult->height = metrics.slider_width + 2 * metrics.trough_border; -+ if (!hasScrollbarButtons) -+ aResult->width = metrics.min_slider_size + 2 * metrics.trough_border; -+ } -+ *aIsOverridable = false; - } - -- *aIsOverridable = false; - } - break; - case NS_THEME_SCROLLBARTHUMB_VERTICAL: - case NS_THEME_SCROLLBARTHUMB_HORIZONTAL: - { -- MozGtkScrollbarMetrics metrics; -- moz_gtk_get_scrollbar_metrics(&metrics); -- -- if (aWidgetType == NS_THEME_SCROLLBARTHUMB_VERTICAL) { -- aResult->width = metrics.slider_width; -- aResult->height = metrics.min_slider_size; -+ if (gtk_check_version(3,20,0) == nullptr) { -+ moz_gtk_get_widget_min_size(NativeThemeToGtkTheme(aWidgetType, aFrame), -+ &(aResult->width), &(aResult->height)); - } else { -- aResult->height = metrics.slider_width; -- aResult->width = metrics.min_slider_size; -- } -+ MozGtkScrollbarMetrics metrics; -+ moz_gtk_get_scrollbar_metrics(&metrics); - -+ if (aWidgetType == NS_THEME_SCROLLBARTHUMB_VERTICAL) { -+ aResult->width = metrics.slider_width; -+ aResult->height = metrics.min_slider_size; -+ } else { -+ aResult->height = metrics.slider_width; -+ aResult->width = metrics.min_slider_size; -+ } -+ } - *aIsOverridable = false; - } - break; -diff -up firefox-51.0/widget/gtk/nsNativeThemeGTK.h.old firefox-51.0/widget/gtk/nsNativeThemeGTK.h ---- firefox-51.0/widget/gtk/nsNativeThemeGTK.h.old 2016-07-25 22:22:07.000000000 +0200 -+++ firefox-51.0/widget/gtk/nsNativeThemeGTK.h 2016-10-27 16:22:27.000000000 +0200 -@@ -74,6 +74,7 @@ protected: - virtual ~nsNativeThemeGTK(); - - private: -+ GtkTextDirection GetTextDirection(nsIFrame* aFrame); - gint GetTabMarginPixels(nsIFrame* aFrame); - bool GetGtkWidgetAndState(uint8_t aWidgetType, nsIFrame* aFrame, - WidgetNodeType& aGtkWidgetType, -@@ -82,6 +83,7 @@ private: - nsIntMargin* aExtra); - - void RefreshWidgetWindow(nsIFrame* aFrame); -+ WidgetNodeType NativeThemeToGtkTheme(uint8_t aWidgetType, nsIFrame* aFrame); - - uint8_t mDisabledWidgetTypes[32]; - uint8_t mSafeWidgetStates[1024]; // 256 widgets * 32 bits per widget -diff -up firefox-51.0/widget/gtk/WidgetStyleCache.cpp.old firefox-51.0/widget/gtk/WidgetStyleCache.cpp ---- firefox-51.0/widget/gtk/WidgetStyleCache.cpp.old 2017-01-16 17:16:53.000000000 +0100 -+++ firefox-51.0/widget/gtk/WidgetStyleCache.cpp 2017-01-06 10:20:43.000000000 +0100 -@@ -33,7 +33,6 @@ static GtkWidget* - CreateWindowWidget() - { - GtkWidget *widget = gtk_window_new(GTK_WINDOW_POPUP); -- gtk_widget_realize(widget); - gtk_widget_set_name(widget, "MozillaGtkWidget"); - return widget; - } -@@ -50,7 +49,6 @@ static void - AddToWindowContainer(GtkWidget* widget) - { - gtk_container_add(GTK_CONTAINER(GetWidget(MOZ_GTK_WINDOW_CONTAINER)), widget); -- gtk_widget_realize(widget); - } - - static GtkWidget* -@@ -142,7 +140,6 @@ CreateToolbarWidget() - { - GtkWidget* widget = gtk_toolbar_new(); - gtk_container_add(GTK_CONTAINER(GetWidget(MOZ_GTK_GRIPPER)), widget); -- gtk_widget_realize(widget); - return widget; - } - -@@ -183,7 +180,6 @@ CreateButtonArrowWidget() - { - GtkWidget* widget = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_OUT); - gtk_container_add(GTK_CONTAINER(GetWidget(MOZ_GTK_TOGGLE_BUTTON)), widget); -- gtk_widget_realize(widget); - gtk_widget_show(widget); - return widget; - } -@@ -205,19 +201,235 @@ CreateEntryWidget() - } - - static GtkWidget* --CreateScrolledWindowWidget() -+CreateComboBoxWidget() - { -- GtkWidget* widget = gtk_scrolled_window_new(nullptr, nullptr); -+ GtkWidget* widget = gtk_combo_box_new(); - AddToWindowContainer(widget); - return widget; - } - -+typedef struct -+{ -+ GType type; -+ GtkWidget** widget; -+} GtkInnerWidgetInfo; -+ -+static void -+GetInnerWidget(GtkWidget* widget, gpointer client_data) -+{ -+ auto info = static_cast(client_data); -+ -+ if (G_TYPE_CHECK_INSTANCE_TYPE(widget, info->type)) { -+ *info->widget = widget; -+ } -+} -+ -+static GtkWidget* -+CreateComboBoxButtonWidget() -+{ -+ GtkWidget* comboBox = GetWidget(MOZ_GTK_COMBOBOX); -+ GtkWidget* comboBoxButton = nullptr; -+ -+ /* Get its inner Button */ -+ GtkInnerWidgetInfo info = { GTK_TYPE_TOGGLE_BUTTON, -+ &comboBoxButton }; -+ gtk_container_forall(GTK_CONTAINER(comboBox), -+ GetInnerWidget, &info); -+ -+ if (!comboBoxButton) { -+ /* Shouldn't be reached with current internal gtk implementation; we -+ * use a generic toggle button as last resort fallback to avoid -+ * crashing. */ -+ comboBoxButton = GetWidget(MOZ_GTK_TOGGLE_BUTTON); -+ } else { -+ /* We need to have pointers to the inner widgets (button, separator, arrow) -+ * of the ComboBox to get the correct rendering from theme engines which -+ * special cases their look. Since the inner layout can change, we ask GTK -+ * to NULL our pointers when they are about to become invalid because the -+ * corresponding widgets don't exist anymore. It's the role of -+ * g_object_add_weak_pointer(). -+ * Note that if we don't find the inner widgets (which shouldn't happen), we -+ * fallback to use generic "non-inner" widgets, and they don't need that kind -+ * of weak pointer since they are explicit children of gProtoLayout and as -+ * such GTK holds a strong reference to them. */ -+ g_object_add_weak_pointer(G_OBJECT(comboBoxButton), -+ reinterpret_cast(sWidgetStorage) + -+ MOZ_GTK_COMBOBOX_BUTTON); -+ } -+ -+ return comboBoxButton; -+} -+ -+static GtkWidget* -+CreateComboBoxArrowWidget() -+{ -+ GtkWidget* comboBoxButton = GetWidget(MOZ_GTK_COMBOBOX_BUTTON); -+ GtkWidget* comboBoxArrow = nullptr; -+ -+ /* Get the widgets inside the Button */ -+ GtkWidget* buttonChild = gtk_bin_get_child(GTK_BIN(comboBoxButton)); -+ if (GTK_IS_BOX(buttonChild)) { -+ /* appears-as-list = FALSE, cell-view = TRUE; the button -+ * contains an hbox. This hbox is there because the ComboBox -+ * needs to place a cell renderer, a separator, and an arrow in -+ * the button when appears-as-list is FALSE. */ -+ GtkInnerWidgetInfo info = { GTK_TYPE_ARROW, -+ &comboBoxArrow }; -+ gtk_container_forall(GTK_CONTAINER(buttonChild), -+ GetInnerWidget, &info); -+ } else if (GTK_IS_ARROW(buttonChild)) { -+ /* appears-as-list = TRUE, or cell-view = FALSE; -+ * the button only contains an arrow */ -+ comboBoxArrow = buttonChild; -+ } -+ -+ if (!comboBoxArrow) { -+ /* Shouldn't be reached with current internal gtk implementation; -+ * we gButtonArrowWidget as last resort fallback to avoid -+ * crashing. */ -+ comboBoxArrow = GetWidget(MOZ_GTK_BUTTON_ARROW); -+ } else { -+ g_object_add_weak_pointer(G_OBJECT(comboBoxArrow), -+ reinterpret_cast(sWidgetStorage) + -+ MOZ_GTK_COMBOBOX_ARROW); -+ } -+ -+ return comboBoxArrow; -+} -+ -+static GtkWidget* -+CreateComboBoxSeparatorWidget() -+{ -+ // Ensure to search for separator only once as it can fail -+ // TODO - it won't initialize after ResetWidgetCache() call -+ static bool isMissingSeparator = false; -+ if (isMissingSeparator) -+ return nullptr; -+ -+ /* Get the widgets inside the Button */ -+ GtkWidget* comboBoxSeparator = nullptr; -+ GtkWidget* buttonChild = -+ gtk_bin_get_child(GTK_BIN(GetWidget(MOZ_GTK_COMBOBOX_BUTTON))); -+ if (GTK_IS_BOX(buttonChild)) { -+ /* appears-as-list = FALSE, cell-view = TRUE; the button -+ * contains an hbox. This hbox is there because the ComboBox -+ * needs to place a cell renderer, a separator, and an arrow in -+ * the button when appears-as-list is FALSE. */ -+ GtkInnerWidgetInfo info = { GTK_TYPE_SEPARATOR, -+ &comboBoxSeparator }; -+ gtk_container_forall(GTK_CONTAINER(buttonChild), -+ GetInnerWidget, &info); -+ } -+ -+ if (comboBoxSeparator) { -+ g_object_add_weak_pointer(G_OBJECT(comboBoxSeparator), -+ reinterpret_cast(sWidgetStorage) + -+ MOZ_GTK_COMBOBOX_SEPARATOR); -+ } else { -+ /* comboBoxSeparator may be NULL -+ * when "appears-as-list" = TRUE or "cell-view" = FALSE; -+ * if there is no separator, then we just won't paint it. */ -+ isMissingSeparator = true; -+ } -+ -+ return comboBoxSeparator; -+} -+ -+static GtkWidget* -+CreateComboBoxEntryWidget() -+{ -+ GtkWidget* widget = gtk_combo_box_new_with_entry(); -+ AddToWindowContainer(widget); -+ return widget; -+} -+ -+static GtkWidget* -+CreateComboBoxEntryTextareaWidget() -+{ -+ GtkWidget* comboBoxTextarea = nullptr; -+ -+ /* Get its inner Entry and Button */ -+ GtkInnerWidgetInfo info = { GTK_TYPE_ENTRY, -+ &comboBoxTextarea }; -+ gtk_container_forall(GTK_CONTAINER(GetWidget(MOZ_GTK_COMBOBOX_ENTRY)), -+ GetInnerWidget, &info); -+ -+ if (!comboBoxTextarea) { -+ comboBoxTextarea = GetWidget(MOZ_GTK_ENTRY); -+ } else { -+ g_object_add_weak_pointer(G_OBJECT(comboBoxTextarea), -+ reinterpret_cast(sWidgetStorage) + -+ MOZ_GTK_COMBOBOX_ENTRY); -+ } -+ -+ return comboBoxTextarea; -+} -+ -+static GtkWidget* -+CreateComboBoxEntryButtonWidget() -+{ -+ GtkWidget* comboBoxButton = nullptr; -+ -+ /* Get its inner Entry and Button */ -+ GtkInnerWidgetInfo info = { GTK_TYPE_TOGGLE_BUTTON, -+ &comboBoxButton }; -+ gtk_container_forall(GTK_CONTAINER(GetWidget(MOZ_GTK_COMBOBOX_ENTRY)), -+ GetInnerWidget, &info); -+ -+ if (!comboBoxButton) { -+ comboBoxButton = GetWidget(MOZ_GTK_TOGGLE_BUTTON); -+ } else { -+ g_object_add_weak_pointer(G_OBJECT(comboBoxButton), -+ reinterpret_cast(sWidgetStorage) + -+ MOZ_GTK_COMBOBOX_ENTRY_BUTTON); -+ } -+ -+ return comboBoxButton; -+} -+ static GtkWidget* -CreateTextViewWidget() -+CreateComboBoxEntryArrowWidget() - { +-{ - GtkWidget* widget = gtk_text_view_new(); - gtk_container_add(GTK_CONTAINER(GetWidget(MOZ_GTK_SCROLLED_WINDOW)), - widget); -+ GtkWidget* comboBoxArrow = nullptr; -+ -+ /* Get the Arrow inside the Button */ -+ GtkWidget* buttonChild = -+ gtk_bin_get_child(GTK_BIN(GetWidget(MOZ_GTK_COMBOBOX_ENTRY_BUTTON))); -+ -+ if (GTK_IS_BOX(buttonChild)) { -+ /* appears-as-list = FALSE, cell-view = TRUE; the button -+ * contains an hbox. This hbox is there because the ComboBox -+ * needs to place a cell renderer, a separator, and an arrow in -+ * the button when appears-as-list is FALSE. */ -+ GtkInnerWidgetInfo info = { GTK_TYPE_ARROW, -+ &comboBoxArrow }; -+ gtk_container_forall(GTK_CONTAINER(buttonChild), -+ GetInnerWidget, &info); -+ } else if (GTK_IS_ARROW(buttonChild)) { -+ /* appears-as-list = TRUE, or cell-view = FALSE; -+ * the button only contains an arrow */ -+ comboBoxArrow = buttonChild; -+ } -+ -+ if (!comboBoxArrow) { -+ /* Shouldn't be reached with current internal gtk implementation; -+ * we gButtonArrowWidget as last resort fallback to avoid -+ * crashing. */ -+ comboBoxArrow = GetWidget(MOZ_GTK_BUTTON_ARROW); -+ } else { -+ g_object_add_weak_pointer(G_OBJECT(comboBoxArrow), -+ reinterpret_cast(sWidgetStorage) + -+ MOZ_GTK_COMBOBOX_ENTRY_ARROW); -+ } -+ -+ return comboBoxArrow; -+} -+ -+static GtkWidget* -+CreateScrolledWindowWidget() -+{ -+ GtkWidget* widget = gtk_scrolled_window_new(nullptr, nullptr); -+ AddToWindowContainer(widget); - return widget; - } - -@@ -227,7 +439,6 @@ CreateMenuSeparatorWidget() - GtkWidget* widget = gtk_separator_menu_item_new(); - gtk_menu_shell_append(GTK_MENU_SHELL(GetWidget(MOZ_GTK_MENUPOPUP)), - widget); -- gtk_widget_realize(widget); - return widget; - } - -@@ -306,15 +517,6 @@ CreateVPanedWidget() - } - - static GtkWidget* --CreateImageMenuItemWidget() --{ -- GtkWidget* widget = gtk_image_menu_item_new(); -- gtk_menu_shell_append(GTK_MENU_SHELL(GetWidget(MOZ_GTK_MENUPOPUP)), widget); -- gtk_widget_realize(widget); - return widget; -} - -static GtkWidget* - CreateScaleWidget(GtkOrientation aOrientation) + CreateMenuSeparatorWidget() { - GtkWidget* widget = gtk_scale_new(aOrientation, nullptr); -@@ -380,8 +582,6 @@ CreateWidget(WidgetNodeType aWidgetType) + GtkWidget* widget = gtk_separator_menu_item_new(); +@@ -591,8 +582,6 @@ CreateWidget(WidgetNodeType aWidgetType) return CreateEntryWidget(); case MOZ_GTK_SCROLLED_WINDOW: return CreateScrolledWindowWidget(); @@ -2568,65 +991,13 @@ diff -up firefox-51.0/widget/gtk/WidgetStyleCache.cpp.old firefox-51.0/widget/gt case MOZ_GTK_TREEVIEW: return CreateTreeViewWidget(); case MOZ_GTK_TREE_HEADER_CELL: -@@ -392,14 +592,28 @@ CreateWidget(WidgetNodeType aWidgetType) - return CreateHPanedWidget(); - case MOZ_GTK_SPLITTER_VERTICAL: - return CreateVPanedWidget(); -- case MOZ_GTK_IMAGEMENUITEM: -- return CreateImageMenuItemWidget(); - case MOZ_GTK_SCALE_HORIZONTAL: - return CreateScaleWidget(GTK_ORIENTATION_HORIZONTAL); - case MOZ_GTK_SCALE_VERTICAL: - return CreateScaleWidget(GTK_ORIENTATION_VERTICAL); - case MOZ_GTK_NOTEBOOK: - return CreateNotebookWidget(); -+ case MOZ_GTK_COMBOBOX: -+ return CreateComboBoxWidget(); -+ case MOZ_GTK_COMBOBOX_BUTTON: -+ return CreateComboBoxButtonWidget(); -+ case MOZ_GTK_COMBOBOX_ARROW: -+ return CreateComboBoxArrowWidget(); -+ case MOZ_GTK_COMBOBOX_SEPARATOR: -+ return CreateComboBoxSeparatorWidget(); -+ case MOZ_GTK_COMBOBOX_ENTRY: -+ return CreateComboBoxEntryWidget(); -+ case MOZ_GTK_COMBOBOX_ENTRY_TEXTAREA: -+ return CreateComboBoxEntryTextareaWidget(); -+ case MOZ_GTK_COMBOBOX_ENTRY_BUTTON: -+ return CreateComboBoxEntryButtonWidget(); -+ case MOZ_GTK_COMBOBOX_ENTRY_ARROW: -+ return CreateComboBoxEntryArrowWidget(); - default: - /* Not implemented */ - return nullptr; -@@ -474,9 +688,20 @@ CreateCSSNode(const char* aName, GtkStyl - reinterpret_cast - (dlsym(RTLD_DEFAULT, "gtk_widget_path_iter_set_object_name")); - -- GtkWidgetPath* path = aParentStyle ? -- gtk_widget_path_copy(gtk_style_context_get_path(aParentStyle)) : -- gtk_widget_path_new(); -+ GtkWidgetPath* path; -+ if (aParentStyle) { -+ path = gtk_widget_path_copy(gtk_style_context_get_path(aParentStyle)); -+ // Copy classes from the parent style context to its corresponding node in -+ // the path, because GTK will only match against ancestor classes if they -+ // are on the path. -+ GList* classes = gtk_style_context_list_classes(aParentStyle); -+ for (GList* link = classes; link; link = link->next) { -+ gtk_widget_path_iter_add_class(path, -1, static_cast(link->data)); -+ } -+ g_list_free(classes); -+ } else { -+ path = gtk_widget_path_new(); -+ } - - gtk_widget_path_append_type(path, aType); - -@@ -508,13 +733,38 @@ GetWidgetRootStyle(WidgetNodeType aNodeT +@@ -744,16 +733,38 @@ GetWidgetRootStyle(WidgetNodeType aNodeT case MOZ_GTK_MENUITEM: style = CreateStyleForWidget(gtk_menu_item_new(), MOZ_GTK_MENUPOPUP); break; +- case MOZ_GTK_IMAGEMENUITEM: +- style = CreateStyleForWidget(gtk_image_menu_item_new(), MOZ_GTK_MENUPOPUP); +- break; - case MOZ_GTK_CHECKMENUITEM_CONTAINER: + case MOZ_GTK_CHECKMENUITEM: style = CreateStyleForWidget(gtk_check_menu_item_new(), MOZ_GTK_MENUPOPUP); @@ -2664,18 +1035,7 @@ diff -up firefox-51.0/widget/gtk/WidgetStyleCache.cpp.old firefox-51.0/widget/gt default: GtkWidget* widget = GetWidget(aNodeType); MOZ_ASSERT(widget); -@@ -576,6 +826,10 @@ GetCssNodeStyleInternal(WidgetNodeType a - style = CreateChildCSSNode(GTK_STYLE_CLASS_SLIDER, - MOZ_GTK_SCROLLBAR_TROUGH_VERTICAL); - break; -+ case MOZ_GTK_SCROLLBAR_BUTTON: -+ style = CreateChildCSSNode(GTK_STYLE_CLASS_BUTTON, -+ MOZ_GTK_SCROLLBAR_CONTENTS_VERTICAL); -+ break; - case MOZ_GTK_RADIOBUTTON: - style = CreateChildCSSNode(GTK_STYLE_CLASS_RADIO, - MOZ_GTK_RADIOBUTTON_CONTAINER); -@@ -584,13 +838,13 @@ GetCssNodeStyleInternal(WidgetNodeType a +@@ -827,13 +838,13 @@ GetCssNodeStyleInternal(WidgetNodeType a style = CreateChildCSSNode(GTK_STYLE_CLASS_CHECK, MOZ_GTK_CHECKBUTTON_CONTAINER); break; @@ -2693,7 +1053,7 @@ diff -up firefox-51.0/widget/gtk/WidgetStyleCache.cpp.old firefox-51.0/widget/gt break; case MOZ_GTK_PROGRESS_TROUGH: /* Progress bar background (trough) */ -@@ -601,11 +855,6 @@ GetCssNodeStyleInternal(WidgetNodeType a +@@ -844,11 +855,6 @@ GetCssNodeStyleInternal(WidgetNodeType a style = CreateChildCSSNode("progress", MOZ_GTK_PROGRESS_TROUGH); break; @@ -2705,7 +1065,7 @@ diff -up firefox-51.0/widget/gtk/WidgetStyleCache.cpp.old firefox-51.0/widget/gt case MOZ_GTK_GRIPPER: // TODO - create from CSS node return GetWidgetStyleWithClass(MOZ_GTK_GRIPPER, -@@ -622,10 +871,28 @@ GetCssNodeStyleInternal(WidgetNodeType a +@@ -865,10 +871,28 @@ GetCssNodeStyleInternal(WidgetNodeType a // TODO - create from CSS node return GetWidgetStyleWithClass(MOZ_GTK_SCROLLED_WINDOW, GTK_STYLE_CLASS_FRAME); @@ -2738,7 +1098,7 @@ diff -up firefox-51.0/widget/gtk/WidgetStyleCache.cpp.old firefox-51.0/widget/gt case MOZ_GTK_FRAME_BORDER: style = CreateChildCSSNode("border", MOZ_GTK_FRAME); break; -@@ -728,27 +995,20 @@ GetWidgetStyleInternal(WidgetNodeType aN +@@ -971,27 +995,20 @@ GetWidgetStyleInternal(WidgetNodeType aN case MOZ_GTK_CHECKBUTTON: return GetWidgetStyleWithClass(MOZ_GTK_CHECKBUTTON_CONTAINER, GTK_STYLE_CLASS_CHECK); @@ -2775,7 +1135,7 @@ diff -up firefox-51.0/widget/gtk/WidgetStyleCache.cpp.old firefox-51.0/widget/gt return style; } case MOZ_GTK_GRIPPER: -@@ -763,9 +1023,25 @@ GetWidgetStyleInternal(WidgetNodeType aN +@@ -1006,9 +1023,25 @@ GetWidgetStyleInternal(WidgetNodeType aN case MOZ_GTK_SCROLLED_WINDOW: return GetWidgetStyleWithClass(MOZ_GTK_SCROLLED_WINDOW, GTK_STYLE_CLASS_FRAME); @@ -2804,3 +1164,4 @@ diff -up firefox-51.0/widget/gtk/WidgetStyleCache.cpp.old firefox-51.0/widget/gt case MOZ_GTK_FRAME_BORDER: return GetWidgetRootStyle(MOZ_GTK_FRAME); case MOZ_GTK_TREEVIEW_VIEW: +diff -up firefox-52.0/widget/gtk/WidgetStyleCache.h.widget-rebase firefox-52.0/widget/gtk/WidgetStyleCache.h