Title: [138691] trunk/Source/WebCore
- Revision
- 138691
- Author
- [email protected]
- Date
- 2013-01-02 18:59:32 -0800 (Wed, 02 Jan 2013)
Log Message
Make ClassList::reset's purpose obvious and don't keep quirks string when not needed
https://bugs.webkit.org/show_bug.cgi?id=105963
Reviewed by Ojan Vafai.
ClassList::reset only exists to handle updating the special SpaceSplitString
for quirks mode documents. This adds a new method that makes this obvious and
instead of updating the string immediately clear the value and lazily
update it. We also clear the value whenever we're inserted into the
document so that when moving from a quirks mode document to a non-quirks
mode document we don't keep the SpaceSplitString around if it's not needed.
No new tests, I'm not sure how to write a test that we don't keep the
SpaceSplitString when moving between quirks and non-quirks mode documents.
* dom/Element.cpp:
(WebCore::Element::classAttributeChanged):
(WebCore::Element::insertedInto):
* dom/Element.h:
(Element):
* dom/ElementRareData.h:
(WebCore::ElementRareData::clearClassListValueForQuirksMode):
* html/ClassList.cpp:
* html/ClassList.h:
(WebCore::ClassList::clearValueForQuirksMode):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (138690 => 138691)
--- trunk/Source/WebCore/ChangeLog 2013-01-03 02:05:15 UTC (rev 138690)
+++ trunk/Source/WebCore/ChangeLog 2013-01-03 02:59:32 UTC (rev 138691)
@@ -1,3 +1,31 @@
+2013-01-02 Elliott Sprehn <[email protected]>
+
+ Make ClassList::reset's purpose obvious and don't keep quirks string when not needed
+ https://bugs.webkit.org/show_bug.cgi?id=105963
+
+ Reviewed by Ojan Vafai.
+
+ ClassList::reset only exists to handle updating the special SpaceSplitString
+ for quirks mode documents. This adds a new method that makes this obvious and
+ instead of updating the string immediately clear the value and lazily
+ update it. We also clear the value whenever we're inserted into the
+ document so that when moving from a quirks mode document to a non-quirks
+ mode document we don't keep the SpaceSplitString around if it's not needed.
+
+ No new tests, I'm not sure how to write a test that we don't keep the
+ SpaceSplitString when moving between quirks and non-quirks mode documents.
+
+ * dom/Element.cpp:
+ (WebCore::Element::classAttributeChanged):
+ (WebCore::Element::insertedInto):
+ * dom/Element.h:
+ (Element):
+ * dom/ElementRareData.h:
+ (WebCore::ElementRareData::clearClassListValueForQuirksMode):
+ * html/ClassList.cpp:
+ * html/ClassList.h:
+ (WebCore::ClassList::clearValueForQuirksMode):
+
2013-01-02 Adam Barth <[email protected]>
[V8] V8DOMWrapper.cpp has many more includes than necessary
Modified: trunk/Source/WebCore/dom/Element.cpp (138690 => 138691)
--- trunk/Source/WebCore/dom/Element.cpp 2013-01-03 02:05:15 UTC (rev 138690)
+++ trunk/Source/WebCore/dom/Element.cpp 2013-01-03 02:59:32 UTC (rev 138691)
@@ -899,8 +899,8 @@
attributeData->clearClass();
}
- if (DOMTokenList* classList = optionalClassList())
- static_cast<ClassList*>(classList)->reset(newClassString);
+ if (hasRareData())
+ elementRareData()->clearClassListValueForQuirksMode();
if (shouldInvalidateStyle)
setNeedsStyleRecalc();
@@ -1101,6 +1101,9 @@
if (!insertionPoint->isInTreeScope())
return InsertionDone;
+ if (hasRareData())
+ elementRareData()->clearClassListValueForQuirksMode();
+
TreeScope* scope = insertionPoint->treeScope();
if (scope != treeScope())
return InsertionDone;
@@ -2209,13 +2212,6 @@
return data->classList();
}
-DOMTokenList* Element::optionalClassList() const
-{
- if (!hasRareData())
- return 0;
- return elementRareData()->classList();
-}
-
DOMStringMap* Element::dataset()
{
ElementRareData* data = ""
Modified: trunk/Source/WebCore/dom/Element.h (138690 => 138691)
--- trunk/Source/WebCore/dom/Element.h 2013-01-03 02:05:15 UTC (rev 138690)
+++ trunk/Source/WebCore/dom/Element.h 2013-01-03 02:59:32 UTC (rev 138691)
@@ -385,7 +385,6 @@
bool webkitMatchesSelector(const String& selectors, ExceptionCode&);
DOMTokenList* classList();
- DOMTokenList* optionalClassList() const;
DOMStringMap* dataset();
Modified: trunk/Source/WebCore/dom/ElementRareData.h (138690 => 138691)
--- trunk/Source/WebCore/dom/ElementRareData.h 2013-01-03 02:05:15 UTC (rev 138690)
+++ trunk/Source/WebCore/dom/ElementRareData.h 2013-01-03 02:59:32 UTC (rev 138691)
@@ -101,6 +101,12 @@
ClassList* classList() const { return m_classList.get(); }
void setClassList(PassOwnPtr<ClassList> classList) { m_classList = classList; }
+ void clearClassListValueForQuirksMode()
+ {
+ if (!m_classList)
+ return;
+ m_classList->clearValueForQuirksMode();
+ }
DatasetDOMStringMap* dataset() const { return m_dataset.get(); }
void setDataset(PassOwnPtr<DatasetDOMStringMap> dataset) { m_dataset = dataset; }
Modified: trunk/Source/WebCore/html/ClassList.cpp (138690 => 138691)
--- trunk/Source/WebCore/html/ClassList.cpp 2013-01-03 02:05:15 UTC (rev 138690)
+++ trunk/Source/WebCore/html/ClassList.cpp 2013-01-03 02:59:32 UTC (rev 138691)
@@ -60,12 +60,6 @@
return m_element->hasClass() && classNames().contains(token);
}
-void ClassList::reset(const String& newClassName)
-{
- if (m_element->document()->inQuirksMode())
- m_classNamesForQuirksMode = adoptPtr(new SpaceSplitString(newClassName, false));
-}
-
const SpaceSplitString& ClassList::classNames() const
{
ASSERT(m_element->hasClass());
Modified: trunk/Source/WebCore/html/ClassList.h (138690 => 138691)
--- trunk/Source/WebCore/html/ClassList.h 2013-01-03 02:05:15 UTC (rev 138690)
+++ trunk/Source/WebCore/html/ClassList.h 2013-01-03 02:59:32 UTC (rev 138691)
@@ -56,7 +56,7 @@
virtual Element* element() OVERRIDE { return m_element; }
- void reset(const String&);
+ void clearValueForQuirksMode() { m_classNamesForQuirksMode = nullptr; }
private:
ClassList(Element*);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes