diff options
Diffstat (limited to 'Source/WebCore/dom/DOMNamedFlowCollection.cpp')
-rw-r--r-- | Source/WebCore/dom/DOMNamedFlowCollection.cpp | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/Source/WebCore/dom/DOMNamedFlowCollection.cpp b/Source/WebCore/dom/DOMNamedFlowCollection.cpp index 30fbab3e7..aedd9e954 100644 --- a/Source/WebCore/dom/DOMNamedFlowCollection.cpp +++ b/Source/WebCore/dom/DOMNamedFlowCollection.cpp @@ -34,9 +34,10 @@ namespace WebCore { -DOMNamedFlowCollection::DOMNamedFlowCollection(NamedFlowCollection::NamedFlowSet& set) +DOMNamedFlowCollection::DOMNamedFlowCollection(const Vector<WebKitNamedFlow*>& namedFlows) { - m_namedFlows.swap(set); + for (Vector<WebKitNamedFlow*>::const_iterator it = namedFlows.begin(); it != namedFlows.end(); ++it) + m_namedFlows.add(*it); } unsigned long DOMNamedFlowCollection::length() const @@ -48,7 +49,7 @@ PassRefPtr<WebKitNamedFlow> DOMNamedFlowCollection::item(unsigned long index) co { if (index >= static_cast<unsigned long>(m_namedFlows.size())) return 0; - NamedFlowCollection::NamedFlowSet::const_iterator it = m_namedFlows.begin(); + DOMNamedFlowSet::const_iterator it = m_namedFlows.begin(); for (unsigned long i = 0; i < index; ++i) ++it; return *it; @@ -56,7 +57,7 @@ PassRefPtr<WebKitNamedFlow> DOMNamedFlowCollection::item(unsigned long index) co PassRefPtr<WebKitNamedFlow> DOMNamedFlowCollection::namedItem(const AtomicString& name) const { - NamedFlowCollection::NamedFlowSet::const_iterator it = m_namedFlows.find<String, NamedFlowCollection::NamedFlowHashTranslator>(name); + DOMNamedFlowSet::const_iterator it = m_namedFlows.find<String, DOMNamedFlowHashTranslator>(name); if (it != m_namedFlows.end()) return *it; return 0; @@ -66,6 +67,20 @@ bool DOMNamedFlowCollection::hasNamedItem(const AtomicString& name) const { return namedItem(name); } + +// The HashFunctions object used by the HashSet to compare between RefPtr<NamedFlows>. +// It is safe to set safeToCompareToEmptyOrDeleted because the HashSet will never contain null pointers or deleted values. +struct DOMNamedFlowCollection::DOMNamedFlowHashFunctions { + static unsigned hash(PassRefPtr<WebKitNamedFlow> key) { return DefaultHash<String>::Hash::hash(key->name()); } + static bool equal(PassRefPtr<WebKitNamedFlow> a, PassRefPtr<WebKitNamedFlow> b) { return a->name() == b->name(); } + static const bool safeToCompareToEmptyOrDeleted = true; +}; + +// The HashTranslator is used to lookup a RefPtr<NamedFlow> in the set using a name. +struct DOMNamedFlowCollection::DOMNamedFlowHashTranslator { + static unsigned hash(const String& key) { return DefaultHash<String>::Hash::hash(key); } + static bool equal(PassRefPtr<WebKitNamedFlow> a, const String& b) { return a->name() == b; } +}; } // namespace WebCore |