Bug 1181243 - Ctrl + F should focus the filter style search bar if the focus is in the rule and computed view r=mikeratcliffe

This commit is contained in:
Gabriel Luong 2015-07-08 10:40:45 -07:00
parent 18236e8280
commit fc48d8b7e2
3 changed files with 36 additions and 1 deletions

View File

@ -307,7 +307,10 @@ InplaceEditor.prototype = {
this._stopAutosize();
this.elt.style.display = this.originalDisplay;
this.elt.focus();
if (this.doc.activeElement == this.input) {
this.elt.focus();
}
this.input.remove();
this.input = null;

View File

@ -145,6 +145,7 @@ function CssHtmlTree(aStyleInspector, aPageStyle)
// Create bound methods.
this.focusWindow = this.focusWindow.bind(this);
this._onKeypress = this._onKeypress.bind(this);
this._onContextMenu = this._onContextMenu.bind(this);
this._contextMenuUpdate = this._contextMenuUpdate.bind(this);
this._onSelectAll = this._onSelectAll.bind(this);
@ -166,6 +167,7 @@ function CssHtmlTree(aStyleInspector, aPageStyle)
this.searchClearButton = doc.getElementById("computedview-searchinput-clear");
this.includeBrowserStylesCheckbox = doc.getElementById("browser-style-checkbox");
this.styleDocument.addEventListener("keypress", this._onKeypress);
this.styleDocument.addEventListener("mousedown", this.focusWindow);
this.element.addEventListener("click", this._onClick);
this.element.addEventListener("copy", this._onCopy);
@ -521,6 +523,20 @@ CssHtmlTree.prototype = {
}).then(null, (err) => console.error(err));
},
/**
* Handle the keypress event in the computed view.
*/
_onKeypress: function(event) {
let isOSX = Services.appinfo.OS == "Darwin";
if (((isOSX && event.metaKey && !event.ctrlKey && !event.altKey) ||
(!isOSX && event.ctrlKey && !event.metaKey && !event.altKey)) &&
event.code === "KeyF") {
this.searchField.focus();
event.preventDefault();
}
},
/**
* Called when the user enters a search term in the filter style search box.
*

View File

@ -1154,6 +1154,7 @@ function CssRuleView(aInspector, aDoc, aStore, aPageStyle) {
this._buildContextMenu = this._buildContextMenu.bind(this);
this._onContextMenu = this._onContextMenu.bind(this);
this._contextMenuUpdate = this._contextMenuUpdate.bind(this);
this._onKeypress = this._onKeypress.bind(this);
this._onAddRule = this._onAddRule.bind(this);
this._onSelectAll = this._onSelectAll.bind(this);
this._onCopy = this._onCopy.bind(this);
@ -1189,6 +1190,7 @@ function CssRuleView(aInspector, aDoc, aStore, aPageStyle) {
this.searchClearButton.hidden = true;
this.doc.addEventListener("keypress", this._onKeypress);
this.element.addEventListener("copy", this._onCopy);
this.element.addEventListener("contextmenu", this._onContextMenu);
this.addRuleButton.addEventListener("click", this._onAddRule);
@ -2634,6 +2636,20 @@ CssRuleView.prototype = {
_onTogglePseudoClass: function(event) {
let target = event.currentTarget;
this.inspector.togglePseudoClass(target.value);
},
/**
* Handle the keypress event in the rule view.
*/
_onKeypress: function(event) {
let isOSX = Services.appinfo.OS == "Darwin";
if (((isOSX && event.metaKey && !event.ctrlKey && !event.altKey) ||
(!isOSX && event.ctrlKey && !event.metaKey && !event.altKey)) &&
event.code === "KeyF") {
this.searchField.focus();
event.preventDefault();
}
}
};