summaryrefslogtreecommitdiffstats
path: root/WebCore/dom/StyledElement.cpp
diff options
context:
space:
mode:
authorAndrei Popescu <andreip@google.com>2009-08-19 14:09:30 +0100
committerAndrei Popescu <andreip@google.com>2009-08-19 14:09:30 +0100
commit058ccc7ba0a4d59b9f6e92808332aa9895425fc7 (patch)
tree276aad5a2bbc2fd7d65d21bfca42c9de88b3dd20 /WebCore/dom/StyledElement.cpp
parent2796dd1bf3b4b01e7e1d96ea91bd3a212f647579 (diff)
downloadexternal_webkit-058ccc7ba0a4d59b9f6e92808332aa9895425fc7.zip
external_webkit-058ccc7ba0a4d59b9f6e92808332aa9895425fc7.tar.gz
external_webkit-058ccc7ba0a4d59b9f6e92808332aa9895425fc7.tar.bz2
Revert "Merge WebKit r47420"
This reverts commit d227fc870c7a697500a3c900c31baf05fb9a8524.
Diffstat (limited to 'WebCore/dom/StyledElement.cpp')
-rw-r--r--WebCore/dom/StyledElement.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/WebCore/dom/StyledElement.cpp b/WebCore/dom/StyledElement.cpp
index 13c23fb..456cc52 100644
--- a/WebCore/dom/StyledElement.cpp
+++ b/WebCore/dom/StyledElement.cpp
@@ -280,6 +280,14 @@ CSSStyleDeclaration* StyledElement::style()
return getInlineStyleDecl();
}
+static inline int toHex(UChar c)
+{
+ return ((c >= '0' && c <= '9') ? (c - '0')
+ : ((c >= 'a' && c <= 'f') ? (c - 'a' + 10)
+ : ((c >= 'A' && c <= 'F') ? (c - 'A' + 10)
+ : -1)));
+}
+
void StyledElement::addCSSProperty(MappedAttribute* attr, int id, const String &value)
{
if (!attr->decl()) createMappedDecl(attr);
@@ -385,9 +393,10 @@ void StyledElement::addCSSColor(MappedAttribute* attr, int id, const String& c)
// search forward for digits in the string
int numDigits = 0;
while (pos < (int)color.length() && numDigits < basicLength) {
- colors[component] <<= 4;
- if (isASCIIHexDigit(color[pos])) {
- colors[component] += toASCIIHexValue(color[pos]);
+ int hex = toHex(color[pos]);
+ colors[component] = (colors[component] << 4);
+ if (hex > 0) {
+ colors[component] += hex;
maxDigit = min(maxDigit, numDigits);
}
numDigits++;
@@ -401,9 +410,10 @@ void StyledElement::addCSSColor(MappedAttribute* attr, int id, const String& c)
// normalize to 00-ff. The highest filled digit counts, minimum is 2 digits
maxDigit -= 2;
- colors[0] >>= 4 * maxDigit;
- colors[1] >>= 4 * maxDigit;
- colors[2] >>= 4 * maxDigit;
+ colors[0] >>= 4*maxDigit;
+ colors[1] >>= 4*maxDigit;
+ colors[2] >>= 4*maxDigit;
+ // ASSERT(colors[0] < 0x100 && colors[1] < 0x100 && colors[2] < 0x100);
color = String::format("#%02x%02x%02x", colors[0], colors[1], colors[2]);
if (attr->decl()->setProperty(id, color, false))