diff options
Diffstat (limited to 'WebCore/inspector/front-end/utilities.js')
-rw-r--r-- | WebCore/inspector/front-end/utilities.js | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/WebCore/inspector/front-end/utilities.js b/WebCore/inspector/front-end/utilities.js index e9d185f..04c9032 100644 --- a/WebCore/inspector/front-end/utilities.js +++ b/WebCore/inspector/front-end/utilities.js @@ -147,13 +147,18 @@ Node.prototype.rangeOfWord = function(offset, stopCharacters, stayWithinNode, di Element.prototype.removeStyleClass = function(className) { - // Test for the simple case before using a RegExp. + // Test for the simple case first. if (this.className === className) { this.className = ""; return; } - this.removeMatchingStyleClasses(className.escapeForRegExp()); + var index = this.className.indexOf(className); + if (index === -1) + return; + + var newClassName = " " + this.className + " "; + this.className = newClassName.replace(" " + className + " ", " "); } Element.prototype.removeMatchingStyleClasses = function(classNameRegex) @@ -173,11 +178,15 @@ Element.prototype.hasStyleClass = function(className) { if (!className) return false; - // Test for the simple case before using a RegExp. + // Test for the simple case if (this.className === className) return true; - var regex = new RegExp("(^|\\s)" + className.escapeForRegExp() + "($|\\s)"); - return regex.test(this.className); + + var index = this.className.indexOf(className); + if (index === -1) + return false; + var toTest = " " + this.className + " "; + return toTest.indexOf(" " + className + " ", index) !== -1; } Element.prototype.positionAt = function(x, y) @@ -222,8 +231,7 @@ Element.prototype.query = function(query) Element.prototype.removeChildren = function() { - while (this.firstChild) - this.removeChild(this.firstChild); + this.innerHTML = ""; } Element.prototype.isInsertionCaretInside = function() @@ -342,7 +350,7 @@ String.prototype.trimWhitespace = function() String.prototype.trimURL = function(baseURLDomain) { - var result = this.replace(new RegExp("^http[s]?:\/\/", "i"), ""); + var result = this.replace(/^https?:\/\//i, ""); if (baseURLDomain) result = result.replace(new RegExp("^" + baseURLDomain.escapeForRegExp(), "i"), ""); return result; @@ -542,6 +550,9 @@ Number.secondsToString = function(seconds, formatterFunction, higherResolution) if (!formatterFunction) formatterFunction = String.sprintf; + if (seconds === 0) + return "0"; + var ms = seconds * 1000; if (higherResolution && ms < 1000) return formatterFunction("%.3fms", ms); @@ -822,3 +833,7 @@ function isEnterKey(event) { // Check if in IME. return event.keyCode !== 229 && event.keyIdentifier === "Enter"; } + +function isFnKey(event) { + return event.keyCode >= 112 && event.keyCode <= 123; +} |