Bug 1084093, part 3 - Use the new ToDeviceColor() function to undo the breakage to gfx.color_management.mode=1 (eCMSMode_All) caused by the Moz2D porting work. r=Bas
authorJonathan Watt <jwatt@jwatt.org>
Fri, 17 Oct 2014 12:53:16 +0100
changeset 237446 8714fdc213ca6bed614ee7981e1fe9f83e7cb67a
parent 237445 6d94aa5503e5b59595991819d5bc61d0522fc185
child 237447 f7f5057765f9deb55a635bb85a0be8a4d2495a90
push id660
push userraliiev@mozilla.com
push dateWed, 18 Feb 2015 20:30:48 +0000
treeherdermozilla-release@49e493494178 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersBas
bugs1084093
milestone36.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1084093, part 3 - Use the new ToDeviceColor() function to undo the breakage to gfx.color_management.mode=1 (eCMSMode_All) caused by the Moz2D porting work. r=Bas
dom/canvas/CanvasRenderingContext2D.cpp
dom/plugins/ipc/PluginInstanceChild.cpp
gfx/thebes/gfxPattern.cpp
layout/base/nsCSSRenderingBorders.cpp
layout/base/nsCSSRenderingBorders.h
layout/forms/nsComboboxControlFrame.cpp
layout/forms/nsGfxRadioControlFrame.cpp
layout/generic/nsBulletFrame.cpp
layout/generic/nsImageFrame.cpp
layout/mathml/nsMathMLmencloseFrame.cpp
layout/svg/SVGTextFrame.cpp
layout/svg/nsSVGPathGeometryFrame.cpp
layout/svg/nsSVGUtils.cpp
layout/xul/tree/nsTreeBodyFrame.cpp
--- a/dom/canvas/CanvasRenderingContext2D.cpp
+++ b/dom/canvas/CanvasRenderingContext2D.cpp
@@ -231,17 +231,17 @@ public:
   {
     // This should only be called once or the mPattern destructor will
     // not be executed.
     NS_ASSERTION(!mPattern.GetPattern(), "ForStyle() should only be called once on CanvasGeneralPattern!");
 
     const ContextState &state = aCtx->CurrentState();
 
     if (state.StyleIsColor(aStyle)) {
-      mPattern.InitColorPattern(Color::FromABGR(state.colorStyles[aStyle]));
+      mPattern.InitColorPattern(ToDeviceColor(state.colorStyles[aStyle]));
     } else if (state.gradientStyles[aStyle] &&
                state.gradientStyles[aStyle]->GetType() == CanvasGradient::Type::LINEAR) {
       CanvasLinearGradient *gradient =
         static_cast<CanvasLinearGradient*>(state.gradientStyles[aStyle].get());
 
       mPattern.InitLinearGradientPattern(gradient->mBegin, gradient->mEnd,
                                          gradient->GetGradientStopsForTarget(aRT));
     } else if (state.gradientStyles[aStyle] &&
--- a/dom/plugins/ipc/PluginInstanceChild.cpp
+++ b/dom/plugins/ipc/PluginInstanceChild.cpp
@@ -3193,17 +3193,17 @@ PluginInstanceChild::PaintRectToSurface(
 
     if (mIsTransparent && !CanPaintOnBackground()) {
         RefPtr<DrawTarget> dt = CreateDrawTargetForSurface(renderSurface);
         gfx::Rect rect(plPaintRect.x, plPaintRect.y,
                        plPaintRect.width, plPaintRect.height);
         // Moz2D treats OP_SOURCE operations as unbounded, so we need to
         // clip to the rect that we want to fill:
         dt->PushClipRect(rect);
-        dt->FillRect(rect, ColorPattern(ToColor(aColor)),
+        dt->FillRect(rect, ColorPattern(ToColor(aColor)), // aColor is already a device color
                      DrawOptions(1.f, CompositionOp::OP_SOURCE));
         dt->PopClip();
         dt->Flush();
     }
 
     PaintRectToPlatformSurface(plPaintRect, renderSurface);
 
     if (renderSurface != aSurface) {
--- a/gfx/thebes/gfxPattern.cpp
+++ b/gfx/thebes/gfxPattern.cpp
@@ -17,17 +17,17 @@
 
 #include <vector>
 
 using namespace mozilla::gfx;
 
 gfxPattern::gfxPattern(const gfxRGBA& aColor)
   : mExtend(EXTEND_NONE)
 {
-  mGfxPattern.InitColorPattern(Color(aColor.r, aColor.g, aColor.b, aColor.a));
+  mGfxPattern.InitColorPattern(ToDeviceColor(aColor));
 }
 
 // linear
 gfxPattern::gfxPattern(gfxFloat x0, gfxFloat y0, gfxFloat x1, gfxFloat y1)
   : mExtend(EXTEND_NONE)
 {
   mGfxPattern.InitLinearGradientPattern(Point(x0, y0), Point(x1, y1), nullptr);
 }
--- a/layout/base/nsCSSRenderingBorders.cpp
+++ b/layout/base/nsCSSRenderingBorders.cpp
@@ -1,23 +1,25 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 // vim:cindent:ts=2:et:sw=2:
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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 "nsCSSRenderingBorders.h"
+
+#include "gfxUtils.h"
 #include "nsStyleConsts.h"
 #include "nsCSSColorUtils.h"
 #include "GeckoProfiler.h"
 #include "nsExpirationTracker.h"
 #include "RoundedRect.h"
 #include "nsClassHashtable.h"
 #include "nsStyleStruct.h"
 #include "gfxContext.h"
-#include "nsCSSRenderingBorders.h"
 #include "mozilla/gfx/2D.h"
 #include "gfx2DGlue.h"
 #include "gfxGradientCache.h"
 #include <algorithm>
 
 using namespace mozilla;
 using namespace mozilla::gfx;
 
@@ -1245,27 +1247,27 @@ nsCSSBorderRenderer::DrawNoCompositeColo
     strokeStart.x += centerAdjusts[i].a * mBorderWidths[i];
     strokeStart.y += centerAdjusts[i].b * mBorderWidths[i];
     strokeEnd.x += centerAdjusts[i].a * mBorderWidths[i];
     strokeEnd.y += centerAdjusts[i].b * mBorderWidths[i];
 
     builder->MoveTo(strokeStart);
     builder->LineTo(strokeEnd);
     RefPtr<Path> path = builder->Finish();
-    dt->Stroke(path, ColorPattern(Color::FromABGR(mBorderColors[i])), StrokeOptions(mBorderWidths[i]));
+    dt->Stroke(path, ColorPattern(ToDeviceColor(mBorderColors[i])), StrokeOptions(mBorderWidths[i]));
     builder = nullptr;
     path = nullptr;
 
     Pattern *pattern;
 
     if (firstColor != secondColor) {
       gradPat.mStops = CreateCornerGradient(c, firstColor, secondColor, dt, gradPat.mBegin, gradPat.mEnd);
       pattern = &gradPat;
     } else {
-      colorPat.mColor = Color::FromABGR(firstColor);
+      colorPat.mColor = ToDeviceColor(firstColor);
       pattern = &colorPat;
     }
 
     builder = dt->CreatePathBuilder();
 
     if (mBorderRadii[c].width > 0 && mBorderRadii[c].height > 0) {
       p0.x = pc.x + cornerMults[i].a * mBorderRadii[c].width;
       p0.y = pc.y + cornerMults[i].b * mBorderRadii[c].height;
--- a/layout/base/nsCSSRenderingBorders.h
+++ b/layout/base/nsCSSRenderingBorders.h
@@ -2,21 +2,26 @@
 // vim:cindent:ts=2:et:sw=2:
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 #ifndef NS_CSS_RENDERING_BORDERS_H
 #define NS_CSS_RENDERING_BORDERS_H
 
+#include "gfxRect.h"
+#include "mozilla/RefPtr.h"
 #include "nsColor.h"
+#include "nsCOMPtr.h"
+#include "nsStyleConsts.h"
 
 class gfxContext;
 class gfxPattern;
 struct gfxRGBA;
+struct nsBorderColors;
 
 namespace mozilla {
 namespace gfx {
 class GradientStops;
 }
 }
 
 // define this to enable a bunch of debug dump info
--- a/layout/forms/nsComboboxControlFrame.cpp
+++ b/layout/forms/nsComboboxControlFrame.cpp
@@ -1,15 +1,16 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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 "nsComboboxControlFrame.h"
 
+#include "gfxUtils.h"
 #include "mozilla/gfx/2D.h"
 #include "mozilla/gfx/PathHelpers.h"
 #include "nsCOMPtr.h"
 #include "nsFocusManager.h"
 #include "nsFormControlFrame.h"
 #include "nsGkAtoms.h"
 #include "nsCSSAnonBoxes.h"
 #include "nsHTMLParts.h"
@@ -1512,17 +1513,17 @@ void nsComboboxControlFrame::PaintFocus(
   // already painted it in the children above. So clipping it here won't do
   // us much good.
 
   /////////////////////
   // draw focus
 
   StrokeOptions strokeOptions;
   nsLayoutUtils::InitDashPattern(strokeOptions, NS_STYLE_BORDER_STYLE_DOTTED);
-  ColorPattern color(nsLayoutUtils::NSColorToColor(StyleColor()->mColor));
+  ColorPattern color(ToDeviceColor(StyleColor()->mColor));
   nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1);
   clipRect.width -= onePixel;
   clipRect.height -= onePixel;
   Rect r =
     ToRect(nsLayoutUtils::RectToGfxRect(clipRect, PresContext()->AppUnitsPerDevPixel()));
   StrokeSnappedEdgesOfRect(r, *aRenderingContext.GetDrawTarget(),
                            color, strokeOptions);
 
--- a/layout/forms/nsGfxRadioControlFrame.cpp
+++ b/layout/forms/nsGfxRadioControlFrame.cpp
@@ -1,16 +1,17 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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 "nsGfxRadioControlFrame.h"
 
 #include "gfx2DGlue.h"
+#include "gfxUtils.h"
 #include "mozilla/gfx/2D.h"
 #include "mozilla/gfx/PathHelpers.h"
 #include "nsLayoutUtils.h"
 #include "nsRenderingContext.h"
 #include "nsDisplayList.h"
 
 using namespace mozilla;
 using namespace mozilla::gfx;
@@ -54,17 +55,17 @@ PaintCheckedRadioButton(nsIFrame* aFrame
   rect.Deflate(aFrame->GetUsedBorderAndPadding());
   rect.Deflate(nsPresContext::CSSPixelsToAppUnits(2),
                nsPresContext::CSSPixelsToAppUnits(2));
 
   Rect devPxRect =
     ToRect(nsLayoutUtils::RectToGfxRect(rect,
                                         aFrame->PresContext()->AppUnitsPerDevPixel()));
 
-  ColorPattern color(nsLayoutUtils::NSColorToColor(aFrame->StyleColor()->mColor));
+  ColorPattern color(ToDeviceColor(aFrame->StyleColor()->mColor));
 
   DrawTarget* drawTarget = aCtx->GetDrawTarget();
   RefPtr<PathBuilder> builder = drawTarget->CreatePathBuilder();
   AppendEllipseToPath(builder, devPxRect.Center(), devPxRect.Size());
   RefPtr<Path> ellipse = builder->Finish();
   drawTarget->Fill(ellipse, color);
 }
 
--- a/layout/generic/nsBulletFrame.cpp
+++ b/layout/generic/nsBulletFrame.cpp
@@ -3,16 +3,17 @@
  * 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/. */
 
 /* rendering object for list-item bullets */
 
 #include "nsBulletFrame.h"
 
 #include "gfx2DGlue.h"
+#include "gfxUtils.h"
 #include "mozilla/gfx/2D.h"
 #include "mozilla/gfx/PathHelpers.h"
 #include "mozilla/MathAlgorithms.h"
 #include "nsCOMPtr.h"
 #include "nsGkAtoms.h"
 #include "nsGenericHTMLElement.h"
 #include "nsAttrValueInlines.h"
 #include "nsPresContext.h"
@@ -311,19 +312,19 @@ nsBulletFrame::PaintBullet(nsRenderingCo
              imageCon, nsLayoutUtils::GetGraphicsFilterForFrame(this),
              dest + aPt, aDirtyRect, nullptr, aFlags);
         return;
       }
     }
   }
 
   nsRefPtr<nsFontMetrics> fm;
-  nscolor col = nsLayoutUtils::GetColor(this, eCSSProperty_color);
-  Color color = nsLayoutUtils::NSColorToColor(col);
-  aRenderingContext.SetColor(col);
+  ColorPattern color(ToDeviceColor(
+                       nsLayoutUtils::GetColor(this, eCSSProperty_color)));
+  aRenderingContext.SetColor(nsLayoutUtils::GetColor(this, eCSSProperty_color));
 
   nsAutoString text;
   switch (listStyleType->GetStyle()) {
   case NS_STYLE_LIST_STYLE_NONE:
     break;
 
   case NS_STYLE_LIST_STYLE_DISC:
   case NS_STYLE_LIST_STYLE_CIRCLE:
@@ -334,19 +335,19 @@ nsBulletFrame::PaintBullet(nsRenderingCo
                   mRect.height - (padding.top + padding.bottom));
       Rect devPxRect =
         ToRect(nsLayoutUtils::RectToGfxRect(rect, PresContext()->AppUnitsPerDevPixel()));
       DrawTarget* drawTarget = aRenderingContext.GetDrawTarget();
       RefPtr<PathBuilder> builder = drawTarget->CreatePathBuilder();
       AppendEllipseToPath(builder, devPxRect.Center(), devPxRect.Size());
       RefPtr<Path> ellipse = builder->Finish();
       if (listStyleType->GetStyle() == NS_STYLE_LIST_STYLE_DISC) {
-        drawTarget->Fill(ellipse, ColorPattern(color));
+        drawTarget->Fill(ellipse, color);
       } else {
-        drawTarget->Stroke(ellipse, ColorPattern(color));
+        drawTarget->Stroke(ellipse, color);
       }
     }
     break;
 
   case NS_STYLE_LIST_STYLE_SQUARE:
     {
       nsRect rect(aPt, mRect.Size());
       rect.Deflate(padding);
--- a/layout/generic/nsImageFrame.cpp
+++ b/layout/generic/nsImageFrame.cpp
@@ -3,16 +3,17 @@
  * 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/. */
 
 /* rendering object for replaced elements with image data */
 
 #include "nsImageFrame.h"
 
 #include "gfx2DGlue.h"
+#include "gfxUtils.h"
 #include "mozilla/DebugOnly.h"
 #include "mozilla/EventStates.h"
 #include "mozilla/gfx/2D.h"
 #include "mozilla/gfx/Helpers.h"
 #include "mozilla/gfx/PathHelpers.h"
 #include "mozilla/MouseEvents.h"
 
 #include "nsCOMPtr.h"
@@ -1254,17 +1255,17 @@ nsImageFrame::DisplayAltFeedback(nsRende
         nsLayoutUtils::GetGraphicsFilterForFrame(this), dest, aDirtyRect,
         nullptr, imgIContainer::FLAG_NONE);
       iconUsed = true;
     }
 
     // if we could not draw the icon, flag that we're waiting for it and
     // just draw some graffiti in the mean time
     if (!iconUsed) {
-      ColorPattern color(Color(1.f, 0.f, 0.f, 1.f));
+      ColorPattern color(ToDeviceColor(Color(1.f, 0.f, 0.f, 1.f)));
       DrawTarget* drawTarget = aRenderingContext.GetDrawTarget();
 
       nscoord iconXPos = (vis->mDirection ==   NS_STYLE_DIRECTION_RTL) ?
                          inner.XMost() - size : inner.x;
 
       // stroked rect:
       nsRect rect(iconXPos, inner.y, size, size);
       Rect devPxRect =
@@ -1314,17 +1315,17 @@ static void PaintDebugImageMap(nsIFrame*
   gfxPoint devPixelOffset =
     nsLayoutUtils::PointToGfxPoint(inner.TopLeft(),
                                    aFrame->PresContext()->AppUnitsPerDevPixel());
   DrawTarget* drawTarget = aCtx->GetDrawTarget();
   AutoRestoreTransform autoRestoreTransform(drawTarget);
   drawTarget->SetTransform(
     drawTarget->GetTransform().PreTranslate(ToPoint(devPixelOffset)));
   f->GetImageMap()->Draw(aFrame, *drawTarget,
-                         ColorPattern(Color(0.f, 0.f, 0.f, 1.f)));
+                         ColorPattern(ToDeviceColor(Color(0.f, 0.f, 0.f, 1.f))));
 }
 #endif
 
 void
 nsDisplayImage::Paint(nsDisplayListBuilder* aBuilder,
                       nsRenderingContext* aCtx) {
   uint32_t flags = imgIContainer::FLAG_NONE;
   if (aBuilder->ShouldSyncDecodeImages()) {
@@ -1491,22 +1492,24 @@ nsImageFrame::PaintImage(nsRenderingCont
     gfxPoint devPixelOffset =
       nsLayoutUtils::PointToGfxPoint(inner.TopLeft(),
                                      PresContext()->AppUnitsPerDevPixel());
     AutoRestoreTransform autoRestoreTransform(drawTarget);
     drawTarget->SetTransform(
       drawTarget->GetTransform().PreTranslate(ToPoint(devPixelOffset)));
 
     // solid white stroke:
-    map->Draw(this, *drawTarget, ColorPattern(Color(1.f, 1.f, 1.f, 1.f)));
+    Color white(1.f, 1.f, 1.f, 1.f);
+    map->Draw(this, *drawTarget, ColorPattern(ToDeviceColor(white)));
 
     // then dashed black stroke over the top:
     StrokeOptions strokeOptions;
     nsLayoutUtils::InitDashPattern(strokeOptions, NS_STYLE_BORDER_STYLE_DOTTED);
-    map->Draw(this, *drawTarget, ColorPattern(Color(0.f, 0.f, 0.f, 1.f)),
+    Color black(0.f, 0.f, 0.f, 1.f);
+    map->Draw(this, *drawTarget, ColorPattern(ToDeviceColor(black)),
               strokeOptions);
   }
 }
 
 void
 nsImageFrame::BuildDisplayList(nsDisplayListBuilder*   aBuilder,
                                const nsRect&           aDirtyRect,
                                const nsDisplayListSet& aLists)
--- a/layout/mathml/nsMathMLmencloseFrame.cpp
+++ b/layout/mathml/nsMathMLmencloseFrame.cpp
@@ -1,16 +1,17 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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 "nsMathMLmencloseFrame.h"
 
 #include "gfx2DGlue.h"
+#include "gfxUtils.h"
 #include "mozilla/gfx/2D.h"
 #include "mozilla/gfx/PathHelpers.h"
 #include "nsPresContext.h"
 #include "nsRenderingContext.h"
 #include "nsWhitespaceTokenizer.h"
 
 #include "nsDisplayList.h"
 #include "gfxContext.h"
@@ -766,19 +767,19 @@ private:
 void nsDisplayNotation::Paint(nsDisplayListBuilder* aBuilder,
                               nsRenderingContext* aCtx)
 {
   // get the gfxRect
   nsPresContext* presContext = mFrame->PresContext();
   gfxRect rect = presContext->AppUnitsToGfxUnits(mRect + ToReferenceFrame());
 
   // paint the frame with the current text color
-  nscolor col = mFrame->GetVisitedDependentColor(eCSSProperty_color);
-  ColorPattern color(nsLayoutUtils::NSColorToColor(col));
-  aCtx->SetColor(col);
+  ColorPattern color(ToDeviceColor(
+                       mFrame->GetVisitedDependentColor(eCSSProperty_color)));
+  aCtx->SetColor(mFrame->GetVisitedDependentColor(eCSSProperty_color));
 
   DrawTarget* drawTarget = aCtx->GetDrawTarget();
 
   // change line width to mThickness
   gfxContext *gfxCtx = aCtx->ThebesContext();
   gfxFloat e = presContext->AppUnitsToGfxUnits(mThickness);
   gfxCtx->Save();
   gfxCtx->SetLineWidth(e);
--- a/layout/svg/SVGTextFrame.cpp
+++ b/layout/svg/SVGTextFrame.cpp
@@ -7,16 +7,17 @@
 #include "SVGTextFrame.h"
 
 // Keep others in (case-insensitive) order:
 #include "DOMSVGPoint.h"
 #include "gfx2DGlue.h"
 #include "gfxFont.h"
 #include "gfxSkipChars.h"
 #include "gfxTypes.h"
+#include "gfxUtils.h"
 #include "LookAndFeel.h"
 #include "mozilla/gfx/2D.h"
 #include "mozilla/gfx/PatternHelpers.h"
 #include "nsAlgorithm.h"
 #include "nsBlockFrame.h"
 #include "nsCaret.h"
 #include "nsContentUtils.h"
 #include "nsGkAtoms.h"
@@ -2921,17 +2922,17 @@ SVGTextDrawPathCallbacks::MakeFillPatter
     nsSVGUtils::MakeFillPatternFor(mFrame, gfx, aOutPattern);
     return;
   }
 
   if (mColor == NS_TRANSPARENT) {
     return;
   }
 
-  aOutPattern->InitColorPattern(ToColor(gfxRGBA(mColor)));
+  aOutPattern->InitColorPattern(ToDeviceColor(mColor));
 }
 
 void
 SVGTextDrawPathCallbacks::FillAndStrokeGeometry()
 {
   bool pushedGroup = false;
   if (mColor == NS_40PERCENT_FOREGROUND_COLOR) {
     pushedGroup = true;
--- a/layout/svg/nsSVGPathGeometryFrame.cpp
+++ b/layout/svg/nsSVGPathGeometryFrame.cpp
@@ -6,16 +6,17 @@
 // Main header first:
 #include "nsSVGPathGeometryFrame.h"
 
 // Keep others in (case-insensitive) order:
 #include "gfx2DGlue.h"
 #include "gfxContext.h"
 #include "gfxPlatform.h"
 #include "gfxSVGGlyphs.h"
+#include "gfxUtils.h"
 #include "mozilla/gfx/2D.h"
 #include "mozilla/gfx/Helpers.h"
 #include "mozilla/RefPtr.h"
 #include "nsDisplayList.h"
 #include "nsGkAtoms.h"
 #include "nsLayoutUtils.h"
 #include "nsRenderingContext.h"
 #include "nsSVGEffects.h"
@@ -696,17 +697,18 @@ nsSVGPathGeometryFrame::Render(gfxContex
 
   // We wait as late as possible before setting the transform so that we don't
   // set it unnecessarily if we return early (it's an expensive operation for
   // some backends).
   gfxContextMatrixAutoSaveRestore autoRestoreTransform(aContext);
   aContext->SetMatrix(aNewTransform);
 
   if (GetStateBits() & NS_STATE_SVG_CLIPPATH_CHILD) {
-    drawTarget->Fill(path, ColorPattern(Color(1.0f, 1.0f, 1.0f, 1.0f)),
+    Color white(1.0f, 1.0f, 1.0f, 1.0f);
+    drawTarget->Fill(path, ColorPattern(ToDeviceColor(white)),
                      DrawOptions(1.0f, CompositionOp::OP_OVER, aaMode));
     return;
   }
 
   gfxTextContextPaint *contextPaint =
     (gfxTextContextPaint*)drawTarget->
       GetUserData(&gfxTextContextPaint::sUserDataKey);
 
--- a/layout/svg/nsSVGUtils.cpp
+++ b/layout/svg/nsSVGUtils.cpp
@@ -1273,22 +1273,20 @@ nsSVGUtils::MakeFillPatternFor(nsIFrame*
       aOutPattern->Init(*pattern->GetPattern(dt));
       return;
     }
   }
 
   // On failure, use the fallback colour in case we have an
   // objectBoundingBox where the width or height of the object is zero.
   // See http://www.w3.org/TR/SVG11/coords.html#ObjectBoundingBox
-  nscolor color = GetFallbackOrPaintColor(aFrame->StyleContext(),
-                                          &nsStyleSVG::mFill);
-  aOutPattern->InitColorPattern(Color(NS_GET_R(color)/255.0,
-                                      NS_GET_G(color)/255.0,
-                                      NS_GET_B(color)/255.0,
-                                      NS_GET_A(color)/255.0 * opacity));
+  Color color(Color::FromABGR(GetFallbackOrPaintColor(aFrame->StyleContext(),
+                                                      &nsStyleSVG::mFill)));
+  color.a *= opacity;
+  aOutPattern->InitColorPattern(ToDeviceColor(color));
 }
 
 /* static */ void
 nsSVGUtils::MakeStrokePatternFor(nsIFrame* aFrame,
                                  gfxContext* aContext,
                                  GeneralPattern* aOutPattern,
                                  gfxTextContextPaint* aContextPaint)
 {
@@ -1336,22 +1334,20 @@ nsSVGUtils::MakeStrokePatternFor(nsIFram
       aOutPattern->Init(*pattern->GetPattern(dt));
       return;
     }
   }
 
   // On failure, use the fallback colour in case we have an
   // objectBoundingBox where the width or height of the object is zero.
   // See http://www.w3.org/TR/SVG11/coords.html#ObjectBoundingBox
-  nscolor color = GetFallbackOrPaintColor(aFrame->StyleContext(),
-                                          &nsStyleSVG::mStroke);
-  aOutPattern->InitColorPattern(Color(NS_GET_R(color)/255.0,
-                                      NS_GET_G(color)/255.0,
-                                      NS_GET_B(color)/255.0,
-                                      NS_GET_A(color)/255.0 * opacity));
+  Color color(Color::FromABGR(GetFallbackOrPaintColor(aFrame->StyleContext(),
+                                                      &nsStyleSVG::mStroke)));
+  color.a *= opacity;
+  aOutPattern->InitColorPattern(ToDeviceColor(color));
 }
 
 /* static */ float
 nsSVGUtils::GetOpacity(nsStyleSVGOpacitySource aOpacityType,
                        const float& aOpacity,
                        gfxTextContextPaint *aOuterContextPaint)
 {
   float opacity = 1.0f;
--- a/layout/xul/tree/nsTreeBodyFrame.cpp
+++ b/layout/xul/tree/nsTreeBodyFrame.cpp
@@ -8,16 +8,17 @@
 #include "mozilla/DebugOnly.h"
 #include "mozilla/EventDispatcher.h"
 #include "mozilla/gfx/2D.h"
 #include "mozilla/gfx/PathHelpers.h"
 #include "mozilla/MathAlgorithms.h"
 #include "mozilla/MouseEvents.h"
 #include "mozilla/Likely.h"
 
+#include "gfxUtils.h"
 #include "nsAlgorithm.h"
 #include "nsCOMPtr.h"
 #include "nsPresContext.h"
 #include "nsNameSpaceManager.h"
 
 #include "nsTreeBodyFrame.h"
 #include "nsTreeSelection.h"
 #include "nsTreeImageListener.h"
@@ -3180,17 +3181,17 @@ nsTreeBodyFrame::PaintCell(int32_t      
       const nsStyleBorder* borderStyle = lineContext->StyleBorder();
       nscolor color;
       bool useForegroundColor;
       borderStyle->GetBorderColor(NS_SIDE_LEFT, color, useForegroundColor);
       if (useForegroundColor) {
         // GetBorderColor didn't touch color, thus grab it from the treeline context
         color = lineContext->StyleColor()->mColor;
       }
-      ColorPattern colorPatt(nsLayoutUtils::NSColorToColor(color));
+      ColorPattern colorPatt(ToDeviceColor(color));
 
       uint8_t style;
       style = borderStyle->GetBorderStyle(NS_SIDE_LEFT);
       StrokeOptions strokeOptions;
       nsLayoutUtils::InitDashPattern(strokeOptions, style);
 
       nscoord srcX = currX + twistyRect.width - mIndentation / 2;
       nscoord lineY = (aRowIndex - mTopRowIndex) * mRowHeight + aPt.y;