diff options
author | Steve Block <steveblock@google.com> | 2010-05-26 10:11:43 +0100 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2010-05-27 11:14:42 +0100 |
commit | e78cbe89e6f337f2f1fe40315be88f742b547151 (patch) | |
tree | d778000b84a04f24bbad50c7fa66244365e960e9 /WebCore/dom/Attribute.cpp | |
parent | 7b582e96e4e909ed7dba1e07153d20fbddaec3f7 (diff) | |
download | external_webkit-e78cbe89e6f337f2f1fe40315be88f742b547151.zip external_webkit-e78cbe89e6f337f2f1fe40315be88f742b547151.tar.gz external_webkit-e78cbe89e6f337f2f1fe40315be88f742b547151.tar.bz2 |
Merge WebKit at r60074: Initial merge by git
Change-Id: I18a2dc5439e36c928351ea829d8fb4e39b062fc7
Diffstat (limited to 'WebCore/dom/Attribute.cpp')
-rw-r--r-- | WebCore/dom/Attribute.cpp | 52 |
1 files changed, 48 insertions, 4 deletions
diff --git a/WebCore/dom/Attribute.cpp b/WebCore/dom/Attribute.cpp index 0ab0bb6..20c05d8 100644 --- a/WebCore/dom/Attribute.cpp +++ b/WebCore/dom/Attribute.cpp @@ -26,20 +26,64 @@ #include "Attr.h" #include "Element.h" +#include <wtf/HashMap.h> +#include <wtf/UnusedParam.h> namespace WebCore { +typedef HashMap<Attribute*, Attr*> AttributeAttrMap; +static AttributeAttrMap& attributeAttrMap() +{ + DEFINE_STATIC_LOCAL(AttributeAttrMap, map, ()); + return map; +} + PassRefPtr<Attribute> Attribute::clone() const { - return adoptRef(new Attribute(m_name, m_value)); + return adoptRef(new Attribute(m_name, m_value, m_isMappedAttribute, m_styleDecl.get())); +} + +Attr* Attribute::attr() const +{ + if (m_hasAttr) { + ASSERT(attributeAttrMap().contains(const_cast<Attribute*>(this))); + return attributeAttrMap().get(const_cast<Attribute*>(this)); + } + + ASSERT(!attributeAttrMap().contains(const_cast<Attribute*>(this))); + return 0; } PassRefPtr<Attr> Attribute::createAttrIfNeeded(Element* e) { - RefPtr<Attr> r = m_impl; - if (!r) - r = Attr::create(e, e->document(), this); + RefPtr<Attr> r; + if (m_hasAttr) { + ASSERT(attributeAttrMap().contains(this)); + r = attributeAttrMap().get(this); + } else { + ASSERT(!attributeAttrMap().contains(this)); + r = Attr::create(e, e->document(), this); // This will end up calling Attribute::bindAttr. + ASSERT(attributeAttrMap().contains(this)); + } + return r.release(); } +void Attribute::bindAttr(Attr* attr) +{ + ASSERT(!m_hasAttr); + ASSERT(!attributeAttrMap().contains(this)); + attributeAttrMap().set(this, attr); + m_hasAttr = true; +} + +void Attribute::unbindAttr(Attr* attr) +{ + ASSERT(m_hasAttr); + ASSERT(attributeAttrMap().contains(this)); + ASSERT_UNUSED(attr, attributeAttrMap().get(this) == attr); + attributeAttrMap().remove(this); + m_hasAttr = false; } + +} // namespace WebCore |