Title: [125239] trunk
Revision
125239
Author
a...@chromium.org
Date
2012-08-09 19:26:35 -0700 (Thu, 09 Aug 2012)

Log Message

HTMLElement.classList cannot remove classnames with uppercase characters
https://bugs.webkit.org/show_bug.cgi?id=93628

Reviewed by Alexey Proskuryakov.

Before this patch we were trying to be smart and determine whether we needed the update m_classNamesForQuirksMode
based on whether m_classNamesForQuirksMode.isNull(), however, m_classNamesForQuirksMode.isNull() is true when the
class name is the empty string.

We also did not update m_classNamesForQuirksMode when the class attribute was cleared.

Source/WebCore:

Updated tests.

* dom/StyledElement.cpp:
(WebCore::StyledElement::classAttributeChanged):
* html/ClassList.cpp:
(WebCore::ClassList::reset):
(WebCore::ClassList::classNames):

LayoutTests:

* fast/dom/HTMLElement/class-list-expected.txt:
* fast/dom/HTMLElement/class-list-quirks-expected.txt:
* fast/dom/HTMLElement/script-tests/class-list.js:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (125238 => 125239)


--- trunk/LayoutTests/ChangeLog	2012-08-10 02:19:15 UTC (rev 125238)
+++ trunk/LayoutTests/ChangeLog	2012-08-10 02:26:35 UTC (rev 125239)
@@ -1,3 +1,20 @@
+2012-08-09  Erik Arvidsson  <a...@chromium.org>
+
+        HTMLElement.classList cannot remove classnames with uppercase characters
+        https://bugs.webkit.org/show_bug.cgi?id=93628
+
+        Reviewed by Alexey Proskuryakov.
+
+        Before this patch we were trying to be smart and determine whether we needed the update m_classNamesForQuirksMode
+        based on whether m_classNamesForQuirksMode.isNull(), however, m_classNamesForQuirksMode.isNull() is true when the
+        class name is the empty string.
+
+        We also did not update m_classNamesForQuirksMode when the class attribute was cleared.
+
+        * fast/dom/HTMLElement/class-list-expected.txt:
+        * fast/dom/HTMLElement/class-list-quirks-expected.txt:
+        * fast/dom/HTMLElement/script-tests/class-list.js:
+
 2012-08-09  MORITA Hajime  <morr...@google.com>
 
         https://bugs.webkit.org/show_bug.cgi?id=93587

Modified: trunk/LayoutTests/fast/dom/HTMLElement/class-list-expected.txt (125238 => 125239)


--- trunk/LayoutTests/fast/dom/HTMLElement/class-list-expected.txt	2012-08-10 02:19:15 UTC (rev 125238)
+++ trunk/LayoutTests/fast/dom/HTMLElement/class-list-expected.txt	2012-08-10 02:26:35 UTC (rev 125239)
@@ -72,6 +72,8 @@
 PASS typeof element.classList is "object"
 PASS element.classList.constructor is DOMTokenList
 PASS element.classList === element.classList is true
+PASS document.body.classList.contains("FAIL") is true
+PASS document.body.className is ""
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/fast/dom/HTMLElement/class-list-quirks-expected.txt (125238 => 125239)


--- trunk/LayoutTests/fast/dom/HTMLElement/class-list-quirks-expected.txt	2012-08-10 02:19:15 UTC (rev 125238)
+++ trunk/LayoutTests/fast/dom/HTMLElement/class-list-quirks-expected.txt	2012-08-10 02:26:35 UTC (rev 125239)
@@ -72,6 +72,8 @@
 PASS typeof element.classList is "object"
 PASS element.classList.constructor is DOMTokenList
 PASS element.classList === element.classList is true
+PASS document.body.classList.contains("FAIL") is true
+PASS document.body.className is ""
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/fast/dom/HTMLElement/script-tests/class-list.js (125238 => 125239)


--- trunk/LayoutTests/fast/dom/HTMLElement/script-tests/class-list.js	2012-08-10 02:19:15 UTC (rev 125238)
+++ trunk/LayoutTests/fast/dom/HTMLElement/script-tests/class-list.js	2012-08-10 02:26:35 UTC (rev 125239)
@@ -259,3 +259,9 @@
 shouldEvaluateTo('element.classList.constructor', 'DOMTokenList');
 
 shouldBeTrue('element.classList === element.classList');
+
+// Bug 93628
+document.body.classList.add('FAIL');
+shouldBeTrue('document.body.classList.contains("FAIL")');
+document.body.classList.remove('FAIL');
+shouldBeEqualToString('document.body.className', '');

Modified: trunk/Source/WebCore/ChangeLog (125238 => 125239)


--- trunk/Source/WebCore/ChangeLog	2012-08-10 02:19:15 UTC (rev 125238)
+++ trunk/Source/WebCore/ChangeLog	2012-08-10 02:26:35 UTC (rev 125239)
@@ -1,3 +1,24 @@
+2012-08-09  Erik Arvidsson  <a...@chromium.org>
+
+        HTMLElement.classList cannot remove classnames with uppercase characters
+        https://bugs.webkit.org/show_bug.cgi?id=93628
+
+        Reviewed by Alexey Proskuryakov.
+
+        Before this patch we were trying to be smart and determine whether we needed the update m_classNamesForQuirksMode
+        based on whether m_classNamesForQuirksMode.isNull(), however, m_classNamesForQuirksMode.isNull() is true when the
+        class name is the empty string.
+
+        We also did not update m_classNamesForQuirksMode when the class attribute was cleared.
+
+        Updated tests.
+
+        * dom/StyledElement.cpp:
+        (WebCore::StyledElement::classAttributeChanged):
+        * html/ClassList.cpp:
+        (WebCore::ClassList::reset):
+        (WebCore::ClassList::classNames):
+
 2012-08-09  Yuta Kitamura  <yu...@chromium.org>
 
         Unreviewed, Chromium-mac (clang) build fix for r125230.

Modified: trunk/Source/WebCore/dom/StyledElement.cpp (125238 => 125239)


--- trunk/Source/WebCore/dom/StyledElement.cpp	2012-08-10 02:19:15 UTC (rev 125238)
+++ trunk/Source/WebCore/dom/StyledElement.cpp	2012-08-10 02:26:35 UTC (rev 125239)
@@ -170,10 +170,12 @@
     if (hasClass) {
         const bool shouldFoldCase = document()->inQuirksMode();
         ensureAttributeData()->setClass(newClassString, shouldFoldCase);
-        if (DOMTokenList* classList = optionalClassList())
-            static_cast<ClassList*>(classList)->reset(newClassString);
     } else if (attributeData())
         mutableAttributeData()->clearClass();
+
+    if (DOMTokenList* classList = optionalClassList())
+        static_cast<ClassList*>(classList)->reset(newClassString);
+
     setNeedsStyleRecalc();
 }
 

Modified: trunk/Source/WebCore/html/ClassList.cpp (125238 => 125239)


--- trunk/Source/WebCore/html/ClassList.cpp	2012-08-10 02:19:15 UTC (rev 125238)
+++ trunk/Source/WebCore/html/ClassList.cpp	2012-08-10 02:26:35 UTC (rev 125239)
@@ -131,14 +131,14 @@
 
 void ClassList::reset(const String& newClassName)
 {
-    if (!m_classNamesForQuirksMode.isNull())
+    if (m_element->document()->inQuirksMode())
         m_classNamesForQuirksMode.set(newClassName, false);
 }
 
 const SpaceSplitString& ClassList::classNames() const
 {
     ASSERT(m_element->hasClass());
-    if (!m_classNamesForQuirksMode.isNull())
+    if (m_element->document()->inQuirksMode())
         return m_classNamesForQuirksMode;
     return m_element->attributeData()->classNames();
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to