summaryrefslogtreecommitdiff
path: root/Source/WebCore/html/HTMLPropertiesCollection.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-03-12 14:11:15 +0100
committerSimon Hausmann <simon.hausmann@nokia.com>2012-03-12 14:11:15 +0100
commitdd91e772430dc294e3bf478c119ef8d43c0a3358 (patch)
tree6f33ce4d5872a5691e0291eb45bf6ab373a5f567 /Source/WebCore/html/HTMLPropertiesCollection.cpp
parentad0d549d4cc13433f77c1ac8f0ab379c83d93f28 (diff)
downloadqtwebkit-dd91e772430dc294e3bf478c119ef8d43c0a3358.tar.gz
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.
Diffstat (limited to 'Source/WebCore/html/HTMLPropertiesCollection.cpp')
-rw-r--r--Source/WebCore/html/HTMLPropertiesCollection.cpp43
1 files changed, 43 insertions, 0 deletions
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<DOMStringList> HTMLPropertiesCollection::names() const
return m_propertyNames;
}
+PassRefPtr<NodeList> HTMLPropertiesCollection::namedItem(const String& name) const
+{
+ if (!base()->isHTMLElement() || !toHTMLElement(base())->fastHasAttribute(itemscopeAttr))
+ return 0;
+
+ m_properties.clear();
+ Vector<RefPtr<Node> > 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)