Bug 846972 part 3. Switch CSSStyleSheet to WebIDL. r=peterv
authorBoris Zbarsky <bzbarsky@mit.edu>
Sun, 17 Mar 2013 10:45:01 -0400
changeset 125142 dd888bc71adc649891a1ab6bfa3d2d10b73d1d82
parent 125141 883db473ec469f8377ba4922776673a21b5e8dc6
child 125143 8c134490188696fb8c93258a67f71fc35419aaa1
push id24449
push useremorley@mozilla.com
push dateMon, 18 Mar 2013 20:06:48 +0000
treeherdermozilla-central@e23e43a2c14e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspeterv
bugs846972
milestone22.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 846972 part 3. Switch CSSStyleSheet to WebIDL. r=peterv
dom/bindings/Bindings.conf
dom/webidl/WebIDL.mk
layout/style/nsCSSStyleSheet.cpp
layout/style/nsCSSStyleSheet.h
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -191,16 +191,21 @@ DOMInterfaces = {
     'nativeType': 'nsROCSSPrimitiveValue',
     'resultNotAddRefed': ['getRGBColorValue', 'getRectValue']
 },
 
 'CSSStyleDeclaration': {
   'nativeType': 'nsICSSDeclaration'
 },
 
+'CSSStyleSheet': {
+    'nativeType': 'nsCSSStyleSheet',
+    'binaryNames': { 'ownerRule': 'DOMOwnerRule' },
+},
+
 'CSSValue': {
   'concrete': False
 },
 
 'CSSValueList': {
   'nativeType': 'nsDOMCSSValueList'
 },
 
@@ -629,16 +634,20 @@ DOMInterfaces = {
     'nativeType': 'nsDOMCSSRGBColor',
     'resultNotAddRefed': [ 'alpha', 'blue', 'green', 'red' ]
 },
 
 'Screen': {
     'nativeType': 'nsScreen',
 },
 
+'StyleSheet': {
+    'nativeType': 'nsCSSStyleSheet',
+},
+
 'SVGAnimatedLengthList': {
     'nativeType': 'mozilla::DOMSVGAnimatedLengthList',
     'headerFile': 'DOMSVGAnimatedLengthList.h'
 },
 
 'SVGAnimatedNumberList': {
     'nativeType': 'mozilla::DOMSVGAnimatedNumberList',
     'headerFile': 'DOMSVGAnimatedNumberList.h'
@@ -1298,23 +1307,25 @@ addExternalHTMLElement('HTMLVideoElement
 addExternalIface('ActivityOptions', nativeType='nsIDOMMozActivityOptions',
                  headerFile='nsIDOMActivityOptions.h')
 addExternalIface('Attr')
 addExternalIface('CanvasGradient', headerFile='nsIDOMCanvasRenderingContext2D.h')
 addExternalIface('CanvasPattern', headerFile='nsIDOMCanvasRenderingContext2D.h')
 addExternalIface('Counter')
 addExternalIface('CSSRule')
 addExternalIface('DOMError')
+addExternalIface('CSSRuleList')
 addExternalIface('DOMStringList')
 addExternalIface('File')
 addExternalIface('HitRegionOptions', nativeType='nsISupports')
 addExternalIface('HTMLCanvasElement', nativeType='mozilla::dom::HTMLCanvasElement')
 addExternalIface('imgINotificationObserver', nativeType='imgINotificationObserver')
 addExternalIface('imgIRequest', nativeType='imgIRequest', notflattened=True)
 addExternalIface('LockedFile')
+addExternalIface('MediaList')
 addExternalIface('MenuBuilder', nativeType='nsIMenuBuilder', notflattened=True)
 addExternalIface('MozBoxObject', nativeType='nsIBoxObject')
 addExternalIface('MozControllers', nativeType='nsIControllers')
 addExternalIface('MozFrameLoader', nativeType='nsIFrameLoader', notflattened=True)
 addExternalIface('MozRDFCompositeDataSource', nativeType='nsIRDFCompositeDataSource',
                  notflattened=True)
 addExternalIface('MozRDFResource', nativeType='nsIRDFResource', notflattened=True)
 addExternalIface('MozXULTemplateBuilder', nativeType='nsIXULTemplateBuilder')
@@ -1322,17 +1333,16 @@ addExternalIface('MozNamedAttrMap')
 addExternalIface('nsIStreamListener', nativeType='nsIStreamListener', notflattened=True)
 addExternalIface('nsISupports', nativeType='nsISupports')
 addExternalIface('nsIEditor', nativeType='nsIEditor', notflattened=True)
 addExternalIface('OutputStream', nativeType='nsIOutputStream',
                  notflattened=True)
 addExternalIface('Principal', nativeType='nsIPrincipal',
                  headerFile='nsIPrincipal.h', notflattened=True)
 addExternalIface('Selection', nativeType='nsISelection')
-addExternalIface('StyleSheet', nativeType='nsIStyleSheet')
 addExternalIface('StyleSheetList')
 addExternalIface('SVGAnimatedEnumeration', headerFile='nsIDOMSVGAnimatedEnum.h')
 addExternalIface('SVGAnimatedNumber')
 addExternalIface('SVGAnimatedString')
 addExternalIface('SVGLength')
 addExternalIface('SVGNumber')
 addExternalIface('TextMetrics', headerFile='nsIDOMCanvasRenderingContext2D.h')
 addExternalIface('Touch', headerFile='nsIDOMTouchEvent.h')
--- a/dom/webidl/WebIDL.mk
+++ b/dom/webidl/WebIDL.mk
@@ -30,16 +30,17 @@ webidl_files = \
   CharacterData.webidl \
   ClientRect.webidl \
   ClientRectList.webidl \
   CommandEvent.webidl \
   Comment.webidl \
   CSS.webidl \
   CSSPrimitiveValue.webidl \
   CSSStyleDeclaration.webidl \
+  CSSStyleSheet.webidl \
   CSSValue.webidl \
   CSSValueList.webidl \
   DelayNode.webidl \
   Document.webidl \
   DocumentFragment.webidl \
   DocumentType.webidl \
   DOMCursor.webidl \
   DOMImplementation.webidl \
@@ -147,16 +148,17 @@ webidl_files = \
   PerformanceNavigation.webidl \
   PerformanceTiming.webidl \
   ProcessingInstruction.webidl \
   Range.webidl \
   Rect.webidl \
   RGBColor.webidl \
   RTCConfiguration.webidl \
   Screen.webidl \
+  StyleSheet.webidl \
   SVGAElement.webidl \
   SVGAltGlyphElement.webidl \
   SVGAngle.webidl \
   SVGAnimatedAngle.webidl \
   SVGAnimatedBoolean.webidl \
   SVGAnimatedLength.webidl \
   SVGAnimatedLengthList.webidl \
   SVGAnimatedNumberList.webidl \
--- a/layout/style/nsCSSStyleSheet.cpp
+++ b/layout/style/nsCSSStyleSheet.cpp
@@ -33,16 +33,17 @@
 #include "nsCOMPtr.h"
 #include "nsContentUtils.h"
 #include "nsIScriptSecurityManager.h"
 #include "mozAutoDocUpdate.h"
 #include "nsRuleNode.h"
 #include "nsMediaFeatures.h"
 #include "nsDOMClassInfoID.h"
 #include "mozilla/Likely.h"
+#include "mozilla/dom/CSSStyleSheetBinding.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 
 // -------------------------------
 // Style Rule List for the DOM
 //
@@ -1026,18 +1027,19 @@ nsCSSStyleSheet::nsCSSStyleSheet(CORSMod
     mOwnerRule(nullptr),
     mDocument(nullptr),
     mOwningNode(nullptr),
     mDisabled(false),
     mDirty(false),
     mScopeElement(nullptr),
     mRuleProcessors(nullptr)
 {
+  mInner = new nsCSSStyleSheetInner(this, aCORSMode);
 
-  mInner = new nsCSSStyleSheetInner(this, aCORSMode);
+  SetIsDOMBinding();
 }
 
 nsCSSStyleSheet::nsCSSStyleSheet(const nsCSSStyleSheet& aCopy,
                                  nsCSSStyleSheet* aParentToUse,
                                  css::ImportRule* aOwnerRuleToUse,
                                  nsIDocument* aDocumentToUse,
                                  nsINode* aOwningNodeToUse)
   : mTitle(aCopy.mTitle),
@@ -1060,16 +1062,18 @@ nsCSSStyleSheet::nsCSSStyleSheet(const n
     EnsureUniqueInner();
   }
 
   if (aCopy.mMedia) {
     // XXX This is wrong; we should be keeping @import rules and
     // sheets in sync!
     aCopy.mMedia->Clone(getter_AddRefs(mMedia));
   }
+
+  SetIsDOMBinding();
 }
 
 nsCSSStyleSheet::~nsCSSStyleSheet()
 {
   for (nsCSSStyleSheet* child = mInner->mFirstChild;
        child;
        child = child->mNext) {
     // XXXbz this is a little bogus; see the XXX comment where we
@@ -2257,8 +2261,15 @@ nsCSSStyleSheet::ParseSheet(const nsAStr
   return NS_OK;
 }
 
 /* virtual */ nsIURI*
 nsCSSStyleSheet::GetOriginalURI() const
 {
   return mInner->mOriginalSheetURI;
 }
+
+/* virtual */
+JSObject*
+nsCSSStyleSheet::WrapObject(JSContext* aCx, JSObject* aScope)
+{
+  return CSSStyleSheetBinding::Wrap(aCx, aScope, this);
+}
--- a/layout/style/nsCSSStyleSheet.h
+++ b/layout/style/nsCSSStyleSheet.h
@@ -292,16 +292,17 @@ public:
   mozilla::dom::ParentObject GetParentObject() const {
     if (mOwningNode) {
       return mozilla::dom::ParentObject(mOwningNode);
     }
 
     return mozilla::dom::ParentObject(static_cast<nsIStyleSheet*>(mParent),
                                       mParent);
   }
+  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
 
 private:
   nsCSSStyleSheet(const nsCSSStyleSheet& aCopy,
                   nsCSSStyleSheet* aParentToUse,
                   mozilla::css::ImportRule* aOwnerRuleToUse,
                   nsIDocument* aDocumentToUse,
                   nsINode* aOwningNodeToUse);