From 0664c2e210176d6c27dff5e50bc6416e9e9ac03a Mon Sep 17 00:00:00 2001 From: Matt Woodrow Date: Sat, 30 Jun 2012 15:06:13 +1200 Subject: [PATCH] Bug 539356 - Part 22 - Force a background color when running android reftests. r=roc --- layout/tools/reftest/reftest.js | 4 ++++ widget/android/nsLookAndFeel.cpp | 2 +- widget/android/nsWindow.cpp | 20 ++++++++++++++++++++ widget/android/nsWindow.h | 2 +- 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/layout/tools/reftest/reftest.js b/layout/tools/reftest/reftest.js index a73adacd489..9e0f3910364 100644 --- a/layout/tools/reftest/reftest.js +++ b/layout/tools/reftest/reftest.js @@ -260,6 +260,10 @@ function InitAndStartRefTests() } catch(e) { gDumpLog("REFTEST TEST-UNEXPECTED-FAIL | | EXCEPTION: " + e + "\n"); } + + try { + prefs.setBoolPref("android.widget_paints_background", false); + } catch (e) {} /* set the gLoadTimeout */ try { diff --git a/widget/android/nsLookAndFeel.cpp b/widget/android/nsLookAndFeel.cpp index bf0a36f4049..003613726a9 100644 --- a/widget/android/nsLookAndFeel.cpp +++ b/widget/android/nsLookAndFeel.cpp @@ -98,7 +98,7 @@ nsLookAndFeel::NativeGetColor(ColorID aID, nscolor &aColor) // (except here at least TextSelectBackground and TextSelectForeground) // The CSS2 colors below are used. case eColorID_WindowBackground: - aColor = mSystemColors.colorBackground; + aColor = NS_RGB(0xFF, 0xFF, 0xFF); break; case eColorID_WindowForeground: aColor = mSystemColors.textColorPrimary; diff --git a/widget/android/nsWindow.cpp b/widget/android/nsWindow.cpp index 6db23c40698..b8624b3993f 100644 --- a/widget/android/nsWindow.cpp +++ b/widget/android/nsWindow.cpp @@ -2247,6 +2247,10 @@ nsWindow::DrawWindowUnderlay(LayerManager* aManager, nsIntRect aRect) AndroidGeckoLayerClient& client = AndroidBridge::Bridge()->GetLayerClient(); if (!client.CreateFrame(&jniFrame, mLayerRendererFrame)) return; + + if (!WidgetPaintsBackground()) + return; + if (!client.ActivateProgram(&jniFrame)) return; if (!mLayerRendererFrame.BeginDrawing(&jniFrame)) return; if (!mLayerRendererFrame.DrawBackground(&jniFrame)) return; @@ -2316,5 +2320,21 @@ nsWindow::ScheduleResumeComposition(int width, int height) } } +bool +nsWindow::WidgetPaintsBackground() +{ + static bool sWidgetPaintsBackground = true; + static bool sWidgetPaintsBackgroundPrefCached = false; + + if (!sWidgetPaintsBackgroundPrefCached) { + sWidgetPaintsBackgroundPrefCached = true; + mozilla::Preferences::AddBoolVarCache(&sWidgetPaintsBackground, + "android.widget_paints_background", + true); + } + + return sWidgetPaintsBackground; +} + #endif diff --git a/widget/android/nsWindow.h b/widget/android/nsWindow.h index debb4c63002..af7a21f4529 100644 --- a/widget/android/nsWindow.h +++ b/widget/android/nsWindow.h @@ -158,7 +158,7 @@ public: static void SchedulePauseComposition(); static void ScheduleResumeComposition(int width, int height); - virtual bool WidgetPaintsBackground() { return true; } + virtual bool WidgetPaintsBackground(); #endif protected: