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