diff options
Diffstat (limited to 'chromium/third_party/WebKit/Source/core/html/DocumentNameCollection.cpp')
-rw-r--r-- | chromium/third_party/WebKit/Source/core/html/DocumentNameCollection.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/chromium/third_party/WebKit/Source/core/html/DocumentNameCollection.cpp b/chromium/third_party/WebKit/Source/core/html/DocumentNameCollection.cpp new file mode 100644 index 00000000000..223f8a90cf8 --- /dev/null +++ b/chromium/third_party/WebKit/Source/core/html/DocumentNameCollection.cpp @@ -0,0 +1,33 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "config.h" +#include "core/html/DocumentNameCollection.h" + +#include "core/html/HTMLEmbedElement.h" +#include "core/html/HTMLFormElement.h" +#include "core/html/HTMLObjectElement.h" + +namespace WebCore { + +DocumentNameCollection::DocumentNameCollection(ContainerNode& document, const AtomicString& name) + : HTMLNameCollection(document, DocumentNamedItems, name) +{ +} + +bool DocumentNameCollection::elementMatches(const Element& element) const +{ + // Match images, forms, applets, embeds, objects and iframes by name, + // applets and object by id, and images by id but only if they have + // a name attribute (this very strange rule matches IE) + if (isHTMLFormElement(element) || isHTMLIFrameElement(element) || (isHTMLEmbedElement(element) && toHTMLEmbedElement(element).isExposed())) + return element.getNameAttribute() == m_name; + if (isHTMLAppletElement(element) || (isHTMLObjectElement(element) && toHTMLObjectElement(element).isExposed())) + return element.getNameAttribute() == m_name || element.getIdAttribute() == m_name; + if (isHTMLImageElement(element)) + return element.getNameAttribute() == m_name || (element.getIdAttribute() == m_name && element.hasName()); + return false; +} + +} // namespace WebCore |