diff options
| author | Steve Block <steveblock@google.com> | 2009-12-17 09:55:06 -0800 |
|---|---|---|
| committer | Android Git Automerger <android-git-automerger@android.com> | 2009-12-17 09:55:06 -0800 |
| commit | b880d713c04257ca40abfef97c300afdead423b8 (patch) | |
| tree | 6982576c228bcd1a7efe98afed544d840751094c /WebCore/inspector/front-end/utilities.js | |
| parent | e2e7a5c57b53f01e63a0245b4420d54b454cb373 (diff) | |
| parent | 643ca7872b450ea4efacab6188849e5aac2ba161 (diff) | |
| download | external_webkit-b880d713c04257ca40abfef97c300afdead423b8.zip external_webkit-b880d713c04257ca40abfef97c300afdead423b8.tar.gz external_webkit-b880d713c04257ca40abfef97c300afdead423b8.tar.bz2 | |
am 643ca787: Merge webkit.org at r51976 : Initial merge by git.
Merge commit '643ca7872b450ea4efacab6188849e5aac2ba161' into eclair-mr2-plus-aosp
* commit '643ca7872b450ea4efacab6188849e5aac2ba161':
Merge webkit.org at r51976 : Initial merge by git.
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; +} |
