Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(182)

Side by Side Diff: Source/core/html/DocumentNameCollection.cpp

Issue 492453002: Make it clear a DocumentNameCollection can only contain HTMLElements (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Clean up Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/html/DocumentNameCollection.h ('k') | Source/core/html/HTMLCollection.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
OLDNEW
« no previous file with comments | « Source/core/html/DocumentNameCollection.h ('k') | Source/core/html/HTMLCollection.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698