Bug 1273706 - Part 22: Add WebIDL bindings for the Properties & Values API. r?dbaron
MozReview-Commit-ID: 5q3vLYLqHFg
--- a/dom/webidl/CSS.webidl
+++ b/dom/webidl/CSS.webidl
@@ -17,8 +17,16 @@ interface CSS {
[Throws]
static boolean supports(DOMString conditionText);
};
// http://dev.w3.org/csswg/cssom/#the-css.escape%28%29-method
partial interface CSS {
static DOMString escape(DOMString ident);
};
+
+// https://drafts.css-houdini.org/css-properties-values-api/#registering-custom-properties
+partial interface CSS {
+ [Throws,Pref="layout.css.properties_and_values.enabled"]
+ static void registerProperty(PropertyDescriptorDict descriptor);
+ [Throws,Pref="layout.css.properties_and_values.enabled"]
+ static void unregisterProperty(DOMString name);
+};
new file mode 100644
--- /dev/null
+++ b/dom/webidl/PropertyDescriptorDict.webidl
@@ -0,0 +1,21 @@
+/* -*- 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
+ * https://drafts.css-houdini.org/css-properties-values-api/#registering-custom-properties
+ *
+ * Copyright © 2016 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
+ * liability, trademark and document use rules apply.
+ */
+
+// Renamed from PropertyDescriptor to avoid conflicting with a JS class of the
+// same name.
+dictionary PropertyDescriptorDict
+{
+ required DOMString name;
+ DOMString syntax;
+ boolean inherits;
+ DOMString initialValue;
+};
--- a/dom/webidl/moz.build
+++ b/dom/webidl/moz.build
@@ -386,16 +386,17 @@ WEBIDL_FILES = [
'PresentationAvailability.webidl',
'PresentationConnection.webidl',
'PresentationConnectionList.webidl',
'PresentationDeviceInfoManager.webidl',
'PresentationReceiver.webidl',
'PresentationRequest.webidl',
'ProcessingInstruction.webidl',
'ProfileTimelineMarker.webidl',
+ 'PropertyDescriptorDict.webidl',
'RadioNodeList.webidl',
'Range.webidl',
'Rect.webidl',
'Request.webidl',
'ResourceStats.webidl',
'ResourceStatsManager.webidl',
'Response.webidl',
'RGBColor.webidl',
--- a/layout/style/CSS.cpp
+++ b/layout/style/CSS.cpp
@@ -102,10 +102,26 @@ CSS::Supports(const GlobalObject& aGloba
/* static */ void
CSS::Escape(const GlobalObject& aGlobal,
const nsAString& aIdent,
nsAString& aReturn)
{
nsStyleUtil::AppendEscapedCSSIdent(aIdent, aReturn);
}
+/* static */ void
+CSS::RegisterProperty(const GlobalObject& aGlobal,
+ const mozilla::dom::PropertyDescriptorDict& aDescriptor,
+ mozilla::ErrorResult& aRv)
+{
+ // STUB: populated by a later patch in this series
+}
+
+/* static */ void
+CSS::UnregisterProperty(const GlobalObject& aGlobal,
+ const nsAString& aName,
+ mozilla::ErrorResult& aRv)
+{
+ // STUB: populated by a later patch in this series
+}
+
} // namespace dom
} // namespace mozilla
--- a/layout/style/CSS.h
+++ b/layout/style/CSS.h
@@ -13,16 +13,17 @@
namespace mozilla {
class ErrorResult;
namespace dom {
class GlobalObject;
+struct PropertyDescriptorDict;
class CSS {
private:
CSS() = delete;
public:
static bool Supports(const GlobalObject& aGlobal,
const nsAString& aProperty,
@@ -31,14 +32,22 @@ public:
static bool Supports(const GlobalObject& aGlobal,
const nsAString& aDeclaration,
ErrorResult& aRv);
static void Escape(const GlobalObject& aGlobal,
const nsAString& aIdent,
nsAString& aReturn);
+
+ static void RegisterProperty(const GlobalObject& aGlobal,
+ const mozilla::dom::PropertyDescriptorDict& aDescriptor,
+ mozilla::ErrorResult& aRv);
+
+ static void UnregisterProperty(const GlobalObject& aGlobal,
+ const nsAString& aName,
+ mozilla::ErrorResult& aRv);
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_CSS_h_