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 62% |
| copy from Source/core/html/ClassList.cpp |
| copy to Source/core/html/RelList.cpp |
| index a6c8156260afde806051b4c5396abec0541d2be7..7216b845645f23646702d2d6b21b5799b28af344 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 Prashant Hiremath (hiremathprashants@gmail.com). |
|
Inactive
2014/07/23 13:26:44
Ditto about copyright.
|
| * |
| * 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,49 +31,57 @@ 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(HTMLNames::relAttr) ? relListAttr().size() : 0; |
|
Inactive
2014/07/23 13:26:44
HTMLNames:: are unnecessary since you are "using"
|
| } |
| -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 |
| +{ |
| + return m_element->hasAttribute(HTMLNames::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) { |
|
Inactive
2014/07/23 13:26:44
curly brackets are unnecessary here.
|
| + m_relAttrNames = adoptPtr(new SpaceSplitString(value(), false)); |
| + } |
| + return *m_relAttrNames.get(); |
|
Inactive
2014/07/23 13:26:44
.get() is not needed.
|
| } |
| -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(); |
| + if (m_relAttrNames) { |
|
Inactive
2014/07/23 13:26:44
We usually do the opposite: return early.
if (!m_
|
| + SpaceSplitString& relAttrList = *m_relAttrNames.get(); |
| + relAttrList.set(relAttrvalue, false); |
|
Inactive
2014/07/23 13:26:44
simply: m_relAttrNames->set(relAttrValue, false);
|
| } |
| - return m_element->elementData()->classNames(); |
| } |
| -void ClassList::trace(Visitor* visitor) |
| +void RelList::trace(Visitor* visitor) |
| { |
| visitor->trace(m_element); |
| DOMTokenList::trace(visitor); |