bug 821593 - use webidl for RGBColor r=bz
authorTrevor Saunders <trev.saunders@gmail.com>
Fri, 14 Dec 2012 02:51:39 -0500
changeset 125358 290224a8e5fa4f4ba79022ef0318715198a2e984
parent 125357 477a1c6b95f90d6cc417ddc09a67ac2fd7f0103e
child 125359 6272bd19f4510120bfec683a1b24d35728c92807
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 - use webidl for RGBColor r=bz
dom/bindings/Bindings.conf
dom/webidl/CSSPrimitiveValue.webidl
dom/webidl/WebIDL.mk
layout/style/Makefile.in
layout/style/nsDOMCSSRGBColor.cpp
layout/style/nsDOMCSSRGBColor.h
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -389,16 +389,21 @@ DOMInterfaces = {
     'headerFile': 'nsPerformance.h'
 },
 
 'PropertyNodeList': {
     'headerFile': 'HTMLPropertiesCollection.h',
     'resultNotAddRefed': [ 'item' ]
 },
 
+'RGBColor': {
+    "nativeType": "nsDOMCSSRGBColor",
+    'resultNotAddRefed': [ "alpha", "blue", "green", "red" ]
+},
+
 'Screen': {
     'nativeType': 'nsScreen',
     'prefable': True,
 },
 
 'SVGLengthList': {
     'nativeType': 'mozilla::DOMSVGLengthList',
     'headerFile': 'DOMSVGLengthList.h',
@@ -801,17 +806,16 @@ addExternalIface('Principal', nativeType
                  headerFile='nsIPrincipal.h', notflattened=True)
 addExternalIface('SVGLength')
 addExternalIface('SVGMatrix')
 addExternalIface('SVGNumber')
 addExternalIface('SVGPathSeg')
 addExternalIface('SVGPoint')
 addExternalIface('SVGTransform')
 addExternalIface("Rect")
-addExternalIface("RGBColor")
 addExternalIface('TextMetrics', headerFile='nsIDOMCanvasRenderingContext2D.h')
 addExternalIface('Touch', headerFile='nsIDOMTouchEvent.h')
 addExternalIface('URI', nativeType='nsIURI', headerFile='nsIURI.h',
                  notflattened=True)
 addExternalIface('UserDataHandler')
 addExternalIface('Window')
 addExternalIface('XPathResult', nativeType='nsISupports')
 addExternalIface('XULElement')
--- a/dom/webidl/CSSPrimitiveValue.webidl
+++ b/dom/webidl/CSSPrimitiveValue.webidl
@@ -1,17 +1,16 @@
 /* -*- Mode: IDL; 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/.
  */
 
 interface Counter;
 interface Rect;
-interface RGBColor;
 
 interface CSSPrimitiveValue : CSSValue {
 
   // UnitTypes
   const unsigned short      CSS_UNKNOWN                    = 0;
   const unsigned short      CSS_NUMBER                     = 1;
   const unsigned short      CSS_PERCENTAGE                 = 2;
   const unsigned short      CSS_EMS                        = 3;
--- a/dom/webidl/WebIDL.mk
+++ b/dom/webidl/WebIDL.mk
@@ -51,16 +51,17 @@ webidl_files = \
   Node.webidl \
   NodeFilter.webidl \
   NodeList.webidl \
   PaintRequestList.webidl \
   PannerNode.webidl \
   Performance.webidl \
   PerformanceNavigation.webidl \
   PerformanceTiming.webidl \
+  RGBColor.webidl \
   Screen.webidl \
   SVGLengthList.webidl \
   SVGNumberList.webidl \
   SVGPathSegList.webidl \
   SVGPointList.webidl \
   SVGTransformList.webidl \
   TextDecoder.webidl \
   TextEncoder.webidl \
--- a/layout/style/Makefile.in
+++ b/layout/style/Makefile.in
@@ -38,16 +38,17 @@ EXPORTS		= \
 		nsCSSPseudoClasses.h \
 		nsCSSPseudoElementList.h \
 		nsCSSPseudoElements.h \
 		nsCSSRuleProcessor.h \
 		nsCSSStyleSheet.h \
 		nsCSSValue.h \
 		nsDOMCSSAttrDeclaration.h \
 		nsDOMCSSDeclaration.h \
+	 nsDOMCSSRGBColor.h \
 		nsDOMMediaQueryList.h \
 		nsICSSDeclaration.h \
 		nsICSSLoaderObserver.h \
 		nsICSSPseudoComparator.h \
 		nsICSSRuleList.h \
 		nsICSSStyleRuleDOMWrapper.h \
 		nsIStyleRule.h \
 		nsIStyleRuleProcessor.h \
--- a/layout/style/nsDOMCSSRGBColor.cpp
+++ b/layout/style/nsDOMCSSRGBColor.cpp
@@ -1,31 +1,36 @@
 /* -*- 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/. */
 
 /* DOM object representing color values in DOM computed style */
 
+#include "nsDOMCSSRGBColor.h"
+
+#include "mozilla/dom/RGBColorBinding.h"
 #include "nsISupports.h"
 #include "nsCOMPtr.h"
 #include "nsIDOMCSSPrimitiveValue.h"
-#include "nsDOMCSSRGBColor.h"
 #include "nsContentUtils.h"
 #include "nsROCSSPrimitiveValue.h"
 #include "nsDOMClassInfoID.h"
 
+using namespace mozilla;
+
 nsDOMCSSRGBColor::nsDOMCSSRGBColor(nsROCSSPrimitiveValue* aRed,
                                    nsROCSSPrimitiveValue* aGreen,
                                    nsROCSSPrimitiveValue* aBlue,
                                    nsROCSSPrimitiveValue* aAlpha,
                                    bool aHasAlpha)
   : mRed(aRed), mGreen(aGreen), mBlue(aBlue), mAlpha(aAlpha)
   , mHasAlpha(aHasAlpha)
 {
+  SetIsDOMBinding();
 }
 
 nsDOMCSSRGBColor::~nsDOMCSSRGBColor(void)
 {
 }
 
 DOMCI_DATA(CSSRGBColor, nsDOMCSSRGBColor)
 
@@ -36,16 +41,22 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CSSRGBColor)
   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
 NS_INTERFACE_MAP_END
 
 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_4(nsDOMCSSRGBColor, mAlpha,  mBlue, mGreen, mRed)
 NS_IMPL_CYCLE_COLLECTING_ADDREF(nsDOMCSSRGBColor)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(nsDOMCSSRGBColor)
 
+JSObject*
+nsDOMCSSRGBColor::WrapObject(JSContext *aCx, JSObject *aScope, bool *aTried)
+{
+  return dom::RGBColorBinding::Wrap(aCx, aScope, this, aTried);
+}
+
 
 NS_IMETHODIMP
 nsDOMCSSRGBColor::GetRed(nsIDOMCSSPrimitiveValue** aRed)
 {
   NS_ENSURE_TRUE(mRed, NS_ERROR_NOT_INITIALIZED);
   *aRed = mRed;
   NS_ADDREF(*aRed);
   return NS_OK;
--- a/layout/style/nsDOMCSSRGBColor.h
+++ b/layout/style/nsDOMCSSRGBColor.h
@@ -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/. */
 
 /* DOM object representing color values in DOM computed style */
 
 #ifndef nsDOMCSSRGBColor_h__
 #define nsDOMCSSRGBColor_h__
 
+#include "mozilla/Attributes.h"
 #include "nsAutoPtr.h"
 #include "nsISupports.h"
 #include "nsIDOMNSRGBAColor.h"
 #include "nsWrapperCache.h"
 
 class nsROCSSPrimitiveValue;
 
 class nsDOMCSSRGBColor : public nsIDOMNSRGBAColor,
@@ -48,16 +49,24 @@ public:
   {
     return mBlue;
   }
   nsROCSSPrimitiveValue* Alpha() const
   {
     return mAlpha;
   }
 
+  nsISupports* GetParentObject() const
+  {
+    return nullptr;
+  }
+
+  virtual JSObject *WrapObject(JSContext *cx, JSObject *aScope, bool *aTried)
+    MOZ_OVERRIDE MOZ_FINAL;
+
 private:
   nsRefPtr<nsROCSSPrimitiveValue> mRed;
   nsRefPtr<nsROCSSPrimitiveValue> mGreen;
   nsRefPtr<nsROCSSPrimitiveValue> mBlue;
   nsRefPtr<nsROCSSPrimitiveValue> mAlpha;
   bool mHasAlpha;
 };