bug 821593 - stop using nsIDOMCSSValue / nsIDOMRGBColor in editor r=bz
authorTrevor Saunders <trev.saunders@gmail.com>
Fri, 14 Dec 2012 04:14:21 -0500
changeset 125993 270ce71000f3e762957edae971d4b97579e10f1f
parent 125992 443df7602f6ef3f7736fc687c0e62a0dc15caf8b
child 125994 6c3f79ca958b4d8801a84b1efd9a43a1bd65afc1
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs821593
milestone20.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 821593 - stop using nsIDOMCSSValue / nsIDOMRGBColor in editor r=bz
editor/libeditor/html/nsHTMLAbsPosition.cpp
--- a/editor/libeditor/html/nsHTMLAbsPosition.cpp
+++ b/editor/libeditor/html/nsHTMLAbsPosition.cpp
@@ -21,24 +21,23 @@
 #include "nsError.h"
 #include "nsGkAtoms.h"
 #include "nsHTMLCSSUtils.h"
 #include "nsHTMLEditRules.h"
 #include "nsHTMLEditUtils.h"
 #include "nsHTMLEditor.h"
 #include "nsHTMLObjectResizer.h"
 #include "nsIContent.h"
-#include "nsIDOMCSSPrimitiveValue.h"
+#include "nsROCSSPrimitiveValue.h"
 #include "nsIDOMCSSStyleDeclaration.h"
-#include "nsIDOMCSSValue.h"
 #include "nsIDOMElement.h"
 #include "nsIDOMEventListener.h"
 #include "nsIDOMEventTarget.h"
 #include "nsIDOMNode.h"
-#include "nsIDOMRGBColor.h"
+#include "nsDOMCSSRGBColor.h"
 #include "nsIDOMWindow.h"
 #include "nsIEditor.h"
 #include "nsIHTMLEditor.h"
 #include "nsIHTMLObjectResizer.h"
 #include "nsINode.h"
 #include "nsIPresShell.h"
 #include "nsISelection.h"
 #include "nsISupportsImpl.h"
@@ -656,51 +655,40 @@ nsHTMLEditor::CheckPositionedElementBGan
                                          bgColorStr);
     NS_ENSURE_SUCCESS(res, res);
     if (bgColorStr.EqualsLiteral("transparent")) {
       nsRefPtr<nsComputedDOMStyle> cssDecl =
         mHTMLCSSUtils->GetComputedStyle(aElement);
       NS_ENSURE_STATE(cssDecl);
 
       // from these declarations, get the one we want and that one only
-      nsCOMPtr<nsIDOMCSSValue> colorCssValue;
-      res = cssDecl->GetPropertyCSSValue(NS_LITERAL_STRING("color"), getter_AddRefs(colorCssValue));
-      NS_ENSURE_SUCCESS(res, res);
+      ErrorResult error;
+      nsRefPtr<dom::CSSValue> cssVal = cssDecl->GetPropertyCSSValue(NS_LITERAL_STRING("color"), error);
+      NS_ENSURE_SUCCESS(error.ErrorCode(), error.ErrorCode());
+
+      nsROCSSPrimitiveValue* val = cssVal->AsPrimitiveValue();
+      NS_ENSURE_TRUE(val);
 
-      uint16_t type;
-      res = colorCssValue->GetCssValueType(&type);
-      NS_ENSURE_SUCCESS(res, res);
-      if (nsIDOMCSSValue::CSS_PRIMITIVE_VALUE == type) {
-        nsCOMPtr<nsIDOMCSSPrimitiveValue> val = do_QueryInterface(colorCssValue);
-        res = val->GetPrimitiveType(&type);
-        NS_ENSURE_SUCCESS(res, res);
-        if (nsIDOMCSSPrimitiveValue::CSS_RGBCOLOR == type) {
-          nsCOMPtr<nsIDOMRGBColor> rgbColor;
-          res = val->GetRGBColorValue(getter_AddRefs(rgbColor));
-          NS_ENSURE_SUCCESS(res, res);
-          nsCOMPtr<nsIDOMCSSPrimitiveValue> red, green, blue;
-          float r, g, b;
-          res = rgbColor->GetRed(getter_AddRefs(red));
-          NS_ENSURE_SUCCESS(res, res);
-          res = rgbColor->GetGreen(getter_AddRefs(green));
-          NS_ENSURE_SUCCESS(res, res);
-          res = rgbColor->GetBlue(getter_AddRefs(blue));
-          NS_ENSURE_SUCCESS(res, res);
-          res = red->GetFloatValue(nsIDOMCSSPrimitiveValue::CSS_NUMBER, &r);
-          NS_ENSURE_SUCCESS(res, res);
-          res = green->GetFloatValue(nsIDOMCSSPrimitiveValue::CSS_NUMBER, &g);
-          NS_ENSURE_SUCCESS(res, res);
-          res = blue->GetFloatValue(nsIDOMCSSPrimitiveValue::CSS_NUMBER, &b);
-          NS_ENSURE_SUCCESS(res, res);
-          if (r >= BLACK_BG_RGB_TRIGGER &&
-              g >= BLACK_BG_RGB_TRIGGER &&
-              b >= BLACK_BG_RGB_TRIGGER)
-            aReturn.AssignLiteral("black");
-          else
-            aReturn.AssignLiteral("white");
-          return NS_OK;
-        }
+      if (nsIDOMCSSPrimitiveValue::CSS_RGBCOLOR == val->PrimitiveType()) {
+        nsDOMCSSRGBColor* rgbVal = val->GetRGBColorValue(error);
+        NS_ENSURE_SUCCESS(error.ErrorCode(), error.ErrorCode());
+        float r = rgbVal->Red()->
+          GetFloatValue(nsIDOMCSSPrimitiveValue::CSS_NUMBER, error);
+        NS_ENSURE_SUCCESS(error.ErrorCode(), error.ErrorCode());
+        float g = rgbVal->Green()->
+          GetFloatValue(nsIDOMCSSPrimitiveValue::CSS_NUMBER, error);
+        NS_ENSURE_SUCCESS(error.ErrorCode(), error.ErrorCode());
+        float b = rgbVal->Blue()->
+          GetFloatValue(nsIDOMCSSPrimitiveValue::CSS_NUMBER, error);
+        NS_ENSURE_SUCCESS(error.ErrorCode(), error.ErrorCode());
+        if (r >= BLACK_BG_RGB_TRIGGER &&
+            g >= BLACK_BG_RGB_TRIGGER &&
+            b >= BLACK_BG_RGB_TRIGGER)
+          aReturn.AssignLiteral("black");
+        else
+          aReturn.AssignLiteral("white");
+        return NS_OK;
       }
     }
   }
 
   return NS_OK;
 }