WebCore:
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 5 Nov 2007 18:52:49 +0000 (18:52 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 5 Nov 2007 18:52:49 +0000 (18:52 +0000)
        Reviewed by Oliver Hunt.

        - fix ASSERTION FAILED: !HashTranslator::equal(KeyTraits::emptyValue(), key) when a class attribute is all-whitespace

        Test: fast/dom/class-all-whitespace.html

        * dom/StyledElement.cpp:
        (WebCore::StyledElement::parseMappedAttribute): Check if there is any
        non-whitespace character in the class attribute.

LayoutTests:

        Reviewed by Oliver Hunt.

        - test that an all-whitespace class attribute does not cause an assertion failure

        * fast/dom/class-all-whitespace-expected.txt: Added.
        * fast/dom/class-all-whitespace.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@27441 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/dom/class-all-whitespace-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/class-all-whitespace.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/dom/StyledElement.cpp

index 408a26a788742a0cf7180bd33e8ad6a7579fc44d..4fb4fdae4c7d9ba53f8bf0107ebf97d297b78031 100644 (file)
@@ -1,3 +1,12 @@
+2007-11-05  Dan Bernstein  <mitz@apple.com>
+
+        Reviewed by Oliver Hunt.
+
+        - test that an all-whitespace class attribute does not cause an assertion failure
+
+        * fast/dom/class-all-whitespace-expected.txt: Added.
+        * fast/dom/class-all-whitespace.html: Added.
+
 2007-11-05  Alexey Proskuryakov  <ap@webkit.org>
 
         Reviewed by Darin.
diff --git a/LayoutTests/fast/dom/class-all-whitespace-expected.txt b/LayoutTests/fast/dom/class-all-whitespace-expected.txt
new file mode 100644 (file)
index 0000000..a49da4b
--- /dev/null
@@ -0,0 +1,3 @@
+Tests that an all-whitespace class attribute does not cause an assertion failure.
+
+
diff --git a/LayoutTests/fast/dom/class-all-whitespace.html b/LayoutTests/fast/dom/class-all-whitespace.html
new file mode 100644 (file)
index 0000000..eaafa64
--- /dev/null
@@ -0,0 +1,15 @@
+<html>
+<head>
+    <style>
+        div.class {  }
+    </style>
+    <script>
+        if (window.layoutTestController)
+            layoutTestController.dumpAsText();
+    </script>
+</head>
+<body>
+    <p>Tests that an all-whitespace <tt>class</tt> attribute does not cause an assertion failure.</p>
+    <div class=" "></div>
+</body>
+</html>
index 9f1d303736d3ea1c71f6e1a73551f3fbd7eb4c51..8aeda189e4e08dc63a5c2cb5fcd361dc124ded55 100644 (file)
@@ -1,3 +1,15 @@
+2007-11-05  Dan Bernstein  <mitz@apple.com>
+
+        Reviewed by Oliver Hunt.
+
+        - fix ASSERTION FAILED: !HashTranslator::equal(KeyTraits::emptyValue(), key) when a class attribute is all-whitespace
+
+        Test: fast/dom/class-all-whitespace.html
+
+        * dom/StyledElement.cpp:
+        (WebCore::StyledElement::parseMappedAttribute): Check if there is any
+        non-whitespace character in the class attribute.
+
 2007-11-05  Brady Eidson  <beidson@apple.com>
 
         Reviewed by Sam
index f91d01e707efdab36d855cc6723f4077a9fc5d34..ad64915bae392200971d8453e465a1d4a39bdcaf 100644 (file)
@@ -216,7 +216,18 @@ void StyledElement::parseMappedAttribute(MappedAttribute *attr)
         setChanged();
     } else if (attr->name() == classAttr) {
         // class
-        setHasClass(!attr->isEmpty());
+        bool hasClass = false;
+        if (!attr->isEmpty()) {
+            const AtomicString& value = attr->value();
+            unsigned len = value.length();
+            for (unsigned i = 0; i < len; ++i) {
+                if (!isClassWhitespace(value[i])) {
+                    hasClass = true;
+                    break;
+                }
+            }
+        }
+        setHasClass(hasClass);
         if (namedAttrMap)
             mappedAttributes()->parseClassAttribute(attr->value());
         setChanged();