Chromium Code Reviews| Index: Source/core/html/RelList.cpp |
| diff --git a/Source/core/html/ClassList.cpp b/Source/core/html/RelList.cpp |
| similarity index 64% |
| copy from Source/core/html/ClassList.cpp |
| copy to Source/core/html/RelList.cpp |
| index a6c8156260afde806051b4c5396abec0541d2be7..1140aa75834722d63a27ad44cac5ef697cd4d5bd 100644 |
| --- a/Source/core/html/ClassList.cpp |
| +++ b/Source/core/html/RelList.cpp |
| @@ -1,5 +1,5 @@ |
| /* |
| - * Copyright (C) 2010 Google Inc. All rights reserved. |
| + * Copyright (C) 2014 Google Inc. All rights reserved. |
| * |
| * Redistribution and use in source and binary forms, with or without |
| * modification, are permitted provided that the following conditions |
| @@ -23,7 +23,7 @@ |
| */ |
| #include "config.h" |
| -#include "core/html/ClassList.h" |
| +#include "core/html/RelList.h" |
| #include "core/dom/Document.h" |
| @@ -31,51 +31,58 @@ namespace WebCore { |
| using namespace HTMLNames; |
| -ClassList::ClassList(Element* element) : m_element(element) { } |
| +RelList::RelList(Element* element) |
| + : m_element(element) |
| +{ |
| +} |
| #if !ENABLE(OILPAN) |
| -void ClassList::ref() |
| +void RelList::ref() |
| { |
| m_element->ref(); |
| } |
| -void ClassList::deref() |
| +void RelList::deref() |
| { |
| m_element->deref(); |
| } |
| #endif |
| -unsigned ClassList::length() const |
| +unsigned RelList::length() const |
| { |
| - return m_element->hasClass() ? classNames().size() : 0; |
| + return m_element->hasAttribute(relAttr) ? relListAttr().size() : 0; |
| } |
| -const AtomicString ClassList::item(unsigned index) const |
| +const AtomicString RelList::item(unsigned index) const |
| { |
| if (index >= length()) |
| return AtomicString(); |
| - return classNames()[index]; |
| + return relListAttr()[index]; |
| +} |
| + |
| +bool RelList::containsInternal(const AtomicString& token) const |
|
Inactive
2014/07/25 12:55:51
When is this method used? I don't see any callers,
prashanth
2014/07/25 14:18:03
I'm also not sure who is caller for it, but it is
Inactive
2014/07/25 14:30:53
Oh right, I missed that it was virtual. Ignore my
|
| +{ |
| + return m_element->hasAttribute(relAttr) && relListAttr().contains(token); |
| } |
| -bool ClassList::containsInternal(const AtomicString& token) const |
| +const SpaceSplitString& RelList::relListAttr() const |
| { |
| - return m_element->hasClass() && classNames().contains(token); |
| + if (!m_relAttrNames) |
| + m_relAttrNames = adoptPtr(new SpaceSplitString(value(), false)); |
| + return *m_relAttrNames; |
| } |
| -const SpaceSplitString& ClassList::classNames() const |
| +void RelList::setValue(const AtomicString& relAttrvalue) |
| { |
| - ASSERT(m_element->hasClass()); |
| - if (m_element->document().inQuirksMode()) { |
| - if (!m_classNamesForQuirksMode) |
| - m_classNamesForQuirksMode = adoptPtr(new SpaceSplitString(value(), false)); |
| - return *m_classNamesForQuirksMode.get(); |
| - } |
| - return m_element->elementData()->classNames(); |
| + if (!m_relAttrNames) |
| + return; |
| + m_relAttrNames->set(relAttrvalue, false); |
| } |
| -void ClassList::trace(Visitor* visitor) |
| +void RelList::trace(Visitor* visitor) |
| { |
| visitor->trace(m_element); |
| + visitor->trace(m_relAttrNames); |
| DOMTokenList::trace(visitor); |
| } |