Bug 923884 - Always use authored colors in markup view. r=jwalker

This commit is contained in:
Michael Ratcliffe 2013-10-08 13:53:19 +01:00
Родитель 97c0516b1a
Коммит 9cab056f2c
3 изменённых файлов: 4 добавлений и 99 удалений

Просмотреть файл

@ -18,7 +18,6 @@ const CONTAINER_FLASHING_DURATION = 500;
const {UndoStack} = require("devtools/shared/undo");
const {editableField, InplaceEditor} = require("devtools/shared/inplace-editor");
const {gDevTools} = Cu.import("resource:///modules/devtools/gDevTools.jsm", {});
const {colorUtils} = require("devtools/css-color");
const promise = require("sdk/core/promise");
Cu.import("resource://gre/modules/devtools/LayoutHelpers.jsm");
@ -410,7 +409,7 @@ MarkupView.prototype = {
continue;
}
if (type === "attributes" || type === "characterData") {
container.update(false);
container.update();
} else if (type === "childList") {
container.childrenDirty = true;
// Update the children to take care of changes in the DOM
@ -1151,9 +1150,9 @@ MarkupContainer.prototype = {
* Update the container's editor to the current state of the
* viewed node.
*/
update: function(parseColors=true) {
update: function() {
if (this.editor.update) {
this.editor.update(parseColors);
this.editor.update();
}
},
@ -1367,7 +1366,7 @@ ElementEditor.prototype = {
/**
* Update the state of the editor from the node.
*/
update: function(parseColors=true) {
update: function() {
let attrs = this.node.attributes;
if (!attrs) {
return;
@ -1386,9 +1385,6 @@ ElementEditor.prototype = {
// Get the attribute editor for each attribute that exists on
// the node and show it.
for (let attr of attrs) {
if (parseColors && typeof attr.value !== "undefined") {
attr.value = colorUtils.processCSSString(attr.value);
}
let attribute = this._createAttribute(attr);
if (!attribute.inplaceEditor) {
attribute.style.removeProperty("display");

Просмотреть файл

@ -4,7 +4,6 @@ support-files = head.js
[browser_bug896181_css_mixed_completion_new_attribute.js]
# Bug 916763 - too many intermittent failures
skip-if = true
[browser_inspector_markup_colorconversion.js]
[browser_inspector_markup_edit.html]
[browser_inspector_markup_edit.js]
[browser_inspector_markup_mutation.html]

Просмотреть файл

@ -1,90 +0,0 @@
/* Any copyright", " is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
function test() {
let promise = Cu.import("resource://gre/modules/commonjs/sdk/core/promise.js").Promise;
let inspector;
let doc;
waitForExplicitFinish();
gBrowser.selectedTab = gBrowser.addTab();
gBrowser.selectedBrowser.addEventListener("load", function onload() {
gBrowser.selectedBrowser.removeEventListener("load", onload, true);
doc = content.document;
waitForFocus(createDocument, content);
}, true);
content.location = "data:text/html,browser_inspector_markupview_colorconversion.js";
function createDocument() {
doc.body.innerHTML = '' +
'<span style="color:red; border-radius:10px; ' +
'background-color:rgba(0, 255, 0, 1); display: inline-block;">' +
'Some styled text</span>';
doc.title = "Style Inspector key binding test";
setupTest();
}
function setupTest() {
let target = TargetFactory.forTab(gBrowser.selectedTab);
gDevTools.showToolbox(target, "inspector").then(function(toolbox) {
inspector = toolbox.getCurrentPanel();
inspector.once("inspector-updated", checkColors);
});
}
function checkColors() {
let node = content.document.querySelector("span");
assertAttributes(node, {
style: "color:#F00; border-radius:10px; background-color:#0F0; display: inline-block;"
}).then(() => {
finishUp();
});
}
// This version of assertAttributes is different from that in other markup
// view tests. This is because in most tests we are checking the node
// attributes but here we need the actual values displayed in the markup panel.
function assertAttributes(node, attributes) {
let deferred = promise.defer();
let attrsToCheck = Object.getOwnPropertyNames(attributes);
ok(node, "captain, we have the node");
let checkAttrs = function() {
let container = inspector.markup._selectedContainer;
let nodeAttrs = container.editor.attrs;
is(node.attributes.length, attrsToCheck.length,
"Node has the correct number of attributes");
for (let attr of attrsToCheck) {
ok(nodeAttrs[attr], "Node has a " + attr + "attribute");
let nodeAttributeText = nodeAttrs[attr].textContent;
[, nodeAttributeText] = nodeAttributeText.match(/^\s*[\w-]+\s*=\s*"(.*)"$/);
is(nodeAttributeText, attributes[attr],
"Node has the correct " + attr + " attribute value.");
}
deferred.resolve();
};
if (inspector.selection.node == node) {
checkAttrs();
} else {
inspector.once("inspector-updated", () => {
checkAttrs();
});
inspector.selection.setNode(node);
}
return deferred.promise;
}
function finishUp() {
doc = inspector = null;
gBrowser.removeCurrentTab();
finish();
}
}