зеркало из https://github.com/mozilla/gecko-dev.git
Bug 689759 - Style Inspector needs a no-results placeholder. r=msucan
This commit is contained in:
Родитель
4c88cb511b
Коммит
2f9465608e
|
@ -81,6 +81,9 @@ function CssHtmlTree(aStyleInspector)
|
|||
this.templateProperty = this.styleDocument.getElementById("templateProperty");
|
||||
this.panel = aStyleInspector.panel;
|
||||
|
||||
// No results text.
|
||||
this.noResults = this.styleDocument.getElementById("noResults");
|
||||
|
||||
// The element that we're inspecting, and the document that it comes from.
|
||||
this.viewedElement = null;
|
||||
this.createStyleViews();
|
||||
|
@ -154,6 +157,9 @@ CssHtmlTree.prototype = {
|
|||
// Toggle for zebra striping
|
||||
_darkStripe: true,
|
||||
|
||||
// Number of visible properties
|
||||
numVisibleProperties: 0,
|
||||
|
||||
get showOnlyUserStyles()
|
||||
{
|
||||
return this.onlyUserStylesCheckbox.checked;
|
||||
|
@ -198,6 +204,9 @@ CssHtmlTree.prototype = {
|
|||
let propView = new PropertyView(this, name);
|
||||
CssHtmlTree.processTemplate(this.templateProperty,
|
||||
this.propertyContainer, propView, true);
|
||||
if (propView.visible) {
|
||||
this.numVisibleProperties++;
|
||||
}
|
||||
propView.refreshAllSelectors();
|
||||
this.propertyViews.push(propView);
|
||||
}
|
||||
|
@ -209,6 +218,7 @@ CssHtmlTree.prototype = {
|
|||
} else {
|
||||
this.htmlComplete = true;
|
||||
this._panelRefreshTimeout = null;
|
||||
this.noResults.hidden = this.numVisibleProperties > 0;
|
||||
Services.obs.notifyObservers(null, "StyleInspector-populated", null);
|
||||
}
|
||||
}
|
||||
|
@ -227,6 +237,11 @@ CssHtmlTree.prototype = {
|
|||
this.win.clearTimeout(this._panelRefreshTimeout);
|
||||
}
|
||||
|
||||
this.noResults.hidden = true;
|
||||
|
||||
// Reset visible property count
|
||||
this.numVisibleProperties = 0;
|
||||
|
||||
// Reset zebra striping.
|
||||
this._darkStripe = true;
|
||||
|
||||
|
@ -246,6 +261,7 @@ CssHtmlTree.prototype = {
|
|||
this._panelRefreshTimeout = this.win.setTimeout(refreshView.bind(this), 15);
|
||||
} else {
|
||||
this._panelRefreshTimeout = null;
|
||||
this.noResults.hidden = this.numVisibleProperties > 0;
|
||||
Services.obs.notifyObservers(null, "StyleInspector-populated", null);
|
||||
}
|
||||
}
|
||||
|
@ -579,6 +595,7 @@ PropertyView.prototype = {
|
|||
return;
|
||||
}
|
||||
|
||||
this.tree.numVisibleProperties++;
|
||||
this.valueNode.innerHTML = this.propertyInfo.value;
|
||||
this.refreshAllSelectors();
|
||||
},
|
||||
|
|
|
@ -63,6 +63,11 @@
|
|||
<div id="path">
|
||||
</div>
|
||||
|
||||
<!-- When no properties are found the following block is displayed. -->
|
||||
<div id="noResults" hidden="">
|
||||
&noPropertiesFound;
|
||||
</div>
|
||||
|
||||
<!-- The output from #templateProperty (below) is appended here. -->
|
||||
<div id="propertyContainer">
|
||||
</div>
|
||||
|
|
|
@ -51,6 +51,7 @@ _BROWSER_TEST_FILES = \
|
|||
browser_bug683672.js \
|
||||
browser_styleinspector_bug_672746_default_styles.js \
|
||||
browser_styleinspector_bug_672744_search_filter.js \
|
||||
browser_styleinspector_bug_689759_no_results_placeholder.js \
|
||||
browser_bug_692400_element_style.js \
|
||||
browser_ruleview_editor.js \
|
||||
browser_ruleview_inherit.js \
|
||||
|
|
|
@ -0,0 +1,118 @@
|
|||
/* vim: set ft=javascript 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 no results placeholder works properly.
|
||||
|
||||
let doc;
|
||||
let stylePanel;
|
||||
|
||||
function createDocument()
|
||||
{
|
||||
doc.body.innerHTML = '<style type="text/css"> ' +
|
||||
'.matches {color: #F00;}</style>' +
|
||||
'<span id="matches" class="matches">Some styled text</span>';
|
||||
doc.title = "Tests that the no results placeholder works properly";
|
||||
ok(window.StyleInspector, "StyleInspector exists");
|
||||
stylePanel = new StyleInspector(window);
|
||||
Services.obs.addObserver(runStyleInspectorTests, "StyleInspector-opened", false);
|
||||
stylePanel.createPanel(false, function() {
|
||||
stylePanel.open(doc.body);
|
||||
});
|
||||
}
|
||||
|
||||
function runStyleInspectorTests()
|
||||
{
|
||||
Services.obs.removeObserver(runStyleInspectorTests, "StyleInspector-opened", false);
|
||||
|
||||
ok(stylePanel.isOpen(), "style inspector is open");
|
||||
|
||||
Services.obs.addObserver(SI_AddFilterText, "StyleInspector-populated", false);
|
||||
|
||||
let span = doc.querySelector("#matches");
|
||||
ok(span, "captain, we have the matches span");
|
||||
|
||||
let htmlTree = stylePanel.cssHtmlTree;
|
||||
stylePanel.selectNode(span);
|
||||
|
||||
is(span, htmlTree.viewedElement,
|
||||
"style inspector node matches the selected node");
|
||||
is(htmlTree.viewedElement, stylePanel.cssLogic.viewedElement,
|
||||
"cssLogic node matches the cssHtmlTree node");
|
||||
}
|
||||
|
||||
function SI_AddFilterText()
|
||||
{
|
||||
Services.obs.removeObserver(SI_AddFilterText, "StyleInspector-populated", false);
|
||||
|
||||
let iframe = stylePanel.iframe;
|
||||
let searchbar = stylePanel.cssHtmlTree.searchField;
|
||||
let searchTerm = "xxxxx";
|
||||
|
||||
Services.obs.addObserver(SI_checkPlaceholderVisible, "StyleInspector-populated", false);
|
||||
info("setting filter text to \"" + searchTerm + "\"");
|
||||
searchbar.focus();
|
||||
for each (let c in searchTerm) {
|
||||
EventUtils.synthesizeKey(c, {}, iframe.contentWindow);
|
||||
}
|
||||
}
|
||||
|
||||
function SI_checkPlaceholderVisible()
|
||||
{
|
||||
Services.obs.removeObserver(SI_checkPlaceholderVisible, "StyleInspector-populated", false);
|
||||
info("SI_checkPlaceholderVisible called");
|
||||
let placeholder = stylePanel.cssHtmlTree.noResults;
|
||||
let iframe = stylePanel.iframe;
|
||||
let display = iframe.contentWindow.getComputedStyle(placeholder).display;
|
||||
|
||||
is(display, "block", "placeholder is visible");
|
||||
|
||||
SI_ClearFilterText();
|
||||
}
|
||||
|
||||
function SI_ClearFilterText()
|
||||
{
|
||||
let iframe = stylePanel.iframe;
|
||||
let searchbar = stylePanel.cssHtmlTree.searchField;
|
||||
|
||||
Services.obs.addObserver(SI_checkPlaceholderHidden, "StyleInspector-populated", false);
|
||||
info("clearing filter text");
|
||||
searchbar.focus();
|
||||
searchbar.value = "";
|
||||
EventUtils.synthesizeKey("c", {}, iframe.contentWindow);
|
||||
}
|
||||
|
||||
function SI_checkPlaceholderHidden()
|
||||
{
|
||||
Services.obs.removeObserver(SI_checkPlaceholderHidden, "StyleInspector-populated", false);
|
||||
let placeholder = stylePanel.cssHtmlTree.noResults;
|
||||
let iframe = stylePanel.iframe;
|
||||
let display = iframe.contentWindow.getComputedStyle(placeholder).display;
|
||||
|
||||
is(display, "none", "placeholder is hidden");
|
||||
|
||||
Services.obs.addObserver(finishUp, "StyleInspector-closed", false);
|
||||
stylePanel.close();
|
||||
}
|
||||
|
||||
function finishUp()
|
||||
{
|
||||
Services.obs.removeObserver(finishUp, "StyleInspector-closed", false);
|
||||
ok(!stylePanel.isOpen(), "style inspector is closed");
|
||||
doc = stylePanel = null;
|
||||
gBrowser.removeCurrentTab();
|
||||
finish();
|
||||
}
|
||||
|
||||
function test()
|
||||
{
|
||||
waitForExplicitFinish();
|
||||
gBrowser.selectedTab = gBrowser.addTab();
|
||||
gBrowser.selectedBrowser.addEventListener("load", function onLoad(evt) {
|
||||
gBrowser.selectedBrowser.removeEventListener(evt.type, onLoad, true);
|
||||
doc = content.document;
|
||||
waitForFocus(createDocument, content);
|
||||
}, true);
|
||||
|
||||
content.location = "data:text/html,no results placeholder test";
|
||||
}
|
|
@ -18,6 +18,11 @@
|
|||
- This is the link title shown in the hover tooltip. -->
|
||||
<!ENTITY helpLinkTitle "Read the documentation for this property">
|
||||
|
||||
<!-- LOCALIZATION NOTE (noPropertiesFound): In the case where there are no CSS
|
||||
- properties to display e.g. due to search criteria this message is
|
||||
- displayed. -->
|
||||
<!ENTITY noPropertiesFound "No CSS properties found.">
|
||||
|
||||
<!-- LOCALIZATION NOTE (unmatchedSelectors): For each style property
|
||||
- the panel shows whether there are any selectors that do not match the
|
||||
- currently selected element. -->
|
||||
|
|
|
@ -224,6 +224,12 @@
|
|||
background-color: rgba(0,0,0,.022);
|
||||
}
|
||||
|
||||
#noResults {
|
||||
font-size: 18px;
|
||||
margin-top: 5px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.header {
|
||||
color: -moz-dialogtext;
|
||||
background-color: -moz-dialog;
|
||||
|
|
|
@ -222,6 +222,12 @@
|
|||
background-color: rgba(0,0,0,.022);
|
||||
}
|
||||
|
||||
#noResults {
|
||||
font-size: 18px;
|
||||
margin-top: 5px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.header {
|
||||
color: -moz-dialogtext;
|
||||
background-color: -moz-dialog;
|
||||
|
|
|
@ -223,6 +223,12 @@
|
|||
background-color: rgba(0,0,0,.022);
|
||||
}
|
||||
|
||||
#noResults {
|
||||
font-size: 18px;
|
||||
margin-top: 5px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.header {
|
||||
color: -moz-dialogtext;
|
||||
background-color: -moz-dialog;
|
||||
|
|
Загрузка…
Ссылка в новой задаче