summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordglazkov@chromium.org <dglazkov@chromium.org@bbb929c8-8fbe-4397-9dbb-9b2b20218538>2014-01-30 17:37:06 +0000
committerdglazkov@chromium.org <dglazkov@chromium.org@bbb929c8-8fbe-4397-9dbb-9b2b20218538>2014-01-30 17:37:06 +0000
commit85d271d78742699a6b04d4ed526d021d53ea3e19 (patch)
tree8a3cc7a782c4a2628e60d6047f17329c92cd0d8f
parentf1e4e86317fd4eecfb83bf0dea0d021ae707c76c (diff)
downloadchromium_src-85d271d78742699a6b04d4ed526d021d53ea3e19.zip
chromium_src-85d271d78742699a6b04d4ed526d021d53ea3e19.tar.gz
chromium_src-85d271d78742699a6b04d4ed526d021d53ea3e19.tar.bz2
Revert 166088 "Have getElementsByClassName() / getElementsByTagN..."
Broke unit tests that were relying on Web* interfaces. For example: http://build.chromium.org/p/chromium.webkit/builders/Android%20Tests%20%28dbg%29/builds/17057/steps/chromiumtestshell_instrumentation_tests/logs/stdio > Have getElementsByClassName() / getElementsByTagName*() return an HTMLCollection > > Have getElementsByClassName() / getElementsByTagName*() return an HTMLCollection > instead of a NodeList, as per the specification: > http://dom.spec.whatwg.org/#document > http://dom.spec.whatwg.org/#element > > This behavior is consistent with Firefox 26 and IE 11. > > R=arv, haraken, tkent > BUG=235008 > > Review URL: https://codereview.chromium.org/143453010 TBR=ch.dumez@samsung.com Review URL: https://codereview.chromium.org/139203007 git-svn-id: svn://svn.chromium.org/blink/trunk@166141 bbb929c8-8fbe-4397-9dbb-9b2b20218538
-rw-r--r--third_party/WebKit/LayoutTests/fast/dom/getElementsByClassName/dumpNodeList.html2
-rw-r--r--third_party/WebKit/LayoutTests/fast/dom/non-numeric-values-numeric-parameters-expected.txt2
-rw-r--r--third_party/WebKit/LayoutTests/fast/dom/script-tests/domListEnumeration.js2
-rw-r--r--third_party/WebKit/LayoutTests/fast/dom/script-tests/non-numeric-values-numeric-parameters.js2
-rw-r--r--third_party/WebKit/LayoutTests/fast/dom/wrapper-classes-expected.txt6
-rw-r--r--third_party/WebKit/LayoutTests/fast/dom/wrapper-classes.html2
-rw-r--r--third_party/WebKit/LayoutTests/fast/js/constructor-expected.txt4
-rw-r--r--third_party/WebKit/LayoutTests/fast/js/getOwnPropertyDescriptor-expected.txt4
-rw-r--r--third_party/WebKit/LayoutTests/fast/js/script-tests/constructor.js6
-rw-r--r--third_party/WebKit/LayoutTests/inspector/console/console-format-collections-expected.txt8
-rw-r--r--third_party/WebKit/Source/core/core.gypi8
-rw-r--r--third_party/WebKit/Source/core/dom/ClassNodeList.cpp (renamed from third_party/WebKit/Source/core/dom/ClassCollection.cpp)15
-rw-r--r--third_party/WebKit/Source/core/dom/ClassNodeList.h (renamed from third_party/WebKit/Source/core/dom/ClassCollection.h)33
-rw-r--r--third_party/WebKit/Source/core/dom/ContainerNode.cpp14
-rw-r--r--third_party/WebKit/Source/core/dom/ContainerNode.h6
-rw-r--r--third_party/WebKit/Source/core/dom/Document.idl6
-rw-r--r--third_party/WebKit/Source/core/dom/Element.idl6
-rw-r--r--third_party/WebKit/Source/core/dom/Node.cpp5
-rw-r--r--third_party/WebKit/Source/core/dom/Node.h4
-rw-r--r--third_party/WebKit/Source/core/dom/NodeRareData.h26
-rw-r--r--third_party/WebKit/Source/core/dom/TagNodeList.cpp (renamed from third_party/WebKit/Source/core/dom/TagCollection.cpp)19
-rw-r--r--third_party/WebKit/Source/core/dom/TagNodeList.h (renamed from third_party/WebKit/Source/core/dom/TagCollection.h)50
-rw-r--r--third_party/WebKit/Source/core/dom/shadow/ShadowRoot.idl8
-rw-r--r--third_party/WebKit/Source/core/fetch/FontResource.cpp22
-rw-r--r--third_party/WebKit/Source/core/html/CollectionType.h7
-rw-r--r--third_party/WebKit/Source/core/html/HTMLAllCollection.cpp2
-rw-r--r--third_party/WebKit/Source/core/html/HTMLAllCollection.h2
-rw-r--r--third_party/WebKit/Source/core/html/HTMLAllCollection.idl2
-rw-r--r--third_party/WebKit/Source/core/html/HTMLCollection.cpp71
-rw-r--r--third_party/WebKit/Source/core/html/HTMLObjectElement.cpp4
-rw-r--r--third_party/WebKit/Source/web/WebHelperPluginImpl.cpp4
-rw-r--r--third_party/WebKit/Source/web/WebNode.cpp11
-rw-r--r--third_party/WebKit/Source/web/WebNodeList.cpp28
-rw-r--r--third_party/WebKit/public/web/WebNode.h3
-rw-r--r--third_party/WebKit/public/web/WebNodeCollection.h2
-rw-r--r--third_party/WebKit/public/web/WebNodeList.h5
36 files changed, 189 insertions, 212 deletions
diff --git a/third_party/WebKit/LayoutTests/fast/dom/getElementsByClassName/dumpNodeList.html b/third_party/WebKit/LayoutTests/fast/dom/getElementsByClassName/dumpNodeList.html
index bbeb3e3..d4e68ac 100644
--- a/third_party/WebKit/LayoutTests/fast/dom/getElementsByClassName/dumpNodeList.html
+++ b/third_party/WebKit/LayoutTests/fast/dom/getElementsByClassName/dumpNodeList.html
@@ -14,7 +14,7 @@
document.getElementById("console").appendChild(item);
}
- HTMLCollection.prototype.dump = function()
+ NodeList.prototype.dump = function()
{
var result = "";
var i = 0;
diff --git a/third_party/WebKit/LayoutTests/fast/dom/non-numeric-values-numeric-parameters-expected.txt b/third_party/WebKit/LayoutTests/fast/dom/non-numeric-values-numeric-parameters-expected.txt
index 93a918f..9b634f7 100644
--- a/third_party/WebKit/LayoutTests/fast/dom/non-numeric-values-numeric-parameters-expected.txt
+++ b/third_party/WebKit/LayoutTests/fast/dom/non-numeric-values-numeric-parameters-expected.txt
@@ -51,7 +51,7 @@ PASS nonNumericPolicy('document.createEvent("MouseEvent").initMouseEvent("a", fa
PASS nonNumericPolicy('document.createEvent("MouseEvent").initMouseEvent("a", false, false, null, 0, 0, 0, 0, 0, false, false, false, false, x, null)') is 'any type allowed'
PASS nonNumericPolicy('document.body.attributes.item(x)') is 'any type allowed'
PASS nonNumericPolicy('document.createNodeIterator(document, x, null, false)') is 'any type allowed'
-PASS nonNumericPolicy('document.getElementsByTagName("div").item(x)') is 'any type allowed'
+PASS nonNumericPolicy('document.getElementsByTagName("div").item(x)') is 'any type allowed (but not omitted)'
PASS nonNumericPolicy('document.createRange().setStart(document, x)') is 'any type allowed (but not omitted)'
PASS nonNumericPolicy('document.createRange().setEnd(document, x)') is 'any type allowed (but not omitted)'
PASS nonNumericPolicy('document.createRange().comparePoint(document, x)') is 'any type allowed (but not omitted)'
diff --git a/third_party/WebKit/LayoutTests/fast/dom/script-tests/domListEnumeration.js b/third_party/WebKit/LayoutTests/fast/dom/script-tests/domListEnumeration.js
index f229a53..b4adb2e 100644
--- a/third_party/WebKit/LayoutTests/fast/dom/script-tests/domListEnumeration.js
+++ b/third_party/WebKit/LayoutTests/fast/dom/script-tests/domListEnumeration.js
@@ -94,7 +94,7 @@ setup();
var resultArray = new Array();
// NodeList
-var nodeList = document.querySelectorAll('ol');
+var nodeList = document.getElementsByTagName('ol');
resultArray = iterateList(nodeList);
shouldBe("resultArray.length", "5");
diff --git a/third_party/WebKit/LayoutTests/fast/dom/script-tests/non-numeric-values-numeric-parameters.js b/third_party/WebKit/LayoutTests/fast/dom/script-tests/non-numeric-values-numeric-parameters.js
index 158a5ac..4e638e2 100644
--- a/third_party/WebKit/LayoutTests/fast/dom/script-tests/non-numeric-values-numeric-parameters.js
+++ b/third_party/WebKit/LayoutTests/fast/dom/script-tests/non-numeric-values-numeric-parameters.js
@@ -294,7 +294,7 @@ shouldBe("nonNumericPolicy('document.createNodeIterator(document, x, null, false
// NodeList
-shouldBe("nonNumericPolicy('document.getElementsByTagName(\"div\").item(x)')", "'any type allowed'");
+shouldBe("nonNumericPolicy('document.getElementsByTagName(\"div\").item(x)')", "'any type allowed (but not omitted)'");
// Range
diff --git a/third_party/WebKit/LayoutTests/fast/dom/wrapper-classes-expected.txt b/third_party/WebKit/LayoutTests/fast/dom/wrapper-classes-expected.txt
index 4ec6e6c..a04b9c2 100644
--- a/third_party/WebKit/LayoutTests/fast/dom/wrapper-classes-expected.txt
+++ b/third_party/WebKit/LayoutTests/fast/dom/wrapper-classes-expected.txt
@@ -32,10 +32,10 @@ PASS classString(document.createNodeIterator(root, 0, null, false)) is "NodeIter
FAIL classString(document.createNodeIterator(root, 0, null, false).__proto__) should be NodeIteratorPrototype. Was Object.
PASS classString(document.createNodeIterator(root, 0, null, false).constructor) is "Function"
PASS document.createNodeIterator(root, 0, null, false).constructor.name is "NodeIterator"
-PASS classString(document.getElementsByTagName('div')) is "HTMLCollection"
-FAIL classString(document.getElementsByTagName('div').__proto__) should be HTMLCollectionPrototype. Was Object.
+PASS classString(document.getElementsByTagName('div')) is "NodeList"
+FAIL classString(document.getElementsByTagName('div').__proto__) should be NodeListPrototype. Was Object.
PASS classString(document.getElementsByTagName('div').constructor) is "Function"
-PASS document.getElementsByTagName('div').constructor.name is "HTMLCollection"
+PASS document.getElementsByTagName('div').constructor.name is "NodeList"
PASS classString(document.createRange()) is "Range"
FAIL classString(document.createRange().__proto__) should be RangePrototype. Was Object.
PASS classString(document.createRange().constructor) is "Function"
diff --git a/third_party/WebKit/LayoutTests/fast/dom/wrapper-classes.html b/third_party/WebKit/LayoutTests/fast/dom/wrapper-classes.html
index 8d094f4..d9841be 100644
--- a/third_party/WebKit/LayoutTests/fast/dom/wrapper-classes.html
+++ b/third_party/WebKit/LayoutTests/fast/dom/wrapper-classes.html
@@ -84,7 +84,7 @@ function runTest()
test("document.implementation", "DOMImplementation");
test("root.attributes", "NamedNodeMap");
test("document.createNodeIterator(root, 0, null, false)", "NodeIterator");
- test("document.getElementsByTagName('div')", "HTMLCollection");
+ test("document.getElementsByTagName('div')", "NodeList");
test("document.createRange()", "Range");
test("document.createTextNode('')", "Text");
test("document.createTreeWalker(root, 0, null, false)", "TreeWalker");
diff --git a/third_party/WebKit/LayoutTests/fast/js/constructor-expected.txt b/third_party/WebKit/LayoutTests/fast/js/constructor-expected.txt
index 7259b68..ea1a4040 100644
--- a/third_party/WebKit/LayoutTests/fast/js/constructor-expected.txt
+++ b/third_party/WebKit/LayoutTests/fast/js/constructor-expected.txt
@@ -12,8 +12,8 @@ PASS window.document.body.constructor === window.HTMLBodyElement is true
PASS window.document.body.constructor.prototype === window.HTMLBodyElement.prototype is true
PASS window.document.body.constructor.prototype.__proto__ === window.HTMLBodyElement.prototype.__proto__ is true
PASS window.document.body.constructor.prototype.__proto__ === window.HTMLElement.prototype is true
-PASS htmlCollection.constructor === window.HTMLCollection is true
-PASS htmlCollection.constructor.prototype === window.HTMLCollection.prototype is true
+PASS nodeList.constructor === window.NodeList is true
+PASS nodeList.constructor.prototype === window.NodeList.prototype is true
PASS mutationEvent.constructor === window.MutationEvent is true
PASS mutationEvent.constructor.prototype.__proto__ === window.Event.prototype is true
PASS successfullyParsed is true
diff --git a/third_party/WebKit/LayoutTests/fast/js/getOwnPropertyDescriptor-expected.txt b/third_party/WebKit/LayoutTests/fast/js/getOwnPropertyDescriptor-expected.txt
index 7692b5aa..8a98c73 100644
--- a/third_party/WebKit/LayoutTests/fast/js/getOwnPropertyDescriptor-expected.txt
+++ b/third_party/WebKit/LayoutTests/fast/js/getOwnPropertyDescriptor-expected.txt
@@ -142,7 +142,7 @@ FAIL Object.getOwnPropertyDescriptor(global, 0).configurable should be false. Th
PASS Object.getOwnPropertyDescriptor(document.getElementsByTagName('div'), 'length').value is 1
PASS Object.getOwnPropertyDescriptor(document.getElementsByTagName('div'), 'length').hasOwnProperty('get') is false
PASS Object.getOwnPropertyDescriptor(document.getElementsByTagName('div'), 'length').hasOwnProperty('set') is false
-PASS Object.getOwnPropertyDescriptor(document.getElementsByTagName('div'), 'length').enumerable is true
+FAIL Object.getOwnPropertyDescriptor(document.getElementsByTagName('div'), 'length').enumerable should be true. Was false.
FAIL Object.getOwnPropertyDescriptor(document.getElementsByTagName('div'), 'length').configurable should be false. Was true.
PASS Object.getOwnPropertyDescriptor(document.getElementsByTagName('div'), 0).value is document.getElementsByTagName('div')[0]
PASS Object.getOwnPropertyDescriptor(document.getElementsByTagName('div'), 0).hasOwnProperty('get') is false
@@ -157,7 +157,7 @@ FAIL Object.getOwnPropertyDescriptor(document.getElementsByClassName('pass'), 0)
PASS Object.getOwnPropertyDescriptor(document.getElementsByClassName('pass'), 'length').value is document.getElementsByClassName('pass').length
PASS Object.getOwnPropertyDescriptor(document.getElementsByClassName('pass'), 'length').hasOwnProperty('get') is false
PASS Object.getOwnPropertyDescriptor(document.getElementsByClassName('pass'), 'length').hasOwnProperty('set') is false
-PASS Object.getOwnPropertyDescriptor(document.getElementsByClassName('pass'), 'length').enumerable is true
+FAIL Object.getOwnPropertyDescriptor(document.getElementsByClassName('pass'), 'length').enumerable should be true. Was false.
FAIL Object.getOwnPropertyDescriptor(document.getElementsByClassName('pass'), 'length').configurable should be false. Was true.
PASS Object.getOwnPropertyDescriptor(select, 'length').value is select.length
PASS Object.getOwnPropertyDescriptor(select, 'length').hasOwnProperty('get') is false
diff --git a/third_party/WebKit/LayoutTests/fast/js/script-tests/constructor.js b/third_party/WebKit/LayoutTests/fast/js/script-tests/constructor.js
index 68a5726..28afa35 100644
--- a/third_party/WebKit/LayoutTests/fast/js/script-tests/constructor.js
+++ b/third_party/WebKit/LayoutTests/fast/js/script-tests/constructor.js
@@ -11,9 +11,9 @@ shouldBeTrue("window.document.body.constructor.prototype === window.HTMLBodyElem
shouldBeTrue("window.document.body.constructor.prototype.__proto__ === window.HTMLBodyElement.prototype.__proto__");
shouldBeTrue("window.document.body.constructor.prototype.__proto__ === window.HTMLElement.prototype");
-var htmlCollection = document.getElementsByTagName('script');
-shouldBeTrue("htmlCollection.constructor === window.HTMLCollection");
-shouldBeTrue("htmlCollection.constructor.prototype === window.HTMLCollection.prototype");
+var nodeList = document.getElementsByTagName('script');
+shouldBeTrue("nodeList.constructor === window.NodeList");
+shouldBeTrue("nodeList.constructor.prototype === window.NodeList.prototype");
var mutationEvent = document.createEvent("MutationEvent");
shouldBeTrue("mutationEvent.constructor === window.MutationEvent");
diff --git a/third_party/WebKit/LayoutTests/inspector/console/console-format-collections-expected.txt b/third_party/WebKit/LayoutTests/inspector/console/console-format-collections-expected.txt
index 6a59ade..620232d 100644
--- a/third_party/WebKit/LayoutTests/inspector/console/console-format-collections-expected.txt
+++ b/third_party/WebKit/LayoutTests/inspector/console/console-format-collections-expected.txt
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: line 15: [object HTMLCollection]
+CONSOLE MESSAGE: line 15: [object NodeList]
CONSOLE MESSAGE: line 19: [object HTMLCollection]
CONSOLE MESSAGE: line 23: [object HTMLOptionsCollection]
CONSOLE MESSAGE: line 27: undefined
@@ -7,7 +7,7 @@ CONSOLE MESSAGE: line 35: [object RadioNodeList]
CONSOLE MESSAGE: line 41: 1,2,
CONSOLE MESSAGE: line 44: [object Object]
CONSOLE MESSAGE: line 51: [object Arguments]
-CONSOLE MESSAGE: line 15: [object HTMLCollection]
+CONSOLE MESSAGE: line 15: [object NodeList]
CONSOLE MESSAGE: line 19: [object HTMLCollection]
CONSOLE MESSAGE: line 23: [object HTMLOptionsCollection]
CONSOLE MESSAGE: line 27: undefined
@@ -18,7 +18,7 @@ CONSOLE MESSAGE: line 44: [object Object]
CONSOLE MESSAGE: line 51: [object Arguments]
Tests that console nicely formats HTML Collections and NodeLists.
-HTMLCollection[1] console-format-collections.html:15
+NodeList[1] console-format-collections.html:15
HTMLCollection[3] console-format-collections.html:19
HTMLOptionsCollection[2] console-format-collections.html:23
HTMLAllCollection[14] console-format-collections.html:27
@@ -27,7 +27,7 @@ RadioNodeList[2] console-format-collections.html:35
Array[2] console-format-collections.html:41
NonArrayWithLength console-format-collections.html:44
Arguments[2] console-format-collections.html:51
-[select#sel, item: function, namedItem: function] console-format-collections.html:15
+[select#sel, item: function] console-format-collections.html:15
[script, script, script, item: function, namedItem: function] console-format-collections.html:19
[option, option, selectedIndex: 0, namedItem: function, add: function, remove: function, item: function] console-format-collections.html:23
[html, head, script, script, script, body, p, div, form#f, select#sel, option, option, input, input, item: function, namedItem: function, tags: function] console-format-collections.html:27
diff --git a/third_party/WebKit/Source/core/core.gypi b/third_party/WebKit/Source/core/core.gypi
index 4dda1fa..621b49a 100644
--- a/third_party/WebKit/Source/core/core.gypi
+++ b/third_party/WebKit/Source/core/core.gypi
@@ -1840,8 +1840,8 @@
'dom/ChildListMutationScope.h',
'dom/ChildNodeList.cpp',
'dom/ChildNodeList.h',
- 'dom/ClassCollection.cpp',
- 'dom/ClassCollection.h',
+ 'dom/ClassNodeList.cpp',
+ 'dom/ClassNodeList.h',
'dom/ClientRect.cpp',
'dom/ClientRect.h',
'dom/ClientRectList.cpp',
@@ -2088,8 +2088,8 @@
'dom/StyleSheetCollection.h',
'dom/StyleSheetScopingNodeList.cpp',
'dom/StyleSheetScopingNodeList.h',
- 'dom/TagCollection.cpp',
- 'dom/TagCollection.h',
+ 'dom/TagNodeList.cpp',
+ 'dom/TagNodeList.h',
'dom/Text.cpp',
'dom/TextLinkColors.cpp',
'dom/TextLinkColors.h',
diff --git a/third_party/WebKit/Source/core/dom/ClassCollection.cpp b/third_party/WebKit/Source/core/dom/ClassNodeList.cpp
index 35a62e5..39f85ef0 100644
--- a/third_party/WebKit/Source/core/dom/ClassCollection.cpp
+++ b/third_party/WebKit/Source/core/dom/ClassNodeList.cpp
@@ -28,23 +28,28 @@
*/
#include "config.h"
-#include "core/dom/ClassCollection.h"
+#include "core/dom/ClassNodeList.h"
#include "core/dom/Document.h"
#include "core/dom/NodeRareData.h"
namespace WebCore {
-ClassCollection::ClassCollection(ContainerNode* rootNode, const AtomicString& classNames)
- : HTMLCollection(rootNode, ClassCollectionType, DoesNotOverrideItemAfter)
+ClassNodeList::ClassNodeList(PassRefPtr<ContainerNode> rootNode, const AtomicString& classNames)
+ : LiveNodeList(rootNode, ClassNodeListType, InvalidateOnClassAttrChange)
, m_classNames(classNames, document().inQuirksMode())
, m_originalClassNames(classNames)
{
}
-ClassCollection::~ClassCollection()
+ClassNodeList::~ClassNodeList()
{
- ownerNode()->nodeLists()->removeCacheWithAtomicName(this, ClassCollectionType, m_originalClassNames);
+ ownerNode()->nodeLists()->removeCacheWithAtomicName(this, ClassNodeListType, m_originalClassNames);
+}
+
+bool ClassNodeList::nodeMatches(const Element& testNode) const
+{
+ return nodeMatchesInlined(testNode);
}
} // namespace WebCore
diff --git a/third_party/WebKit/Source/core/dom/ClassCollection.h b/third_party/WebKit/Source/core/dom/ClassNodeList.h
index a906537..a6672bc 100644
--- a/third_party/WebKit/Source/core/dom/ClassCollection.h
+++ b/third_party/WebKit/Source/core/dom/ClassNodeList.h
@@ -27,49 +27,52 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef ClassCollection_h
-#define ClassCollection_h
+#ifndef ClassNodeList_h
+#define ClassNodeList_h
#include "core/dom/Element.h"
+#include "core/dom/LiveNodeList.h"
+#include "core/dom/Node.h"
#include "core/dom/SpaceSplitString.h"
-#include "core/html/HTMLCollection.h"
namespace WebCore {
-class ClassCollection FINAL : public HTMLCollection {
+class ClassNodeList FINAL : public LiveNodeList {
public:
// classNames argument is an AtomicString because it is common for Elements to share the same class names.
// It is also used to construct a SpaceSplitString (m_classNames) and its constructor requires an AtomicString.
- static PassRefPtr<ClassCollection> create(ContainerNode* rootNode, CollectionType type, const AtomicString& classNames)
+ static PassRefPtr<ClassNodeList> create(PassRefPtr<ContainerNode> rootNode, CollectionType type, const AtomicString& classNames)
{
- ASSERT_UNUSED(type, type == ClassCollectionType);
- return adoptRef(new ClassCollection(rootNode, classNames));
+ ASSERT_UNUSED(type, type == ClassNodeListType);
+ return adoptRef(new ClassNodeList(rootNode, classNames));
}
- virtual ~ClassCollection();
+ virtual ~ClassNodeList();
- bool elementMatches(const Element&) const;
+ bool nodeMatchesInlined(const Element&) const;
private:
- ClassCollection(ContainerNode* rootNode, const AtomicString& classNames);
+ ClassNodeList(PassRefPtr<ContainerNode> rootNode, const AtomicString& classNames);
+
+ virtual bool nodeMatches(const Element&) const OVERRIDE;
SpaceSplitString m_classNames;
AtomicString m_originalClassNames;
};
-inline bool ClassCollection::elementMatches(const Element& testElement) const
+inline bool ClassNodeList::nodeMatchesInlined(const Element& testNode) const
{
- if (!testElement.hasClass())
+ if (!testNode.hasClass())
return false;
if (!m_classNames.size())
return false;
// FIXME: DOM4 allows getElementsByClassName to return non StyledElement.
// https://bugs.webkit.org/show_bug.cgi?id=94718
- if (!testElement.isStyledElement())
+ if (!testNode.isStyledElement())
return false;
- return testElement.classNames().containsAll(m_classNames);
+ return testNode.classNames().containsAll(m_classNames);
}
} // namespace WebCore
-#endif // ClassCollection_h
+#endif // ClassNodeList_h
diff --git a/third_party/WebKit/Source/core/dom/ContainerNode.cpp b/third_party/WebKit/Source/core/dom/ContainerNode.cpp
index f815d00..2f162a0 100644
--- a/third_party/WebKit/Source/core/dom/ContainerNode.cpp
+++ b/third_party/WebKit/Source/core/dom/ContainerNode.cpp
@@ -25,7 +25,7 @@
#include "bindings/v8/ExceptionState.h"
#include "core/dom/ChildListMutationScope.h"
-#include "core/dom/ClassCollection.h"
+#include "core/dom/ClassNodeList.h"
#include "core/dom/ContainerNodeAlgorithms.h"
#include "core/dom/ElementTraversal.h"
#include "core/dom/ExceptionCode.h"
@@ -999,17 +999,17 @@ void ContainerNode::updateTreeAfterInsertion(Node& child)
dispatchChildInsertionEvents(child);
}
-PassRefPtr<HTMLCollection> ContainerNode::getElementsByTagName(const AtomicString& localName)
+PassRefPtr<NodeList> ContainerNode::getElementsByTagName(const AtomicString& localName)
{
if (localName.isNull())
return 0;
if (document().isHTMLDocument())
- return ensureRareData().ensureNodeLists().addCacheWithAtomicName<HTMLTagCollection>(this, HTMLTagCollectionType, localName);
- return ensureRareData().ensureNodeLists().addCacheWithAtomicName<TagCollection>(this, TagCollectionType, localName);
+ return ensureRareData().ensureNodeLists().addCacheWithAtomicName<HTMLTagNodeList>(this, HTMLTagNodeListType, localName);
+ return ensureRareData().ensureNodeLists().addCacheWithAtomicName<TagNodeList>(this, TagNodeListType, localName);
}
-PassRefPtr<HTMLCollection> ContainerNode::getElementsByTagNameNS(const AtomicString& namespaceURI, const AtomicString& localName)
+PassRefPtr<NodeList> ContainerNode::getElementsByTagNameNS(const AtomicString& namespaceURI, const AtomicString& localName)
{
if (localName.isNull())
return 0;
@@ -1029,9 +1029,9 @@ PassRefPtr<NodeList> ContainerNode::getElementsByName(const AtomicString& elemen
// Takes an AtomicString in argument because it is common for elements to share the same set of class names.
// Therefore, the ClassNodeList factory function expects an AtomicString type.
-PassRefPtr<HTMLCollection> ContainerNode::getElementsByClassName(const AtomicString& classNames)
+PassRefPtr<NodeList> ContainerNode::getElementsByClassName(const AtomicString& classNames)
{
- return ensureRareData().ensureNodeLists().addCacheWithAtomicName<ClassCollection>(this, ClassCollectionType, classNames);
+ return ensureRareData().ensureNodeLists().addCacheWithAtomicName<ClassNodeList>(this, ClassNodeListType, classNames);
}
PassRefPtr<RadioNodeList> ContainerNode::radioNodeList(const AtomicString& name, bool onlyMatchImgElements)
diff --git a/third_party/WebKit/Source/core/dom/ContainerNode.h b/third_party/WebKit/Source/core/dom/ContainerNode.h
index 1ba2f8a..77080b8 100644
--- a/third_party/WebKit/Source/core/dom/ContainerNode.h
+++ b/third_party/WebKit/Source/core/dom/ContainerNode.h
@@ -104,10 +104,10 @@ public:
void removeChild(Node* child, ExceptionState& = ASSERT_NO_EXCEPTION);
void appendChild(PassRefPtr<Node> newChild, ExceptionState& = ASSERT_NO_EXCEPTION);
- PassRefPtr<HTMLCollection> getElementsByTagName(const AtomicString&);
- PassRefPtr<HTMLCollection> getElementsByTagNameNS(const AtomicString& namespaceURI, const AtomicString& localName);
+ PassRefPtr<NodeList> getElementsByTagName(const AtomicString&);
+ PassRefPtr<NodeList> getElementsByTagNameNS(const AtomicString& namespaceURI, const AtomicString& localName);
PassRefPtr<NodeList> getElementsByName(const AtomicString& elementName);
- PassRefPtr<HTMLCollection> getElementsByClassName(const AtomicString& classNames);
+ PassRefPtr<NodeList> getElementsByClassName(const AtomicString& classNames);
PassRefPtr<RadioNodeList> radioNodeList(const AtomicString&, bool onlyMatchImgElements = false);
// These methods are only used during parsing.
diff --git a/third_party/WebKit/Source/core/dom/Document.idl b/third_party/WebKit/Source/core/dom/Document.idl
index d444dce..0589635 100644
--- a/third_party/WebKit/Source/core/dom/Document.idl
+++ b/third_party/WebKit/Source/core/dom/Document.idl
@@ -36,7 +36,7 @@ callback CustomElementConstructor = Element ();
[RaisesException, MeasureAs=DocumentCreateCDATASection] CDATASection createCDATASection([Default=Undefined] optional DOMString data); // Removed from DOM4.
[RaisesException] ProcessingInstruction createProcessingInstruction(DOMString target, DOMString data);
[RaisesException, MeasureAs=DocumentCreateAttribute] Attr createAttribute([Default=Undefined] optional DOMString name); // Removed from DOM4.
- [PerWorldBindings] HTMLCollection getElementsByTagName(DOMString localName);
+ [PerWorldBindings] NodeList getElementsByTagName(DOMString localName);
// Introduced in DOM Level 2:
@@ -44,7 +44,7 @@ callback CustomElementConstructor = Element ();
[CustomElementCallbacks, PerWorldBindings, ActivityLogging=ForIsolatedWorlds, RaisesException] Element createElementNS([TreatNullAs=NullString] DOMString namespaceURI, DOMString qualifiedName);
[RaisesException, MeasureAs=DocumentCreateAttributeNS] Attr createAttributeNS([TreatNullAs=NullString,Default=Undefined] optional DOMString namespaceURI,
[TreatNullAs=NullString,Default=Undefined] optional DOMString qualifiedName); // Removed from DOM4.
- HTMLCollection getElementsByTagNameNS([TreatNullAs=NullString] DOMString namespaceURI, DOMString localName);
+ NodeList getElementsByTagNameNS([TreatNullAs=NullString] DOMString namespaceURI, DOMString localName);
[PerWorldBindings] Element getElementById(DOMString elementId);
// DOM Level 3 Core
@@ -146,7 +146,7 @@ callback CustomElementConstructor = Element ();
CanvasRenderingContext getCSSCanvasContext(DOMString contextId, DOMString name, long width, long height);
// HTML 5
- HTMLCollection getElementsByClassName(DOMString classNames);
+ NodeList getElementsByClassName(DOMString classNames);
readonly attribute Element activeElement;
boolean hasFocus();
diff --git a/third_party/WebKit/Source/core/dom/Element.idl b/third_party/WebKit/Source/core/dom/Element.idl
index e4e3fb9..5ce30ec 100644
--- a/third_party/WebKit/Source/core/dom/Element.idl
+++ b/third_party/WebKit/Source/core/dom/Element.idl
@@ -32,7 +32,7 @@
[MeasureAs=ElementGetAttributeNode] Attr getAttributeNode([Default=Undefined] optional DOMString name); // Removed from DOM4.
[RaisesException, CustomElementCallbacks, MeasureAs=ElementSetAttributeNode] Attr setAttributeNode([Default=Undefined, StrictTypeChecking] optional Attr newAttr); // Removed from DOM4.
[RaisesException, CustomElementCallbacks, MeasureAs=ElementRemoveAttributeNode] Attr removeAttributeNode([Default=Undefined, StrictTypeChecking] optional Attr oldAttr); // Removed from DOM4.
- [PerWorldBindings] HTMLCollection getElementsByTagName(DOMString name);
+ [PerWorldBindings] NodeList getElementsByTagName(DOMString name);
[PerWorldBindings] readonly attribute NamedNodeMap attributes;
[MeasureAs=HasAttributes] boolean hasAttributes();
@@ -42,7 +42,7 @@
DOMString getAttributeNS([TreatNullAs=NullString] DOMString namespaceURI, DOMString localName);
[RaisesException, CustomElementCallbacks] void setAttributeNS([TreatNullAs=NullString] DOMString namespaceURI, DOMString qualifiedName, DOMString value);
[CustomElementCallbacks] void removeAttributeNS([TreatNullAs=NullString] DOMString namespaceURI, DOMString localName);
- HTMLCollection getElementsByTagNameNS([TreatNullAs=NullString] DOMString namespaceURI, DOMString localName);
+ NodeList getElementsByTagNameNS([TreatNullAs=NullString] DOMString namespaceURI, DOMString localName);
[MeasureAs=ElementGetAttributeNodeNS] Attr getAttributeNodeNS([TreatNullAs=NullString,Default=Undefined] optional DOMString namespaceURI,
[Default=Undefined] optional DOMString localName); // Removed from DOM4.
[RaisesException, CustomElementCallbacks, MeasureAs=ElementSetAttributeNodeNS] Attr setAttributeNodeNS([Default=Undefined, StrictTypeChecking] optional Attr newAttr); // Removed from DOM4.
@@ -86,7 +86,7 @@
void scrollByPages([Default=Undefined] optional long pages);
// HTML 5
- HTMLCollection getElementsByClassName(DOMString classNames);
+ NodeList getElementsByClassName(DOMString classNames);
[TreatNullAs=NullString, CustomElementCallbacks, PerWorldBindings, ActivityLogging=SetterForIsolatedWorlds, RaisesException=Setter] attribute DOMString innerHTML;
[TreatNullAs=NullString, CustomElementCallbacks, RaisesException=Setter] attribute DOMString outerHTML;
[CustomElementCallbacks, RaisesException] void insertAdjacentHTML(DOMString where, DOMString html);
diff --git a/third_party/WebKit/Source/core/dom/Node.cpp b/third_party/WebKit/Source/core/dom/Node.cpp
index 3757bdb..66bbfbc 100644
--- a/third_party/WebKit/Source/core/dom/Node.cpp
+++ b/third_party/WebKit/Source/core/dom/Node.cpp
@@ -48,6 +48,7 @@
#include "core/dom/ProcessingInstruction.h"
#include "core/dom/Range.h"
#include "core/dom/StaticNodeList.h"
+#include "core/dom/TagNodeList.h"
#include "core/dom/TemplateContentDocumentFragment.h"
#include "core/dom/Text.h"
#include "core/dom/TreeScopeAdopter.h"
@@ -1909,8 +1910,8 @@ void NodeListsNodeData::invalidateCaches(const QualifiedName* attrName)
if (attrName)
return;
- TagCollectionCacheNS::iterator tagCacheEnd = m_tagCollectionCacheNS.end();
- for (TagCollectionCacheNS::iterator it = m_tagCollectionCacheNS.begin(); it != tagCacheEnd; ++it)
+ TagNodeListCacheNS::iterator tagCacheEnd = m_tagNodeListCacheNS.end();
+ for (TagNodeListCacheNS::iterator it = m_tagNodeListCacheNS.begin(); it != tagCacheEnd; ++it)
it->value->invalidateCache();
}
diff --git a/third_party/WebKit/Source/core/dom/Node.h b/third_party/WebKit/Source/core/dom/Node.h
index 7f884a2..1ace0be 100644
--- a/third_party/WebKit/Source/core/dom/Node.h
+++ b/third_party/WebKit/Source/core/dom/Node.h
@@ -47,7 +47,7 @@
namespace WebCore {
class Attribute;
-class ClassCollection;
+class ClassNodeList;
class ContainerNode;
class DOMSettableTokenList;
class Document;
@@ -80,7 +80,7 @@ class RenderBoxModelObject;
class RenderObject;
class RenderStyle;
class ShadowRoot;
-class TagCollection;
+class TagNodeList;
class Text;
class TouchEvent;
diff --git a/third_party/WebKit/Source/core/dom/NodeRareData.h b/third_party/WebKit/Source/core/dom/NodeRareData.h
index 403a0b2..9b4c989 100644
--- a/third_party/WebKit/Source/core/dom/NodeRareData.h
+++ b/third_party/WebKit/Source/core/dom/NodeRareData.h
@@ -27,7 +27,7 @@
#include "core/dom/LiveNodeList.h"
#include "core/dom/MutationObserverRegistration.h"
#include "core/dom/QualifiedName.h"
-#include "core/dom/TagCollection.h"
+#include "core/dom/TagNodeList.h"
#include "core/page/Page.h"
#include "wtf/HashSet.h"
#include "wtf/OwnPtr.h"
@@ -96,7 +96,7 @@ public:
typedef HashMap<std::pair<unsigned char, AtomicString>, LiveNodeListBase*, NodeListCacheMapEntryHash<AtomicString> > NodeListAtomicNameCacheMap;
typedef HashMap<std::pair<unsigned char, String>, LiveNodeListBase*, NodeListCacheMapEntryHash<String> > NodeListNameCacheMap;
- typedef HashMap<QualifiedName, TagCollection*> TagCollectionCacheNS;
+ typedef HashMap<QualifiedName, TagNodeList*> TagNodeListCacheNS;
template<typename T>
PassRefPtr<T> addCacheWithAtomicName(ContainerNode* node, CollectionType collectionType, const AtomicString& name)
@@ -141,14 +141,14 @@ public:
return list.release();
}
- PassRefPtr<TagCollection> addCacheWithQualifiedName(ContainerNode* node, const AtomicString& namespaceURI, const AtomicString& localName)
+ PassRefPtr<TagNodeList> addCacheWithQualifiedName(ContainerNode* node, const AtomicString& namespaceURI, const AtomicString& localName)
{
QualifiedName name(nullAtom, localName, namespaceURI);
- TagCollectionCacheNS::AddResult result = m_tagCollectionCacheNS.add(name, 0);
+ TagNodeListCacheNS::AddResult result = m_tagNodeListCacheNS.add(name, 0);
if (!result.isNewEntry)
return result.iterator->value;
- RefPtr<TagCollection> list = TagCollection::create(node, namespaceURI, localName);
+ RefPtr<TagNodeList> list = TagNodeList::create(node, namespaceURI, localName);
result.iterator->value = list.get();
return list.release();
}
@@ -169,13 +169,13 @@ public:
m_nameCaches.remove(namedNodeListKey(collectionType, name));
}
- void removeCacheWithQualifiedName(LiveNodeListBase* list, const AtomicString& namespaceURI, const AtomicString& localName)
+ void removeCacheWithQualifiedName(LiveNodeList* list, const AtomicString& namespaceURI, const AtomicString& localName)
{
QualifiedName name(nullAtom, localName, namespaceURI);
- ASSERT(list == m_tagCollectionCacheNS.get(name));
+ ASSERT(list == m_tagNodeListCacheNS.get(name));
if (deleteThisAndUpdateNodeRareDataIfAboutToRemoveLastList(list->ownerNode()))
return;
- m_tagCollectionCacheNS.remove(name);
+ m_tagNodeListCacheNS.remove(name);
}
static PassOwnPtr<NodeListsNodeData> create()
@@ -186,7 +186,7 @@ public:
void invalidateCaches(const QualifiedName* attrName = 0);
bool isEmpty() const
{
- return m_atomicNameCaches.isEmpty() && m_nameCaches.isEmpty() && m_tagCollectionCacheNS.isEmpty();
+ return m_atomicNameCaches.isEmpty() && m_nameCaches.isEmpty() && m_tagNodeListCacheNS.isEmpty();
}
void adoptTreeScope()
@@ -213,8 +213,8 @@ public:
newDocument.registerNodeList(list);
}
- TagCollectionCacheNS::const_iterator tagEnd = m_tagCollectionCacheNS.end();
- for (TagCollectionCacheNS::const_iterator it = m_tagCollectionCacheNS.begin(); it != tagEnd; ++it) {
+ TagNodeListCacheNS::const_iterator tagEnd = m_tagNodeListCacheNS.end();
+ for (TagNodeListCacheNS::const_iterator it = m_tagNodeListCacheNS.begin(); it != tagEnd; ++it) {
LiveNodeListBase* list = it->value;
ASSERT(!list->isRootedAtDocument());
oldDocument.unregisterNodeList(list);
@@ -244,7 +244,7 @@ private:
NodeList* m_childNodeList;
NodeListAtomicNameCacheMap m_atomicNameCaches;
NodeListNameCacheMap m_nameCaches;
- TagCollectionCacheNS m_tagCollectionCacheNS;
+ TagNodeListCacheNS m_tagNodeListCacheNS;
};
class NodeMutationObserverData {
@@ -310,7 +310,7 @@ inline bool NodeListsNodeData::deleteThisAndUpdateNodeRareDataIfAboutToRemoveLas
{
ASSERT(ownerNode);
ASSERT(ownerNode->nodeLists() == this);
- if ((m_childNodeList ? 1 : 0) + m_atomicNameCaches.size() + m_nameCaches.size() + m_tagCollectionCacheNS.size() != 1)
+ if ((m_childNodeList ? 1 : 0) + m_atomicNameCaches.size() + m_nameCaches.size() + m_tagNodeListCacheNS.size() != 1)
return false;
ownerNode->clearNodeLists();
return true;
diff --git a/third_party/WebKit/Source/core/dom/TagCollection.cpp b/third_party/WebKit/Source/core/dom/TagNodeList.cpp
index 169e2a3..2df54f5 100644
--- a/third_party/WebKit/Source/core/dom/TagCollection.cpp
+++ b/third_party/WebKit/Source/core/dom/TagNodeList.cpp
@@ -22,22 +22,22 @@
*/
#include "config.h"
-#include "core/dom/TagCollection.h"
+#include "core/dom/TagNodeList.h"
#include "core/dom/NodeRareData.h"
#include "wtf/Assertions.h"
namespace WebCore {
-TagCollection::TagCollection(ContainerNode* rootNode, CollectionType type, const AtomicString& namespaceURI, const AtomicString& localName)
- : HTMLCollection(rootNode, type, DoesNotOverrideItemAfter)
+TagNodeList::TagNodeList(PassRefPtr<ContainerNode> rootNode, CollectionType type, const AtomicString& namespaceURI, const AtomicString& localName)
+ : LiveNodeList(rootNode, type, DoNotInvalidateOnAttributeChanges)
, m_namespaceURI(namespaceURI)
, m_localName(localName)
{
ASSERT(m_namespaceURI.isNull() || !m_namespaceURI.isEmpty());
}
-TagCollection::~TagCollection()
+TagNodeList::~TagNodeList()
{
if (m_namespaceURI == starAtom)
ownerNode()->nodeLists()->removeCacheWithAtomicName(this, type(), m_localName);
@@ -45,7 +45,7 @@ TagCollection::~TagCollection()
ownerNode()->nodeLists()->removeCacheWithQualifiedName(this, m_namespaceURI, m_localName);
}
-bool TagCollection::elementMatches(const Element& testNode) const
+bool TagNodeList::nodeMatches(const Element& testNode) const
{
// Implements http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-getelementsbytagnamens
if (m_localName != starAtom && m_localName != testNode.localName())
@@ -54,10 +54,15 @@ bool TagCollection::elementMatches(const Element& testNode) const
return m_namespaceURI == starAtom || m_namespaceURI == testNode.namespaceURI();
}
-HTMLTagCollection::HTMLTagCollection(ContainerNode* rootNode, const AtomicString& localName)
- : TagCollection(rootNode, HTMLTagCollectionType, starAtom, localName)
+HTMLTagNodeList::HTMLTagNodeList(PassRefPtr<ContainerNode> rootNode, const AtomicString& localName)
+ : TagNodeList(rootNode, HTMLTagNodeListType, starAtom, localName)
, m_loweredLocalName(localName.lower())
{
}
+bool HTMLTagNodeList::nodeMatches(const Element& testNode) const
+{
+ return nodeMatchesInlined(testNode);
+}
+
} // namespace WebCore
diff --git a/third_party/WebKit/Source/core/dom/TagCollection.h b/third_party/WebKit/Source/core/dom/TagNodeList.h
index 393741e..282fffc 100644
--- a/third_party/WebKit/Source/core/dom/TagCollection.h
+++ b/third_party/WebKit/Source/core/dom/TagNodeList.h
@@ -21,63 +21,65 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef TagCollection_h
-#define TagCollection_h
+#ifndef TagNodeList_h
+#define TagNodeList_h
#include "core/dom/Element.h"
-#include "core/html/HTMLCollection.h"
+#include "core/dom/LiveNodeList.h"
#include "wtf/text/AtomicString.h"
namespace WebCore {
-// Collection that limits to a particular tag.
-class TagCollection : public HTMLCollection {
+// NodeList that limits to a particular tag.
+class TagNodeList : public LiveNodeList {
public:
- static PassRefPtr<TagCollection> create(ContainerNode* rootNode, const AtomicString& namespaceURI, const AtomicString& localName)
+ static PassRefPtr<TagNodeList> create(PassRefPtr<ContainerNode> rootNode, const AtomicString& namespaceURI, const AtomicString& localName)
{
ASSERT(namespaceURI != starAtom);
- return adoptRef(new TagCollection(rootNode, TagCollectionType, namespaceURI, localName));
+ return adoptRef(new TagNodeList(rootNode, TagNodeListType, namespaceURI, localName));
}
- static PassRefPtr<TagCollection> create(ContainerNode* rootNode, CollectionType type, const AtomicString& localName)
+ static PassRefPtr<TagNodeList> create(PassRefPtr<ContainerNode> rootNode, CollectionType type, const AtomicString& localName)
{
- ASSERT_UNUSED(type, type == TagCollectionType);
- return adoptRef(new TagCollection(rootNode, TagCollectionType, starAtom, localName));
+ ASSERT_UNUSED(type, type == TagNodeListType);
+ return adoptRef(new TagNodeList(rootNode, TagNodeListType, starAtom, localName));
}
- virtual ~TagCollection();
-
- bool elementMatches(const Element&) const;
+ virtual ~TagNodeList();
protected:
- TagCollection(ContainerNode* rootNode, CollectionType, const AtomicString& namespaceURI, const AtomicString& localName);
+ TagNodeList(PassRefPtr<ContainerNode> rootNode, CollectionType, const AtomicString& namespaceURI, const AtomicString& localName);
+
+ virtual bool nodeMatches(const Element&) const OVERRIDE;
AtomicString m_namespaceURI;
AtomicString m_localName;
};
-class HTMLTagCollection FINAL : public TagCollection {
+class HTMLTagNodeList FINAL : public TagNodeList {
public:
- static PassRefPtr<HTMLTagCollection> create(ContainerNode* rootNode, CollectionType type, const AtomicString& localName)
+ static PassRefPtr<HTMLTagNodeList> create(PassRefPtr<ContainerNode> rootNode, CollectionType type, const AtomicString& localName)
{
- ASSERT_UNUSED(type, type == HTMLTagCollectionType);
- return adoptRef(new HTMLTagCollection(rootNode, localName));
+ ASSERT_UNUSED(type, type == HTMLTagNodeListType);
+ return adoptRef(new HTMLTagNodeList(rootNode, localName));
}
- bool elementMatches(const Element&) const;
+ bool nodeMatchesInlined(const Element&) const;
private:
- HTMLTagCollection(ContainerNode* rootNode, const AtomicString& localName);
+ HTMLTagNodeList(PassRefPtr<ContainerNode> rootNode, const AtomicString& localName);
+
+ virtual bool nodeMatches(const Element&) const OVERRIDE;
AtomicString m_loweredLocalName;
};
-inline bool HTMLTagCollection::elementMatches(const Element& testElement) const
+inline bool HTMLTagNodeList::nodeMatchesInlined(const Element& testNode) const
{
// Implements http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-getelementsbytagname
if (m_localName != starAtom) {
- const AtomicString& localName = testElement.isHTMLElement() ? m_loweredLocalName : m_localName;
- if (localName != testElement.localName())
+ const AtomicString& localName = testNode.isHTMLElement() ? m_loweredLocalName : m_localName;
+ if (localName != testNode.localName())
return false;
}
ASSERT(m_namespaceURI == starAtom);
@@ -86,4 +88,4 @@ inline bool HTMLTagCollection::elementMatches(const Element& testElement) const
} // namespace WebCore
-#endif // TagCollection_h
+#endif // TagNodeList_h
diff --git a/third_party/WebKit/Source/core/dom/shadow/ShadowRoot.idl b/third_party/WebKit/Source/core/dom/shadow/ShadowRoot.idl
index 4a74d5a2..5173b2b 100644
--- a/third_party/WebKit/Source/core/dom/shadow/ShadowRoot.idl
+++ b/third_party/WebKit/Source/core/dom/shadow/ShadowRoot.idl
@@ -36,10 +36,10 @@
[RaisesException] Node cloneNode([Default=Undefined] optional boolean deep);
Selection getSelection();
Element getElementById([Default=Undefined] optional DOMString elementId);
- HTMLCollection getElementsByClassName([Default=Undefined] optional DOMString className);
- HTMLCollection getElementsByTagName([Default=Undefined] optional DOMString tagName);
- HTMLCollection getElementsByTagNameNS([TreatNullAs=NullString,Default=Undefined] optional DOMString namespaceURI,
- [Default=Undefined] optional DOMString localName);
+ NodeList getElementsByClassName([Default=Undefined] optional DOMString className);
+ NodeList getElementsByTagName([Default=Undefined] optional DOMString tagName);
+ NodeList getElementsByTagNameNS([TreatNullAs=NullString,Default=Undefined] optional DOMString namespaceURI,
+ [Default=Undefined] optional DOMString localName);
Element elementFromPoint([Default=Undefined] optional long x,
[Default=Undefined] optional long y);
diff --git a/third_party/WebKit/Source/core/fetch/FontResource.cpp b/third_party/WebKit/Source/core/fetch/FontResource.cpp
index a3c8824..d45debb 100644
--- a/third_party/WebKit/Source/core/fetch/FontResource.cpp
+++ b/third_party/WebKit/Source/core/fetch/FontResource.cpp
@@ -37,7 +37,7 @@
#if ENABLE(SVG_FONTS)
#include "SVGNames.h"
-#include "core/html/HTMLCollection.h"
+#include "core/dom/NodeList.h"
#include "core/svg/SVGDocument.h"
#include "core/svg/SVGFontElement.h"
#endif
@@ -127,26 +127,26 @@ bool FontResource::ensureSVGFontData()
SVGFontElement* FontResource::getSVGFontById(const String& fontName) const
{
- RefPtr<HTMLCollection> collection = m_externalSVGDocument->getElementsByTagNameNS(SVGNames::fontTag.namespaceURI(), SVGNames::fontTag.localName());
- if (!collection)
+ RefPtr<NodeList> list = m_externalSVGDocument->getElementsByTagNameNS(SVGNames::fontTag.namespaceURI(), SVGNames::fontTag.localName());
+ if (!list)
return 0;
- unsigned collectionLength = collection->length();
- if (!collectionLength)
+ unsigned listLength = list->length();
+ if (!listLength)
return 0;
#ifndef NDEBUG
- for (unsigned i = 0; i < collectionLength; ++i) {
- ASSERT(collection->item(i));
- ASSERT(collection->item(i)->hasTagName(SVGNames::fontTag));
+ for (unsigned i = 0; i < listLength; ++i) {
+ ASSERT(list->item(i));
+ ASSERT(list->item(i)->hasTagName(SVGNames::fontTag));
}
#endif
if (fontName.isEmpty())
- return toSVGFontElement(collection->item(0));
+ return toSVGFontElement(list->item(0));
- for (unsigned i = 0; i < collectionLength; ++i) {
- SVGFontElement* element = toSVGFontElement(collection->item(i));
+ for (unsigned i = 0; i < listLength; ++i) {
+ SVGFontElement* element = toSVGFontElement(list->item(i));
if (element->getIdAttribute() == fontName)
return element;
}
diff --git a/third_party/WebKit/Source/core/html/CollectionType.h b/third_party/WebKit/Source/core/html/CollectionType.h
index 05e412f..d63a3bc 100644
--- a/third_party/WebKit/Source/core/html/CollectionType.h
+++ b/third_party/WebKit/Source/core/html/CollectionType.h
@@ -52,13 +52,12 @@ enum CollectionType {
MapAreas,
FormControls,
- ClassCollectionType,
- TagCollectionType,
- HTMLTagCollectionType,
-
// Live NodeList.
ChildNodeListType,
+ ClassNodeListType,
NameNodeListType,
+ TagNodeListType,
+ HTMLTagNodeListType,
RadioNodeListType,
RadioImgNodeListType,
LabelsNodeListType,
diff --git a/third_party/WebKit/Source/core/html/HTMLAllCollection.cpp b/third_party/WebKit/Source/core/html/HTMLAllCollection.cpp
index c4f5b7e..1d2a103 100644
--- a/third_party/WebKit/Source/core/html/HTMLAllCollection.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLAllCollection.cpp
@@ -84,7 +84,7 @@ void HTMLAllCollection::anonymousNamedGetter(const AtomicString& name, bool& ret
returnValue0 = NamedNodesCollection::create(namedItems);
}
-PassRefPtr<HTMLCollection> HTMLAllCollection::tags(const AtomicString& name)
+PassRefPtr<NodeList> HTMLAllCollection::tags(const AtomicString& name)
{
return ownerNode()->getElementsByTagName(name);
}
diff --git a/third_party/WebKit/Source/core/html/HTMLAllCollection.h b/third_party/WebKit/Source/core/html/HTMLAllCollection.h
index 323773a..f5f69ca 100644
--- a/third_party/WebKit/Source/core/html/HTMLAllCollection.h
+++ b/third_party/WebKit/Source/core/html/HTMLAllCollection.h
@@ -37,7 +37,7 @@ public:
Node* namedItemWithIndex(const AtomicString& name, unsigned index) const;
void anonymousNamedGetter(const AtomicString& name, bool&, RefPtr<NodeList>&, bool&, RefPtr<Element>&);
- PassRefPtr<HTMLCollection> tags(const AtomicString&);
+ PassRefPtr<NodeList> tags(const AtomicString&);
private:
HTMLAllCollection(ContainerNode*, CollectionType);
diff --git a/third_party/WebKit/Source/core/html/HTMLAllCollection.idl b/third_party/WebKit/Source/core/html/HTMLAllCollection.idl
index 9193c72..6a135f2 100644
--- a/third_party/WebKit/Source/core/html/HTMLAllCollection.idl
+++ b/third_party/WebKit/Source/core/html/HTMLAllCollection.idl
@@ -34,5 +34,5 @@
[NotEnumerable] getter (NodeList or Element) (DOMString name);
[Custom] Element namedItem(DOMString name);
// FIXME: This should return an HTMLAllCollection.
- [MeasureAs=DocumentAllTags] HTMLCollection tags(DOMString name);
+ [MeasureAs=DocumentAllTags] NodeList tags(DOMString name);
};
diff --git a/third_party/WebKit/Source/core/html/HTMLCollection.cpp b/third_party/WebKit/Source/core/html/HTMLCollection.cpp
index cb25f06..74a2ccf 100644
--- a/third_party/WebKit/Source/core/html/HTMLCollection.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLCollection.cpp
@@ -24,7 +24,7 @@
#include "core/html/HTMLCollection.h"
#include "HTMLNames.h"
-#include "core/dom/ClassCollection.h"
+#include "core/dom/ClassNodeList.h"
#include "core/dom/ElementTraversal.h"
#include "core/dom/NodeList.h"
#include "core/dom/NodeRareData.h"
@@ -40,9 +40,6 @@ using namespace HTMLNames;
static bool shouldOnlyIncludeDirectChildren(CollectionType type)
{
switch (type) {
- case ClassCollectionType:
- case TagCollectionType:
- case HTMLTagCollectionType:
case DocAll:
case DocAnchors:
case DocApplets:
@@ -66,7 +63,10 @@ static bool shouldOnlyIncludeDirectChildren(CollectionType type)
case TableTBodies:
return true;
case ChildNodeListType:
+ case ClassNodeListType:
case NameNodeListType:
+ case TagNodeListType:
+ case HTMLTagNodeListType:
case RadioNodeListType:
case RadioImgNodeListType:
case LabelsNodeListType:
@@ -91,9 +91,6 @@ static NodeListRootType rootTypeFromCollectionType(CollectionType type)
case DocumentNamedItems:
case FormControls:
return NodeListIsRootedAtDocument;
- case ClassCollectionType:
- case TagCollectionType:
- case HTMLTagCollectionType:
case NodeChildren:
case TableTBodies:
case TSectionRows:
@@ -105,7 +102,10 @@ static NodeListRootType rootTypeFromCollectionType(CollectionType type)
case MapAreas:
return NodeListIsRootedAtNode;
case ChildNodeListType:
+ case ClassNodeListType:
case NameNodeListType:
+ case TagNodeListType:
+ case HTMLTagNodeListType:
case RadioNodeListType:
case RadioImgNodeListType:
case LabelsNodeListType:
@@ -118,8 +118,6 @@ static NodeListRootType rootTypeFromCollectionType(CollectionType type)
static NodeListInvalidationType invalidationTypeExcludingIdAndNameAttributes(CollectionType type)
{
switch (type) {
- case TagCollectionType:
- case HTMLTagCollectionType:
case DocImages:
case DocEmbeds:
case DocForms:
@@ -148,10 +146,11 @@ static NodeListInvalidationType invalidationTypeExcludingIdAndNameAttributes(Col
return InvalidateOnIdNameAttrChange;
case FormControls:
return InvalidateForFormControls;
- case ClassCollectionType:
- return InvalidateOnClassAttrChange;
case ChildNodeListType:
+ case ClassNodeListType:
case NameNodeListType:
+ case TagNodeListType:
+ case HTMLTagNodeListType:
case RadioNodeListType:
case RadioImgNodeListType:
case LabelsNodeListType:
@@ -176,11 +175,9 @@ PassRefPtr<HTMLCollection> HTMLCollection::create(ContainerNode* base, Collectio
HTMLCollection::~HTMLCollection()
{
- // HTMLNameCollection, ClassCollection and TagCollection remove cache by themselves.
- if (type() != WindowNamedItems && type() != DocumentNamedItems && type() != ClassCollectionType
- && type() != HTMLTagCollectionType && type() != TagCollectionType) {
+ // HTMLNameCollection removes cache by itself.
+ if (type() != WindowNamedItems && type() != DocumentNamedItems)
ownerNode()->nodeLists()->removeCacheWithAtomicName(this, type());
- }
}
void HTMLCollection::invalidateCache() const
@@ -195,24 +192,7 @@ inline bool isMatchingElement(const NodeListType&, const Element&);
template <> inline bool isMatchingElement(const HTMLCollection& htmlCollection, const Element& element)
{
CollectionType type = htmlCollection.type();
-
- // These collections apply to any kind of Elements, not just HTMLElements.
- switch (type) {
- case DocAll:
- case NodeChildren:
- return true;
- case ClassCollectionType:
- return static_cast<const ClassCollection&>(htmlCollection).elementMatches(element);
- case TagCollectionType:
- return static_cast<const TagCollection&>(htmlCollection).elementMatches(element);
- case HTMLTagCollectionType:
- return static_cast<const HTMLTagCollection&>(htmlCollection).elementMatches(element);
- default:
- break;
- }
-
- // The following only applies to HTMLElements.
- if (!element.isHTMLElement())
+ if (!element.isHTMLElement() && !(type == DocAll || type == NodeChildren || type == WindowNamedItems))
return false;
switch (type) {
@@ -249,17 +229,18 @@ template <> inline bool isMatchingElement(const HTMLCollection& htmlCollection,
return (element.hasLocalName(aTag) || element.hasLocalName(areaTag)) && element.fastHasAttribute(hrefAttr);
case DocAnchors:
return element.hasLocalName(aTag) && element.fastHasAttribute(nameAttr);
- case ClassCollectionType:
- case TagCollectionType:
- case HTMLTagCollectionType:
case DocAll:
case NodeChildren:
+ return true;
case FormControls:
case DocumentNamedItems:
case TableRows:
case WindowNamedItems:
case ChildNodeListType:
+ case ClassNodeListType:
case NameNodeListType:
+ case TagNodeListType:
+ case HTMLTagNodeListType:
case RadioNodeListType:
case RadioImgNodeListType:
case LabelsNodeListType:
@@ -273,6 +254,16 @@ template <> inline bool isMatchingElement(const LiveNodeList& nodeList, const El
return nodeList.nodeMatches(element);
}
+template <> inline bool isMatchingElement(const HTMLTagNodeList& nodeList, const Element& element)
+{
+ return nodeList.nodeMatchesInlined(element);
+}
+
+template <> inline bool isMatchingElement(const ClassNodeList& nodeList, const Element& element)
+{
+ return nodeList.nodeMatchesInlined(element);
+}
+
static Node* previousNode(const Node& base, const Node& previous, bool onlyIncludeDirectChildren)
{
return onlyIncludeDirectChildren ? previous.previousSibling() : NodeTraversal::previous(previous, &base);
@@ -371,6 +362,10 @@ inline Node* LiveNodeList::traverseToFirstElement(const ContainerNode& root) con
switch (type()) {
case ChildNodeListType:
return root.firstChild();
+ case HTMLTagNodeListType:
+ return firstMatchingElement(static_cast<const HTMLTagNodeList&>(*this), root);
+ case ClassNodeListType:
+ return firstMatchingElement(static_cast<const ClassNodeList&>(*this), root);
default:
return firstMatchingElement(static_cast<const LiveNodeList&>(*this), root);
}
@@ -383,6 +378,10 @@ inline Node* LiveNodeList::traverseForwardToOffset(unsigned offset, Node& curren
switch (type()) {
case ChildNodeListType:
return traverseSiblingsForwardToOffset(offset, currentNode, currentOffset);
+ case HTMLTagNodeListType:
+ return traverseMatchingElementsForwardToOffset(static_cast<const HTMLTagNodeList&>(*this), offset, toElement(currentNode), currentOffset, root);
+ case ClassNodeListType:
+ return traverseMatchingElementsForwardToOffset(static_cast<const ClassNodeList&>(*this), offset, toElement(currentNode), currentOffset, root);
default:
return traverseMatchingElementsForwardToOffset(*this, offset, toElement(currentNode), currentOffset, root);
}
diff --git a/third_party/WebKit/Source/core/html/HTMLObjectElement.cpp b/third_party/WebKit/Source/core/html/HTMLObjectElement.cpp
index 46505bd..cf644a1 100644
--- a/third_party/WebKit/Source/core/html/HTMLObjectElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLObjectElement.cpp
@@ -28,12 +28,12 @@
#include "bindings/v8/ScriptEventListener.h"
#include "core/dom/Attribute.h"
#include "core/dom/ElementTraversal.h"
+#include "core/dom/NodeList.h"
#include "core/dom/Text.h"
#include "core/dom/shadow/ShadowRoot.h"
#include "core/events/ThreadLocalEventNames.h"
#include "core/fetch/ImageResource.h"
#include "core/html/FormDataList.h"
-#include "core/html/HTMLCollection.h"
#include "core/html/HTMLDocument.h"
#include "core/html/HTMLImageLoader.h"
#include "core/html/HTMLMetaElement.h"
@@ -235,7 +235,7 @@ bool HTMLObjectElement::shouldAllowQuickTimeClassIdQuirk()
|| !equalIgnoringCase(classId(), "clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"))
return false;
- RefPtr<HTMLCollection> metaElements = document().getElementsByTagName(HTMLNames::metaTag.localName());
+ RefPtr<NodeList> metaElements = document().getElementsByTagName(HTMLNames::metaTag.localName());
unsigned length = metaElements->length();
for (unsigned i = 0; i < length; ++i) {
ASSERT(metaElements->item(i)->isHTMLElement());
diff --git a/third_party/WebKit/Source/web/WebHelperPluginImpl.cpp b/third_party/WebKit/Source/web/WebHelperPluginImpl.cpp
index bf08236..163e40b 100644
--- a/third_party/WebKit/Source/web/WebHelperPluginImpl.cpp
+++ b/third_party/WebKit/Source/web/WebHelperPluginImpl.cpp
@@ -40,7 +40,7 @@
#include "WebViewClient.h"
#include "WebViewImpl.h"
#include "WebWidgetClient.h"
-#include "core/html/HTMLCollection.h"
+#include "core/dom/NodeList.h"
#include "core/html/HTMLPlugInElement.h"
#include "core/loader/EmptyClients.h"
#include "core/loader/FrameLoadRequest.h"
@@ -180,7 +180,7 @@ WebPlugin* WebHelperPluginImpl::getPlugin()
{
ASSERT(m_page);
- RefPtr<HTMLCollection> objectElements = m_page->mainFrame()->document()->getElementsByTagName(WebCore::HTMLNames::objectTag.localName());
+ RefPtr<NodeList> objectElements = m_page->mainFrame()->document()->getElementsByTagName(WebCore::HTMLNames::objectTag.localName());
ASSERT(objectElements && objectElements->length() == 1);
if (!objectElements || objectElements->length() < 1)
return 0;
diff --git a/third_party/WebKit/Source/web/WebNode.cpp b/third_party/WebKit/Source/web/WebNode.cpp
index ba4168e..d069fbd 100644
--- a/third_party/WebKit/Source/web/WebNode.cpp
+++ b/third_party/WebKit/Source/web/WebNode.cpp
@@ -38,18 +38,17 @@
#include "WebDocument.h"
#include "WebElement.h"
#include "WebFrameImpl.h"
-#include "WebNodeCollection.h"
#include "WebNodeList.h"
#include "WebPluginContainer.h"
#include "WebPluginContainerImpl.h"
#include "bindings/v8/ExceptionState.h"
#include "core/dom/Document.h"
#include "core/dom/Element.h"
+#include "core/dom/EmptyNodeList.h"
+#include "core/events/Event.h"
#include "core/dom/Node.h"
#include "core/dom/NodeList.h"
#include "core/editing/markup.h"
-#include "core/events/Event.h"
-#include "core/html/HTMLCollection.h"
#include "core/rendering/RenderObject.h"
#include "core/rendering/RenderWidget.h"
#include "platform/Widget.h"
@@ -192,11 +191,11 @@ void WebNode::simulateClick()
m_private->dispatchSimulatedClick(0);
}
-WebNodeCollection WebNode::getElementsByTagName(const WebString& tag) const
+WebNodeList WebNode::getElementsByTagName(const WebString& tag) const
{
if (m_private->isContainerNode())
- return WebNodeCollection(toContainerNode(m_private.get())->getElementsByTagName(tag));
- return WebNodeCollection();
+ return WebNodeList(toContainerNode(m_private.get())->getElementsByTagName(tag));
+ return WebNodeList(EmptyNodeList::create(m_private.get()));
}
WebElement WebNode::querySelector(const WebString& tag, WebExceptionCode& ec) const
diff --git a/third_party/WebKit/Source/web/WebNodeList.cpp b/third_party/WebKit/Source/web/WebNodeList.cpp
index e8ca7ad..3a16283 100644
--- a/third_party/WebKit/Source/web/WebNodeList.cpp
+++ b/third_party/WebKit/Source/web/WebNodeList.cpp
@@ -31,10 +31,8 @@
#include "config.h"
#include "WebNodeList.h"
-#include "core/dom/Element.h"
#include "core/dom/Node.h"
#include "core/dom/NodeList.h"
-#include "core/html/HTMLCollection.h"
#include "wtf/PassRefPtr.h"
#include "WebNode.h"
@@ -43,32 +41,6 @@ using namespace WebCore;
namespace blink {
-// FIXME(crbug.com/235008): Remove once chromium has been updated to stop using
-// WebCollection as a WebNodeList.
-class NodeListWithInternalCollection FINAL : public NodeList {
-public:
- explicit NodeListWithInternalCollection(HTMLCollection* collection)
- : m_collection(collection)
- {
- }
-
- // We have null checks in the following methods because WebNodeList does not have a isNull() method
- // and callers need to be moved to WebNodeCollection and need to handle null using
- // WebNodeCollection::isNull().
- virtual unsigned length() const OVERRIDE { return m_collection ? m_collection->length() : 0; }
- virtual Node* item(unsigned index) const OVERRIDE { return m_collection ? m_collection->item(index) : 0; }
- virtual Node* namedItem(const AtomicString& elementId) const OVERRIDE { return m_collection ? m_collection->namedItem(elementId) : 0; }
-
-private:
- RefPtr<HTMLCollection> m_collection;
-};
-
-WebNodeList::WebNodeList(const WebNodeCollection& n)
- : m_private(0)
-{
- assign(new NodeListWithInternalCollection(n.m_private));
-}
-
void WebNodeList::reset()
{
assign(0);
diff --git a/third_party/WebKit/public/web/WebNode.h b/third_party/WebKit/public/web/WebNode.h
index 22e58b1..2457e70 100644
--- a/third_party/WebKit/public/web/WebNode.h
+++ b/third_party/WebKit/public/web/WebNode.h
@@ -45,7 +45,6 @@ class WebDOMEventListenerPrivate;
class WebDocument;
class WebElement;
class WebFrame;
-class WebNodeCollection;
class WebNodeList;
class WebPluginContainer;
@@ -114,7 +113,7 @@ public:
BLINK_EXPORT void addEventListener(const WebString& eventType, WebDOMEventListener* listener, bool useCapture);
BLINK_EXPORT bool dispatchEvent(const WebDOMEvent&);
BLINK_EXPORT void simulateClick();
- BLINK_EXPORT WebNodeCollection getElementsByTagName(const WebString&) const;
+ BLINK_EXPORT WebNodeList getElementsByTagName(const WebString&) const;
BLINK_EXPORT WebElement querySelector(const WebString&, WebExceptionCode&) const;
BLINK_EXPORT WebElement rootEditableElement() const;
BLINK_EXPORT bool focused() const;
diff --git a/third_party/WebKit/public/web/WebNodeCollection.h b/third_party/WebKit/public/web/WebNodeCollection.h
index d2f0465..a01ac7b 100644
--- a/third_party/WebKit/public/web/WebNodeCollection.h
+++ b/third_party/WebKit/public/web/WebNodeCollection.h
@@ -71,8 +71,6 @@ private:
void assign(WebCore::HTMLCollection*);
WebCore::HTMLCollection* m_private;
mutable unsigned m_current;
-
- friend class WebNodeList;
};
} // namespace blink
diff --git a/third_party/WebKit/public/web/WebNodeList.h b/third_party/WebKit/public/web/WebNodeList.h
index 14271f6..80484366 100644
--- a/third_party/WebKit/public/web/WebNodeList.h
+++ b/third_party/WebKit/public/web/WebNodeList.h
@@ -32,7 +32,6 @@
#define WebNodeList_h
#include "../platform/WebCommon.h"
-#include "WebNodeCollection.h"
namespace WebCore { class NodeList; }
#if BLINK_IMPLEMENTATION
@@ -55,10 +54,6 @@ public:
return *this;
}
- // FIXME(crbug.com/235008): Remove once chromium has been updated to stop using
- // WebCollection as a WebNodeList.
- BLINK_EXPORT WebNodeList(const WebNodeCollection&);
-
BLINK_EXPORT void reset();
BLINK_EXPORT void assign(const WebNodeList&);