Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(361)

Unified Diff: sky/engine/core/dom/DOMTokenList.cpp

Issue 789843004: Merge ClassList into DOMTokenList. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/engine/core/dom/DOMTokenList.h ('k') | sky/engine/core/dom/Element.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/engine/core/dom/DOMTokenList.cpp
diff --git a/sky/engine/core/dom/DOMTokenList.cpp b/sky/engine/core/dom/DOMTokenList.cpp
index 28e2a7f189abbce6b781cff7c55e80eab0bf2931..001af3a2d4fd9ffae4f6af069667a6042037e496 100644
--- a/sky/engine/core/dom/DOMTokenList.cpp
+++ b/sky/engine/core/dom/DOMTokenList.cpp
@@ -26,12 +26,63 @@
#include "sky/engine/core/dom/DOMTokenList.h"
#include "sky/engine/bindings/core/v8/ExceptionState.h"
+#include "sky/engine/core/dom/Document.h"
+#include "sky/engine/core/dom/Element.h"
#include "sky/engine/core/dom/ExceptionCode.h"
+#include "sky/engine/core/dom/SpaceSplitString.h"
#include "sky/engine/core/html/parser/HTMLParserIdioms.h"
#include "sky/engine/wtf/text/StringBuilder.h"
namespace blink {
+DOMTokenList::DOMTokenList(Element& element)
+ : m_element(&element)
+{
+}
+
+void DOMTokenList::ref()
+{
+ m_element->ref();
+}
+
+void DOMTokenList::deref()
+{
+ m_element->deref();
+}
+
+unsigned DOMTokenList::length() const
+{
+ return m_element->hasClass() ? classNames().size() : 0;
+}
+
+const AtomicString DOMTokenList::item(unsigned index) const
+{
+ if (index >= length())
+ return AtomicString();
+ return classNames()[index];
+}
+
+bool DOMTokenList::containsInternal(const AtomicString& token) const
+{
+ return m_element->hasClass() && classNames().contains(token);
+}
+
+const SpaceSplitString& DOMTokenList::classNames() const
+{
+ ASSERT(m_element->hasClass());
+ return m_element->classNames();
+}
+
+const AtomicString& DOMTokenList::value() const
+{
+ return m_element->getAttribute(HTMLNames::classAttr);
+}
+
+void DOMTokenList::setValue(const AtomicString& value)
+{
+ m_element->setAttribute(HTMLNames::classAttr, value);
+}
+
bool DOMTokenList::validateToken(const String& token, ExceptionState& exceptionState)
{
if (token.isEmpty()) {
« no previous file with comments | « sky/engine/core/dom/DOMTokenList.h ('k') | sky/engine/core/dom/Element.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698