summaryrefslogtreecommitdiffstats
path: root/chromium/third_party/WebKit/Source/core/html/WindowNameCollection.cpp
blob: 7321f853f292cc426b718476b70af09862d436a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// 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/WindowNameCollection.h"

#include "core/html/HTMLImageElement.h"

namespace WebCore {

WindowNameCollection::WindowNameCollection(ContainerNode& document, const AtomicString& name)
    : HTMLNameCollection(document, WindowNamedItems, name)
{
}

bool WindowNameCollection::elementMatches(const Element& element) const
{
    // Match only images, forms, applets, embeds and objects by name,
    // but anything by id
    if (isHTMLImageElement(element)
        || isHTMLFormElement(element)
        || isHTMLAppletElement(element)
        || isHTMLEmbedElement(element)
        || isHTMLObjectElement(element)) {
        if (element.getNameAttribute() == m_name)
            return true;
    }
    return element.getIdAttribute() == m_name;
}

} // namespace WebCore