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

Unified Diff: Source/core/html/DocumentNameCollection.cpp

Issue 315473002: Stop having HTMLNameCollection override HTMLCollection::virtualItemAfter() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: Source/core/html/DocumentNameCollection.cpp
diff --git a/Source/core/html/DocumentNameCollection.cpp b/Source/core/html/DocumentNameCollection.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..223f8a90cf8d11cc51b7b785fb7adf47b06eff36
--- /dev/null
+++ b/Source/core/html/DocumentNameCollection.cpp
@@ -0,0 +1,33 @@
+// 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/DocumentNameCollection.h"
+
+#include "core/html/HTMLEmbedElement.h"
+#include "core/html/HTMLFormElement.h"
+#include "core/html/HTMLObjectElement.h"
+
+namespace WebCore {
+
+DocumentNameCollection::DocumentNameCollection(ContainerNode& document, const AtomicString& name)
+ : HTMLNameCollection(document, DocumentNamedItems, name)
+{
+}
+
+bool DocumentNameCollection::elementMatches(const Element& element) const
+{
+ // Match images, forms, applets, embeds, objects and iframes by name,
+ // applets and object by id, and images by id but only if they have
+ // a name attribute (this very strange rule matches IE)
+ if (isHTMLFormElement(element) || isHTMLIFrameElement(element) || (isHTMLEmbedElement(element) && toHTMLEmbedElement(element).isExposed()))
+ return element.getNameAttribute() == m_name;
+ if (isHTMLAppletElement(element) || (isHTMLObjectElement(element) && toHTMLObjectElement(element).isExposed()))
+ return element.getNameAttribute() == m_name || element.getIdAttribute() == m_name;
+ if (isHTMLImageElement(element))
+ return element.getNameAttribute() == m_name || (element.getIdAttribute() == m_name && element.hasName());
+ return false;
+}
+
+} // namespace WebCore

Powered by Google App Engine
This is Rietveld 408576698