OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "config.h" |
| 6 #include "core/html/DocumentNameCollection.h" |
| 7 |
| 8 #include "core/html/HTMLEmbedElement.h" |
| 9 #include "core/html/HTMLFormElement.h" |
| 10 #include "core/html/HTMLObjectElement.h" |
| 11 |
| 12 namespace WebCore { |
| 13 |
| 14 DocumentNameCollection::DocumentNameCollection(ContainerNode& document, const At
omicString& name) |
| 15 : HTMLNameCollection(document, DocumentNamedItems, name) |
| 16 { |
| 17 } |
| 18 |
| 19 bool DocumentNameCollection::elementMatches(const Element& element) const |
| 20 { |
| 21 // Match images, forms, applets, embeds, objects and iframes by name, |
| 22 // applets and object by id, and images by id but only if they have |
| 23 // a name attribute (this very strange rule matches IE) |
| 24 if (isHTMLFormElement(element) || isHTMLIFrameElement(element) || (isHTMLEmb
edElement(element) && toHTMLEmbedElement(element).isExposed())) |
| 25 return element.getNameAttribute() == m_name; |
| 26 if (isHTMLAppletElement(element) || (isHTMLObjectElement(element) && toHTMLO
bjectElement(element).isExposed())) |
| 27 return element.getNameAttribute() == m_name || element.getIdAttribute()
== m_name; |
| 28 if (isHTMLImageElement(element)) |
| 29 return element.getNameAttribute() == m_name || (element.getIdAttribute()
== m_name && element.hasName()); |
| 30 return false; |
| 31 } |
| 32 |
| 33 } // namespace WebCore |
OLD | NEW |