[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
darin at apple.com
darin at apple.com
Wed Dec 22 14:07:24 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 7156d95edc0ca32760ae66cbd30d778a545040fa
Author: darin at apple.com <darin at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Mon Oct 4 22:41:47 2010 +0000
2010-10-04 Darin Adler <darin at apple.com>
Reviewed by Dan Bernstein.
Use isHTMLSpace in more places, and optimize it
https://bugs.webkit.org/show_bug.cgi?id=47103
* css/CSSParser.cpp:
(WebCore::parseColorInt): Use isHTMLSpace instead of a separate isCSSWhitespace function.
(WebCore::parseAlphaValue): Ditto.
(WebCore::CSSParser::text): Ditto.
* dom/SpaceSplitString.h: Removed isClassWhitespace.
* dom/SpaceSplitString.cpp:
(WebCore::SpaceSplitStringData::createVector): Use isHTMLSpace instead of isClassWhitespace.
* dom/StyledElement.cpp:
(WebCore::StyledElement::classAttributeChanged): Ditto.
* html/DOMTokenList.cpp:
(WebCore::validateToken): Ditto.
(WebCore::DOMTokenList::removeInternal): Ditto.
* html/parser/HTMLParserIdioms.h: Added histogram data an changed so that non-spaces take
only a single branch and plain old spaces take only two branches.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@69044 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 2d71a9b..a6355ab 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,28 @@
+2010-10-04 Darin Adler <darin at apple.com>
+
+ Reviewed by Dan Bernstein.
+
+ Use isHTMLSpace in more places, and optimize it
+ https://bugs.webkit.org/show_bug.cgi?id=47103
+
+ * css/CSSParser.cpp:
+ (WebCore::parseColorInt): Use isHTMLSpace instead of a separate isCSSWhitespace function.
+ (WebCore::parseAlphaValue): Ditto.
+ (WebCore::CSSParser::text): Ditto.
+
+ * dom/SpaceSplitString.h: Removed isClassWhitespace.
+
+ * dom/SpaceSplitString.cpp:
+ (WebCore::SpaceSplitStringData::createVector): Use isHTMLSpace instead of isClassWhitespace.
+ * dom/StyledElement.cpp:
+ (WebCore::StyledElement::classAttributeChanged): Ditto.
+ * html/DOMTokenList.cpp:
+ (WebCore::validateToken): Ditto.
+ (WebCore::DOMTokenList::removeInternal): Ditto.
+
+ * html/parser/HTMLParserIdioms.h: Added histogram data an changed so that non-spaces take
+ only a single branch and plain old spaces take only two branches.
+
2010-10-04 Justin Schuh <jschuh at chromium.org>
Reviewed by James Robinson.
diff --git a/WebCore/css/CSSParser.cpp b/WebCore/css/CSSParser.cpp
index 6c2110f..21811ff 100644
--- a/WebCore/css/CSSParser.cpp
+++ b/WebCore/css/CSSParser.cpp
@@ -25,15 +25,14 @@
#include "config.h"
#include "CSSParser.h"
-#include "CSSTimingFunctionValue.h"
#include "CSSBorderImageValue.h"
#include "CSSCanvasValue.h"
#include "CSSCharsetRule.h"
#include "CSSCursorImageValue.h"
-#include "CSSImageValue.h"
#include "CSSFontFaceRule.h"
#include "CSSFontFaceSrcValue.h"
#include "CSSGradientValue.h"
+#include "CSSImageValue.h"
#include "CSSImportRule.h"
#include "CSSInheritedValue.h"
#include "CSSInitialValue.h"
@@ -50,6 +49,7 @@
#include "CSSSelector.h"
#include "CSSStyleRule.h"
#include "CSSStyleSheet.h"
+#include "CSSTimingFunctionValue.h"
#include "CSSUnicodeRangeValue.h"
#include "CSSValueKeywords.h"
#include "CSSValueList.h"
@@ -61,6 +61,7 @@
#include "FloatConversion.h"
#include "FontFamilyValue.h"
#include "FontValue.h"
+#include "HTMLParserIdioms.h"
#include "HashTools.h"
#include "MediaList.h"
#include "MediaQueryExp.h"
@@ -3759,19 +3760,12 @@ bool CSSParser::parseFontFaceUnicodeRange()
return true;
}
-// FIXME: This is the same as isHTMLSpace, so I think we should eliminate this function
-// and use that instead. Pedants who say CSS is not HTML need not apply.
-static inline bool isCSSWhitespace(UChar c)
-{
- return c == ' ' || c == '\t' || c == '\r' || c == '\n' || c == '\f';
-}
-
static inline bool parseColorInt(const UChar*& string, const UChar* end, UChar terminator, int& value)
{
const UChar* current = string;
int localValue = 0;
bool negative = false;
- while (current != end && isCSSWhitespace(*current))
+ while (current != end && isHTMLSpace(*current))
current++;
if (current != end && *current == '-') {
negative = true;
@@ -3790,7 +3784,7 @@ static inline bool parseColorInt(const UChar*& string, const UChar* end, UChar t
}
localValue = newValue;
}
- while (current != end && isCSSWhitespace(*current))
+ while (current != end && isHTMLSpace(*current))
current++;
if (current == end || *current++ != terminator)
return false;
@@ -3815,7 +3809,7 @@ static inline bool isTenthAlpha(const UChar* string, const int length)
static inline bool parseAlphaValue(const UChar*& string, const UChar* end, UChar terminator, int& value)
{
- while (string != end && isCSSWhitespace(*string))
+ while (string != end && isHTMLSpace(*string))
string++;
value = 0;
@@ -5199,11 +5193,11 @@ UChar* CSSParser::text(int *length)
start += 4;
l -= 5;
// strip {w}
- while (l && isCSSWhitespace(*start)) {
+ while (l && isHTMLSpace(*start)) {
++start;
--l;
}
- while (l && isCSSWhitespace(start[l - 1]))
+ while (l && isHTMLSpace(start[l - 1]))
--l;
if (l && (*start == '"' || *start == '\'')) {
ASSERT(l >= 2 && start[l - 1] == *start);
@@ -5217,11 +5211,11 @@ UChar* CSSParser::text(int *length)
start += 12;
l -= 13;
// strip {w}
- while (l && isCSSWhitespace(*start)) {
+ while (l && isHTMLSpace(*start)) {
++start;
--l;
}
- while (l && isCSSWhitespace(start[l - 1]))
+ while (l && isHTMLSpace(start[l - 1]))
--l;
break;
default:
@@ -5273,7 +5267,7 @@ UChar* CSSParser::text(int *length)
uc = 0xfffd;
*out++ = uc;
escape = 0;
- if (isCSSWhitespace(*current))
+ if (isHTMLSpace(*current))
continue;
}
if (!escape && *current == '\\') {
diff --git a/WebCore/dom/SpaceSplitString.cpp b/WebCore/dom/SpaceSplitString.cpp
index b062dbf..8a2710c 100644
--- a/WebCore/dom/SpaceSplitString.cpp
+++ b/WebCore/dom/SpaceSplitString.cpp
@@ -21,6 +21,7 @@
#include "config.h"
#include "SpaceSplitString.h"
+#include "HTMLParserIdioms.h"
#include <wtf/ASCIICType.h>
using namespace WTF;
@@ -53,12 +54,12 @@ void SpaceSplitStringData::createVector()
unsigned length = m_string.length();
unsigned start = 0;
while (true) {
- while (start < length && isClassWhitespace(characters[start]))
+ while (start < length && isHTMLSpace(characters[start]))
++start;
if (start >= length)
break;
unsigned end = start + 1;
- while (end < length && !isClassWhitespace(characters[end]))
+ while (end < length && isNotHTMLSpace(characters[end]))
++end;
m_vector.append(AtomicString(characters + start, end - start));
diff --git a/WebCore/dom/SpaceSplitString.h b/WebCore/dom/SpaceSplitString.h
index 0d3650e..09ca8d9 100644
--- a/WebCore/dom/SpaceSplitString.h
+++ b/WebCore/dom/SpaceSplitString.h
@@ -81,11 +81,6 @@ namespace WebCore {
OwnPtr<SpaceSplitStringData> m_data;
};
- inline bool isClassWhitespace(UChar c)
- {
- return c == ' ' || c == '\r' || c == '\n' || c == '\t' || c == '\f';
- }
-
} // namespace WebCore
#endif // SpaceSplitString_h
diff --git a/WebCore/dom/StyledElement.cpp b/WebCore/dom/StyledElement.cpp
index f07fda9..45b80c5 100644
--- a/WebCore/dom/StyledElement.cpp
+++ b/WebCore/dom/StyledElement.cpp
@@ -31,6 +31,7 @@
#include "DOMTokenList.h"
#include "Document.h"
#include "HTMLNames.h"
+#include "HTMLParserIdioms.h"
#include <wtf/HashFunctions.h>
using namespace std;
@@ -213,7 +214,7 @@ void StyledElement::classAttributeChanged(const AtomicString& newClassString)
unsigned length = newClassString.length();
unsigned i;
for (i = 0; i < length; ++i) {
- if (!isClassWhitespace(characters[i]))
+ if (isNotHTMLSpace(characters[i]))
break;
}
bool hasClass = i < length;
diff --git a/WebCore/html/DOMTokenList.cpp b/WebCore/html/DOMTokenList.cpp
index 8ee45a2..d19875b 100644
--- a/WebCore/html/DOMTokenList.cpp
+++ b/WebCore/html/DOMTokenList.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010, Google Inc. All rights reserved.
+ * Copyright (C) 2010 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -27,6 +27,7 @@
#include "Element.h"
#include "HTMLNames.h"
+#include "HTMLParserIdioms.h"
#include "SpaceSplitString.h"
#include "StringBuilder.h"
@@ -43,7 +44,7 @@ static bool validateToken(const AtomicString& token, ExceptionCode& ec)
unsigned length = token.length();
for (unsigned i = 0; i < length; ++i) {
- if (isClassWhitespace(token[i])) {
+ if (isHTMLSpace(token[i])) {
ec = INVALID_CHARACTER_ERR;
return false;
}
@@ -139,25 +140,25 @@ void DOMTokenList::removeInternal(const AtomicString& token) const
// Step 5
while (position < inputLength) {
- if (isClassWhitespace(input[position])) { // 6
+ if (isHTMLSpace(input[position])) { // 6
output.append(input[position++]); // 6.1, 6.2
continue; // 6.3
}
// Step 7
Vector<UChar> s;
- while (position < inputLength && !isClassWhitespace(input[position]))
+ while (position < inputLength && isNotHTMLSpace(input[position]))
s.append(input[position++]);
// Step 8
if (s == token) {
// Step 8.1
- while (position < inputLength && isClassWhitespace(input[position]))
+ while (position < inputLength && isHTMLSpace(input[position]))
++position;
// Step 8.2
size_t j = output.size();
- while (j > 0 && isClassWhitespace(output[j - 1]))
+ while (j > 0 && isHTMLSpace(output[j - 1]))
--j;
output.resize(j);
diff --git a/WebCore/html/parser/HTMLParserIdioms.h b/WebCore/html/parser/HTMLParserIdioms.h
index f4704f7..4839138 100644
--- a/WebCore/html/parser/HTMLParserIdioms.h
+++ b/WebCore/html/parser/HTMLParserIdioms.h
@@ -52,8 +52,17 @@ bool parseHTMLInteger(const String&, int&);
inline bool isHTMLSpace(UChar character)
{
- // FIXME: Consider branch permutations as we did in isASCIISpace.
- return character == '\t' || character == '\x0A' || character == '\x0C' || character == '\x0D' || character == ' ';
+ // Histogram from Apple's page load test combined with some ad hoc browsing some other test suites.
+ //
+ // 82%: 216330 non-space characters, all > U+0020
+ // 11%: 30017 plain space characters, U+0020
+ // 5%: 12099 newline characters, U+000A
+ // 2%: 5346 tab characters, U+0009
+ //
+ // No other characters seen. No U+000C or U+000D, and no other control characters.
+ // Accordingly, we check for non-spaces first, then space, then newline, then tab, then the other characters.
+
+ return character <= ' ' && (character == ' ' || character == '\n' || character == '\t' || character == '\r' || character == '\f');
}
inline bool isNotHTMLSpace(UChar character)
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list