From dd91e772430dc294e3bf478c119ef8d43c0a3358 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Mon, 12 Mar 2012 14:11:15 +0100 Subject: Imported WebKit commit 3db4eb1820ac8fb03065d7ea73a4d9db1e8fea1a (http://svn.webkit.org/repository/webkit/trunk@110422) This includes build fixes for the latest qtbase/qtdeclarative as well as the final QML2 API. --- Source/WebCore/html/HTMLPropertiesCollection.cpp | 43 ++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'Source/WebCore/html/HTMLPropertiesCollection.cpp') diff --git a/Source/WebCore/html/HTMLPropertiesCollection.cpp b/Source/WebCore/html/HTMLPropertiesCollection.cpp index 6aac467ad..68045cbba 100644 --- a/Source/WebCore/html/HTMLPropertiesCollection.cpp +++ b/Source/WebCore/html/HTMLPropertiesCollection.cpp @@ -39,6 +39,7 @@ #include "HTMLElement.h" #include "HTMLNames.h" #include "Node.h" +#include "StaticNodeList.h" namespace WebCore { @@ -172,6 +173,48 @@ PassRefPtr HTMLPropertiesCollection::names() const return m_propertyNames; } +PassRefPtr HTMLPropertiesCollection::namedItem(const String& name) const +{ + if (!base()->isHTMLElement() || !toHTMLElement(base())->fastHasAttribute(itemscopeAttr)) + return 0; + + m_properties.clear(); + Vector > namedItems; + findPropetiesOfAnItem(base()); + + std::sort(m_properties.begin(), m_properties.end(), compareTreeOrder); + + // For each item properties, split the value of that itemprop attribute on spaces. + // Add element to namedItem that contains a property named name, with the order preserved. + for (size_t i = 0; i < m_properties.size(); ++i) { + DOMSettableTokenList* itemProperty = m_properties[i]->itemProp(); + if (itemProperty->tokens().contains(name)) + namedItems.append(m_properties[i]); + } + + // FIXME: HTML5 specifies that this should return PropertyNodeList. + return namedItems.isEmpty() ? 0 : StaticNodeList::adopt(namedItems); +} + +bool HTMLPropertiesCollection::hasNamedItem(const AtomicString& name) const +{ + if (!base()->isHTMLElement() || !toHTMLElement(base())->fastHasAttribute(itemscopeAttr)) + return false; + + m_properties.clear(); + findPropetiesOfAnItem(base()); + + // For each item properties, split the value of that itemprop attribute on spaces. + // Return true if element contains a property named name. + for (size_t i = 0; i < m_properties.size(); ++i) { + DOMSettableTokenList* itemProperty = m_properties[i]->itemProp(); + if (itemProperty->tokens().contains(name)) + return true; + } + + return false; +} + } // namespace WebCore #endif // ENABLE(MICRODATA) -- cgit v1.2.1