- Revision
- 154707
- Author
- [email protected]
- Date
- 2013-08-27 13:49:57 -0700 (Tue, 27 Aug 2013)
Log Message
Clean ClassList and DOMSettableTokenList
https://bugs.webkit.org/show_bug.cgi?id=120344
Reviewed by Ryosuke Niwa.
This patch cleans ClassList and DOMSettableTokenList to make it simpler to update
SpaceSplitString:
- Move the implementation of virtual functions to the cpp file.
- Clean the #includes.
- Make the implemented pure virtual methods final.
- Make the element() accessor const.
* html/ClassList.cpp:
(WebCore::ClassList::create):
(WebCore::ClassList::element):
(WebCore::ClassList::value):
(WebCore::ClassList::setValue):
(WebCore::ClassList::classNames):
* html/ClassList.h:
* html/DOMSettableTokenList.cpp:
(WebCore::DOMSettableTokenList::create):
(WebCore::DOMSettableTokenList::ref):
(WebCore::DOMSettableTokenList::deref):
(WebCore::DOMSettableTokenList::length):
(WebCore::DOMSettableTokenList::value):
* html/DOMSettableTokenList.h:
* html/DOMTokenList.h:
(WebCore::DOMTokenList::element):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (154706 => 154707)
--- trunk/Source/WebCore/ChangeLog 2013-08-27 20:47:27 UTC (rev 154706)
+++ trunk/Source/WebCore/ChangeLog 2013-08-27 20:49:57 UTC (rev 154707)
@@ -1,3 +1,34 @@
+2013-08-27 Benjamin Poulain <[email protected]>
+
+ Clean ClassList and DOMSettableTokenList
+ https://bugs.webkit.org/show_bug.cgi?id=120344
+
+ Reviewed by Ryosuke Niwa.
+
+ This patch cleans ClassList and DOMSettableTokenList to make it simpler to update
+ SpaceSplitString:
+ - Move the implementation of virtual functions to the cpp file.
+ - Clean the #includes.
+ - Make the implemented pure virtual methods final.
+ - Make the element() accessor const.
+
+ * html/ClassList.cpp:
+ (WebCore::ClassList::create):
+ (WebCore::ClassList::element):
+ (WebCore::ClassList::value):
+ (WebCore::ClassList::setValue):
+ (WebCore::ClassList::classNames):
+ * html/ClassList.h:
+ * html/DOMSettableTokenList.cpp:
+ (WebCore::DOMSettableTokenList::create):
+ (WebCore::DOMSettableTokenList::ref):
+ (WebCore::DOMSettableTokenList::deref):
+ (WebCore::DOMSettableTokenList::length):
+ (WebCore::DOMSettableTokenList::value):
+ * html/DOMSettableTokenList.h:
+ * html/DOMTokenList.h:
+ (WebCore::DOMTokenList::element):
+
2013-08-27 Arunprasad Rajkumar <[email protected]>
Replace currentTime() with monotonicallyIncreasingTime() in WebCore
Modified: trunk/Source/WebCore/html/ClassList.cpp (154706 => 154707)
--- trunk/Source/WebCore/html/ClassList.cpp 2013-08-27 20:47:27 UTC (rev 154706)
+++ trunk/Source/WebCore/html/ClassList.cpp 2013-08-27 20:49:57 UTC (rev 154707)
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2010 Google Inc. All rights reserved.
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -25,15 +26,17 @@
#include "config.h"
#include "ClassList.h"
+#include "Element.h"
+#include "HTMLNames.h"
#include "HTMLParserIdioms.h"
-#include "SpaceSplitString.h"
namespace WebCore {
-using namespace HTMLNames;
+PassOwnPtr<ClassList> ClassList::create(Element* element)
+{
+ return adoptPtr(new ClassList(element));
+}
-ClassList::ClassList(Element* element) : m_element(element) { }
-
void ClassList::ref()
{
m_element->ref();
@@ -56,18 +59,33 @@
return classNames()[index];
}
+Element* ClassList::element() const
+{
+ return m_element;
+}
+
bool ClassList::containsInternal(const AtomicString& token) const
{
return m_element->hasClass() && classNames().contains(token);
}
+AtomicString ClassList::value() const
+{
+ return m_element->getAttribute(HTMLNames::classAttr);
+}
+
+void ClassList::setValue(const AtomicString& value)
+{
+ m_element->setAttribute(HTMLNames::classAttr, value);
+}
+
const SpaceSplitString& ClassList::classNames() const
{
ASSERT(m_element->hasClass());
if (m_element->document()->inQuirksMode()) {
- if (!m_classNamesForQuirksMode)
- m_classNamesForQuirksMode = adoptPtr(new SpaceSplitString(value(), false));
- return *m_classNamesForQuirksMode.get();
+ if (!m_classNamesForQuirksMode.size())
+ m_classNamesForQuirksMode.set(value(), false);
+ return m_classNamesForQuirksMode;
}
return m_element->elementData()->classNames();
}
Modified: trunk/Source/WebCore/html/ClassList.h (154706 => 154707)
--- trunk/Source/WebCore/html/ClassList.h 2013-08-27 20:47:27 UTC (rev 154706)
+++ trunk/Source/WebCore/html/ClassList.h 2013-08-27 20:49:57 UTC (rev 154707)
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2010 Google Inc. All rights reserved.
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,47 +27,40 @@
#define ClassList_h
#include "DOMTokenList.h"
-#include "Element.h"
-#include "HTMLNames.h"
#include "SpaceSplitString.h"
-#include <wtf/OwnPtr.h>
-#include <wtf/PassOwnPtr.h>
namespace WebCore {
class Element;
-typedef int ExceptionCode;
-
class ClassList : public DOMTokenList {
public:
- static PassOwnPtr<ClassList> create(Element* element)
- {
- return adoptPtr(new ClassList(element));
- }
+ static PassOwnPtr<ClassList> create(Element*);
- virtual void ref() OVERRIDE;
- virtual void deref() OVERRIDE;
+ virtual void ref() OVERRIDE FINAL;
+ virtual void deref() OVERRIDE FINAL;
- virtual unsigned length() const OVERRIDE;
- virtual const AtomicString item(unsigned index) const OVERRIDE;
+ virtual unsigned length() const OVERRIDE FINAL;
+ virtual const AtomicString item(unsigned index) const OVERRIDE FINAL;
- virtual Element* element() OVERRIDE { return m_element; }
+ virtual Element* element() const OVERRIDE FINAL;
- void clearValueForQuirksMode() { m_classNamesForQuirksMode = nullptr; }
+ void clearValueForQuirksMode() { m_classNamesForQuirksMode.clear(); }
private:
- ClassList(Element*);
+ ClassList(Element* element)
+ : m_element(element)
+ {
+ }
- virtual bool containsInternal(const AtomicString&) const OVERRIDE;
+ virtual bool containsInternal(const AtomicString&) const OVERRIDE FINAL;
+ virtual AtomicString value() const OVERRIDE FINAL;
+ virtual void setValue(const AtomicString&) OVERRIDE FINAL;
const SpaceSplitString& classNames() const;
- virtual AtomicString value() const OVERRIDE { return m_element->getAttribute(HTMLNames::classAttr); }
- virtual void setValue(const AtomicString& value) OVERRIDE { m_element->setAttribute(HTMLNames::classAttr, value); }
-
Element* m_element;
- mutable OwnPtr<SpaceSplitString> m_classNamesForQuirksMode;
+ mutable SpaceSplitString m_classNamesForQuirksMode;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/html/DOMSettableTokenList.cpp (154706 => 154707)
--- trunk/Source/WebCore/html/DOMSettableTokenList.cpp 2013-08-27 20:47:27 UTC (rev 154706)
+++ trunk/Source/WebCore/html/DOMSettableTokenList.cpp 2013-08-27 20:49:57 UTC (rev 154707)
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2010 Google Inc. All rights reserved.
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -27,16 +28,26 @@
namespace WebCore {
-DOMSettableTokenList::DOMSettableTokenList()
- : m_value()
- , m_tokens()
+PassRefPtr<DOMSettableTokenList> DOMSettableTokenList::create()
{
+ return adoptRef(new DOMSettableTokenList());
}
-DOMSettableTokenList::~DOMSettableTokenList()
+void DOMSettableTokenList::ref()
{
+ RefCounted<DOMSettableTokenList>::ref();
}
+void DOMSettableTokenList::deref()
+{
+ RefCounted<DOMSettableTokenList>::deref();
+}
+
+unsigned DOMSettableTokenList::length() const
+{
+ return m_tokens.size();
+}
+
const AtomicString DOMSettableTokenList::item(unsigned index) const
{
if (index >= length())
@@ -49,6 +60,11 @@
return m_tokens.contains(token);
}
+AtomicString DOMSettableTokenList::value() const
+{
+ return m_value;
+}
+
void DOMSettableTokenList::setValue(const AtomicString& value)
{
m_value = value;
Modified: trunk/Source/WebCore/html/DOMSettableTokenList.h (154706 => 154707)
--- trunk/Source/WebCore/html/DOMSettableTokenList.h 2013-08-27 20:47:27 UTC (rev 154706)
+++ trunk/Source/WebCore/html/DOMSettableTokenList.h 2013-08-27 20:49:57 UTC (rev 154707)
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2010 Google Inc. All rights reserved.
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -37,28 +38,19 @@
class DOMSettableTokenList : public DOMTokenList, public RefCounted<DOMSettableTokenList> {
WTF_MAKE_FAST_ALLOCATED;
public:
- static PassRefPtr<DOMSettableTokenList> create()
- {
- return adoptRef(new DOMSettableTokenList());
- }
- virtual ~DOMSettableTokenList();
+ static PassRefPtr<DOMSettableTokenList> create();
- virtual void ref() OVERRIDE { RefCounted<DOMSettableTokenList>::ref(); }
- virtual void deref() OVERRIDE { RefCounted<DOMSettableTokenList>::deref(); }
+ virtual void ref() OVERRIDE FINAL;
+ virtual void deref() OVERRIDE FINAL;
- virtual unsigned length() const OVERRIDE { return m_tokens.size(); }
- virtual const AtomicString item(unsigned index) const OVERRIDE;
+ virtual unsigned length() const OVERRIDE FINAL;
+ virtual const AtomicString item(unsigned index) const OVERRIDE FINAL;
- virtual AtomicString value() const OVERRIDE { return m_value; }
- virtual void setValue(const AtomicString&) OVERRIDE;
+ virtual AtomicString value() const OVERRIDE FINAL;
+ virtual void setValue(const AtomicString&) OVERRIDE FINAL;
- const SpaceSplitString& tokens() const { return m_tokens; }
-
-protected:
- DOMSettableTokenList();
-
private:
- virtual bool containsInternal(const AtomicString&) const OVERRIDE;
+ virtual bool containsInternal(const AtomicString&) const OVERRIDE FINAL;
AtomicString m_value;
SpaceSplitString m_tokens;
Modified: trunk/Source/WebCore/html/DOMTokenList.h (154706 => 154707)
--- trunk/Source/WebCore/html/DOMTokenList.h 2013-08-27 20:47:27 UTC (rev 154706)
+++ trunk/Source/WebCore/html/DOMTokenList.h 2013-08-27 20:49:57 UTC (rev 154707)
@@ -56,7 +56,7 @@
AtomicString toString() const { return value(); }
- virtual Element* element() { return 0; }
+ virtual Element* element() const { return 0; }
protected:
virtual AtomicString value() const = 0;