зеркало из https://github.com/mozilla/gecko-dev.git
Bug 155918 inefficent use of search and match in linkToolbarHandler.js p=stevechapel@earthlink.net r=me sr=jst
This commit is contained in:
Родитель
63bcbecc45
Коммит
a9e0202cc6
|
@ -195,22 +195,16 @@ LinkElementDecorator.prototype.isIgnored =
|
||||||
function()
|
function()
|
||||||
{
|
{
|
||||||
if (!this.rel) return true;
|
if (!this.rel) return true;
|
||||||
for (var i = 0; i < this.relValues.length; i++) {
|
for (var i = 0; i < this.relValues.length; i++)
|
||||||
var testVal = this.relValues[i].toLowerCase();
|
if (/^stylesheet$|^icon$|^fontdef$|^p3pv|^schema./i.test(this.relValues[i]))
|
||||||
if ((testVal == "stylesheet") ||
|
|
||||||
(testVal == "icon") ||
|
|
||||||
(testVal == "fontdef") ||
|
|
||||||
(testVal.match(/^p3pv/)) ||
|
|
||||||
(testVal.match(/^schema./)))
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
LinkElementDecorator.convertRevMade =
|
LinkElementDecorator.convertRevMade =
|
||||||
function(rel, rev)
|
function(rel, rev)
|
||||||
{
|
{
|
||||||
if (!rel && rev && LinkElementDecorator.findWord("made", rev.toLowerCase()))
|
if (!rel && rev && /\bmade\b/i.test(rev))
|
||||||
return rev;
|
return rev;
|
||||||
else
|
else
|
||||||
return rel;
|
return rel;
|
||||||
|
@ -245,9 +239,7 @@ function()
|
||||||
// XXX: lookup more meaningful and localized version of media,
|
// XXX: lookup more meaningful and localized version of media,
|
||||||
// i.e. media="print" becomes "Printable" or some such
|
// i.e. media="print" becomes "Printable" or some such
|
||||||
// XXX: use localized version of ":" separator
|
// XXX: use localized version of ":" separator
|
||||||
if (this.media
|
if (this.media && !/\ball\b|\bscreen\b/i.test(this.media))
|
||||||
&& !LinkElementDecorator.findWord("all", this.media.toLowerCase())
|
|
||||||
&& !LinkElementDecorator.findWord("screen", this.media.toLowerCase()))
|
|
||||||
prefix += this.media + ": ";
|
prefix += this.media + ": ";
|
||||||
if (this.hreflang)
|
if (this.hreflang)
|
||||||
prefix += languageDictionary.lookupLanguageName(this.hreflang)
|
prefix += languageDictionary.lookupLanguageName(this.hreflang)
|
||||||
|
@ -256,27 +248,6 @@ function()
|
||||||
return this.title ? prefix + this.title : prefix;
|
return this.title ? prefix + this.title : prefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
LinkElementDecorator.findWord =
|
|
||||||
function(word, string)
|
|
||||||
{
|
|
||||||
var barePattern = eval("/^" + word + "$/");
|
|
||||||
var middlePattern = eval("/[-\\W]" + word + "[-\\W]/");
|
|
||||||
var startPattern = eval("/^" + word + "[-\\W]/");
|
|
||||||
var endPattern = eval("/[-\\W]" + word + "$/");
|
|
||||||
|
|
||||||
if (string.search(barePattern) != -1)
|
|
||||||
return true;
|
|
||||||
if (string.search(middlePattern) != -1)
|
|
||||||
return true;
|
|
||||||
if (string.search(startPattern) != -1)
|
|
||||||
return true;
|
|
||||||
if (string.search(endPattern) != -1)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function AnchorElementDecorator(element) {
|
function AnchorElementDecorator(element) {
|
||||||
this.constructor(element);
|
this.constructor(element);
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче