| Index: Source/core/html/HTMLAllCollection.cpp
|
| diff --git a/Source/core/html/HTMLAllCollection.cpp b/Source/core/html/HTMLAllCollection.cpp
|
| index dfbc4661c25779369797a710732d05c58175c6a4..c2e83aafac09e28f18e1005c1abca222dea4be7d 100644
|
| --- a/Source/core/html/HTMLAllCollection.cpp
|
| +++ b/Source/core/html/HTMLAllCollection.cpp
|
| @@ -1,5 +1,6 @@
|
| /*
|
| * Copyright (C) 2009, 2011, 2012 Apple Inc. All rights reserved.
|
| + * Copyright (C) 2014 Samsung Electronics. All rights reserved.
|
| *
|
| * Redistribution and use in source and binary forms, with or without
|
| * modification, are permitted provided that the following conditions
|
| @@ -26,11 +27,16 @@
|
| #include "config.h"
|
| #include "core/html/HTMLAllCollection.h"
|
|
|
| +#include "HTMLNames.h"
|
| #include "core/dom/Element.h"
|
| #include "core/dom/NamedNodesCollection.h"
|
| +#include "core/html/HTMLElement.h"
|
| +#include "wtf/HashSet.h"
|
|
|
| namespace WebCore {
|
|
|
| +using namespace HTMLNames;
|
| +
|
| PassRefPtr<HTMLAllCollection> HTMLAllCollection::create(ContainerNode* node, CollectionType type)
|
| {
|
| return adoptRef(new HTMLAllCollection(node, type));
|
| @@ -42,6 +48,52 @@ HTMLAllCollection::HTMLAllCollection(ContainerNode* node, CollectionType type)
|
| ScriptWrappable::init(this);
|
| }
|
|
|
| +bool HTMLAllCollection::elementNameShouldBeVisible(const HTMLElement& element)
|
| +{
|
| + // The document.all collection returns only certain types of elements by name,
|
| + // although it returns any type of element by id.
|
| + return element.hasLocalName(aTag)
|
| + || element.hasLocalName(appletTag)
|
| + || element.hasLocalName(areaTag)
|
| + || element.hasLocalName(embedTag)
|
| + || element.hasLocalName(formTag)
|
| + || element.hasLocalName(frameTag)
|
| + || element.hasLocalName(framesetTag)
|
| + || element.hasLocalName(iframeTag)
|
| + || element.hasLocalName(imgTag)
|
| + || element.hasLocalName(objectTag)
|
| + || element.hasLocalName(inputTag) // FIXME: Not according to spec.
|
| + || element.hasLocalName(selectTag); // FIXME: Not according to spec.
|
| +}
|
| +
|
| +void HTMLAllCollection::supportedPropertyNames(Vector<String>& names)
|
| +{
|
| + // As per the specification (http://www.whatwg.org/specs/web-apps/current-work/multipage/common-dom-interfaces.html#htmlallcollection-0):
|
| + // The supported property names consist of the non-empty values of all the id attributes of all the elements
|
| + // represented by the collection, and the non-empty values of all the name attributes of all the a, applet,
|
| + // area, embed, form, frame, frameset, iframe, img, and object elements represented by the collection, in
|
| + // tree order, ignoring later duplicates, with the id of an element preceding its name if it contributes
|
| + // both, they differ from each other, and neither is the duplicate of an earlier entry.
|
| + HashSet<AtomicString> existingNames;
|
| + ContainerNode& root = rootNode();
|
| + for (Element* element = traverseToFirstElement(root); element; element = traverseNextElement(*element, root)) {
|
| + const AtomicString& idAttribute = element->getIdAttribute();
|
| + if (!idAttribute.isEmpty()) {
|
| + HashSet<AtomicString>::AddResult addResult = existingNames.add(idAttribute);
|
| + if (addResult.isNewEntry)
|
| + names.append(idAttribute);
|
| + }
|
| + if (!element->isHTMLElement())
|
| + continue;
|
| + const AtomicString& nameAttribute = element->getNameAttribute();
|
| + if (!nameAttribute.isEmpty() && elementNameShouldBeVisible(toHTMLElement(*element))) {
|
| + HashSet<AtomicString>::AddResult addResult = existingNames.add(nameAttribute);
|
| + if (addResult.isNewEntry)
|
| + names.append(nameAttribute);
|
| + }
|
| + }
|
| +}
|
| +
|
| HTMLAllCollection::~HTMLAllCollection()
|
| {
|
| }
|
| @@ -64,7 +116,7 @@ Element* HTMLAllCollection::namedItemWithIndex(const AtomicString& name, unsigne
|
| return 0;
|
| }
|
|
|
| -void HTMLAllCollection::anonymousNamedGetter(const AtomicString& name, bool& returnValue0Enabled, RefPtr<NodeList>& returnValue0, bool& returnValue1Enabled, RefPtr<Element>& returnValue1)
|
| +void HTMLAllCollection::namedGetter(const AtomicString& name, bool& returnValue0Enabled, RefPtr<NodeList>& returnValue0, bool& returnValue1Enabled, RefPtr<Element>& returnValue1)
|
| {
|
| Vector<RefPtr<Element> > namedItems;
|
| this->namedItems(name, namedItems);
|
|
|