bug 824970 - use webidl for Rect r=bz
authorTrevor Saunders <trev.saunders@gmail.com>
Wed, 26 Dec 2012 07:26:36 -0500
changeset 126321 28042058474412c4d51267ecbe5478e65f72a86c
parent 126320 03ece6d48d9f80b20f7a7264fbfe6dd75c148f72
child 126322 cdc397a8e017d4523e2ced42dca1424265ed2dac
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
bugs824970
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 824970 - use webidl for Rect r=bz
dom/bindings/Bindings.conf
dom/webidl/CSSPrimitiveValue.webidl
dom/webidl/WebIDL.mk
layout/style/nsDOMCSSRect.cpp
layout/style/nsDOMCSSRect.h
layout/style/nsROCSSPrimitiveValue.cpp
layout/style/nsROCSSPrimitiveValue.h
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -454,16 +454,21 @@ DOMInterfaces = {
     'headerFile': 'nsPerformance.h'
 },
 
 'PropertyNodeList': {
     'headerFile': 'HTMLPropertiesCollection.h',
     'resultNotAddRefed': [ 'item' ]
 },
 
+'Rect': {
+    "nativeType": "nsDOMCSSRect",
+    'resultNotAddRefed': [ "top", "right", "bottom", "left" ]
+},
+
 'RGBColor': {
     "nativeType": "nsDOMCSSRGBColor",
     'resultNotAddRefed': [ "alpha", "blue", "green", "red" ]
 },
 
 'Screen': {
     'nativeType': 'nsScreen',
     'prefable': True,
@@ -1025,17 +1030,16 @@ addExternalIface('NamedNodeMap')
 addExternalIface('NodeIterator')
 addExternalIface('nsISupports', nativeType='nsISupports')
 addExternalIface('OutputStream', nativeType='nsIOutputStream',
                  notflattened=True)
 addExternalIface('Principal', nativeType='nsIPrincipal',
                  headerFile='nsIPrincipal.h', notflattened=True)
 addExternalIface('ProcessingInstruction', nativeType='nsXMLProcessingInstruction')
 addExternalIface('Range', nativeType='nsRange')
-addExternalIface("Rect")
 addExternalIface('Selection', nativeType='nsISelection')
 addExternalIface('StyleSheetList')
 addExternalIface('SVGAnimatedString')
 addExternalIface('SVGLength')
 addExternalIface('SVGNumber')
 addExternalIface('SVGSVGElement', nativeType='nsSVGSVGElement')
 addExternalIface('Text', nativeType='nsTextNode')
 addExternalIface('TextMetrics', headerFile='nsIDOMCanvasRenderingContext2D.h')
--- a/dom/webidl/CSSPrimitiveValue.webidl
+++ b/dom/webidl/CSSPrimitiveValue.webidl
@@ -1,16 +1,15 @@
 /* -*- 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 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
@@ -68,16 +68,17 @@ webidl_files = \
   NodeFilter.webidl \
   NodeList.webidl \
   PaintRequest.webidl \
   PaintRequestList.webidl \
   PannerNode.webidl \
   Performance.webidl \
   PerformanceNavigation.webidl \
   PerformanceTiming.webidl \
+  Rect.webidl \
   RGBColor.webidl \
   Screen.webidl \
   SVGAngle.webidl \
   SVGAnimatedAngle.webidl \
   SVGAnimatedBoolean.webidl \
   SVGAnimatedLengthList.webidl \
   SVGAnimatedNumberList.webidl \
   SVGAnimatedPreserveAspectRatio.webidl \
--- a/layout/style/nsDOMCSSRect.cpp
+++ b/layout/style/nsDOMCSSRect.cpp
@@ -1,28 +1,32 @@
 /* -*- 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 rectangle values in DOM computed style */
 
+#include "mozilla/dom/RectBinding.h"
 #include "nsISupports.h"
 #include "nsCOMPtr.h"
 #include "nsROCSSPrimitiveValue.h"
 #include "nsDOMCSSRect.h"
 #include "nsContentUtils.h"
 #include "nsDOMClassInfoID.h"
 
+using namespace mozilla;
+
 nsDOMCSSRect::nsDOMCSSRect(nsROCSSPrimitiveValue* aTop,
                            nsROCSSPrimitiveValue* aRight,
                            nsROCSSPrimitiveValue* aBottom,
                            nsROCSSPrimitiveValue* aLeft)
   : mTop(aTop), mRight(aRight), mBottom(aBottom), mLeft(aLeft)
 {
+  SetIsDOMBinding();
 }
 
 nsDOMCSSRect::~nsDOMCSSRect(void)
 {
 }
 
 DOMCI_DATA(CSSRect, nsDOMCSSRect)
 
@@ -33,17 +37,23 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CSSRect)
   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
 NS_INTERFACE_MAP_END
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(nsDOMCSSRect)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(nsDOMCSSRect)
 
 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_4(nsDOMCSSRect, mTop, mBottom, mLeft, mRight)
-  
+ 
+JSObject*
+nsDOMCSSRect::WrapObject(JSContext* cx, JSObject* scope, bool* tried)
+{
+ return dom::RectBinding::Wrap(cx, scope, this, tried);
+}
+
 NS_IMETHODIMP
 nsDOMCSSRect::GetTop(nsIDOMCSSPrimitiveValue** aTop)
 {
   NS_ENSURE_TRUE(mTop, NS_ERROR_NOT_INITIALIZED);
   *aTop = mTop;
   NS_ADDREF(*aTop);
   return NS_OK;
 }
--- a/layout/style/nsDOMCSSRect.h
+++ b/layout/style/nsDOMCSSRect.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 rectangle values in DOM computed style */
 
 #ifndef nsDOMCSSRect_h_
 #define nsDOMCSSRect_h_
 
+#include "mozilla/Attributes.h"
 #include "nsISupports.h"
 #include "nsIDOMRect.h"
 #include "nsAutoPtr.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsWrapperCache.h"
 
 class nsROCSSPrimitiveValue;
 
@@ -31,16 +32,21 @@ public:
 
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsDOMCSSRect)
 
   nsROCSSPrimitiveValue* Top() const { return mTop; }
   nsROCSSPrimitiveValue* Right() const { return mRight; }
   nsROCSSPrimitiveValue* Bottom() const { return mBottom; }
   nsROCSSPrimitiveValue* Left() const { return mLeft; }
 
+  nsISupports* GetParentObject() const { return nullptr; }
+
+  virtual JSObject* WrapObject(JSContext* cx, JSObject* scope, bool* tried)
+    MOZ_OVERRIDE MOZ_FINAL;
+
 private:
   nsRefPtr<nsROCSSPrimitiveValue> mTop;
   nsRefPtr<nsROCSSPrimitiveValue> mRight;
   nsRefPtr<nsROCSSPrimitiveValue> mBottom;
   nsRefPtr<nsROCSSPrimitiveValue> mLeft;
 };
 
 #endif /* nsDOMCSSRect_h_ */
--- a/layout/style/nsROCSSPrimitiveValue.cpp
+++ b/layout/style/nsROCSSPrimitiveValue.cpp
@@ -453,17 +453,17 @@ nsROCSSPrimitiveValue::GetCounterValue(n
 
 already_AddRefed<nsIDOMCounter>
 nsROCSSPrimitiveValue::GetCounterValue(ErrorResult& aRv)
 {
   aRv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR);
   return nullptr;
 }
 
-already_AddRefed<nsIDOMRect>
+already_AddRefed<nsDOMCSSRect>
 nsROCSSPrimitiveValue::GetRectValue(ErrorResult& aRv)
 {
   if (mType != CSS_RECT) {
     aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
     return nullptr;
   }
 
   NS_ASSERTION(mValue.mRect, "mValue.mRect should never be null");
--- a/layout/style/nsROCSSPrimitiveValue.h
+++ b/layout/style/nsROCSSPrimitiveValue.h
@@ -50,17 +50,17 @@ public:
   }
   void SetFloatValue(uint16_t aUnitType, float aValue,
                      mozilla::ErrorResult& aRv);
   float GetFloatValue(uint16_t aUnitType, mozilla::ErrorResult& aRv);
   void GetStringValue(nsString& aString, mozilla::ErrorResult& aRv);
   void SetStringValue(uint16_t aUnitType, const nsAString& aString,
                       mozilla::ErrorResult& aRv);
   already_AddRefed<nsIDOMCounter> GetCounterValue(mozilla::ErrorResult& aRv);
-  already_AddRefed<nsIDOMRect> GetRectValue(mozilla::ErrorResult& aRv);
+  already_AddRefed<nsDOMCSSRect> GetRectValue(mozilla::ErrorResult& aRv);
   nsDOMCSSRGBColor *GetRGBColorValue(mozilla::ErrorResult& aRv);
 
   // nsROCSSPrimitiveValue
   nsROCSSPrimitiveValue();
   ~nsROCSSPrimitiveValue();
 
   void SetNumber(float aValue);
   void SetNumber(int32_t aValue);