Bug 539356 - Part 22 - Force a background color when running android reftests. r=roc
authorMatt Woodrow <mwoodrow@mozilla.com>
Sat, 30 Jun 2012 15:06:13 +1200
changeset 102824 ba7021170544272ea019fce1323e3475b70a85ff
parent 102823 ef4557011ad31383d15e08379c8a4261e7463b0c
child 102825 3f8e99e9234442b96484b5fe66d9d39e57c63a20
push idunknown
push userunknown
push dateunknown
reviewersroc
bugs539356
milestone16.0a1
Bug 539356 - Part 22 - Force a background color when running android reftests. r=roc
layout/tools/reftest/reftest.js
widget/android/nsLookAndFeel.cpp
widget/android/nsWindow.cpp
widget/android/nsWindow.h
--- a/layout/tools/reftest/reftest.js
+++ b/layout/tools/reftest/reftest.js
@@ -255,16 +255,20 @@ function InitAndStartRefTests()
 {
     /* These prefs are optional, so we don't need to spit an error to the log */
     try {
         var prefs = Components.classes["@mozilla.org/preferences-service;1"].
                     getService(Components.interfaces.nsIPrefBranch);
     } catch(e) {
         gDumpLog("REFTEST TEST-UNEXPECTED-FAIL | | EXCEPTION: " + e + "\n");
     }
+
+    try {
+      prefs.setBoolPref("android.widget_paints_background", false);
+    } catch (e) {}
     
     /* set the gLoadTimeout */
     try {
         gLoadTimeout = prefs.getIntPref("reftest.timeout");
     } catch(e) { 
         gLoadTimeout = 5 * 60 * 1000; //5 minutes as per bug 479518
     }
     
--- a/widget/android/nsLookAndFeel.cpp
+++ b/widget/android/nsLookAndFeel.cpp
@@ -93,17 +93,17 @@ nsLookAndFeel::NativeGetColor(ColorID aI
     // XXX we'll want to use context.obtainStyledAttributes on the java side to
     // get all of these; see TextView.java for a good exmaple.
 
     switch (aID) {
         // These colors don't seem to be used for anything anymore in Mozilla
         // (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;
         break;
     case eColorID_WidgetBackground:
         aColor = mSystemColors.colorBackground;
         break;
     case eColorID_WidgetForeground:
--- a/widget/android/nsWindow.cpp
+++ b/widget/android/nsWindow.cpp
@@ -2242,16 +2242,20 @@ nsWindow::DrawWindowUnderlay(LayerManage
     NS_ABORT_IF_FALSE(env, "No JNI environment at DrawWindowUnderlay()!");
     if (!env)
         return;
 
     AutoLocalJNIFrame jniFrame(env);
 
     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;
     if (!client.DeactivateProgram(&jniFrame)) return; // redundant, but in case somebody adds code after this...
 }
 
 void
 nsWindow::DrawWindowOverlay(LayerManager* aManager, nsIntRect aRect)
@@ -2311,10 +2315,26 @@ nsWindow::SchedulePauseComposition()
 void
 nsWindow::ScheduleResumeComposition(int width, int height)
 {
     if (sCompositorParent) {
         sCompositorParent->ScheduleResumeOnCompositorThread(width, 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
 
--- a/widget/android/nsWindow.h
+++ b/widget/android/nsWindow.h
@@ -153,17 +153,17 @@ public:
 
     static void SetCompositor(mozilla::layers::CompositorParent* aCompositorParent,
                               mozilla::layers::CompositorChild* aCompositorChild,
                               ::base::Thread* aCompositorThread);
     static void ScheduleComposite();
     static void SchedulePauseComposition();
     static void ScheduleResumeComposition(int width, int height);
 
-    virtual bool WidgetPaintsBackground() { return true; }
+    virtual bool WidgetPaintsBackground();
 #endif
 
 protected:
     void BringToFront();
     nsWindow *FindTopLevel();
     bool DrawTo(gfxASurface *targetSurface);
     bool DrawTo(gfxASurface *targetSurface, const nsIntRect &aRect);
     bool IsTopLevel();