summaryrefslogtreecommitdiffstats
path: root/devtools/client/fronts/media-rule.js
diff options
context:
space:
mode:
Diffstat (limited to 'devtools/client/fronts/media-rule.js')
-rw-r--r--devtools/client/fronts/media-rule.js54
1 files changed, 54 insertions, 0 deletions
diff --git a/devtools/client/fronts/media-rule.js b/devtools/client/fronts/media-rule.js
new file mode 100644
index 0000000000..48f23aa61e
--- /dev/null
+++ b/devtools/client/fronts/media-rule.js
@@ -0,0 +1,54 @@
+/* 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/. */
+
+"use strict";
+
+const {
+ FrontClassWithSpec,
+ registerFront,
+} = require("devtools/shared/protocol");
+const { mediaRuleSpec } = require("devtools/shared/specs/media-rule");
+
+/**
+ * Corresponding client-side front for a MediaRuleActor.
+ */
+class MediaRuleFront extends FrontClassWithSpec(mediaRuleSpec) {
+ constructor(client, targetFront, parentFront) {
+ super(client, targetFront, parentFront);
+
+ this._onMatchesChange = this._onMatchesChange.bind(this);
+ this.on("matches-change", this._onMatchesChange);
+ }
+
+ _onMatchesChange(matches) {
+ this._form.matches = matches;
+ }
+
+ form(form) {
+ this.actorID = form.actor;
+ this._form = form;
+ }
+
+ get mediaText() {
+ return this._form.mediaText;
+ }
+ get conditionText() {
+ return this._form.conditionText;
+ }
+ get matches() {
+ return this._form.matches;
+ }
+ get line() {
+ return this._form.line || -1;
+ }
+ get column() {
+ return this._form.column || -1;
+ }
+ get parentStyleSheet() {
+ return this.conn.getFrontByID(this._form.parentStyleSheet);
+ }
+}
+
+exports.MediaRuleFront = MediaRuleFront;
+registerFront(MediaRuleFront);