Backout Bug 705707 due to oranges; a=#fx-team

This commit is contained in:
Rob Campbell 2012-02-10 14:31:07 -04:00
Родитель fa8bfa3fd1
Коммит 35fc81ed75
12 изменённых файлов: 48 добавлений и 215 удалений

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

@ -273,7 +273,6 @@ CssHtmlTree.prototype = {
this._matchedProperties = null; this._matchedProperties = null;
if (this.htmlComplete) { if (this.htmlComplete) {
this.refreshSourceFilter();
this.refreshPanel(); this.refreshPanel();
} else { } else {
if (this._refreshProcess) { if (this._refreshProcess) {
@ -282,9 +281,6 @@ CssHtmlTree.prototype = {
CssHtmlTree.processTemplate(this.templateRoot, this.root, this); CssHtmlTree.processTemplate(this.templateRoot, this.root, this);
// Refresh source filter ... this must be done after templateRoot has been
// processed.
this.refreshSourceFilter();
this.numVisibleProperties = 0; this.numVisibleProperties = 0;
let fragment = this.doc.createDocumentFragment(); let fragment = this.doc.createDocumentFragment();
this._refreshProcess = new UpdateProcess(this.win, CssHtmlTree.propertyNames, { this._refreshProcess = new UpdateProcess(this.win, CssHtmlTree.propertyNames, {
@ -366,28 +362,21 @@ CssHtmlTree.prototype = {
}, },
/** /**
* The change event handler for the onlyUserStyles checkbox. * The change event handler for the onlyUserStyles checkbox. When
* onlyUserStyles.checked is true we do not display properties that have no
* matched selectors, and we do not display UA styles. If .checked is false we
* do display even properties with no matched selectors, and we include the UA
* styles.
* *
* @param {Event} aEvent the DOM Event object. * @param {Event} aEvent the DOM Event object.
*/ */
onlyUserStylesChanged: function CssHtmltree_onlyUserStylesChanged(aEvent) onlyUserStylesChanged: function CssHtmltree_onlyUserStylesChanged(aEvent)
{
this.refreshSourceFilter();
this.refreshPanel();
},
/**
* When onlyUserStyles.checked is true we only display properties that have
* matched selectors and have been included by the document or one of the
* document's stylesheets. If .checked is false we display all properties
* including those that come from UA stylesheets.
*/
refreshSourceFilter: function CssHtmlTree_setSourceFilter()
{ {
this._matchedProperties = null; this._matchedProperties = null;
this.cssLogic.sourceFilter = this.showOnlyUserStyles ? this.cssLogic.sourceFilter = this.showOnlyUserStyles ?
CssLogic.FILTER.ALL : CssLogic.FILTER.ALL :
CssLogic.FILTER.UA; CssLogic.FILTER.UA;
this.refreshPanel();
}, },
/** /**

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

@ -232,7 +232,7 @@ CssLogic.prototype = {
// Update the CssSheet objects. // Update the CssSheet objects.
this.forEachSheet(function(aSheet) { this.forEachSheet(function(aSheet) {
aSheet._sheetAllowed = -1; aSheet._sheetAllowed = -1;
if (aSheet.contentSheet && aSheet.sheetAllowed) { if (!aSheet.systemSheet && aSheet.sheetAllowed) {
ruleCount += aSheet.ruleCount; ruleCount += aSheet.ruleCount;
} }
}, this); }, this);
@ -345,7 +345,7 @@ CssLogic.prototype = {
let sheets = []; let sheets = [];
this.forEachSheet(function (aSheet) { this.forEachSheet(function (aSheet) {
if (aSheet.contentSheet) { if (!aSheet.systemSheet) {
sheets.push(aSheet); sheets.push(aSheet);
} }
}, this); }, this);
@ -395,7 +395,7 @@ CssLogic.prototype = {
} }
sheet = new CssSheet(this, aDomSheet, aIndex); sheet = new CssSheet(this, aDomSheet, aIndex);
if (sheet.sheetAllowed && sheet.contentSheet) { if (sheet.sheetAllowed && !sheet.systemSheet) {
this._ruleCount += sheet.ruleCount; this._ruleCount += sheet.ruleCount;
} }
@ -569,7 +569,7 @@ CssLogic.prototype = {
this.forEachSheet(function (aSheet) { this.forEachSheet(function (aSheet) {
// We do not show unmatched selectors from system stylesheets // We do not show unmatched selectors from system stylesheets
if (!aSheet.contentSheet || aSheet.disabled || !aSheet.mediaMatches) { if (aSheet.systemSheet || aSheet.disabled || !aSheet.mediaMatches) {
return; return;
} }
@ -664,7 +664,7 @@ CssLogic.prototype = {
sheet._passId = this._passId; sheet._passId = this._passId;
} }
if (filter === CssLogic.FILTER.ALL && !sheet.contentSheet) { if (filter !== CssLogic.FILTER.UA && sheet.systemSheet) {
continue; continue;
} }
@ -710,7 +710,7 @@ CssLogic.prototype = {
let result = {}; let result = {};
this.forSomeSheets(function (aSheet) { this.forSomeSheets(function (aSheet) {
if (!aSheet.contentSheet || aSheet.disabled || !aSheet.mediaMatches) { if (aSheet.systemSheet || aSheet.disabled || !aSheet.mediaMatches) {
return false; return false;
} }
@ -865,23 +865,29 @@ XPCOMUtils.defineLazyGetter(CssLogic, "_strings", function() Services.strings
.createBundle("chrome://browser/locale/devtools/styleinspector.properties")); .createBundle("chrome://browser/locale/devtools/styleinspector.properties"));
/** /**
* Is the given property sheet a content stylesheet? * Is the given property sheet a system (user agent) stylesheet?
* *
* @param {CSSStyleSheet} aSheet a stylesheet * @param {CSSStyleSheet} aSheet a stylesheet
* @return {boolean} true if the given stylesheet is a content stylesheet, * @return {boolean} true if the given stylesheet is a system stylesheet or
* false otherwise. * false otherwise.
*/ */
CssLogic.isContentStylesheet = function CssLogic_isContentStylesheet(aSheet) CssLogic.isSystemStyleSheet = function CssLogic_isSystemStyleSheet(aSheet)
{ {
// All sheets with owner nodes have been included by content. if (!aSheet) {
if (aSheet.ownerNode) {
return true; return true;
} }
// If the sheet has a CSSImportRule we need to check the parent stylesheet. let url = aSheet.href;
if (aSheet.ownerRule instanceof Ci.nsIDOMCSSImportRule) {
return CssLogic.isContentStylesheet(aSheet.parentStyleSheet); if (!url) return false;
} if (url.length === 0) return true;
// Check for http[s]
if (url[0] === 'h') return false;
if (url.substr(0, 9) === "resource:") return true;
if (url.substr(0, 7) === "chrome:") return true;
if (url === "XPCSafeJSObjectWrapper.cpp") return true;
if (url.substr(0, 6) === "about:") return true;
return false; return false;
}; };
@ -936,7 +942,7 @@ function CssSheet(aCssLogic, aDomSheet, aIndex)
{ {
this._cssLogic = aCssLogic; this._cssLogic = aCssLogic;
this.domSheet = aDomSheet; this.domSheet = aDomSheet;
this.index = this.contentSheet ? aIndex : -100 * aIndex; this.index = this.systemSheet ? -100 * aIndex : aIndex;
// Cache of the sheets href. Cached by the getter. // Cache of the sheets href. Cached by the getter.
this._href = null; this._href = null;
@ -954,21 +960,21 @@ function CssSheet(aCssLogic, aDomSheet, aIndex)
CssSheet.prototype = { CssSheet.prototype = {
_passId: null, _passId: null,
_contentSheet: null, _systemSheet: null,
_mediaMatches: null, _mediaMatches: null,
/** /**
* Tells if the stylesheet is provided by the browser or not. * Tells if the stylesheet is provided by the browser or not.
* *
* @return {boolean} false if this is a browser-provided stylesheet, or true * @return {boolean} true if this is a browser-provided stylesheet, or false
* otherwise. * otherwise.
*/ */
get contentSheet() get systemSheet()
{ {
if (this._contentSheet === null) { if (this._systemSheet === null) {
this._contentSheet = CssLogic.isContentStylesheet(this.domSheet); this._systemSheet = CssLogic.isSystemStyleSheet(this.domSheet);
} }
return this._contentSheet; return this._systemSheet;
}, },
/** /**
@ -1042,7 +1048,7 @@ CssSheet.prototype = {
this._sheetAllowed = true; this._sheetAllowed = true;
let filter = this._cssLogic.sourceFilter; let filter = this._cssLogic.sourceFilter;
if (filter === CssLogic.FILTER.ALL && !this.contentSheet) { if (filter === CssLogic.FILTER.ALL && this.systemSheet) {
this._sheetAllowed = false; this._sheetAllowed = false;
} }
if (filter !== CssLogic.FILTER.ALL && filter !== CssLogic.FILTER.UA) { if (filter !== CssLogic.FILTER.ALL && filter !== CssLogic.FILTER.UA) {
@ -1196,13 +1202,13 @@ function CssRule(aCssSheet, aDomRule, aElement)
this.line = this._cssSheet._cssLogic.domUtils.getRuleLine(this._domRule); this.line = this._cssSheet._cssLogic.domUtils.getRuleLine(this._domRule);
this.source = this._cssSheet.shortSource + ":" + this.line; this.source = this._cssSheet.shortSource + ":" + this.line;
this.href = this._cssSheet.href; this.href = this._cssSheet.href;
this.contentRule = this._cssSheet.contentSheet; this.systemRule = this._cssSheet.systemSheet;
} else if (aElement) { } else if (aElement) {
this._selectors = [ new CssSelector(this, "@element.style") ]; this._selectors = [ new CssSelector(this, "@element.style") ];
this.line = -1; this.line = -1;
this.source = CssLogic.l10n("rule.sourceElement"); this.source = CssLogic.l10n("rule.sourceElement");
this.href = "#"; this.href = "#";
this.contentRule = true; this.systemRule = false;
this.sourceElement = aElement; this.sourceElement = aElement;
} }
} }
@ -1390,12 +1396,12 @@ CssSelector.prototype = {
/** /**
* Check if the selector comes from a browser-provided stylesheet. * Check if the selector comes from a browser-provided stylesheet.
* *
* @return {boolean} true if the selector comes from a content-provided * @return {boolean} true if the selector comes from a browser-provided
* stylesheet, or false otherwise. * stylesheet, or false otherwise.
*/ */
get contentRule() get systemRule()
{ {
return this._cssRule.contentRule; return this._cssRule.systemRule;
}, },
/** /**
@ -1788,12 +1794,12 @@ function CssSelectorInfo(aSelector, aProperty, aValue, aStatus)
4 important 4 important
5 inline important 5 inline important
*/ */
let scorePrefix = this.contentRule ? 2 : 0; let scorePrefix = this.systemRule ? 0 : 2;
if (this.elementStyle) { if (this.elementStyle) {
scorePrefix++; scorePrefix++;
} }
if (this.important) { if (this.important) {
scorePrefix += this.contentRule ? 2 : 1; scorePrefix += this.systemRule ? 1 : 2;
} }
this.specificityScore = "" + scorePrefix + this.specificity.ids + this.specificityScore = "" + scorePrefix + this.specificity.ids +
@ -1896,9 +1902,9 @@ CssSelectorInfo.prototype = {
* @return {boolean} true if the selector comes from a browser-provided * @return {boolean} true if the selector comes from a browser-provided
* stylesheet, or false otherwise. * stylesheet, or false otherwise.
*/ */
get contentRule() get systemRule()
{ {
return this.selector.contentRule; return this.selector.systemRule;
}, },
/** /**
@ -1910,8 +1916,8 @@ CssSelectorInfo.prototype = {
*/ */
compareTo: function CssSelectorInfo_compareTo(aThat) compareTo: function CssSelectorInfo_compareTo(aThat)
{ {
if (!this.contentRule && aThat.contentRule) return 1; if (this.systemRule && !aThat.systemRule) return 1;
if (this.contentRule && !aThat.contentRule) return -1; if (!this.systemRule && aThat.systemRule) return -1;
if (this.elementStyle && !aThat.elementStyle) { if (this.elementStyle && !aThat.elementStyle) {
if (!this.important && aThat.important) return 1; if (!this.important && aThat.important) return 1;

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

@ -181,8 +181,8 @@ ElementStyle.prototype = {
let domRule = domRules.GetElementAt(i); let domRule = domRules.GetElementAt(i);
// XXX: Optionally provide access to system sheets. // XXX: Optionally provide access to system sheets.
let contentSheet = CssLogic.isContentStylesheet(domRule.parentStyleSheet); let systemSheet = CssLogic.isSystemStyleSheet(domRule.parentStyleSheet);
if (!contentSheet) { if (systemSheet) {
continue; continue;
} }

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

@ -59,19 +59,11 @@ _BROWSER_TEST_FILES = \
browser_ruleview_manipulation.js \ browser_ruleview_manipulation.js \
browser_ruleview_override.js \ browser_ruleview_override.js \
browser_ruleview_ui.js \ browser_ruleview_ui.js \
browser_bug705707_is_content_stylesheet.js \
head.js \ head.js \
$(NULL) $(NULL)
_BROWSER_TEST_PAGES = \ _BROWSER_TEST_PAGES = \
browser_bug683672.html \ browser_bug683672.html \
browser_bug705707_is_content_stylesheet.html \
browser_bug705707_is_content_stylesheet_imported.css \
browser_bug705707_is_content_stylesheet_imported2.css \
browser_bug705707_is_content_stylesheet_linked.css \
browser_bug705707_is_content_stylesheet_script.css \
browser_bug705707_is_content_stylesheet.xul \
browser_bug705707_is_content_stylesheet_xul.css \
$(NULL) $(NULL)
libs:: $(_BROWSER_TEST_FILES) libs:: $(_BROWSER_TEST_FILES)

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

@ -1,33 +0,0 @@
<html>
<head>
<title>test</title>
<link href="./browser_bug705707_is_content_stylesheet_linked.css" rel="stylesheet" type="text/css">
<script>
// Load script.css
function loadCSS() {
var link = document.createElement('link');
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = "./browser_bug705707_is_content_stylesheet_script.css";
document.getElementsByTagName('head')[0].appendChild(link);
}
</script>
<style>
table {
border: 1px solid #000;
}
</style>
</head>
<body onload="loadCSS();">
<table id="target">
<tr>
<td>
<h3>Simple test</h3>
</td>
</tr>
</table>
</body>
</html>

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

@ -1,93 +0,0 @@
/* vim: set ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
// Tests that the correct stylesheets origins are identified in HTML & XUL
// stylesheets
let doc;
const TEST_URI = "http://example.com/browser/browser/devtools/styleinspector/" +
"test/browser_bug705707_is_content_stylesheet.html";
const TEST_URI2 = "http://example.com/browser/browser/devtools/styleinspector/" +
"test/browser_bug705707_is_content_stylesheet.xul";
let tempScope = {};
Cu.import("resource:///modules/devtools/CssLogic.jsm", tempScope);
let CssLogic = tempScope.CssLogic;
function test()
{
waitForExplicitFinish();
addTab(TEST_URI);
browser.addEventListener("load", htmlLoaded, true);
}
function htmlLoaded()
{
browser.removeEventListener("load", htmlLoaded, true);
doc = content.document;
testFromHTML()
}
function testFromHTML()
{
let target = doc.querySelector("#target");
executeSoon(function() {
checkSheets(target);
gBrowser.removeCurrentTab();
openXUL();
});
}
function openXUL()
{
addTab(TEST_URI2);
browser.addEventListener("load", xulLoaded, true);
}
function xulLoaded()
{
browser.removeEventListener("load", xulLoaded, true);
doc = content.document;
testFromXUL()
}
function testFromXUL()
{
let target = doc.querySelector("#target");
executeSoon(function() {
checkSheets(target);
finishUp();
});
}
function checkSheets(aTarget)
{
let domUtils = Cc["@mozilla.org/inspector/dom-utils;1"]
.getService(Ci.inIDOMUtils);
let domRules = domUtils.getCSSStyleRules(aTarget);
for (let i = 0, n = domRules.Count(); i < n; i++) {
let domRule = domRules.GetElementAt(i);
let sheet = domRule.parentStyleSheet;
let isContentSheet = CssLogic.isContentStylesheet(sheet);
if (!sheet.href ||
/browser_bug705707_is_content_stylesheet_/.test(sheet.href)) {
ok(isContentSheet, sheet.href + " identified as content stylesheet");
} else {
ok(!isContentSheet, sheet.href + " identified as non-content stylesheet");
}
}
}
function finishUp()
{
info("finishing up");
doc = null;
gBrowser.removeCurrentTab();
finish();
}

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

@ -1,9 +0,0 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/xul.css" type="text/css"?>
<?xml-stylesheet href="./browser_bug705707_is_content_stylesheet_xul.css"
type="text/css"?>
<!DOCTYPE window>
<window id="testwindow" xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<label id="target" value="Simple XUL document" />
</window>

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

@ -1,5 +0,0 @@
@import url("./browser_bug705707_is_content_stylesheet_imported2.css");
#target {
text-decoration: underline;
}

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

@ -1,3 +0,0 @@
#target {
text-decoration: underline;
}

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

@ -1,3 +0,0 @@
table {
border-collapse: collapse;
}

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

@ -1,5 +0,0 @@
@import url("./browser_bug705707_is_content_stylesheet_imported.css");
table {
opacity: 1;
}

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

@ -1,3 +0,0 @@
#target {
font-size: 200px;
}