Bug 921191 - Allow inspection/editing of SVG elements' CSS properties. r=mratcliffe

This commit is contained in:
Paul Rouget 2013-10-09 09:46:48 -04:00
parent 999a9d57df
commit 2184c53f22
4 changed files with 98 additions and 3 deletions

View File

@ -564,6 +564,14 @@ var StyleSheetActor = protocol.ActorClass({
return this.actorID;
}
let href;
if (this.rawSheet.ownerNode) {
if (this.rawSheet.ownerNode instanceof Ci.nsIDOMHTMLDocument)
href = this.rawSheet.ownerNode.location.href;
if (this.rawSheet.ownerNode.ownerDocument)
href = this.rawSheet.ownerNode.ownerDocument.location.href;
}
return {
actor: this.actorID,
@ -572,7 +580,7 @@ var StyleSheetActor = protocol.ActorClass({
// nodeHref stores the URI of the document that
// included the sheet.
nodeHref: this.rawSheet.ownerNode ? this.rawSheet.ownerNode.ownerDocument.location.href : undefined,
nodeHref: href,
system: !CssLogic.isContentStylesheet(this.rawSheet),
disabled: this.rawSheet.disabled ? true : undefined
@ -719,9 +727,13 @@ var StyleRuleActor = protocol.ActorClass({
let document;
if (this.rawNode) {
document = this.rawNode.ownerDocument;
} else {
if (this.rawRule.parentStyleSheet.ownerNode instanceof Ci.nsIDOMHTMLDocument) {
document = this.rawRule.parentStyleSheet.ownerNode;
} else {
document = this.rawRule.parentStyleSheet.ownerNode.ownerDocument;
}
}
let tempElement = document.createElement("div");

View File

@ -27,5 +27,6 @@ support-files =
[test_styles-computed.html]
[test_styles-matched.html]
[test_styles-modify.html]
[test_styles-svg.html]
[test_unsafeDereference.html]
[test_evalInGlobal-outerized_this.html]

View File

@ -16,6 +16,9 @@
background-color: #f06;
}
}
#svgcontent rect {
fill: rgb(1,2,3);
}
</style>
<link type="text/css" rel="stylesheet" href="inspector-styles-data.css"></link>
<body>
@ -51,5 +54,9 @@
Screen mediaqueried.
</div>
<div id="svgcontent">
<svg><rect></rect></svg>
</div>
</body>
</html>

View File

@ -0,0 +1,75 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=921191
Bug 921191 - allow inspection/editing of SVG elements' CSS properties
-->
<head>
<meta charset="utf-8">
<title>Test for Bug </title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
<script type="application/javascript;version=1.8" src="inspector-helpers.js"></script>
<script type="application/javascript;version=1.8">
Components.utils.import("resource://gre/modules/devtools/Loader.jsm");
const promise = devtools.require("sdk/core/promise");
const inspector = devtools.require("devtools/server/actors/inspector");
window.onload = function() {
SimpleTest.waitForExplicitFinish();
runNextTest();
}
var gWalker = null;
var gStyles = null;
var gClient = null;
addTest(function setup() {
let url = document.getElementById("inspectorContent").href;
attachURL(url, function(err, client, tab, doc) {
gInspectee = doc;
let {InspectorFront} = devtools.require("devtools/server/actors/inspector");
let inspector = InspectorFront(client, tab);
promiseDone(inspector.getWalker().then(walker => {
ok(walker, "getWalker() should return an actor.");
gClient = client;
gWalker = walker;
return inspector.getPageStyle();
}).then(styles => {
gStyles = styles;
}).then(runNextTest));
});
});
addTest(function inheritedUserStyles() {
let node = node;
promiseDone(gWalker.querySelector(gWalker.rootNode, "#svgcontent rect").then(node => {
return gStyles.getApplied(node, { inherited: true, filter: "user" });
}).then(applied => {
is(applied.length, 3, "Should have 3 rules");
is(applied[1].rule.cssText, "fill: rgb(1, 2, 3);", "cssText is right");
}).then(runNextTest));
});
addTest(function cleanup() {
delete gStyles;
delete gWalker;
delete gClient;
runNextTest();
});
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=921191">Mozilla Bug 921191</a>
<a id="inspectorContent" target="_blank" href="inspector-styles-data.html">Test Document</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
</pre>
</body>
</html>