--- a/devtools/server/actors/object/previewers.js
+++ b/devtools/server/actors/object/previewers.js
@@ -541,17 +541,16 @@ previewers.Object = [
function ArrayLike({obj, hooks}, grip, rawObj) {
if (isWorker || !rawObj ||
obj.class != "DOMStringList" &&
obj.class != "DOMTokenList" &&
obj.class != "CSSRuleList" &&
obj.class != "MediaList" &&
obj.class != "StyleSheetList" &&
- obj.class != "CSSValueList" &&
obj.class != "NamedNodeMap" &&
obj.class != "FileList" &&
obj.class != "NodeList") {
return false;
}
if (typeof rawObj.length != "number") {
return false;
--- a/dom/base/nsGlobalWindowInner.cpp
+++ b/dom/base/nsGlobalWindowInner.cpp
@@ -2845,19 +2845,17 @@ struct InterfaceShimEntry {
// We add shims from Components.interfaces.nsIDOMFoo to window.Foo for each
// interface that has interface constants that sites might be getting off
// of Ci.
const InterfaceShimEntry kInterfaceShimMap[] =
{ { "nsIXMLHttpRequest", "XMLHttpRequest" },
{ "nsIDOMDOMException", "DOMException" },
{ "nsIDOMNode", "Node" },
- { "nsIDOMCSSPrimitiveValue", "CSSPrimitiveValue" },
{ "nsIDOMCSSRule", "CSSRule" },
- { "nsIDOMCSSValue", "CSSValue" },
{ "nsIDOMEvent", "Event" },
{ "nsIDOMNSEvent", "Event" },
{ "nsIDOMKeyEvent", "KeyEvent" },
{ "nsIDOMMouseEvent", "MouseEvent" },
{ "nsIDOMMouseScrollEvent", "MouseScrollEvent" },
{ "nsIDOMMutationEvent", "MutationEvent" },
{ "nsIDOMUIEvent", "UIEvent" },
{ "nsIDOMHTMLMediaElement", "HTMLMediaElement" },
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -187,20 +187,16 @@ DOMInterfaces = {
'concrete': False,
'nativeType': 'mozilla::css::GroupRule',
},
'CSSLexer': {
'wrapperCache': False
},
-'CSSPrimitiveValue': {
- 'nativeType': 'nsROCSSPrimitiveValue',
-},
-
'CSSRule': {
'concrete': False,
'nativeType': 'mozilla::css::Rule'
},
'CSSStyleDeclaration': {
'nativeType': 'nsICSSDeclaration'
},
@@ -209,24 +205,16 @@ DOMInterfaces = {
'nativeType': 'mozilla::BindingStyleRule',
},
'CSSStyleSheet': {
'nativeType': 'mozilla::StyleSheet',
'binaryNames': { 'ownerRule': 'DOMOwnerRule' },
},
-'CSSValue': {
- 'concrete': False
-},
-
-'CSSValueList': {
- 'nativeType': 'nsDOMCSSValueList'
-},
-
'DedicatedWorkerGlobalScope': {
'headerFile': 'mozilla/dom/WorkerScope.h',
},
'DeviceAcceleration': {
'headerFile': 'mozilla/dom/DeviceMotionEvent.h',
},
@@ -713,38 +701,30 @@ DOMInterfaces = {
'Range': {
'nativeType': 'nsRange',
'binaryNames': {
'__stringifier': 'ToString'
}
},
-'Rect': {
- 'nativeType': 'nsDOMCSSRect',
-},
-
'Request': {
'binaryNames': {
'headers': 'headers_',
'referrerPolicy': 'referrerPolicy_'
},
'implicitJSContext': [ 'arrayBuffer', 'blob', 'formData', 'json', 'text' ],
},
'Response': {
'binaryNames': { 'headers': 'headers_' },
'implicitJSContext': [ 'arrayBuffer', 'blob', 'formData', 'json', 'text',
'clone', 'cloneUnfiltered' ],
},
-'RGBColor': {
- 'nativeType': 'nsDOMCSSRGBColor',
-},
-
'RTCDataChannel': {
'nativeType': 'nsDOMDataChannel',
},
'Screen': {
'nativeType': 'nsScreen',
},
--- a/dom/tests/mochitest/general/test_interfaces.js
+++ b/dom/tests/mochitest/general/test_interfaces.js
@@ -256,38 +256,32 @@ var interfaceNamesInGlobalScope =
{name: "CSSMediaRule", insecureContext: true},
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "CSSMozDocumentRule", insecureContext: true},
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "CSSNamespaceRule", insecureContext: true},
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "CSSPageRule", insecureContext: true},
// IMPORTANT: Do not change this list without review from a DOM peer!
- {name: "CSSPrimitiveValue", insecureContext: true},
-// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "CSSPseudoElement", insecureContext: true, release: false},
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "CSSRule", insecureContext: true},
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "CSSRuleList", insecureContext: true},
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "CSSStyleDeclaration", insecureContext: true},
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "CSSStyleRule", insecureContext: true},
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "CSSStyleSheet", insecureContext: true},
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "CSSSupportsRule", insecureContext: true},
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "CSSTransition", insecureContext: true, release: false},
// IMPORTANT: Do not change this list without review from a DOM peer!
- {name: "CSSValue", insecureContext: true},
-// IMPORTANT: Do not change this list without review from a DOM peer!
- {name: "CSSValueList", insecureContext: true},
-// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "CustomElementRegistry", insecureContext: true},
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "CustomEvent", insecureContext: true},
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "DataTransfer", insecureContext: true},
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "DataTransferItem", insecureContext: true},
// IMPORTANT: Do not change this list without review from a DOM peer!
@@ -816,24 +810,20 @@ var interfaceNamesInGlobalScope =
{name: "PushSubscription", insecureContext: true},
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "PushSubscriptionOptions", insecureContext: true},
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "RadioNodeList", insecureContext: true},
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "Range", insecureContext: true},
// IMPORTANT: Do not change this list without review from a DOM peer!
- {name: "Rect", insecureContext: true},
-// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "Request", insecureContext: true},
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "Response", insecureContext: true},
// IMPORTANT: Do not change this list without review from a DOM peer!
- {name: "RGBColor", insecureContext: true},
-// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "RTCCertificate", insecureContext: true},
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "RTCDataChannel", insecureContext: true},
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "RTCDataChannelEvent", insecureContext: true},
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "RTCDTMFSender", insecureContext: true},
// IMPORTANT: Do not change this list without review from a DOM peer!
deleted file mode 100644
--- a/dom/webidl/CSSPrimitiveValue.webidl
+++ /dev/null
@@ -1,54 +0,0 @@
-/* -*- 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 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;
- const unsigned short CSS_EXS = 4;
- const unsigned short CSS_PX = 5;
- const unsigned short CSS_CM = 6;
- const unsigned short CSS_MM = 7;
- const unsigned short CSS_IN = 8;
- const unsigned short CSS_PT = 9;
- const unsigned short CSS_PC = 10;
- const unsigned short CSS_DEG = 11;
- const unsigned short CSS_RAD = 12;
- const unsigned short CSS_GRAD = 13;
- const unsigned short CSS_MS = 14;
- const unsigned short CSS_S = 15;
- const unsigned short CSS_HZ = 16;
- const unsigned short CSS_KHZ = 17;
- const unsigned short CSS_DIMENSION = 18;
- const unsigned short CSS_STRING = 19;
- const unsigned short CSS_URI = 20;
- const unsigned short CSS_IDENT = 21;
- const unsigned short CSS_ATTR = 22;
- const unsigned short CSS_COUNTER = 23;
- const unsigned short CSS_RECT = 24;
- const unsigned short CSS_RGBCOLOR = 25;
-
- readonly attribute unsigned short primitiveType;
- [Throws]
- void setFloatValue(unsigned short unitType,
- float floatValue);
- [Throws]
- float getFloatValue(unsigned short unitType);
- [Throws]
- void setStringValue(unsigned short stringType,
- DOMString stringValue);
- [Throws]
- DOMString getStringValue();
- [Throws]
- void getCounterValue(); // always throws
- [Throws]
- Rect getRectValue();
- [Throws]
- RGBColor getRGBColorValue();
-};
deleted file mode 100644
--- a/dom/webidl/CSSValue.webidl
+++ /dev/null
@@ -1,19 +0,0 @@
-/* -*- 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 CSSValue {
-
- // UnitTypes
- const unsigned short CSS_INHERIT = 0;
- const unsigned short CSS_PRIMITIVE_VALUE = 1;
- const unsigned short CSS_VALUE_LIST = 2;
- const unsigned short CSS_CUSTOM = 3;
-
- [Throws]
- attribute DOMString cssText;
-
- readonly attribute unsigned short cssValueType;
-};
deleted file mode 100644
--- a/dom/webidl/CSSValueList.webidl
+++ /dev/null
@@ -1,10 +0,0 @@
-/* -*- 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 CSSValueList : CSSValue {
- readonly attribute unsigned long length;
- getter CSSValue? item(unsigned long index);
-};
deleted file mode 100644
--- a/dom/webidl/RGBColor.webidl
+++ /dev/null
@@ -1,17 +0,0 @@
-/* -*- 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/.
- *
- * The origin of this IDL file is
- * http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-RGBColor
- */
-
-interface RGBColor {
- readonly attribute CSSPrimitiveValue red;
- readonly attribute CSSPrimitiveValue green;
- readonly attribute CSSPrimitiveValue blue;
-
- // mozilla specific
- readonly attribute CSSPrimitiveValue alpha;
-};
deleted file mode 100644
--- a/dom/webidl/Rect.webidl
+++ /dev/null
@@ -1,12 +0,0 @@
-/* -*- 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 Rect {
- readonly attribute CSSPrimitiveValue top;
- readonly attribute CSSPrimitiveValue right;
- readonly attribute CSSPrimitiveValue bottom;
- readonly attribute CSSPrimitiveValue left;
-};
--- a/dom/webidl/moz.build
+++ b/dom/webidl/moz.build
@@ -438,27 +438,24 @@ WEBIDL_FILES = [
'CSSImportRule.webidl',
'CSSKeyframeRule.webidl',
'CSSKeyframesRule.webidl',
'CSSLexer.webidl',
'CSSMediaRule.webidl',
'CSSMozDocumentRule.webidl',
'CSSNamespaceRule.webidl',
'CSSPageRule.webidl',
- 'CSSPrimitiveValue.webidl',
'CSSPseudoElement.webidl',
'CSSRule.webidl',
'CSSRuleList.webidl',
'CSSStyleDeclaration.webidl',
'CSSStyleRule.webidl',
'CSSStyleSheet.webidl',
'CSSSupportsRule.webidl',
'CSSTransition.webidl',
- 'CSSValue.webidl',
- 'CSSValueList.webidl',
'CustomElementRegistry.webidl',
'DataTransfer.webidl',
'DataTransferItem.webidl',
'DataTransferItemList.webidl',
'DecoderDoctorNotification.webidl',
'DedicatedWorkerGlobalScope.webidl',
'DelayNode.webidl',
'DeviceMotionEvent.webidl',
@@ -735,20 +732,18 @@ WEBIDL_FILES = [
'PushEvent.webidl',
'PushManager.webidl',
'PushManager.webidl',
'PushMessageData.webidl',
'PushSubscription.webidl',
'PushSubscriptionOptions.webidl',
'RadioNodeList.webidl',
'Range.webidl',
- 'Rect.webidl',
'Request.webidl',
'Response.webidl',
- 'RGBColor.webidl',
'RTCStatsReport.webidl',
'Screen.webidl',
'ScreenOrientation.webidl',
'ScriptProcessorNode.webidl',
'ScrollAreaEvent.webidl',
'ScrollBoxObject.webidl',
'Selection.webidl',
'ServiceWorker.webidl',
--- a/editor/libeditor/HTMLAbsPositionEditor.cpp
+++ b/editor/libeditor/HTMLAbsPositionEditor.cpp
@@ -9,17 +9,16 @@
#include "HTMLEditorObjectResizerUtils.h"
#include "HTMLEditRules.h"
#include "HTMLEditUtils.h"
#include "TextEditUtils.h"
#include "mozilla/EditAction.h"
#include "mozilla/EditorUtils.h"
#include "mozilla/Preferences.h"
#include "mozilla/TextEditRules.h"
-#include "mozilla/dom/CSSPrimitiveValueBinding.h"
#include "mozilla/dom/Selection.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/EventTarget.h"
#include "mozilla/mozalloc.h"
#include "nsAString.h"
#include "nsAlgorithm.h"
#include "nsCOMPtr.h"
#include "nsComputedDOMStyle.h"
--- a/editor/libeditor/HTMLAnonymousNodeEditor.cpp
+++ b/editor/libeditor/HTMLAnonymousNodeEditor.cpp
@@ -1,16 +1,15 @@
/* 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 "mozilla/HTMLEditor.h"
#include "mozilla/Attributes.h"
-#include "mozilla/dom/CSSPrimitiveValueBinding.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/EventTarget.h"
#include "mozilla/mozalloc.h"
#include "nsAString.h"
#include "nsCOMPtr.h"
#include "nsComputedDOMStyle.h"
#include "nsDebug.h"
#include "nsError.h"
--- a/layout/style/CSSValue.h
+++ b/layout/style/CSSValue.h
@@ -4,39 +4,48 @@
* 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 values in DOM computed style */
#ifndef mozilla_dom_CSSValue_h_
#define mozilla_dom_CSSValue_h_
-#include "nsWrapperCache.h"
#include "nsStringFwd.h"
+#include "mozilla/RefCounted.h"
class nsROCSSPrimitiveValue;
namespace mozilla {
class ErrorResult;
} // namespace mozilla
namespace mozilla {
namespace dom {
/**
* CSSValue - a DOM object representing values in DOM computed style.
*/
-class CSSValue : public nsISupports,
- public nsWrapperCache
+class CSSValue : public RefCounted<CSSValue>
{
public:
+ MOZ_DECLARE_REFCOUNTED_TYPENAME(CSSValue);
+ enum : uint16_t {
+ CSS_INHERIT,
+ CSS_PRIMITIVE_VALUE,
+ CSS_VALUE_LIST,
+ CSS_CUSTOM,
+ };
+
// CSSValue
virtual void GetCssText(nsString& aText, mozilla::ErrorResult& aRv) = 0;
virtual void SetCssText(const nsAString& aText, mozilla::ErrorResult& aRv) = 0;
virtual uint16_t CssValueType() const = 0;
+ virtual ~CSSValue() { };
+
// Downcasting
/**
* Return this as a nsROCSSPrimitiveValue* if its a primitive value, and null
* otherwise.
*
* Defined in nsROCSSPrimitiveValue.h.
*/
--- a/layout/style/nsComputedDOMStyle.cpp
+++ b/layout/style/nsComputedDOMStyle.cpp
@@ -8,17 +8,16 @@
#include "nsComputedDOMStyle.h"
#include "mozilla/ArrayUtils.h"
#include "mozilla/FontPropertyTypes.h"
#include "mozilla/Preferences.h"
#include "nsError.h"
-#include "mozilla/dom/CSSPrimitiveValueBinding.h"
#include "nsIFrame.h"
#include "nsIFrameInlines.h"
#include "mozilla/ComputedStyle.h"
#include "nsIScrollableFrame.h"
#include "nsContentUtils.h"
#include "nsIContent.h"
#include "nsDOMCSSRect.h"
@@ -1362,17 +1361,17 @@ nsComputedDOMStyle::DoGetContent()
case eStyleContentType_Attr: {
// XXXbholley: We don't correctly serialize namespaces here. Doing so
// would require either storing the prefix on the nsStyleContentAttr,
// or poking at the namespaces in the stylesheet to map from the
// namespace URL.
nsAutoString str;
nsStyleUtil::AppendEscapedCSSIdent(
nsDependentString(data.GetAttr()->mName->GetUTF16String()), str);
- val->SetString(str, CSSPrimitiveValueBinding::CSS_ATTR);
+ val->SetString(str, nsROCSSPrimitiveValue::CSS_ATTR);
break;
}
case eStyleContentType_Counter:
case eStyleContentType_Counters: {
/* FIXME: counters should really use an object */
nsAutoString str;
if (type == eStyleContentType_Counter) {
str.AppendLiteral("counter(");
@@ -1387,17 +1386,17 @@ nsComputedDOMStyle::DoGetContent()
nsStyleUtil::AppendEscapedCSSString(counters->mSeparator, str);
}
if (counters->mCounterStyle != CounterStyleManager::GetDecimalStyle()) {
str.AppendLiteral(", ");
AppendCounterStyle(counters->mCounterStyle, str);
}
str.Append(char16_t(')'));
- val->SetString(str, CSSPrimitiveValueBinding::CSS_COUNTER);
+ val->SetString(str, nsROCSSPrimitiveValue::CSS_COUNTER);
break;
}
case eStyleContentType_OpenQuote:
val->SetIdent(eCSSKeyword_open_quote);
break;
case eStyleContentType_CloseQuote:
val->SetIdent(eCSSKeyword_close_quote);
break;
--- a/layout/style/nsDOMCSSRGBColor.cpp
+++ b/layout/style/nsDOMCSSRGBColor.cpp
@@ -3,38 +3,23 @@
/* 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 "nsROCSSPrimitiveValue.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)
{
}
-nsDOMCSSRGBColor::~nsDOMCSSRGBColor(void)
-{
-}
-
-NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(nsDOMCSSRGBColor, mAlpha, mBlue, mGreen, mRed)
-
-NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(nsDOMCSSRGBColor, AddRef)
-NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(nsDOMCSSRGBColor, Release)
-
-JSObject*
-nsDOMCSSRGBColor::WrapObject(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
-{
- return dom::RGBColorBinding::Wrap(aCx, this, aGivenProto);
-}
-
+nsDOMCSSRGBColor::~nsDOMCSSRGBColor() = default;
--- a/layout/style/nsDOMCSSRGBColor.h
+++ b/layout/style/nsDOMCSSRGBColor.h
@@ -5,33 +5,30 @@
* 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 "nsWrapperCache.h"
+#include "mozilla/RefPtr.h"
class nsROCSSPrimitiveValue;
-class nsDOMCSSRGBColor : public nsWrapperCache
+class nsDOMCSSRGBColor final : public mozilla::RefCounted<nsDOMCSSRGBColor>
{
public:
+ MOZ_DECLARE_REFCOUNTED_TYPENAME(nsDOMCSSRGBColor);
nsDOMCSSRGBColor(nsROCSSPrimitiveValue* aRed,
nsROCSSPrimitiveValue* aGreen,
nsROCSSPrimitiveValue* aBlue,
nsROCSSPrimitiveValue* aAlpha,
bool aHasAlpha);
- NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(nsDOMCSSRGBColor)
-
- NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(nsDOMCSSRGBColor)
-
bool HasAlpha() const { return mHasAlpha; }
// RGBColor webidl interface
nsROCSSPrimitiveValue* Red() const
{
return mRed;
}
nsROCSSPrimitiveValue* Green() const
@@ -42,26 +39,19 @@ public:
{
return mBlue;
}
nsROCSSPrimitiveValue* Alpha() const
{
return mAlpha;
}
- nsISupports* GetParentObject() const
- {
- return nullptr;
- }
+ ~nsDOMCSSRGBColor();
- JSObject *WrapObject(JSContext *cx, JS::Handle<JSObject*> aGivenProto) final;
-
-private:
- virtual ~nsDOMCSSRGBColor(void);
-
+protected:
RefPtr<nsROCSSPrimitiveValue> mRed;
RefPtr<nsROCSSPrimitiveValue> mGreen;
RefPtr<nsROCSSPrimitiveValue> mBlue;
RefPtr<nsROCSSPrimitiveValue> mAlpha;
bool mHasAlpha;
};
#endif // nsDOMCSSRGBColor_h__
--- a/layout/style/nsDOMCSSRect.cpp
+++ b/layout/style/nsDOMCSSRect.cpp
@@ -3,40 +3,21 @@
/* 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 "nsDOMCSSRect.h"
-#include "mozilla/dom/RectBinding.h"
#include "nsROCSSPrimitiveValue.h"
using namespace mozilla;
nsDOMCSSRect::nsDOMCSSRect(nsROCSSPrimitiveValue* aTop,
nsROCSSPrimitiveValue* aRight,
nsROCSSPrimitiveValue* aBottom,
nsROCSSPrimitiveValue* aLeft)
: mTop(aTop), mRight(aRight), mBottom(aBottom), mLeft(aLeft)
{
}
-nsDOMCSSRect::~nsDOMCSSRect(void)
-{
-}
-
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsDOMCSSRect)
- NS_INTERFACE_MAP_ENTRY(nsISupports)
- 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(nsDOMCSSRect, mTop, mBottom, mLeft, mRight)
-
-JSObject*
-nsDOMCSSRect::WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto)
-{
- return dom::RectBinding::Wrap(cx, this, aGivenProto);
-}
+nsDOMCSSRect::~nsDOMCSSRect() = default;
--- a/layout/style/nsDOMCSSRect.h
+++ b/layout/style/nsDOMCSSRect.h
@@ -5,44 +5,36 @@
* 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 "nsCycleCollectionParticipant.h"
-#include "nsWrapperCache.h"
+#include "mozilla/RefPtr.h"
class nsROCSSPrimitiveValue;
-class nsDOMCSSRect final : public nsISupports,
- public nsWrapperCache
+class nsDOMCSSRect final : public RefCounted<nsDOMCSSRect>
{
public:
+ MOZ_DECLARE_REFCOUNTED_TYPENAME(nsDOMCSSRect);
+
nsDOMCSSRect(nsROCSSPrimitiveValue* aTop,
nsROCSSPrimitiveValue* aRight,
nsROCSSPrimitiveValue* aBottom,
nsROCSSPrimitiveValue* aLeft);
- NS_DECL_CYCLE_COLLECTING_ISUPPORTS
- 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; }
-
- JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto) final;
-
-protected:
- virtual ~nsDOMCSSRect(void);
+ ~nsDOMCSSRect();
private:
RefPtr<nsROCSSPrimitiveValue> mTop;
RefPtr<nsROCSSPrimitiveValue> mRight;
RefPtr<nsROCSSPrimitiveValue> mBottom;
RefPtr<nsROCSSPrimitiveValue> mLeft;
};
--- a/layout/style/nsDOMCSSValueList.cpp
+++ b/layout/style/nsDOMCSSValueList.cpp
@@ -2,48 +2,27 @@
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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 lists of values in DOM computed style */
#include "nsDOMCSSValueList.h"
-#include "mozilla/dom/CSSValueBinding.h"
-#include "mozilla/dom/CSSValueListBinding.h"
#include "mozilla/Move.h"
using namespace mozilla;
using namespace mozilla::dom;
nsDOMCSSValueList::nsDOMCSSValueList(bool aCommaDelimited, bool aReadonly)
: CSSValue(), mCommaDelimited(aCommaDelimited), mReadonly(aReadonly)
{
}
-nsDOMCSSValueList::~nsDOMCSSValueList()
-{
-}
-
-NS_IMPL_CYCLE_COLLECTING_ADDREF(nsDOMCSSValueList)
-NS_IMPL_CYCLE_COLLECTING_RELEASE(nsDOMCSSValueList)
-
-// QueryInterface implementation for nsDOMCSSValueList
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsDOMCSSValueList)
- NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
- NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, CSSValue)
-NS_INTERFACE_MAP_END
-
-NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(nsDOMCSSValueList, mCSSValues)
-
-JSObject*
-nsDOMCSSValueList::WrapObject(JSContext *cx, JS::Handle<JSObject*> aGivenProto)
-{
- return dom::CSSValueListBinding::Wrap(cx, this, aGivenProto);
-}
+nsDOMCSSValueList::~nsDOMCSSValueList() = default;
void
nsDOMCSSValueList::AppendCSSValue(already_AddRefed<CSSValue> aValue)
{
RefPtr<CSSValue> val = aValue;
mCSSValues.AppendElement(Move(val));
}
@@ -104,10 +83,10 @@ nsDOMCSSValueList::SetCssText(const nsAS
}
MOZ_ASSERT_UNREACHABLE("Can't SetCssText yet: please write me!");
}
uint16_t
nsDOMCSSValueList::CssValueType() const
{
- return CSSValueBinding::CSS_VALUE_LIST;
+ return CSSValue::CSS_VALUE_LIST;
}
--- a/layout/style/nsDOMCSSValueList.h
+++ b/layout/style/nsDOMCSSValueList.h
@@ -10,19 +10,16 @@
#define nsDOMCSSValueList_h___
#include "CSSValue.h"
#include "nsTArray.h"
class nsDOMCSSValueList final : public mozilla::dom::CSSValue
{
public:
- NS_DECL_CYCLE_COLLECTING_ISUPPORTS
- NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsDOMCSSValueList)
-
// nsDOMCSSValueList
nsDOMCSSValueList(bool aCommaDelimited, bool aReadonly);
/**
* Adds a value to this list.
*/
void AppendCSSValue(already_AddRefed<CSSValue> aValue);
@@ -48,20 +45,18 @@ public:
return mCSSValues.Length();
}
nsISupports* GetParentObject()
{
return nullptr;
}
- virtual JSObject *WrapObject(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override;
-
-private:
- ~nsDOMCSSValueList();
+protected:
+ virtual ~nsDOMCSSValueList();
bool mCommaDelimited; // some value lists use a comma
// as the delimiter, some just use
// spaces.
bool mReadonly; // Are we read-only?
InfallibleTArray<RefPtr<CSSValue> > mCSSValues;
--- a/layout/style/nsROCSSPrimitiveValue.cpp
+++ b/layout/style/nsROCSSPrimitiveValue.cpp
@@ -3,111 +3,66 @@
/* 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 values in DOM computed style */
#include "nsROCSSPrimitiveValue.h"
-#include "mozilla/dom/CSSPrimitiveValueBinding.h"
#include "nsPresContext.h"
#include "nsStyleUtil.h"
#include "nsDOMCSSRGBColor.h"
#include "nsDOMCSSRect.h"
#include "nsIURI.h"
#include "nsError.h"
-// There is no CSS_TURN constant on the CSSPrimitiveValue interface,
-// since that unit is newer than DOM Level 2 Style, and CSS OM will
-// probably expose CSS values in some other way in the future. We
-// use this value in mType for "turn"-unit angles, but we define it
-// here to avoid exposing it to content.
-#define CSS_TURN 30U
-// Likewise we have some internal aliases for CSS_NUMBER that we don't
-// want to expose.
-#define CSS_NUMBER_INT32 31U
-#define CSS_NUMBER_UINT32 32U
-
using namespace mozilla;
using namespace mozilla::dom;
nsROCSSPrimitiveValue::nsROCSSPrimitiveValue()
- : CSSValue(), mType(CSSPrimitiveValueBinding::CSS_PX)
+ : CSSValue(), mType(CSS_PX)
{
mValue.mAppUnits = 0;
}
nsROCSSPrimitiveValue::~nsROCSSPrimitiveValue()
{
Reset();
}
-NS_IMPL_CYCLE_COLLECTING_ADDREF(nsROCSSPrimitiveValue)
-NS_IMPL_CYCLE_COLLECTING_RELEASE(nsROCSSPrimitiveValue)
-
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsROCSSPrimitiveValue)
- NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
- NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, CSSValue)
-NS_INTERFACE_MAP_END
-
-NS_IMPL_CYCLE_COLLECTION_CLASS(nsROCSSPrimitiveValue)
-
-NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(nsROCSSPrimitiveValue)
-
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsROCSSPrimitiveValue)
- if (tmp->mType == CSSPrimitiveValueBinding::CSS_URI) {
- NS_IMPL_CYCLE_COLLECTION_TRAVERSE_RAWPTR(mValue.mURI)
- } else if (tmp->mType == CSSPrimitiveValueBinding::CSS_RGBCOLOR) {
- NS_IMPL_CYCLE_COLLECTION_TRAVERSE_RAWPTR(mValue.mColor)
- } else if (tmp->mType == CSSPrimitiveValueBinding::CSS_RECT) {
- NS_IMPL_CYCLE_COLLECTION_TRAVERSE_RAWPTR(mValue.mRect)
- }
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
-
-NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsROCSSPrimitiveValue)
- NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
- tmp->Reset();
-NS_IMPL_CYCLE_COLLECTION_UNLINK_END
-
-JSObject*
-nsROCSSPrimitiveValue::WrapObject(JSContext *cx, JS::Handle<JSObject*> aGivenProto)
-{
- return dom::CSSPrimitiveValueBinding::Wrap(cx, this, aGivenProto);
-}
-
nsresult
nsROCSSPrimitiveValue::GetCssText(nsAString& aCssText)
{
nsAutoString tmpStr;
aCssText.Truncate();
nsresult result = NS_OK;
switch (mType) {
- case CSSPrimitiveValueBinding::CSS_PX:
+ case CSS_PX:
{
float val = nsPresContext::AppUnitsToFloatCSSPixels(mValue.mAppUnits);
nsStyleUtil::AppendCSSNumber(val, tmpStr);
tmpStr.AppendLiteral("px");
break;
}
- case CSSPrimitiveValueBinding::CSS_IDENT:
+ case CSS_IDENT:
{
AppendUTF8toUTF16(nsCSSKeywords::GetStringValue(mValue.mKeyword),
tmpStr);
break;
}
- case CSSPrimitiveValueBinding::CSS_STRING:
- case CSSPrimitiveValueBinding::CSS_COUNTER: /* FIXME: COUNTER should use an object */
+ case CSS_STRING:
+ case CSS_COUNTER: /* FIXME: COUNTER should use an object */
{
tmpStr.Append(mValue.mString);
break;
}
- case CSSPrimitiveValueBinding::CSS_URI:
+ case CSS_URI:
{
if (mValue.mURI) {
nsAutoCString specUTF8;
nsresult rv = mValue.mURI->GetSpec(specUTF8);
NS_ENSURE_SUCCESS(rv, rv);
tmpStr.AssignLiteral("url(");
nsStyleUtil::AppendEscapedCSSString(NS_ConvertUTF8toUTF16(specUTF8),
@@ -117,69 +72,69 @@ nsROCSSPrimitiveValue::GetCssText(nsAStr
// http://dev.w3.org/csswg/css3-values/#attr defines
// 'about:invalid' as the default value for url attributes,
// so let's also use it here as the default computed value
// for invalid URLs.
tmpStr.AssignLiteral(u"url(about:invalid)");
}
break;
}
- case CSSPrimitiveValueBinding::CSS_ATTR:
+ case CSS_ATTR:
{
tmpStr.AppendLiteral("attr(");
tmpStr.Append(mValue.mString);
tmpStr.Append(char16_t(')'));
break;
}
- case CSSPrimitiveValueBinding::CSS_PERCENTAGE:
+ case CSS_PERCENTAGE:
{
nsStyleUtil::AppendCSSNumber(mValue.mFloat * 100, tmpStr);
tmpStr.Append(char16_t('%'));
break;
}
- case CSSPrimitiveValueBinding::CSS_NUMBER:
+ case CSS_NUMBER:
{
nsStyleUtil::AppendCSSNumber(mValue.mFloat, tmpStr);
break;
}
case CSS_NUMBER_INT32:
{
tmpStr.AppendInt(mValue.mInt32);
break;
}
case CSS_NUMBER_UINT32:
{
tmpStr.AppendInt(mValue.mUint32);
break;
}
- case CSSPrimitiveValueBinding::CSS_DEG:
+ case CSS_DEG:
{
nsStyleUtil::AppendCSSNumber(mValue.mFloat, tmpStr);
tmpStr.AppendLiteral("deg");
break;
}
- case CSSPrimitiveValueBinding::CSS_GRAD:
+ case CSS_GRAD:
{
nsStyleUtil::AppendCSSNumber(mValue.mFloat, tmpStr);
tmpStr.AppendLiteral("grad");
break;
}
- case CSSPrimitiveValueBinding::CSS_RAD:
+ case CSS_RAD:
{
nsStyleUtil::AppendCSSNumber(mValue.mFloat, tmpStr);
tmpStr.AppendLiteral("rad");
break;
}
case CSS_TURN:
{
nsStyleUtil::AppendCSSNumber(mValue.mFloat, tmpStr);
tmpStr.AppendLiteral("turn");
break;
}
- case CSSPrimitiveValueBinding::CSS_RECT:
+ case CSS_RECT:
{
NS_ASSERTION(mValue.mRect, "mValue.mRect should never be null");
NS_NAMED_LITERAL_STRING(comma, ", ");
nsAutoString sideValue;
tmpStr.AssignLiteral("rect(");
// get the top
result = mValue.mRect->Top()->GetCssText(sideValue);
if (NS_FAILED(result))
@@ -197,17 +152,17 @@ nsROCSSPrimitiveValue::GetCssText(nsAStr
tmpStr.Append(sideValue + comma);
// get the left
result = mValue.mRect->Left()->GetCssText(sideValue);
if (NS_FAILED(result))
break;
tmpStr.Append(sideValue + NS_LITERAL_STRING(")"));
break;
}
- case CSSPrimitiveValueBinding::CSS_RGBCOLOR:
+ case CSS_RGBCOLOR:
{
NS_ASSERTION(mValue.mColor, "mValue.mColor should never be null");
ErrorResult error;
NS_NAMED_LITERAL_STRING(comma, ", ");
nsAutoString colorValue;
if (mValue.mColor->HasAlpha())
tmpStr.AssignLiteral("rgba(");
else
@@ -238,34 +193,34 @@ nsROCSSPrimitiveValue::GetCssText(nsAStr
break;
tmpStr.Append(comma + colorValue);
}
tmpStr.Append(')');
break;
}
- case CSSPrimitiveValueBinding::CSS_S:
+ case CSS_S:
{
nsStyleUtil::AppendCSSNumber(mValue.mFloat, tmpStr);
tmpStr.Append('s');
break;
}
- case CSSPrimitiveValueBinding::CSS_CM:
- case CSSPrimitiveValueBinding::CSS_MM:
- case CSSPrimitiveValueBinding::CSS_IN:
- case CSSPrimitiveValueBinding::CSS_PT:
- case CSSPrimitiveValueBinding::CSS_PC:
- case CSSPrimitiveValueBinding::CSS_UNKNOWN:
- case CSSPrimitiveValueBinding::CSS_EMS:
- case CSSPrimitiveValueBinding::CSS_EXS:
- case CSSPrimitiveValueBinding::CSS_MS:
- case CSSPrimitiveValueBinding::CSS_HZ:
- case CSSPrimitiveValueBinding::CSS_KHZ:
- case CSSPrimitiveValueBinding::CSS_DIMENSION:
+ case CSS_CM:
+ case CSS_MM:
+ case CSS_IN:
+ case CSS_PT:
+ case CSS_PC:
+ case CSS_UNKNOWN:
+ case CSS_EMS:
+ case CSS_EXS:
+ case CSS_MS:
+ case CSS_HZ:
+ case CSS_KHZ:
+ case CSS_DIMENSION:
NS_ERROR("We have a bogus value set. This should not happen");
return NS_ERROR_DOM_INVALID_ACCESS_ERR;
}
if (NS_SUCCEEDED(result)) {
aCssText.Assign(tmpStr);
}
@@ -282,106 +237,106 @@ void
nsROCSSPrimitiveValue::SetCssText(const nsAString& aText, ErrorResult& aRv)
{
aRv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR);
}
uint16_t
nsROCSSPrimitiveValue::CssValueType() const
{
- return CSSValueBinding::CSS_PRIMITIVE_VALUE;
+ return CSSValue::CSS_PRIMITIVE_VALUE;
}
void
nsROCSSPrimitiveValue::SetFloatValue(uint16_t aType, float aVal,
ErrorResult& aRv)
{
aRv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR);
}
float
nsROCSSPrimitiveValue::GetFloatValue(uint16_t aUnitType, ErrorResult& aRv)
{
switch(aUnitType) {
- case CSSPrimitiveValueBinding::CSS_PX:
- if (mType == CSSPrimitiveValueBinding::CSS_PX) {
+ case CSS_PX:
+ if (mType == CSS_PX) {
return nsPresContext::AppUnitsToFloatCSSPixels(mValue.mAppUnits);
}
break;
- case CSSPrimitiveValueBinding::CSS_CM:
- if (mType == CSSPrimitiveValueBinding::CSS_PX) {
+ case CSS_CM:
+ if (mType == CSS_PX) {
return mValue.mAppUnits * CM_PER_INCH_FLOAT /
nsPresContext::AppUnitsPerCSSInch();
}
break;
- case CSSPrimitiveValueBinding::CSS_MM:
- if (mType == CSSPrimitiveValueBinding::CSS_PX) {
+ case CSS_MM:
+ if (mType == CSS_PX) {
return mValue.mAppUnits * MM_PER_INCH_FLOAT /
nsPresContext::AppUnitsPerCSSInch();
}
break;
- case CSSPrimitiveValueBinding::CSS_IN:
- if (mType == CSSPrimitiveValueBinding::CSS_PX) {
+ case CSS_IN:
+ if (mType == CSS_PX) {
return mValue.mAppUnits / nsPresContext::AppUnitsPerCSSInch();
}
break;
- case CSSPrimitiveValueBinding::CSS_PT:
- if (mType == CSSPrimitiveValueBinding::CSS_PX) {
+ case CSS_PT:
+ if (mType == CSS_PX) {
return mValue.mAppUnits * POINTS_PER_INCH_FLOAT /
nsPresContext::AppUnitsPerCSSInch();
}
break;
- case CSSPrimitiveValueBinding::CSS_PC:
- if (mType == CSSPrimitiveValueBinding::CSS_PX) {
+ case CSS_PC:
+ if (mType == CSS_PX) {
return mValue.mAppUnits * 6.0f /
nsPresContext::AppUnitsPerCSSInch();
}
break;
- case CSSPrimitiveValueBinding::CSS_PERCENTAGE:
- if (mType == CSSPrimitiveValueBinding::CSS_PERCENTAGE) {
+ case CSS_PERCENTAGE:
+ if (mType == CSS_PERCENTAGE) {
return mValue.mFloat * 100;
}
break;
- case CSSPrimitiveValueBinding::CSS_NUMBER:
- if (mType == CSSPrimitiveValueBinding::CSS_NUMBER) {
+ case CSS_NUMBER:
+ if (mType == CSS_NUMBER) {
return mValue.mFloat;
}
if (mType == CSS_NUMBER_INT32) {
return mValue.mInt32;
}
if (mType == CSS_NUMBER_UINT32) {
return mValue.mUint32;
}
break;
- case CSSPrimitiveValueBinding::CSS_UNKNOWN:
- case CSSPrimitiveValueBinding::CSS_EMS:
- case CSSPrimitiveValueBinding::CSS_EXS:
- case CSSPrimitiveValueBinding::CSS_DEG:
- case CSSPrimitiveValueBinding::CSS_RAD:
- case CSSPrimitiveValueBinding::CSS_GRAD:
- case CSSPrimitiveValueBinding::CSS_MS:
- case CSSPrimitiveValueBinding::CSS_S:
- case CSSPrimitiveValueBinding::CSS_HZ:
- case CSSPrimitiveValueBinding::CSS_KHZ:
- case CSSPrimitiveValueBinding::CSS_DIMENSION:
- case CSSPrimitiveValueBinding::CSS_STRING:
- case CSSPrimitiveValueBinding::CSS_URI:
- case CSSPrimitiveValueBinding::CSS_IDENT:
- case CSSPrimitiveValueBinding::CSS_ATTR:
- case CSSPrimitiveValueBinding::CSS_COUNTER:
- case CSSPrimitiveValueBinding::CSS_RECT:
- case CSSPrimitiveValueBinding::CSS_RGBCOLOR:
+ case CSS_UNKNOWN:
+ case CSS_EMS:
+ case CSS_EXS:
+ case CSS_DEG:
+ case CSS_RAD:
+ case CSS_GRAD:
+ case CSS_MS:
+ case CSS_S:
+ case CSS_HZ:
+ case CSS_KHZ:
+ case CSS_DIMENSION:
+ case CSS_STRING:
+ case CSS_URI:
+ case CSS_IDENT:
+ case CSS_ATTR:
+ case CSS_COUNTER:
+ case CSS_RECT:
+ case CSS_RGBCOLOR:
break;
}
aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
return 0;
}
void
@@ -390,24 +345,24 @@ nsROCSSPrimitiveValue::SetStringValue(ui
{
aRv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR);
}
void
nsROCSSPrimitiveValue::GetStringValue(nsString& aReturn, ErrorResult& aRv)
{
switch (mType) {
- case CSSPrimitiveValueBinding::CSS_IDENT:
+ case CSS_IDENT:
CopyUTF8toUTF16(nsCSSKeywords::GetStringValue(mValue.mKeyword), aReturn);
break;
- case CSSPrimitiveValueBinding::CSS_STRING:
- case CSSPrimitiveValueBinding::CSS_ATTR:
+ case CSS_STRING:
+ case CSS_ATTR:
aReturn.Assign(mValue.mString);
break;
- case CSSPrimitiveValueBinding::CSS_URI: {
+ case CSS_URI: {
nsAutoCString spec;
if (mValue.mURI) {
nsresult rv = mValue.mURI->GetSpec(spec);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return;
}
}
@@ -425,43 +380,43 @@ void
nsROCSSPrimitiveValue::GetCounterValue(ErrorResult& aRv)
{
aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
}
nsDOMCSSRect*
nsROCSSPrimitiveValue::GetRectValue(ErrorResult& aRv)
{
- if (mType != CSSPrimitiveValueBinding::CSS_RECT) {
+ if (mType != CSS_RECT) {
aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
return nullptr;
}
NS_ASSERTION(mValue.mRect, "mValue.mRect should never be null");
return mValue.mRect;
}
nsDOMCSSRGBColor*
nsROCSSPrimitiveValue::GetRGBColorValue(ErrorResult& aRv)
{
- if (mType != CSSPrimitiveValueBinding::CSS_RGBCOLOR) {
+ if (mType != CSS_RGBCOLOR) {
aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
return nullptr;
}
NS_ASSERTION(mValue.mColor, "mValue.mColor should never be null");
return mValue.mColor;
}
void
nsROCSSPrimitiveValue::SetNumber(float aValue)
{
Reset();
mValue.mFloat = aValue;
- mType = CSSPrimitiveValueBinding::CSS_NUMBER;
+ mType = CSS_NUMBER;
}
void
nsROCSSPrimitiveValue::SetNumber(int32_t aValue)
{
Reset();
mValue.mInt32 = aValue;
mType = CSS_NUMBER_INT32;
@@ -475,186 +430,185 @@ nsROCSSPrimitiveValue::SetNumber(uint32_
mType = CSS_NUMBER_UINT32;
}
void
nsROCSSPrimitiveValue::SetPercent(float aValue)
{
Reset();
mValue.mFloat = aValue;
- mType = CSSPrimitiveValueBinding::CSS_PERCENTAGE;
+ mType = CSS_PERCENTAGE;
}
void
nsROCSSPrimitiveValue::SetDegree(float aValue)
{
Reset();
mValue.mFloat = aValue;
- mType = CSSPrimitiveValueBinding::CSS_DEG;
+ mType = CSS_DEG;
}
void
nsROCSSPrimitiveValue::SetGrad(float aValue)
{
Reset();
mValue.mFloat = aValue;
- mType = CSSPrimitiveValueBinding::CSS_GRAD;
+ mType = CSS_GRAD;
}
void
nsROCSSPrimitiveValue::SetRadian(float aValue)
{
Reset();
mValue.mFloat = aValue;
- mType = CSSPrimitiveValueBinding::CSS_RAD;
+ mType = CSS_RAD;
}
void
nsROCSSPrimitiveValue::SetTurn(float aValue)
{
Reset();
mValue.mFloat = aValue;
mType = CSS_TURN;
}
void
nsROCSSPrimitiveValue::SetAppUnits(nscoord aValue)
{
Reset();
mValue.mAppUnits = aValue;
- mType = CSSPrimitiveValueBinding::CSS_PX;
+ mType = CSS_PX;
}
void
nsROCSSPrimitiveValue::SetAppUnits(float aValue)
{
SetAppUnits(NSToCoordRound(aValue));
}
void
nsROCSSPrimitiveValue::SetIdent(nsCSSKeyword aKeyword)
{
NS_PRECONDITION(aKeyword != eCSSKeyword_UNKNOWN &&
0 <= aKeyword && aKeyword < eCSSKeyword_COUNT,
"bad keyword");
Reset();
mValue.mKeyword = aKeyword;
- mType = CSSPrimitiveValueBinding::CSS_IDENT;
+ mType = CSS_IDENT;
}
// FIXME: CSS_STRING should imply a string with "" and a need for escaping.
void
nsROCSSPrimitiveValue::SetString(const nsACString& aString, uint16_t aType)
{
Reset();
mValue.mString = ToNewUnicode(aString);
if (mValue.mString) {
mType = aType;
} else {
// XXXcaa We should probably let the caller know we are out of memory
- mType = CSSPrimitiveValueBinding::CSS_UNKNOWN;
+ mType = CSS_UNKNOWN;
}
}
// FIXME: CSS_STRING should imply a string with "" and a need for escaping.
void
nsROCSSPrimitiveValue::SetString(const nsAString& aString, uint16_t aType)
{
Reset();
mValue.mString = ToNewUnicode(aString);
if (mValue.mString) {
mType = aType;
} else {
// XXXcaa We should probably let the caller know we are out of memory
- mType = CSSPrimitiveValueBinding::CSS_UNKNOWN;
+ mType = CSS_UNKNOWN;
}
}
void
nsROCSSPrimitiveValue::SetURI(nsIURI *aURI)
{
Reset();
mValue.mURI = aURI;
NS_IF_ADDREF(mValue.mURI);
- mType = CSSPrimitiveValueBinding::CSS_URI;
+ mType = CSS_URI;
}
void
nsROCSSPrimitiveValue::SetColor(nsDOMCSSRGBColor* aColor)
{
NS_PRECONDITION(aColor, "Null RGBColor being set!");
Reset();
mValue.mColor = aColor;
if (mValue.mColor) {
NS_ADDREF(mValue.mColor);
- mType = CSSPrimitiveValueBinding::CSS_RGBCOLOR;
+ mType = CSS_RGBCOLOR;
}
else {
- mType = CSSPrimitiveValueBinding::CSS_UNKNOWN;
+ mType = CSS_UNKNOWN;
}
}
void
nsROCSSPrimitiveValue::SetRect(nsDOMCSSRect* aRect)
{
NS_PRECONDITION(aRect, "Null rect being set!");
Reset();
mValue.mRect = aRect;
if (mValue.mRect) {
NS_ADDREF(mValue.mRect);
- mType = CSSPrimitiveValueBinding::CSS_RECT;
+ mType = CSS_RECT;
}
else {
- mType = CSSPrimitiveValueBinding::CSS_UNKNOWN;
+ mType = CSS_UNKNOWN;
}
}
void
nsROCSSPrimitiveValue::SetTime(float aValue)
{
Reset();
mValue.mFloat = aValue;
- mType = CSSPrimitiveValueBinding::CSS_S;
+ mType = CSS_S;
}
void
nsROCSSPrimitiveValue::Reset()
{
switch (mType) {
- case CSSPrimitiveValueBinding::CSS_IDENT:
+ case CSS_IDENT:
break;
- case CSSPrimitiveValueBinding::CSS_STRING:
- case CSSPrimitiveValueBinding::CSS_ATTR:
- case CSSPrimitiveValueBinding::CSS_COUNTER: // FIXME: Counter should use an object
+ case CSS_STRING:
+ case CSS_ATTR:
+ case CSS_COUNTER: // FIXME: Counter should use an object
NS_ASSERTION(mValue.mString, "Null string should never happen");
free(mValue.mString);
mValue.mString = nullptr;
break;
- case CSSPrimitiveValueBinding::CSS_URI:
+ case CSS_URI:
NS_IF_RELEASE(mValue.mURI);
break;
- case CSSPrimitiveValueBinding::CSS_RECT:
+ case CSS_RECT:
NS_ASSERTION(mValue.mRect, "Null Rect should never happen");
NS_RELEASE(mValue.mRect);
break;
- case CSSPrimitiveValueBinding::CSS_RGBCOLOR:
+ case CSS_RGBCOLOR:
NS_ASSERTION(mValue.mColor, "Null RGBColor should never happen");
NS_RELEASE(mValue.mColor);
break;
}
- mType = CSSPrimitiveValueBinding::CSS_UNKNOWN;
+ mType = CSS_UNKNOWN;
}
uint16_t
nsROCSSPrimitiveValue::PrimitiveType()
{
// New value types were introduced but not added to CSS OM.
// Return CSS_UNKNOWN to avoid exposing CSS_TURN to content.
- if (mType > CSSPrimitiveValueBinding::CSS_RGBCOLOR) {
- if (mType == CSS_NUMBER_INT32 ||
- mType == CSS_NUMBER_UINT32) {
- return CSSPrimitiveValueBinding::CSS_NUMBER;
+ if (mType > CSS_RGBCOLOR) {
+ if (mType == CSS_NUMBER_INT32 || mType == CSS_NUMBER_UINT32) {
+ return CSS_NUMBER;
}
- return CSSPrimitiveValueBinding::CSS_UNKNOWN;
+ return CSS_UNKNOWN;
}
return mType;
}
--- a/layout/style/nsROCSSPrimitiveValue.h
+++ b/layout/style/nsROCSSPrimitiveValue.h
@@ -4,37 +4,63 @@
* 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 values in DOM computed style */
#ifndef nsROCSSPrimitiveValue_h___
#define nsROCSSPrimitiveValue_h___
-#include "mozilla/dom/CSSPrimitiveValueBinding.h"
-#include "mozilla/dom/CSSValueBinding.h"
-
#include "nsCSSKeywords.h"
#include "CSSValue.h"
#include "nsCOMPtr.h"
#include "nsCoord.h"
class nsIURI;
class nsDOMCSSRect;
class nsDOMCSSRGBColor;
/**
* Read-only CSS primitive value - a DOM object representing values in DOM
* computed style.
*/
class nsROCSSPrimitiveValue final : public mozilla::dom::CSSValue
{
public:
- NS_DECL_CYCLE_COLLECTING_ISUPPORTS
- NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsROCSSPrimitiveValue)
+ enum : uint16_t {
+ CSS_UNKNOWN,
+ CSS_NUMBER,
+ CSS_PERCENTAGE,
+ CSS_EMS,
+ CSS_EXS,
+ CSS_PX,
+ CSS_CM,
+ CSS_MM,
+ CSS_IN,
+ CSS_PT,
+ CSS_PC,
+ CSS_DEG,
+ CSS_RAD,
+ CSS_GRAD,
+ CSS_MS,
+ CSS_S,
+ CSS_HZ,
+ CSS_KHZ,
+ CSS_DIMENSION,
+ CSS_STRING,
+ CSS_URI,
+ CSS_IDENT,
+ CSS_ATTR,
+ CSS_COUNTER,
+ CSS_RECT,
+ CSS_RGBCOLOR,
+ CSS_TURN,
+ CSS_NUMBER_INT32,
+ CSS_NUMBER_UINT32,
+ };
// CSSValue
void GetCssText(nsString& aText, mozilla::ErrorResult& aRv) final;
void SetCssText(const nsAString& aText, mozilla::ErrorResult& aRv) final;
uint16_t CssValueType() const final;
// CSSPrimitiveValue
uint16_t PrimitiveType();
@@ -59,38 +85,27 @@ public:
void SetDegree(float aValue);
void SetGrad(float aValue);
void SetRadian(float aValue);
void SetTurn(float aValue);
void SetAppUnits(nscoord aValue);
void SetAppUnits(float aValue);
void SetIdent(nsCSSKeyword aKeyword);
// FIXME: CSS_STRING should imply a string with "" and a need for escaping.
- void SetString(
- const nsACString& aString,
- uint16_t aType = mozilla::dom::CSSPrimitiveValueBinding::CSS_STRING);
+ void SetString(const nsACString& aString, uint16_t aType = CSS_STRING);
// FIXME: CSS_STRING should imply a string with "" and a need for escaping.
- void SetString(
- const nsAString& aString,
- uint16_t aType = mozilla::dom::CSSPrimitiveValueBinding::CSS_STRING);
+ void SetString(const nsAString& aString, uint16_t aType = CSS_STRING);
void SetURI(nsIURI *aURI);
void SetColor(nsDOMCSSRGBColor* aColor);
void SetRect(nsDOMCSSRect* aRect);
void SetTime(float aValue);
void Reset();
- nsISupports* GetParentObject() const
- {
- return nullptr;
- }
-
- virtual JSObject *WrapObject(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override;
-
-private:
- ~nsROCSSPrimitiveValue();
+ virtual ~nsROCSSPrimitiveValue();
+protected:
uint16_t mType;
union {
nscoord mAppUnits;
float mFloat;
int32_t mInt32;
uint32_t mUint32;
@@ -101,13 +116,13 @@ private:
nsIURI* MOZ_OWNING_REF mURI;
nsCSSKeyword mKeyword;
} mValue;
};
inline nsROCSSPrimitiveValue*
mozilla::dom::CSSValue::AsPrimitiveValue()
{
- return CssValueType() == CSSValueBinding::CSS_PRIMITIVE_VALUE ?
- static_cast<nsROCSSPrimitiveValue*>(this) : nullptr;
+ return CssValueType() == mozilla::dom::CSSValue::CSS_PRIMITIVE_VALUE
+ ? static_cast<nsROCSSPrimitiveValue*>(this) : nullptr;
}
#endif /* nsROCSSPrimitiveValue_h___ */