зеркало из https://github.com/mozilla/gecko-dev.git
Fix for urlbar autocomplete bug # 54392 r=ducarroz, sr=alecf
This commit is contained in:
Родитель
abac1cf7ac
Коммит
7e2782ec3e
|
@ -131,26 +131,50 @@ function addToUrlbarHistory()
|
|||
return;
|
||||
if (localstore) {
|
||||
var entries = rdfc.MakeSeq(localstore, rdf.GetResource("nc:urlbar-history"));
|
||||
var entry = rdf.GetLiteral(urlToAdd);
|
||||
var index = entries.IndexOf(entry);
|
||||
|
||||
if (index != -1) {
|
||||
// we've got it already. Remove it from its old place
|
||||
// and insert it to the top
|
||||
//dump("URL already in urlbar history\n");
|
||||
if (!entries)
|
||||
return;
|
||||
var elements = entries.GetElements();
|
||||
if (!elements)
|
||||
return;
|
||||
var index = 0;
|
||||
// create the nsIURI objects for comparing the 2 urls
|
||||
var uriToAdd = Components.classes["@mozilla.org/network/standard-url;1"]
|
||||
.createInstance(Components.interfaces.nsIURI);
|
||||
uriToAdd.spec = urlToAdd;
|
||||
//dump("** URL entered = " + urlToAdd + "\n");
|
||||
var rdfUri = Components.classes["@mozilla.org/network/standard-url;1"]
|
||||
.createInstance(Components.interfaces.nsIURI);
|
||||
while(elements.hasMoreElements()) {
|
||||
entry = elements.getNext();
|
||||
if (entry) {
|
||||
index ++;
|
||||
entry= entry.QueryInterface(Components.interfaces.nsIRDFLiteral);
|
||||
var rdfValue = entry.Value;
|
||||
//dump("**** value obtained from RDF " + rdfValue + "\n");
|
||||
rdfUri.spec = rdfValue;
|
||||
if (rdfUri.equals(uriToAdd)) {
|
||||
// URI already present in the database
|
||||
// Remove it from its current position.
|
||||
// It is inserted to the top after the while loop.
|
||||
//dump("*** URL are the same \n");
|
||||
entries.RemoveElementAt(index, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} // while
|
||||
|
||||
var entry = rdf.GetLiteral(urlToAdd);
|
||||
// Otherwise, we've got a new URL in town. Add it!
|
||||
// Put the new entry at the front of the list.
|
||||
// Put the value as it was typed by the user in to RDF
|
||||
// Insert it to the beginning of the list.
|
||||
entries.InsertElementAt(entry, 1, true);
|
||||
|
||||
// Remove any expired history items so that we don't let this grow
|
||||
// without bound.
|
||||
// Remove any expired history items so that we don't let
|
||||
// this grow without bound.
|
||||
for (index = entries.GetCount(); index > MAX_HISTORY_ITEMS; --index) {
|
||||
entries.RemoveElementAt(index, true);
|
||||
}
|
||||
}
|
||||
} // for
|
||||
} // localstore
|
||||
}
|
||||
|
||||
function createMenuItem( aParent, aIndex, aValue)
|
||||
|
|
Загрузка…
Ссылка в новой задаче