Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge

  • Loading branch information...
commit c5b57bc5abbf5e0586831f54787ba884639a7ef6 2 parents 052797b + 5144308
@janodvarko janodvarko authored
View
5 extension/content/firebug/accessible/a11y.js
@@ -1237,6 +1237,11 @@ Firebug.A11yModel = Obj.extend(Firebug.Module,
onObjectBoxSelected: function(objectBox, forceFocus)
{
var panel = Firebug.getElementPanel(objectBox);
+
+ // See issue 5934
+ if (panel.editing)
+ return;
+
var panelA11y = this.getPanelA11y(panel);
if (!panelA11y)
return;
View
59 extension/content/firebug/css/selectorEditor.js
@@ -0,0 +1,59 @@
+/* See license.txt for terms of usage */
+
+define([
+ "firebug/firebug",
+ "firebug/lib/domplate",
+ "firebug/lib/locale",
+],
+function(Firebug, Domplate, Locale) {
+with (Domplate) {
+
+// ********************************************************************************************* //
+// Constants
+
+const Cc = Components.classes;
+const Ci = Components.interfaces;
+
+// ********************************************************************************************* //
+// CSS Selector Editor
+
+function SelectorEditor(panel)
+{
+ var doc = panel.document;
+
+ this.panel = panel;
+ this.box = this.tag.replace({}, doc, this);
+ this.input = this.box;
+
+ this.tabNavigation = false;
+ this.tabCompletion = true;
+ this.completeAsYouType = false;
+ this.fixedWidth = true;
+}
+
+SelectorEditor.prototype = domplate(Firebug.InlineEditor.prototype,
+{
+ tag:
+ INPUT({"class": "fixedWidthEditor a11yFocusNoTab",
+ type: "text",
+ title: Locale.$STR("Selector"),
+ oninput: "$onInput",
+ onkeypress: "$onKeyPress"}
+ ),
+
+ endEditing: function(target, value, cancel)
+ {
+ if (cancel || value == "")
+ return;
+
+ this.panel.setTrialSelector(target, value);
+ },
+});
+
+// ********************************************************************************************* //
+// Registration
+
+return SelectorEditor;
+
+// ********************************************************************************************* //
+}});
View
392 extension/content/firebug/css/selectorPanel.js
@@ -0,0 +1,392 @@
+/* See license.txt for terms of usage */
+
+define([
+ "firebug/firebug",
+ "firebug/lib/object",
+ "firebug/lib/locale",
+ "firebug/lib/events",
+ "firebug/lib/dom",
+ "firebug/lib/domplate",
+ "firebug/css/selectorEditor",
+],
+function(Firebug, Obj, Locale, Events, Dom, Domplate, SelectorEditor) {
+with (Domplate) {
+
+// ********************************************************************************************* //
+// Constants
+
+const Cc = Components.classes;
+const Ci = Components.interfaces;
+
+const prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch2);
+
+// ********************************************************************************************* //
+// CSS Selector Panel
+
+/**
+ * @panel Selector side panel displaying HTML elements for the current selector,
+ * either from the CSS main panel or user entry
+ */
+function SelectorPanel() {}
+SelectorPanel.prototype = Obj.extend(Firebug.Panel,
+/** @lends SelectorPanel */
+{
+ name: "selector",
+ parentPanel: "stylesheet",
+ title: Locale.$STR("css.selector.Selection"),
+ editable: true,
+
+ // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+ // Initialization
+
+ initialize: function(context, doc)
+ {
+ Firebug.Panel.initialize.apply(this, arguments);
+ },
+
+ initializeNode: function(oldPanelNode)
+ {
+ Firebug.Panel.initializeNode.apply(this, arguments);
+
+ this.setSelection = Obj.bind(this.setSelection, this);
+ this.clearSelection = Obj.bind(this.clearSelection, this);
+ this.lockSelection = Obj.bind(this.lockSelection, this);
+
+ var panelNode = this.mainPanel.panelNode;
+ Events.addEventListener(panelNode, "mouseover", this.setSelection, false);
+ Events.addEventListener(panelNode, "mouseout", this.clearSelection, false);
+ Events.addEventListener(panelNode, "mousedown", this.lockSelection, false);
+ },
+
+ destroyNode: function()
+ {
+ var panelNode = this.mainPanel.panelNode;
+ Events.removeEventListener(panelNode, "mouseover", this.setSelection, false);
+ Events.removeEventListener(panelNode, "mouseout", this.clearSelection, false);
+ Events.removeEventListener(panelNode, "mousedown", this.lockSelection, false);
+
+ Firebug.Panel.destroyNode.apply(this, arguments);
+ },
+
+ show: function(state)
+ {
+ Firebug.Panel.show.apply(this, arguments);
+
+ this.refresh();
+ },
+
+ // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+ getCSSStyleRule: function(event)
+ {
+ var object = Firebug.getRepObject(event.target);
+
+ if (object && (object instanceof window.CSSStyleRule))
+ return object;
+ },
+
+ getCSSRuleElement: function(element)
+ {
+ while (element && !element.classList.contains("cssRule"))
+ element = element.parentNode;
+
+ return element;
+ },
+
+ // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+ // Selection
+
+ setSelection: function(event)
+ {
+ var rule = this.getCSSStyleRule(event);
+
+ if (rule)
+ {
+ // then we have entered a rule element
+ var ruleElement = this.getCSSRuleElement(event.target);
+ if (ruleElement && ruleElement !== this.lockedElement)
+ ruleElement.classList.add("selectedSelectorRule");
+
+ this.selection = rule;
+ this.rebuild();
+ }
+ },
+
+ clearSelection: function(event)
+ {
+ if (this.selection !== this.lockedSelection)
+ {
+ this.selection = this.lockedSelection;
+ this.rebuild();
+ }
+
+ var rule = this.getCSSStyleRule(event);
+ if (rule)
+ {
+ // then we are leaving a rule element that we may have highlighted.
+ var ruleElement = this.getCSSRuleElement(event.target);
+ if (ruleElement)
+ ruleElement.classList.remove("selectedSelectorRule");
+ }
+ },
+
+ lockSelection: function(event)
+ {
+ var rule = this.getCSSStyleRule(event);
+ if (rule)
+ {
+ if (this.lockedElement)
+ this.lockedElement.classList.remove("lockedSelectorRule");
+
+ this.lockedElement = this.getCSSRuleElement(event.target);
+
+ if (this.lockedElement)
+ {
+ this.lockedElement.classList.add("lockedSelectorRule");
+ this.lockedElement.classList.remove("selectedSelectorRule");
+ }
+
+ this.lockedSelection = rule;
+ }
+ },
+
+ hide: function()
+ {
+ Firebug.Panel.hide.apply(this, arguments);
+ },
+
+ refresh: function()
+ {
+ var root = this.context.window.document.documentElement;
+ this.selection = this.mainPanel.selection;
+ this.rebuild(true);
+ },
+
+ /**
+ * returns an array of Elements matched from selector
+ */
+ getSelectedElements: function(selectorText)
+ {
+ var selections = Firebug.currentContext.window.document.querySelectorAll(selectorText);
+
+ // For some reason the return value of querySelectorAll()
+ // is not recognized as a NodeList anymore since Firefox 10.0.
+ // See issue 5442.
+ if (selections)
+ {
+ var elements = [];
+ for (var i=0; i<selections.length; i++)
+ elements.push(selections[i]);
+
+ return elements;
+ }
+ else
+ {
+ throw new Error("Selection Failed: " + selections);
+ }
+ },
+
+ /**
+ * Build content of the panel. The basic layout of the panel is generated by
+ * {@link SelectorTemplate} template.
+ */
+ rebuild: function()
+ {
+ if (this.selection)
+ {
+ try
+ {
+ var selectorText;
+
+ if (this.selection instanceof window.CSSStyleRule)
+ selectorText = this.selection.selectorText;
+ else
+ selectorText = this.selection;
+
+ var elements = this.getSelectedElements(selectorText);
+ if (elements && elements.length != 0)
+ {
+ SelectorTemplate.tag.replace({object: elements}, this.panelNode);
+ this.showTrialSelector(this.trialSelector);
+ return;
+ }
+ }
+ catch (e)
+ {
+ var table = SelectorTemplate.tag.replace({object: []}, this.panelNode);
+ var tbody = table.lastChild;
+
+ WarningTemplate.selectErrorTag.insertRows({object: e}, tbody.lastChild);
+ WarningTemplate.selectErrorTextTag.insertRows({object: e}, tbody.lastChild);
+
+ this.showTrialSelector(this.trialSelector);
+ return;
+ }
+ }
+
+ var table = SelectorTemplate.tag.replace({object: []}, this.panelNode);
+ var tbody = table.lastChild;
+
+ if (this.trialSelector)
+ {
+ WarningTemplate.noSelectionResultsTag.insertRows(
+ {object: this.selection}, tbody.lastChild)
+ }
+ else
+ {
+ WarningTemplate.noSelectionTag.insertRows(
+ {object: this.selection}, tbody.lastChild);
+ }
+
+ this.showTrialSelector(this.trialSelector);
+ },
+
+ getObjectPath: function(object)
+ {
+ if (FBTrace.DBG_SELECTOR)
+ FBTrace.sysout("css.selector.getObjectPath NOOP", object);
+ },
+
+ supportsObject: function(object)
+ {
+ return 0;
+ },
+
+ // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+ tryASelector:function(element)
+ {
+ if (!this.trialSelector)
+ this.trialSelector = this.selection ? this.selection.selectorText : "";
+
+ this.editProperty(element, this.trialSelector);
+ },
+
+ editProperty: function(row, editValue)
+ {
+ Firebug.Editor.startEditing(row, editValue);
+ },
+
+ getEditor: function(target, value)
+ {
+ if (!this.editor)
+ this.editor = new SelectorEditor(this);
+
+ return this.editor;
+ },
+
+ setTrialSelector: function(target, value)
+ {
+ if (this.lockedElement)
+ this.lockedElement.classList.remove("lockedSelectorRule");
+
+ this.trialSelector = value;
+ this.selection = this.trialSelector;
+ this.lockedElement = target;
+ this.lockedSelection = this.selection;
+ this.rebuild();
+ },
+
+ showTrialSelector: function(trialSelector)
+ {
+ var show = trialSelector ? true : false;
+ Dom.collapse(this.document.getElementById("trialHint"), show);
+
+ var trialSelectorDiv = this.document.getElementById("trialSelector");
+ trialSelectorDiv.textContent = trialSelector;
+ Dom.collapse(trialSelectorDiv, !show);
+ },
+});
+
+// ********************************************************************************************* //
+
+var BaseRep = domplate(Firebug.Rep,
+{
+ // xxxHonza: shouldn't this be in Firebug.Rep?
+ getNaturalTag: function(value)
+ {
+ var rep = Firebug.getRep(value);
+ var tag = rep.shortTag ? rep.shortTag : rep.tag;
+ return tag;
+ }
+});
+
+// ********************************************************************************************* //
+
+var TrialRow =
+ TR({"class": "watchNewRow", level: 0, onclick: "$onClickEditor"},
+ TD({"class": "watchEditCell", colspan: 3},
+ DIV({"class": "watchEditBox a11yFocusNoTab", "id": "trialHint",
+ role: "button", "tabindex" : "0",
+ "aria-label": Locale.$STR("a11y.labels.press enter to add new selector")},
+ Locale.$STR("css.selector.TryASelector")
+ ),
+ DIV({"class": "trialSelector", "id": "trialSelector"}, "")
+ )
+ );
+
+// ********************************************************************************************* //
+
+/**
+ * @domplate: Template for basic layout of the {@link SelectorPanel} panel.
+ */
+var SelectorTemplate = domplate(BaseRep,
+{
+ // object will be array of elements CSSStyleRule
+ tag:
+ TABLE({"class": "cssSelectionTable", cellpadding: 0, cellspacing: 0},
+ TBODY({"class": "cssSelectionTBody"},
+ TrialRow,
+ FOR("element", "$object",
+ TR({"class": "selectionElementRow", _repObject: "$element"},
+ TD({"class": "selectionElement"},
+ TAG( "$element|getNaturalTag", {object: "$element"})
+ )
+ )
+ )
+ )
+ ),
+
+ onClickEditor: function(event)
+ {
+ var tr = event.currentTarget;
+ var panel = Firebug.getElementPanel(tr);
+ panel.tryASelector(tr);
+ },
+});
+
+// ********************************************************************************************* //
+
+var WarningTemplate = domplate(Firebug.Rep,
+{
+ noSelectionTag:
+ TR({"class": "selectbugWarning "},
+ TD({"class": "selectionElement"}, Locale.$STR("css.selector.noSelection"))
+ ),
+
+ noSelectionResultsTag:
+ TR({"class": "selectbugWarning "},
+ TD({"class": "selectionElement"}, Locale.$STR("css.selector.noSelectionResults"))
+ ),
+
+ selectErrorTag:
+ TR({"class": "selectbugWarning"},
+ TD({"class": "selectionElement"}, Locale.$STR("css.selector.selectorError"))
+ ),
+
+ selectErrorTextTag:
+ TR({"class": "selectbugWarning"},
+ TD({"class": "selectionErrorText selectionElement"}, SPAN("$object"))
+ ),
+});
+
+// ********************************************************************************************* //
+// Registration
+
+Firebug.registerStylesheet("chrome://firebug/skin/selector.css");
+Firebug.registerPanel(SelectorPanel);
+
+return SelectorPanel;
+
+// ********************************************************************************************* //
+}});
View
51 extension/content/firebug/lib/trace.js
@@ -10,6 +10,8 @@ const Cu = Components.utils;
// ********************************************************************************************* //
// Firebug Trace - FBTrace
+var TraceAPI = ["dump", "sysout", "setScope", "matchesNode", "time", "timeEnd"];
+
var scope = {};
try
@@ -22,7 +24,6 @@ catch (err)
{
getTracer: function(prefDomain)
{
- var TraceAPI = ["dump", "sysout", "setScope", "matchesNode", "time", "timeEnd"];
var TraceObj = {};
for (var i=0; i<TraceAPI.length; i++)
TraceObj[TraceAPI[i]] = function() {};
@@ -63,8 +64,54 @@ function getStackDump()
};
// ********************************************************************************************* //
+// Wrapper
+
+/**
+ * Wraps tracer for given option. Logs made throug the wrapper will automatially
+ * be checked against the option and only displayed if the option is true.
+ * If FBTrace console isn't installed all options are false and there is no
+ * additional performance penalty.
+ */
+function TraceWrapper(tracer, option)
+{
+ function createMethodWrapper(method)
+ {
+ return function()
+ {
+ // Check the option before the log is passed to the tracing console.
+ if (tracer[option])
+ tracer[method].apply(tracer, arguments);
+ }
+ }
+
+ for (var i=0; i<TraceAPI.length; i++)
+ {
+ var method = TraceAPI[i];
+ this[method] = createMethodWrapper(method);
+ }
+}
+
+// ********************************************************************************************* //
+
+var tracer = scope.traceConsoleService.getTracer("extensions.firebug");
+
+/**
+ * Support for scoped logging.
+ *
+ * Example:
+ * FBTrace = FBTrace.to("DBG_NET");
+ *
+ * // This log will be displayed only if DBG_NET option is on
+ * FBTrace.sysout("net.initialiaze");
+ */
+tracer.to = function(option)
+{
+ return new TraceWrapper(this, option);
+}
+
+// ********************************************************************************************* //
-return scope.traceConsoleService.getTracer("extensions.firebug");
+return tracer;
// ********************************************************************************************* //
});
View
1  extension/content/firebug/moduleConfig.js
@@ -61,6 +61,7 @@ Firebug.getModuleLoaderConfig = function(baseConfig)
"firebug/css/computedPanel",
"firebug/cookies/cookieModule",
"firebug/cookies/cookiePanel",
+ "firebug/css/selectorPanel",
// Remoting
"firebug/remoting/connectionMenu",
View
1  extension/defaults/preferences/tracingConsole.js
@@ -72,3 +72,4 @@ pref("extensions.firebug.DBG_MENU", false); // Menus and context men
pref("extensions.firebug.DBG_BTI", false); // Browser Tools Interface
pref("extensions.firebug.DBG_DOMTREE", false); // DomTree Widget
pref("extensions.firebug.DBG_GRIPCACHE", false); // Cache for remote objects - grips (comes over RDP)
+pref("extensions.firebug.DBG_SELECTOR", false); // Selector side panel (in the CSS panel)
View
7 extension/locale/en-US/firebug.properties
@@ -1665,3 +1665,10 @@ console.cmd.help.help=Displays help for all available commands.
# if registered command doesn't have help URL associated and the user clicks on the command name.
# List of command names is displayed if you type "help" (without quotes) into the command line.
console.cmd.helpUrlNotAvailable=Help page for this command is not available.
+
+css.selector.noSelection=Mouseover CSS Rules to preview, Click to select one
+css.selector.noSelectionResults=No matching elements
+css.selector.selectorError=Selection failed:
+css.selector.Selection=Selection
+css.selector.TryASelector=Try a selector...
+
View
41 extension/skin/classic/selector.css
@@ -0,0 +1,41 @@
+/* Rules for selectbug's Selector panel elements */
+.cssSelectionTable {
+ width: 100%;
+}
+.selectionElement {
+ padding: 0 0 0 1ex;
+}
+
+.selectbugWarning {
+ font-size: 11px;
+ color: gray;
+ padding: 2px 0 0 1ex;
+}
+
+.selectionErrorText {
+ color: black;
+ padding: 1em;
+ background-color: #FFEBEB;
+}
+
+/* Rules for selectbug's effect on CSS stylesheet panel */
+.selectedSelectorRule {
+ border-color: Highlight !important;
+ background-color: #EBF5FF !important;
+ color: #000000 !important;
+ cursor: pointer;
+}
+
+.cssSelector,
+.cssPropName,
+.cssPropValue {
+ cursor: text;
+}
+
+.lockedSelectorRule {
+ background-color: Highlight;
+}
+
+.lockedSelectorRule * {
+ color: HighlightText !important;
+}
View
7 tests/FBTest/content/FBTestFirebug.js
@@ -1124,9 +1124,12 @@ this.OneShotHandler = function(eventTarget, eventName, onEvent, capturing)
* Notice that FBTest automatically resets all preferences before every single test is executed.
* @param {Object} value New value of the preference.
*/
-this.setPref = function(pref, value)
+this.setPref = function(pref, value, prefDomain)
{
- FW.Firebug.setPref(FW.Firebug.prefDomain, pref, value);
+ if (!prefDomain)
+ prefDomain = FW.Firebug.prefDomain;
+
+ FW.Firebug.setPref(prefDomain, pref, value);
};
/**
View
16 tests/content/net/4905/issue4905.js
@@ -5,6 +5,12 @@ function runTest()
FBTest.openNewTab(basePath + "net/4905/issue4905.html", function(win)
{
FBTest.openFirebug();
+
+ // Enable browser cache
+ var browserCache = FW.Firebug.NetMonitor.BrowserCache;
+ var browserCacheEnabled = browserCache.isEnabled();
+ browserCache.toggle(true);
+
FBTest.selectPanel("net");
FBTest.enableNetPanel();
@@ -15,7 +21,7 @@ function runTest()
counter: 2
};
- FBTest.waitForDisplayedElement("net", options, function(row)
+ var callbackFunction = function(row)
{
var panelNode = FBTest.selectPanel("net").panelNode;
@@ -36,8 +42,14 @@ function runTest()
"Cached response headers must include 'Cache-Control' header");
}
+ // Disable browser cache again if it was disabled before
+ if (!browserCacheEnabled)
+ browserCache.toggle(false);
+
FBTest.testDone("issue4905.DONE");
- });
+ };
+
+ FBTest.waitForDisplayedElement("net", options, callbackFunction);
FBTest.reload();
});
Please sign in to comment.
Something went wrong with that request. Please try again.