зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1085745 - Add a way to select the autocomplete popup in CSS based on which input it is opened for;r=dao
This commit is contained in:
Родитель
efa7152141
Коммит
02659e2f3b
|
@ -109,6 +109,9 @@ function startTest() {
|
|||
is(autocomplete.highlightNonMatches, false,
|
||||
"highlight non matches getter returned false correctly");
|
||||
|
||||
ok(!autocomplete.popup.hasAttribute("autocompleteinput"),
|
||||
"autocompleteinput on popup not set by default");
|
||||
|
||||
check();
|
||||
}
|
||||
|
||||
|
@ -146,6 +149,9 @@ function checkResult() {
|
|||
isnot(style.getPropertyCSSValue("color").cssText, "rgb(255, 0, 0)",
|
||||
"not nomatch and not highlightNonMatches - should not be red");
|
||||
|
||||
is (autocomplete.popup.getAttribute("autocompleteinput"), "autocomplete",
|
||||
"The popup's autocompleteinput attribute is set to the ID of the textbox");
|
||||
|
||||
setTimeout(check, 0);
|
||||
}
|
||||
else {
|
||||
|
@ -165,6 +171,9 @@ function checkResult() {
|
|||
isnot(style.getPropertyCSSValue("color").cssText, "rgb(255, 0, 0)",
|
||||
"nomatch and not highlightNonMatches - should not be red");
|
||||
|
||||
ok(!autocomplete.popup.hasAttribute("autocompleteinput"),
|
||||
"autocompleteinput on popup not set when closed");
|
||||
|
||||
setTimeout(function() {
|
||||
// Unregister the factory so that we don't get in the way of other tests
|
||||
componentManager.unregisterFactory(autoCompleteSimpleID, autoCompleteSimple);
|
||||
|
|
|
@ -897,6 +897,21 @@ extends="chrome://global/content/bindings/popup.xml#popup">
|
|||
this._normalMaxRows = this.mInput.maxRows;
|
||||
}
|
||||
|
||||
// Set an attribute for styling the popup based on the input.
|
||||
let inputID = "";
|
||||
if (this.mInput && this.mInput.ownerDocument &&
|
||||
this.mInput.ownerDocument.documentURIObject.schemeIs("chrome")) {
|
||||
inputID = this.mInput.id;
|
||||
// Take care of elements with no id that are inside xbl bindings
|
||||
if (!inputID) {
|
||||
let bindingParent = this.mInput.ownerDocument.getBindingParent(this.mInput);
|
||||
if (bindingParent) {
|
||||
inputID = bindingParent.id;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.setAttribute("autocompleteinput", inputID);
|
||||
|
||||
this.mPopupOpen = true;
|
||||
]]></handler>
|
||||
|
||||
|
@ -907,6 +922,7 @@ extends="chrome://global/content/bindings/popup.xml#popup">
|
|||
var controller = this.view.QueryInterface(Components.interfaces.nsIAutoCompleteController);
|
||||
controller.stopSearch();
|
||||
|
||||
this.removeAttribute("autocompleteinput");
|
||||
this.mPopupOpen = false;
|
||||
|
||||
// Reset the maxRows property to the cached "normal" value, and reset
|
||||
|
|
Загрузка…
Ссылка в новой задаче