Diff
Modified: trunk/LayoutTests/ChangeLog (188734 => 188735)
--- trunk/LayoutTests/ChangeLog 2015-08-21 01:46:36 UTC (rev 188734)
+++ trunk/LayoutTests/ChangeLog 2015-08-21 02:10:29 UTC (rev 188735)
@@ -1,3 +1,24 @@
+2015-08-20 Chris Dumez <cdu...@apple.com>
+
+ getElementsByClassName() should return an HTMLCollection
+ https://bugs.webkit.org/show_bug.cgi?id=147980
+
+ Reviewed by Darin Adler.
+
+ * fast/dom/getElementsByClassName/dumpHTMLCollection-expected.txt: Renamed from LayoutTests/fast/dom/getElementsByClassName/dumpNodeList-expected.txt.
+ * fast/dom/getElementsByClassName/dumpHTMLCollection.html: Renamed from LayoutTests/fast/dom/getElementsByClassName/dumpNodeList.html.
+ Rename test now that getElementsByClassName returns an HTMLCollection
+ and update the test to update the HTMLCollection prototype instead
+ of the NodeList one.
+
+ * fast/dom/getElementsByClassName/return-type-expected.txt: Added.
+ * fast/dom/getElementsByClassName/return-type.html: Added.
+ New test that checks that getElementsByClassName() returns an
+ HTMLCollection.
+
+ * inspector/model/remote-object-expected.txt:
+ Rebaseline.
+
2015-08-20 Myles C. Maxfield <mmaxfi...@apple.com>
Test gardening after r188167
Copied: trunk/LayoutTests/fast/dom/getElementsByClassName/dumpHTMLCollection-expected.txt (from rev 188734, trunk/LayoutTests/fast/dom/getElementsByClassName/dumpNodeList-expected.txt) (0 => 188735)
--- trunk/LayoutTests/fast/dom/getElementsByClassName/dumpHTMLCollection-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/dom/getElementsByClassName/dumpHTMLCollection-expected.txt 2015-08-21 02:10:29 UTC (rev 188735)
@@ -0,0 +1,26 @@
+Line 1
+Line 2
+Line 3
+
+line 4
+line 5
+
+[object HTMLDivElement], [object HTMLDivElement], [object HTMLDivElement], length: 3
+[object HTMLDivElement], [object HTMLDivElement], [object HTMLDivElement], [object HTMLParagraphElement], length: 4
+[object HTMLDivElement], [object HTMLDivElement], length: 2
+[object HTMLDivElement], [object HTMLDivElement], length: 2
+length: 0
+length: 0
+length: 0
+length: 0
+length: 0
+[object HTMLDivElement], length: 1
+[object HTMLDivElement], [object HTMLParagraphElement], length: 2
+[object HTMLDivElement], length: 1
+[object HTMLDivElement], length: 1
+length: 0
+length: 0
+length: 0
+length: 0
+length: 0
+
Copied: trunk/LayoutTests/fast/dom/getElementsByClassName/dumpHTMLCollection.html (from rev 188734, trunk/LayoutTests/fast/dom/getElementsByClassName/dumpNodeList.html) (0 => 188735)
--- trunk/LayoutTests/fast/dom/getElementsByClassName/dumpHTMLCollection.html (rev 0)
+++ trunk/LayoutTests/fast/dom/getElementsByClassName/dumpHTMLCollection.html 2015-08-21 02:10:29 UTC (rev 188735)
@@ -0,0 +1,54 @@
+<html>
+<body>
+<div class="one">Line 1<div class="two">Line 2</div><p>Line <i>3</i></p></div>
+<div id="test" class="one two"><div class="one two">line 4</div><p class="two">line 5</p></div>
+<p><ol id="console"></ol></p>
+<script type="text/_javascript_">
+ if (window.testRunner)
+ testRunner.dumpAsText();
+
+ function log(message)
+ {
+ var item = document.createElement("li");
+ item.appendChild(document.createTextNode(message));
+ document.getElementById("console").appendChild(item);
+ }
+
+ HTMLCollection.prototype.dump = function()
+ {
+ var result = "";
+ var i = 0;
+ for (; i < this.length; i++)
+ result += this[i] + ", ";
+ result += "length: " + i;
+ return result;
+ }
+
+ try {
+ var elm = document.getElementById("test");
+
+ log(document.getElementsByClassName("one").dump());
+ log(document.getElementsByClassName("two").dump());
+ log(document.getElementsByClassName("one two").dump());
+ log(document.getElementsByClassName("one\t\t\n \ftwo").dump());
+ log(document.getElementsByClassName("").dump());
+ log(document.getElementsByClassName("onetwo").dump());
+ log(document.getElementsByClassName().dump());
+ log(document.getElementsByClassName(null).dump());
+ log(document.getElementsByClassName(undefined).dump());
+
+ log(elm.getElementsByClassName("one").dump());
+ log(elm.getElementsByClassName("two").dump());
+ log(elm.getElementsByClassName("one two").dump());
+ log(elm.getElementsByClassName("one\t\t\n \ftwo").dump());
+ log(elm.getElementsByClassName("").dump());
+ log(elm.getElementsByClassName("onetwo").dump());
+ log(elm.getElementsByClassName().dump());
+ log(elm.getElementsByClassName(null).dump());
+ log(elm.getElementsByClassName(undefined).dump());
+ } catch (ex) {
+ log("Exception: " + ex.description);
+ }
+</script>
+</body>
+</html>
Deleted: trunk/LayoutTests/fast/dom/getElementsByClassName/dumpNodeList-expected.txt (188734 => 188735)
--- trunk/LayoutTests/fast/dom/getElementsByClassName/dumpNodeList-expected.txt 2015-08-21 01:46:36 UTC (rev 188734)
+++ trunk/LayoutTests/fast/dom/getElementsByClassName/dumpNodeList-expected.txt 2015-08-21 02:10:29 UTC (rev 188735)
@@ -1,26 +0,0 @@
-Line 1
-Line 2
-Line 3
-
-line 4
-line 5
-
-[object HTMLDivElement], [object HTMLDivElement], [object HTMLDivElement], length: 3
-[object HTMLDivElement], [object HTMLDivElement], [object HTMLDivElement], [object HTMLParagraphElement], length: 4
-[object HTMLDivElement], [object HTMLDivElement], length: 2
-[object HTMLDivElement], [object HTMLDivElement], length: 2
-length: 0
-length: 0
-length: 0
-length: 0
-length: 0
-[object HTMLDivElement], length: 1
-[object HTMLDivElement], [object HTMLParagraphElement], length: 2
-[object HTMLDivElement], length: 1
-[object HTMLDivElement], length: 1
-length: 0
-length: 0
-length: 0
-length: 0
-length: 0
-
Deleted: trunk/LayoutTests/fast/dom/getElementsByClassName/dumpNodeList.html (188734 => 188735)
--- trunk/LayoutTests/fast/dom/getElementsByClassName/dumpNodeList.html 2015-08-21 01:46:36 UTC (rev 188734)
+++ trunk/LayoutTests/fast/dom/getElementsByClassName/dumpNodeList.html 2015-08-21 02:10:29 UTC (rev 188735)
@@ -1,54 +0,0 @@
-<html>
-<body>
-<div class="one">Line 1<div class="two">Line 2</div><p>Line <i>3</i></p></div>
-<div id="test" class="one two"><div class="one two">line 4</div><p class="two">line 5</p></div>
-<p><ol id="console"></ol></p>
-<script type="text/_javascript_">
- if (window.testRunner)
- testRunner.dumpAsText();
-
- function log(message)
- {
- var item = document.createElement("li");
- item.appendChild(document.createTextNode(message));
- document.getElementById("console").appendChild(item);
- }
-
- NodeList.prototype.dump = function()
- {
- var result = "";
- var i = 0;
- for (; i < this.length; i++)
- result += this[i] + ", ";
- result += "length: " + i;
- return result;
- }
-
- try {
- var elm = document.getElementById("test");
-
- log(document.getElementsByClassName("one").dump());
- log(document.getElementsByClassName("two").dump());
- log(document.getElementsByClassName("one two").dump());
- log(document.getElementsByClassName("one\t\t\n \ftwo").dump());
- log(document.getElementsByClassName("").dump());
- log(document.getElementsByClassName("onetwo").dump());
- log(document.getElementsByClassName().dump());
- log(document.getElementsByClassName(null).dump());
- log(document.getElementsByClassName(undefined).dump());
-
- log(elm.getElementsByClassName("one").dump());
- log(elm.getElementsByClassName("two").dump());
- log(elm.getElementsByClassName("one two").dump());
- log(elm.getElementsByClassName("one\t\t\n \ftwo").dump());
- log(elm.getElementsByClassName("").dump());
- log(elm.getElementsByClassName("onetwo").dump());
- log(elm.getElementsByClassName().dump());
- log(elm.getElementsByClassName(null).dump());
- log(elm.getElementsByClassName(undefined).dump());
- } catch (ex) {
- log("Exception: " + ex.description);
- }
-</script>
-</body>
-</html>
Added: trunk/LayoutTests/fast/dom/getElementsByClassName/return-type-expected.txt (0 => 188735)
--- trunk/LayoutTests/fast/dom/getElementsByClassName/return-type-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/dom/getElementsByClassName/return-type-expected.txt 2015-08-21 02:10:29 UTC (rev 188735)
@@ -0,0 +1,11 @@
+Tests that getElementsByTagName() returns an HTMLCollection.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS document.getElementsByClassName("test").__proto__ is HTMLCollection.prototype
+PASS document.body.getElementsByClassName("test").__proto__ is HTMLCollection.prototype
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/dom/getElementsByClassName/return-type.html (0 => 188735)
--- trunk/LayoutTests/fast/dom/getElementsByClassName/return-type.html (rev 0)
+++ trunk/LayoutTests/fast/dom/getElementsByClassName/return-type.html 2015-08-21 02:10:29 UTC (rev 188735)
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<script>
+description("Tests that getElementsByTagName() returns an HTMLCollection.");
+
+shouldBe('document.getElementsByClassName("test").__proto__', 'HTMLCollection.prototype');
+shouldBe('document.body.getElementsByClassName("test").__proto__', 'HTMLCollection.prototype');
+</script>
+<script src=""
+<body>
+</html>
Modified: trunk/LayoutTests/inspector/model/remote-object-expected.txt (188734 => 188735)
--- trunk/LayoutTests/inspector/model/remote-object-expected.txt 2015-08-21 01:46:36 UTC (rev 188734)
+++ trunk/LayoutTests/inspector/model/remote-object-expected.txt 2015-08-21 02:10:29 UTC (rev 188735)
@@ -2004,12 +2004,12 @@
"_type": "object",
"_subtype": "array",
"_objectId": "<filtered>",
- "_description": "NodeList",
+ "_description": "HTMLCollection",
"_size": 3,
"_preview": {
"_type": "object",
"_subtype": "array",
- "_description": "NodeList",
+ "_description": "HTMLCollection",
"_lossless": false,
"_overflow": false,
"_size": 3,
Modified: trunk/Source/WebCore/CMakeLists.txt (188734 => 188735)
--- trunk/Source/WebCore/CMakeLists.txt 2015-08-21 01:46:36 UTC (rev 188734)
+++ trunk/Source/WebCore/CMakeLists.txt 2015-08-21 02:10:29 UTC (rev 188735)
@@ -1357,7 +1357,7 @@
dom/CheckedRadioButtons.cpp
dom/ChildListMutationScope.cpp
dom/ChildNodeList.cpp
- dom/ClassNodeList.cpp
+ dom/ClassCollection.cpp
dom/ClientRect.cpp
dom/ClientRectList.cpp
dom/ClipboardEvent.cpp
Modified: trunk/Source/WebCore/ChangeLog (188734 => 188735)
--- trunk/Source/WebCore/ChangeLog 2015-08-21 01:46:36 UTC (rev 188734)
+++ trunk/Source/WebCore/ChangeLog 2015-08-21 02:10:29 UTC (rev 188735)
@@ -1,3 +1,95 @@
+2015-08-20 Chris Dumez <cdu...@apple.com>
+
+ getElementsByClassName() should return an HTMLCollection
+ https://bugs.webkit.org/show_bug.cgi?id=147980
+
+ Reviewed by Darin Adler.
+
+ Update Document.getElementsByClassName() and Element.getElementsByClassName()
+ to return an HTMLCollection instead of a NodeList, as per the specification:
+ - https://dom.spec.whatwg.org/#interface-document
+ - https://dom.spec.whatwg.org/#interface-element
+
+ This behavior is also consistent with other major browsers. Due to this and
+ the fact that NodeList / HTMLCollection pretty much the same API, the
+ compatibility risk should be fairly low.
+
+ I also verified that the performance is the same according to the following
+ performance test:
+ PerformanceTests/DOM/get-elements-by-class-name-traversal-uncached.html
+
+ Tests: fast/dom/getElementsByClassName/dumpHTMLCollection.html
+ fast/dom/getElementsByClassName/return-type.html
+
+ * CMakeLists.txt:
+ * WebCore.vcxproj/WebCore.vcxproj:
+ * WebCore.xcodeproj/project.pbxproj:
+ Rename ClassNodeList.cpp file.
+
+ * bindings/scripts/CodeGeneratorObjC.pm:
+ (GetImplClassName):
+ Indicate that NodeList is implemented as NodeListBase. This is
+ needed so that DOMNodeList can have either an HTMLCollection or
+ a NodeList as internal representation. NodeListBase is a new
+ common base class for HTMLCollection and NodeList.
+
+ * dom/ClassCollection.cpp: Renamed from Source/WebCore/dom/ClassNodeList.cpp.
+ (WebCore::ClassCollection::create):
+ (WebCore::ClassCollection::~ClassCollection):
+ * dom/ClassCollection.h: Renamed from Source/WebCore/dom/ClassNodeList.h.
+ (WebCore::ClassCollection::ClassCollection):
+ (WebCore::ClassCollection::elementMatches):
+ Rename ClassNodeList to ClassCollection and have it subclass
+ CachedHTMLCollection instead of ClassNodeList.
+
+ * dom/ContainerNode.cpp:
+ (WebCore::ContainerNode::getElementsByClassName):
+ Have getElementsByClassName return an HTMLCollection instead of a
+ NodeList.
+
+ (WebCore::ContainerNode::getElementsByClassNameForObjC):
+ New method returns a NodeListBase for ObjC bindings, so they can
+ convert the return value into a DOMNodeList. We need this to not
+ break ObjC API compatibility.
+
+ * dom/Document.idl:
+ * dom/Element.idl:
+ Have getElementsByClassName return an HTMLCollection instead of a
+ NodeList, except for ObjC bindings.
+
+ * dom/NodeList.h:
+ Have NodeList subclass NodeListBase.
+
+ * dom/NodeListBase.h: Added.
+ New common base interface for HTMLCollection and NodeList. This is
+ so that the internal representation for ObjC's DOMNodeList can be
+ a NodeListBase instead of a NodeList. This way, the ObjC API can
+ keep returning a DOMNodeList, even though our implementation now
+ returns an HTMLCollection instead of a NodeList.
+
+ * dom/NodeRareData.h:
+ (WebCore::NodeListTypeIdentifier<NameNodeList>::value):
+ (WebCore::NodeListTypeIdentifier<TagNodeList>::value):
+ (WebCore::NodeListTypeIdentifier<HTMLTagNodeList>::value):
+ (WebCore::NodeListTypeIdentifier<RadioNodeList>::value):
+ (WebCore::NodeListTypeIdentifier<LabelsNodeList>::value):
+ Drop ClassNodeList from the NodeListTypeIndentifiers.
+
+ * html/CollectionType.h:
+ Add new ByClass CollectionType for ClassCollection.
+
+ * html/GenericCachedHTMLCollection.cpp:
+ (WebCore::GenericCachedHTMLCollection<traversalType>::elementMatches):
+ Handle new ByClass CollectionType in the switch statement.
+
+ * html/HTMLCollection.cpp:
+ (WebCore::invalidationTypeExcludingIdAndNameAttributes):
+ (WebCore::HTMLCollection::~HTMLCollection):
+ Add support for new ByClass Collection type.
+
+ * html/HTMLCollection.h:
+ Have HTMLCollection subclass the NodeListBase interface.
+
2015-08-20 Myles C. Maxfield <mmaxfi...@apple.com>
Fix the iOS build after r188726
Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj (188734 => 188735)
--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj 2015-08-21 01:46:36 UTC (rev 188734)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj 2015-08-21 02:10:29 UTC (rev 188735)
@@ -13603,7 +13603,7 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
</ClCompile>
- <ClCompile Include="..\dom\ClassNodeList.cpp">
+ <ClCompile Include="..\dom\ClassCollection.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|Win32'">true</ExcludedFromBuild>
@@ -22020,7 +22020,7 @@
<ClInclude Include="..\dom\CheckedRadioButtons.h" />
<ClInclude Include="..\dom\ChildListMutationScope.h" />
<ClInclude Include="..\dom\ChildNodeList.h" />
- <ClInclude Include="..\dom\ClassNodeList.h" />
+ <ClInclude Include="..\dom\ClassCollection.h" />
<ClInclude Include="..\dom\ClientRect.h" />
<ClInclude Include="..\dom\ClientRectList.h" />
<ClInclude Include="..\dom\ClipboardEvent.h" />
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (188734 => 188735)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2015-08-21 01:46:36 UTC (rev 188734)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2015-08-21 02:10:29 UTC (rev 188735)
@@ -2677,10 +2677,10 @@
830030F51B7D33B500ED3AAC /* GenericCachedHTMLCollection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 830030F31B7D33A600ED3AAC /* GenericCachedHTMLCollection.cpp */; };
830030F61B7D33B500ED3AAC /* GenericCachedHTMLCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = 830030F41B7D33A600ED3AAC /* GenericCachedHTMLCollection.h */; };
830030F81B7D3B7800ED3AAC /* CachedHTMLCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = 830030F71B7D398800ED3AAC /* CachedHTMLCollection.h */; };
- 831D48C01B7D9A52006DE39A /* ClassNodeList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 831D48BE1B7D9A46006DE39A /* ClassNodeList.cpp */; };
- 831D48C11B7D9A52006DE39A /* ClassNodeList.h in Headers */ = {isa = PBXBuildFile; fileRef = 831D48BF1B7D9A46006DE39A /* ClassNodeList.h */; };
832B843419D8E55100B26055 /* SVGAnimateElementBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 832B843319D8E55100B26055 /* SVGAnimateElementBase.h */; };
832B843619D8E57400B26055 /* SVGAnimateElementBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 832B843519D8E57400B26055 /* SVGAnimateElementBase.cpp */; };
+ 8348BFAB1B85729800912F36 /* ClassCollection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8348BFA91B85729500912F36 /* ClassCollection.cpp */; };
+ 8348BFAC1B85729800912F36 /* ClassCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = 8348BFAA1B85729500912F36 /* ClassCollection.h */; };
83520C7E1A71BFCC006BD2AA /* CSSFontFamily.h in Headers */ = {isa = PBXBuildFile; fileRef = 83520C7D1A71BFCC006BD2AA /* CSSFontFamily.h */; };
835D363719FF6193004C93AB /* StyleBuilderCustom.h in Headers */ = {isa = PBXBuildFile; fileRef = 835D363619FF6193004C93AB /* StyleBuilderCustom.h */; };
836FBCEA178C113200B21A15 /* SVGAnimatedTypeAnimator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 836FBCE9178C113200B21A15 /* SVGAnimatedTypeAnimator.cpp */; };
@@ -2690,6 +2690,7 @@
8386A97019F61E4F00E1EC4A /* StyleBuilder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8386A96E19F61E4F00E1EC4A /* StyleBuilder.cpp */; };
839AAFEC1A0C0C8D00605F99 /* HTMLWBRElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 839AAFEA1A0C0C8D00605F99 /* HTMLWBRElement.cpp */; };
839AAFED1A0C0C8D00605F99 /* HTMLWBRElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 839AAFEB1A0C0C8D00605F99 /* HTMLWBRElement.h */; };
+ 83AAE64A1B85816B009FAF70 /* NodeListBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 83AAE6491B858168009FAF70 /* NodeListBase.h */; settings = {ATTRIBUTES = (Private, ); }; };
83B9687B19F8AB83004EF7AF /* StyleBuilderConverter.h in Headers */ = {isa = PBXBuildFile; fileRef = 83B9687919F8AB83004EF7AF /* StyleBuilderConverter.h */; };
83C05A5A1A686212007E5DEA /* StylePropertyShorthandFunctions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83C05A581A686212007E5DEA /* StylePropertyShorthandFunctions.cpp */; };
83C05A5B1A686212007E5DEA /* StylePropertyShorthandFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C05A591A686212007E5DEA /* StylePropertyShorthandFunctions.h */; };
@@ -10040,10 +10041,10 @@
830030F31B7D33A600ED3AAC /* GenericCachedHTMLCollection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GenericCachedHTMLCollection.cpp; sourceTree = "<group>"; };
830030F41B7D33A600ED3AAC /* GenericCachedHTMLCollection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GenericCachedHTMLCollection.h; sourceTree = "<group>"; };
830030F71B7D398800ED3AAC /* CachedHTMLCollection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CachedHTMLCollection.h; sourceTree = "<group>"; };
- 831D48BE1B7D9A46006DE39A /* ClassNodeList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ClassNodeList.cpp; sourceTree = "<group>"; };
- 831D48BF1B7D9A46006DE39A /* ClassNodeList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ClassNodeList.h; sourceTree = "<group>"; };
832B843319D8E55100B26055 /* SVGAnimateElementBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimateElementBase.h; sourceTree = "<group>"; };
832B843519D8E57400B26055 /* SVGAnimateElementBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGAnimateElementBase.cpp; sourceTree = "<group>"; };
+ 8348BFA91B85729500912F36 /* ClassCollection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ClassCollection.cpp; sourceTree = "<group>"; };
+ 8348BFAA1B85729500912F36 /* ClassCollection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ClassCollection.h; sourceTree = "<group>"; };
83520C7D1A71BFCC006BD2AA /* CSSFontFamily.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSFontFamily.h; sourceTree = "<group>"; };
835D363619FF6193004C93AB /* StyleBuilderCustom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleBuilderCustom.h; sourceTree = "<group>"; };
8369E58F1AFDD0300087DF68 /* NonDocumentTypeChildNode.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = NonDocumentTypeChildNode.idl; sourceTree = "<group>"; };
@@ -10054,6 +10055,7 @@
8386A96E19F61E4F00E1EC4A /* StyleBuilder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StyleBuilder.cpp; sourceTree = "<group>"; };
839AAFEA1A0C0C8D00605F99 /* HTMLWBRElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLWBRElement.cpp; sourceTree = "<group>"; };
839AAFEB1A0C0C8D00605F99 /* HTMLWBRElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLWBRElement.h; sourceTree = "<group>"; };
+ 83AAE6491B858168009FAF70 /* NodeListBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NodeListBase.h; sourceTree = "<group>"; };
83B9687919F8AB83004EF7AF /* StyleBuilderConverter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleBuilderConverter.h; sourceTree = "<group>"; };
83C05A581A686212007E5DEA /* StylePropertyShorthandFunctions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StylePropertyShorthandFunctions.cpp; sourceTree = "<group>"; };
83C05A591A686212007E5DEA /* StylePropertyShorthandFunctions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StylePropertyShorthandFunctions.h; sourceTree = "<group>"; };
@@ -23177,8 +23179,8 @@
83D26D3C1AFDCC50001B3873 /* ChildNode.idl */,
A818721A0977D3C0005826D9 /* ChildNodeList.cpp */,
A81872150977D3C0005826D9 /* ChildNodeList.h */,
- 831D48BE1B7D9A46006DE39A /* ClassNodeList.cpp */,
- 831D48BF1B7D9A46006DE39A /* ClassNodeList.h */,
+ 8348BFA91B85729500912F36 /* ClassCollection.cpp */,
+ 8348BFAA1B85729500912F36 /* ClassCollection.h */,
BCC065770F3CE1B700CD2D87 /* ClientRect.cpp */,
BCC065780F3CE1B700CD2D87 /* ClientRect.h */,
BCC065790F3CE1B700CD2D87 /* ClientRect.idl */,
@@ -23402,6 +23404,7 @@
1A750D870A90E394000FF215 /* NodeIterator.idl */,
A81872100977D3C0005826D9 /* NodeList.h */,
85ACA9FA0A9B631000671E90 /* NodeList.idl */,
+ 83AAE6491B858168009FAF70 /* NodeListBase.h */,
7CEAC1081B483D7F00334482 /* NodeOrString.cpp */,
7CEAC1061B483D1D00334482 /* NodeOrString.h */,
4FAB48661643A67E00F70C07 /* NodeRareData.cpp */,
@@ -24571,7 +24574,6 @@
85E711960AC5D5350053270F /* DOMDocumentTypeInternal.h in Headers */,
8518DCE90A9CC80D0091B7A6 /* DOMDOMImplementation.h in Headers */,
85E711970AC5D5350053270F /* DOMDOMImplementationInternal.h in Headers */,
- 831D48C11B7D9A52006DE39A /* ClassNodeList.h in Headers */,
52CCA9E815E3F64C0053C77F /* DOMDOMNamedFlowCollection.h in Headers */,
52CCA9EA15E3F64C0053C77F /* DOMDOMNamedFlowCollectionInternal.h in Headers */,
2D9A247415B9C2E300D34527 /* DOMDOMSecurityPolicy.h in Headers */,
@@ -24796,6 +24798,7 @@
85E711D90AC5D5350053270F /* DOMTextInternal.h in Headers */,
188604B40F2E654A000B6443 /* DOMTimer.h in Headers */,
05FD69E012845D4300B2BEB3 /* DOMTimeStamp.h in Headers */,
+ 8348BFAC1B85729800912F36 /* ClassCollection.h in Headers */,
76FC2B0C12370DA0006A991A /* DOMTokenList.h in Headers */,
0F54DCD51880F867003EEDBB /* DOMTouch.h in Headers */,
0F54DCD71880F867003EEDBB /* DOMTouchEvent.h in Headers */,
@@ -26233,6 +26236,7 @@
1477E7770BF4134A00152872 /* PageCache.h in Headers */,
CD5E5B5F1A15CE54000C609E /* PageConfiguration.h in Headers */,
F3820893147D35F90010BC06 /* PageConsoleAgent.h in Headers */,
+ 83AAE64A1B85816B009FAF70 /* NodeListBase.h in Headers */,
DAED203116F244480070EC0F /* PageConsoleClient.h in Headers */,
A5A2AF0C1829734300DE1729 /* PageDebuggable.h in Headers */,
F34742DD134362F000531BC2 /* PageDebuggerAgent.h in Headers */,
@@ -28997,7 +29001,6 @@
A9C6E64C0D7465E7006442E9 /* JSDOMPluginArrayCustom.cpp in Sources */,
A9C6E64D0D7465E7006442E9 /* JSDOMPluginCustom.cpp in Sources */,
E172AF8F1811BC3700FBADB9 /* JSDOMPromise.cpp in Sources */,
- 831D48C01B7D9A52006DE39A /* ClassNodeList.cpp in Sources */,
BC5A86B50C3367E800EEA649 /* JSDOMSelection.cpp in Sources */,
4ACBC0CA12713D0A0094F9B2 /* JSDOMSettableTokenList.cpp in Sources */,
C5137CF211A58378004ADB99 /* JSDOMStringList.cpp in Sources */,
@@ -29884,6 +29887,7 @@
B776D43D1104527500BEB0EC /* PrintContext.cpp in Sources */,
A8EA7EBD0A1945D000A8EF5F /* ProcessingInstruction.cpp in Sources */,
E44613EB0CD681B400FADA75 /* ProgressEvent.cpp in Sources */,
+ 8348BFAB1B85729800912F36 /* ClassCollection.cpp in Sources */,
A715E652134BBBEC00D8E713 /* ProgressShadowElement.cpp in Sources */,
1A2A68230B5BEDE70002A480 /* ProgressTracker.cpp in Sources */,
E4BBED0E14F4025D003F0B98 /* PropertySetCSSStyleDeclaration.cpp in Sources */,
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorObjC.pm (188734 => 188735)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorObjC.pm 2015-08-21 01:46:36 UTC (rev 188734)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorObjC.pm 2015-08-21 02:10:29 UTC (rev 188735)
@@ -420,6 +420,7 @@
{
my $name = shift;
+ return "NodeListBase" if $name eq "NodeList";
return "DOMWindow" if $name eq "AbstractView";
return $name;
}
Copied: trunk/Source/WebCore/dom/ClassCollection.cpp (from rev 188734, trunk/Source/WebCore/dom/ClassNodeList.cpp) (0 => 188735)
--- trunk/Source/WebCore/dom/ClassCollection.cpp (rev 0)
+++ trunk/Source/WebCore/dom/ClassCollection.cpp 2015-08-21 02:10:29 UTC (rev 188735)
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2007-2008, 2014, 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2007 David Smith (catfish....@gmail.com)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ClassCollection.h"
+
+#include "NodeRareData.h"
+#include "StyledElement.h"
+
+namespace WebCore {
+
+Ref<ClassCollection> ClassCollection::create(ContainerNode& rootNode, CollectionType type, const AtomicString& classNames)
+{
+ ASSERT(type == ByClass);
+ return adoptRef(*new ClassCollection(rootNode, type, classNames));
+}
+
+ClassCollection::~ClassCollection()
+{
+ ownerNode().nodeLists()->removeCachedCollection(this, m_originalClassNames);
+}
+
+} // namespace WebCore
Copied: trunk/Source/WebCore/dom/ClassCollection.h (from rev 188734, trunk/Source/WebCore/dom/ClassNodeList.h) (0 => 188735)
--- trunk/Source/WebCore/dom/ClassCollection.h (rev 0)
+++ trunk/Source/WebCore/dom/ClassCollection.h 2015-08-21 02:10:29 UTC (rev 188735)
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2007, 2014, 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2007 David Smith (catfish....@gmail.com)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ClassCollection_h
+#define ClassCollection_h
+
+#include "CachedHTMLCollection.h"
+#include "Element.h"
+#include "SpaceSplitString.h"
+
+namespace WebCore {
+
+class ClassCollection final : public CachedHTMLCollection<ClassCollection, CollectionTypeTraits<ByClass>::traversalType> {
+public:
+ static Ref<ClassCollection> create(ContainerNode&, CollectionType, const AtomicString& classNames);
+
+ virtual ~ClassCollection();
+
+ bool elementMatches(Element&) const;
+
+private:
+ ClassCollection(ContainerNode& rootNode, CollectionType, const AtomicString& classNames);
+
+ SpaceSplitString m_classNames;
+ AtomicString m_originalClassNames;
+};
+
+inline ClassCollection::ClassCollection(ContainerNode& rootNode, CollectionType type, const AtomicString& classNames)
+ : CachedHTMLCollection<ClassCollection, CollectionTypeTraits<ByClass>::traversalType>(rootNode, type)
+ , m_classNames(classNames, rootNode.document().inQuirksMode())
+ , m_originalClassNames(classNames)
+{
+}
+
+inline bool ClassCollection::elementMatches(Element& element) const
+{
+ if (!element.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 (!element.isStyledElement())
+ return false;
+ return element.classNames().containsAll(m_classNames);
+}
+
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_HTMLCOLLECTION(ClassCollection, ByClass)
+
+#endif // ClassCollection_h
Deleted: trunk/Source/WebCore/dom/ClassNodeList.cpp (188734 => 188735)
--- trunk/Source/WebCore/dom/ClassNodeList.cpp 2015-08-21 01:46:36 UTC (rev 188734)
+++ trunk/Source/WebCore/dom/ClassNodeList.cpp 2015-08-21 02:10:29 UTC (rev 188735)
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2007-2008, 2014 Apple Inc. All rights reserved.
- * Copyright (C) 2007 David Smith (catfish....@gmail.com)
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ClassNodeList.h"
-
-#include "NodeRareData.h"
-#include "StyledElement.h"
-
-namespace WebCore {
-
-Ref<ClassNodeList> ClassNodeList::create(ContainerNode& rootNode, const AtomicString& classNames)
-{
- return adoptRef(*new ClassNodeList(rootNode, classNames));
-}
-
-ClassNodeList::~ClassNodeList()
-{
- ownerNode().nodeLists()->removeCacheWithAtomicName(this, m_originalClassNames);
-}
-
-} // namespace WebCore
Deleted: trunk/Source/WebCore/dom/ClassNodeList.h (188734 => 188735)
--- trunk/Source/WebCore/dom/ClassNodeList.h 2015-08-21 01:46:36 UTC (rev 188734)
+++ trunk/Source/WebCore/dom/ClassNodeList.h 2015-08-21 02:10:29 UTC (rev 188735)
@@ -1,78 +0,0 @@
-/*
- * Copyright (C) 2007, 2014 Apple Inc. All rights reserved.
- * Copyright (C) 2007 David Smith (catfish....@gmail.com)
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ClassNodeList_h
-#define ClassNodeList_h
-
-#include "Element.h"
-#include "LiveNodeList.h"
-#include "Node.h"
-#include "SpaceSplitString.h"
-
-namespace WebCore {
-
-class ClassNodeList final : public CachedLiveNodeList<ClassNodeList> {
-public:
- static Ref<ClassNodeList> create(ContainerNode&, const AtomicString& classNames);
-
- virtual ~ClassNodeList();
-
- virtual bool elementMatches(Element&) const override;
- virtual bool isRootedAtDocument() const override { return false; }
-
-private:
- ClassNodeList(ContainerNode& rootNode, const AtomicString& classNames);
-
- SpaceSplitString m_classNames;
- AtomicString m_originalClassNames;
-};
-
-inline ClassNodeList::ClassNodeList(ContainerNode& rootNode, const AtomicString& classNames)
- : CachedLiveNodeList(rootNode, InvalidateOnClassAttrChange)
- , m_classNames(classNames, document().inQuirksMode())
- , m_originalClassNames(classNames)
-{
-}
-
-inline bool ClassNodeList::elementMatches(Element& element) const
-{
- if (!element.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 (!element.isStyledElement())
- return false;
- return element.classNames().containsAll(m_classNames);
-}
-
-} // namespace WebCore
-
-#endif // ClassNodeList_h
Modified: trunk/Source/WebCore/dom/ContainerNode.cpp (188734 => 188735)
--- trunk/Source/WebCore/dom/ContainerNode.cpp 2015-08-21 01:46:36 UTC (rev 188734)
+++ trunk/Source/WebCore/dom/ContainerNode.cpp 2015-08-21 02:10:29 UTC (rev 188735)
@@ -27,7 +27,7 @@
#include "ChildListMutationScope.h"
#include "Chrome.h"
#include "ChromeClient.h"
-#include "ClassNodeList.h"
+#include "ClassCollection.h"
#include "ContainerNodeAlgorithms.h"
#include "Editor.h"
#include "FloatRect.h"
@@ -890,11 +890,16 @@
return ensureRareData().ensureNodeLists().addCacheWithAtomicName<NameNodeList>(*this, elementName);
}
-RefPtr<NodeList> ContainerNode::getElementsByClassName(const AtomicString& classNames)
+RefPtr<HTMLCollection> ContainerNode::getElementsByClassName(const AtomicString& classNames)
{
- return ensureRareData().ensureNodeLists().addCacheWithAtomicName<ClassNodeList>(*this, classNames);
+ return ensureRareData().ensureNodeLists().addCachedCollection<ClassCollection>(*this, ByClass, classNames);
}
+RefPtr<NodeListBase> ContainerNode::getElementsByClassNameForObjC(const AtomicString& classNames)
+{
+ return getElementsByClassName(classNames);
+}
+
RefPtr<RadioNodeList> ContainerNode::radioNodeList(const AtomicString& name)
{
ASSERT(hasTagName(HTMLNames::formTag) || hasTagName(HTMLNames::fieldsetTag));
Modified: trunk/Source/WebCore/dom/ContainerNode.h (188734 => 188735)
--- trunk/Source/WebCore/dom/ContainerNode.h 2015-08-21 01:46:36 UTC (rev 188734)
+++ trunk/Source/WebCore/dom/ContainerNode.h 2015-08-21 02:10:29 UTC (rev 188735)
@@ -31,6 +31,7 @@
namespace WebCore {
class HTMLCollection;
+class NodeListBase;
class NodeOrString;
class QualifiedName;
class RenderElement;
@@ -145,7 +146,8 @@
RefPtr<NodeList> getElementsByTagName(const AtomicString&);
RefPtr<NodeList> getElementsByTagNameNS(const AtomicString& namespaceURI, const AtomicString& localName);
RefPtr<NodeList> getElementsByName(const String& elementName);
- RefPtr<NodeList> getElementsByClassName(const AtomicString& classNames);
+ RefPtr<HTMLCollection> getElementsByClassName(const AtomicString& classNames);
+ RefPtr<NodeListBase> getElementsByClassNameForObjC(const AtomicString& classNames);
RefPtr<RadioNodeList> radioNodeList(const AtomicString&);
// From the ParentNode interface - https://dom.spec.whatwg.org/#interface-parentnode
Modified: trunk/Source/WebCore/dom/DOMAllInOne.cpp (188734 => 188735)
--- trunk/Source/WebCore/dom/DOMAllInOne.cpp 2015-08-21 01:46:36 UTC (rev 188734)
+++ trunk/Source/WebCore/dom/DOMAllInOne.cpp 2015-08-21 02:10:29 UTC (rev 188735)
@@ -35,7 +35,7 @@
#include "CheckedRadioButtons.cpp"
#include "ChildListMutationScope.cpp"
#include "ChildNodeList.cpp"
-#include "ClassNodeList.cpp"
+#include "ClassCollection.cpp"
#include "ClientRect.cpp"
#include "ClientRectList.cpp"
#include "ClipboardEvent.cpp"
Modified: trunk/Source/WebCore/dom/Document.idl (188734 => 188735)
--- trunk/Source/WebCore/dom/Document.idl 2015-08-21 01:46:36 UTC (rev 188734)
+++ trunk/Source/WebCore/dom/Document.idl 2015-08-21 02:10:29 UTC (rev 188735)
@@ -210,7 +210,11 @@
#endif
// HTML 5
- NodeList getElementsByClassName([Default=Undefined] optional DOMString classNames);
+#if defined(LANGUAGE_OBJECTIVE_C) && LANGUAGE_OBJECTIVE_C
+ [ImplementedAs=getElementsByClassNameForObjC] NodeList getElementsByClassName([Default=Undefined] optional DOMString classNames);
+#else
+ HTMLCollection getElementsByClassName([Default=Undefined] optional DOMString classNames);
+#endif
readonly attribute Element activeElement;
boolean hasFocus();
Modified: trunk/Source/WebCore/dom/Element.idl (188734 => 188735)
--- trunk/Source/WebCore/dom/Element.idl 2015-08-21 01:46:36 UTC (rev 188734)
+++ trunk/Source/WebCore/dom/Element.idl 2015-08-21 02:10:29 UTC (rev 188735)
@@ -107,7 +107,11 @@
void scrollByPages([Default=Undefined] optional long pages);
// HTML 5
- NodeList getElementsByClassName([Default=Undefined] optional DOMString name);
+#if defined(LANGUAGE_OBJECTIVE_C) && LANGUAGE_OBJECTIVE_C
+ [ImplementedAs=getElementsByClassNameForObjC] NodeList getElementsByClassName([Default=Undefined] optional DOMString name);
+#else
+ HTMLCollection getElementsByClassName([Default=Undefined] optional DOMString name);
+#endif
[TreatNullAs=NullString, SetterRaisesException] attribute DOMString innerHTML;
[TreatNullAs=NullString, SetterRaisesException] attribute DOMString outerHTML;
Modified: trunk/Source/WebCore/dom/LiveNodeList.cpp (188734 => 188735)
--- trunk/Source/WebCore/dom/LiveNodeList.cpp 2015-08-21 01:46:36 UTC (rev 188734)
+++ trunk/Source/WebCore/dom/LiveNodeList.cpp 2015-08-21 02:10:29 UTC (rev 188735)
@@ -23,7 +23,7 @@
#include "config.h"
#include "LiveNodeList.h"
-#include "ClassNodeList.h"
+#include "ClassCollection.h"
#include "Element.h"
#include "ElementTraversal.h"
#include "HTMLCollection.h"
Modified: trunk/Source/WebCore/dom/Node.h (188734 => 188735)
--- trunk/Source/WebCore/dom/Node.h 2015-08-21 01:46:36 UTC (rev 188734)
+++ trunk/Source/WebCore/dom/Node.h 2015-08-21 02:10:29 UTC (rev 188735)
@@ -43,7 +43,7 @@
namespace WebCore {
class Attribute;
-class ClassNodeList;
+class ClassCollection;
class ContainerNode;
class DOMSettableTokenList;
class Document;
Modified: trunk/Source/WebCore/dom/NodeList.h (188734 => 188735)
--- trunk/Source/WebCore/dom/NodeList.h 2015-08-21 01:46:36 UTC (rev 188734)
+++ trunk/Source/WebCore/dom/NodeList.h 2015-08-21 02:10:29 UTC (rev 188735)
@@ -24,21 +24,19 @@
#ifndef NodeList_h
#define NodeList_h
+#include "NodeListBase.h"
#include "ScriptWrappable.h"
#include <wtf/Forward.h>
-#include <wtf/RefCounted.h>
namespace WebCore {
class Node;
-class NodeList : public ScriptWrappable, public RefCounted<NodeList> {
+class NodeList : public NodeListBase, public ScriptWrappable {
public:
virtual ~NodeList() { }
// DOM methods & attributes for NodeList
- virtual unsigned length() const = 0;
- virtual Node* item(unsigned index) const = 0;
virtual Node* namedItem(const AtomicString&) const = 0;
// Other methods (not part of DOM)
Added: trunk/Source/WebCore/dom/NodeListBase.h (0 => 188735)
--- trunk/Source/WebCore/dom/NodeListBase.h (rev 0)
+++ trunk/Source/WebCore/dom/NodeListBase.h 2015-08-21 02:10:29 UTC (rev 188735)
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef NodeListBase_h
+#define NodeListBase_h
+
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+class Node;
+
+// This is a common base class for NodeList / HTMLCollection to maintain legacy ObjC API compatibility.
+class NodeListBase : public RefCounted<NodeListBase> {
+public:
+ virtual ~NodeListBase() { }
+
+ virtual unsigned length() const = 0;
+ virtual Node* item(unsigned index) const = 0;
+};
+
+} // namespace WebCore.
+
+#endif // NodeListBase_h
+
Modified: trunk/Source/WebCore/dom/NodeRareData.h (188734 => 188735)
--- trunk/Source/WebCore/dom/NodeRareData.h 2015-08-21 01:46:36 UTC (rev 188734)
+++ trunk/Source/WebCore/dom/NodeRareData.h 2015-08-21 02:10:29 UTC (rev 188735)
@@ -23,7 +23,7 @@
#define NodeRareData_h
#include "ChildNodeList.h"
-#include "ClassNodeList.h"
+#include "ClassCollection.h"
#include "DOMSettableTokenList.h"
#include "HTMLCollection.h"
#include "HTMLNames.h"
@@ -47,12 +47,11 @@
class TreeScope;
template <class ListType> struct NodeListTypeIdentifier;
-template <> struct NodeListTypeIdentifier<ClassNodeList> { static int value() { return 0; } };
-template <> struct NodeListTypeIdentifier<NameNodeList> { static int value() { return 1; } };
-template <> struct NodeListTypeIdentifier<TagNodeList> { static int value() { return 2; } };
-template <> struct NodeListTypeIdentifier<HTMLTagNodeList> { static int value() { return 3; } };
-template <> struct NodeListTypeIdentifier<RadioNodeList> { static int value() { return 4; } };
-template <> struct NodeListTypeIdentifier<LabelsNodeList> { static int value() { return 5; } };
+template <> struct NodeListTypeIdentifier<NameNodeList> { static int value() { return 0; } };
+template <> struct NodeListTypeIdentifier<TagNodeList> { static int value() { return 1; } };
+template <> struct NodeListTypeIdentifier<HTMLTagNodeList> { static int value() { return 2; } };
+template <> struct NodeListTypeIdentifier<RadioNodeList> { static int value() { return 3; } };
+template <> struct NodeListTypeIdentifier<LabelsNodeList> { static int value() { return 4; } };
class NodeListsNodeData {
WTF_MAKE_NONCOPYABLE(NodeListsNodeData); WTF_MAKE_FAST_ALLOCATED;
Modified: trunk/Source/WebCore/html/CollectionType.h (188734 => 188735)
--- trunk/Source/WebCore/html/CollectionType.h 2015-08-21 01:46:36 UTC (rev 188734)
+++ trunk/Source/WebCore/html/CollectionType.h 2015-08-21 02:10:29 UTC (rev 188735)
@@ -50,7 +50,8 @@
SelectedOptions,
DataListOptions,
MapAreas,
- FormControls
+ FormControls,
+ ByClass,
};
enum class CollectionTraversalType { Descendants, ChildrenOnly, CustomForwardOnly };
Modified: trunk/Source/WebCore/html/GenericCachedHTMLCollection.cpp (188734 => 188735)
--- trunk/Source/WebCore/html/GenericCachedHTMLCollection.cpp 2015-08-21 01:46:36 UTC (rev 188734)
+++ trunk/Source/WebCore/html/GenericCachedHTMLCollection.cpp 2015-08-21 02:10:29 UTC (rev 188735)
@@ -71,6 +71,7 @@
return (element.hasTagName(aTag) || element.hasTagName(areaTag)) && element.fastHasAttribute(hrefAttr);
case DocAnchors:
return element.hasTagName(aTag) && element.fastHasAttribute(nameAttr);
+ case ByClass:
case DocAll:
case DocumentNamedItems:
case FormControls:
Modified: trunk/Source/WebCore/html/HTMLCollection.cpp (188734 => 188735)
--- trunk/Source/WebCore/html/HTMLCollection.cpp 2015-08-21 01:46:36 UTC (rev 188734)
+++ trunk/Source/WebCore/html/HTMLCollection.cpp 2015-08-21 02:10:29 UTC (rev 188735)
@@ -46,6 +46,7 @@
case DocumentNamedItems:
case FormControls:
return HTMLCollection::IsRootedAtDocument;
+ case ByClass:
case NodeChildren:
case TableTBodies:
case TSectionRows:
@@ -82,6 +83,8 @@
case DataListOptions:
// FIXME: We can do better some day.
return InvalidateOnAnyAttrChange;
+ case ByClass:
+ return InvalidateOnClassAttrChange;
case DocAnchors:
return InvalidateOnNameAttrChange;
case DocLinks:
@@ -113,9 +116,16 @@
if (hasNamedElementCache())
document().collectionWillClearIdNameMap(*this);
- // HTMLNameCollection removes cache by itself.
- if (type() != WindowNamedItems && type() != DocumentNamedItems)
+ // HTMLNameCollection & ClassCollection remove cache by themselves.
+ // FIXME: We need a cleaner way to handle this.
+ switch (type()) {
+ case ByClass:
+ case WindowNamedItems:
+ case DocumentNamedItems:
+ break;
+ default:
ownerNode().nodeLists()->removeCachedCollection(this);
+ }
}
void HTMLCollection::invalidateCache(Document& document)
Modified: trunk/Source/WebCore/html/HTMLCollection.h (188734 => 188735)
--- trunk/Source/WebCore/html/HTMLCollection.h 2015-08-21 01:46:36 UTC (rev 188734)
+++ trunk/Source/WebCore/html/HTMLCollection.h 2015-08-21 02:10:29 UTC (rev 188735)
@@ -58,13 +58,12 @@
#endif
};
-class HTMLCollection : public ScriptWrappable, public RefCounted<HTMLCollection> {
+class HTMLCollection : public NodeListBase, public ScriptWrappable {
public:
virtual ~HTMLCollection();
// DOM API
- virtual unsigned length() const = 0;
- virtual Element* item(unsigned offset) const = 0;
+ virtual Element* item(unsigned index) const = 0; // Tighten return type from NodeListBase::item().
virtual Element* namedItem(const AtomicString& name) const = 0;
PassRefPtr<NodeList> tags(const String&);