From e074e058318dca0dd6489cb51f9533855e465183 Mon Sep 17 00:00:00 2001 From: "mitz@apple.com" Date: Mon, 5 Nov 2007 18:52:49 +0000 Subject: [PATCH] WebCore: 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 | 9 +++++++++ .../fast/dom/class-all-whitespace-expected.txt | 3 +++ LayoutTests/fast/dom/class-all-whitespace.html | 15 +++++++++++++++ WebCore/ChangeLog | 12 ++++++++++++ WebCore/dom/StyledElement.cpp | 13 ++++++++++++- 5 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 LayoutTests/fast/dom/class-all-whitespace-expected.txt create mode 100644 LayoutTests/fast/dom/class-all-whitespace.html diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog index 408a26a78874..4fb4fdae4c7d 100644 --- a/LayoutTests/ChangeLog +++ b/LayoutTests/ChangeLog @@ -1,3 +1,12 @@ +2007-11-05 Dan Bernstein + + 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 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 index 000000000000..a49da4baf7e3 --- /dev/null +++ b/LayoutTests/fast/dom/class-all-whitespace-expected.txt @@ -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 index 000000000000..eaafa6467cc6 --- /dev/null +++ b/LayoutTests/fast/dom/class-all-whitespace.html @@ -0,0 +1,15 @@ + + + + + + +

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

+
+ + diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog index 9f1d303736d3..8aeda189e4e0 100644 --- a/WebCore/ChangeLog +++ b/WebCore/ChangeLog @@ -1,3 +1,15 @@ +2007-11-05 Dan Bernstein + + 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 Reviewed by Sam diff --git a/WebCore/dom/StyledElement.cpp b/WebCore/dom/StyledElement.cpp index f91d01e707ef..ad64915bae39 100644 --- a/WebCore/dom/StyledElement.cpp +++ b/WebCore/dom/StyledElement.cpp @@ -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(); -- 2.36.0