Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / html / WindowNameCollection.cpp
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/WindowNameCollection.h"
7
8 #include "core/html/HTMLImageElement.h"
9
10 namespace blink {
11
12 WindowNameCollection::WindowNameCollection(ContainerNode& document, const AtomicString& name)
13     : HTMLNameCollection(document, WindowNamedItems, name)
14 {
15 }
16
17 bool WindowNameCollection::elementMatches(const Element& element) const
18 {
19     // Match only images, forms, applets, embeds and objects by name,
20     // but anything by id
21     if (isHTMLImageElement(element)
22         || isHTMLFormElement(element)
23         || isHTMLAppletElement(element)
24         || isHTMLEmbedElement(element)
25         || isHTMLObjectElement(element)) {
26         if (element.getNameAttribute() == m_name)
27             return true;
28     }
29     return element.getIdAttribute() == m_name;
30 }
31
32 } // namespace blink