Bug 171388

Summary: Update DOMTokenList.replace() to match the latest DOM specification
Product: WebKit Reporter: Chris Dumez <cdumez>
Component: DOMAssignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: achristensen, annevk, benjamin, buildbot, cdumez, cmarcelo, commit-queue, darin, dbates, esprehn+autocc, ggaren, gyuyoung.kim, rniwa, sam
Priority: P2 Keywords: WebExposed
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch none

Description Chris Dumez 2017-04-27 12:48:21 PDT
Update DOMTokenList.replace() to match the latest DOM specification after:
- https://github.com/whatwg/dom/issues/442
- https://github.com/whatwg/infra/pull/126

Test:
- https://github.com/w3c/web-platform-tests/pull/5725

Basically, (a, b, c).replace(a, c) should return (c, b) instead of (b, c).
Comment 1 Chris Dumez 2017-04-27 14:51:51 PDT
Created attachment 308450 [details]
Patch
Comment 2 Build Bot 2017-04-27 14:54:24 PDT
Attachment 308450 [details] did not pass style-queue:


ERROR: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:566:  More than one command on the same line  [whitespace/newline] [4]
ERROR: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:567:  More than one command on the same line  [whitespace/newline] [4]
ERROR: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:570:  More than one command on the same line  [whitespace/newline] [4]
ERROR: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:571:  More than one command on the same line  [whitespace/newline] [4]
ERROR: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:572:  More than one command on the same line  [whitespace/newline] [4]
ERROR: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:573:  More than one command on the same line  [whitespace/newline] [4]
ERROR: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:574:  More than one command on the same line  [whitespace/newline] [4]
ERROR: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:575:  More than one command on the same line  [whitespace/newline] [4]
ERROR: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:601:  More than one command on the same line  [whitespace/newline] [4]
ERROR: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:604:  More than one command on the same line  [whitespace/newline] [4]
ERROR: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:607:  More than one command on the same line  [whitespace/newline] [4]
ERROR: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:609:  More than one command on the same line  [whitespace/newline] [4]
ERROR: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:643:  More than one command on the same line  [whitespace/newline] [4]
ERROR: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:645:  More than one command on the same line  [whitespace/newline] [4]
ERROR: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:647:  More than one command on the same line  [whitespace/newline] [4]
ERROR: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:650:  More than one command on the same line  [whitespace/newline] [4]
Total errors found: 16 in 8 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Alex Christensen 2017-04-27 15:56:52 PDT
Comment on attachment 308450 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=308450&action=review

> Source/WebCore/html/DOMTokenList.cpp:181
> +    tokens.removeFirstMatching(matchesItemOrReplacement, index + 1);

Do we only want to remove the first one? Can the lists have duplicate values? Can we test this? Can we assert that there aren't duplicates?
Comment 4 Chris Dumez 2017-04-27 16:10:27 PDT
Comment on attachment 308450 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=308450&action=review

>> Source/WebCore/html/DOMTokenList.cpp:181
>> +    tokens.removeFirstMatching(matchesItemOrReplacement, index + 1);
> 
> Do we only want to remove the first one? Can the lists have duplicate values? Can we test this? Can we assert that there aren't duplicates?

I can assert, yes. a DOMTokenList is meant to wrap an ordered set as per the spec, so there should be no duplicate.
Comment 5 Chris Dumez 2017-04-27 18:39:38 PDT
Created attachment 308490 [details]
Patch
Comment 6 Chris Dumez 2017-04-27 18:40:09 PDT
(In reply to Chris Dumez from comment #4)
> Comment on attachment 308450 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=308450&action=review
> 
> >> Source/WebCore/html/DOMTokenList.cpp:181
> >> +    tokens.removeFirstMatching(matchesItemOrReplacement, index + 1);
> > 
> > Do we only want to remove the first one? Can the lists have duplicate values? Can we test this? Can we assert that there aren't duplicates?
> 
> I can assert, yes. a DOMTokenList is meant to wrap an ordered set as per the
> spec, so there should be no duplicate.

I added assertions in this latest iteration.
Comment 7 Build Bot 2017-04-27 18:42:08 PDT
Attachment 308490 [details] did not pass style-queue:


ERROR: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:566:  More than one command on the same line  [whitespace/newline] [4]
ERROR: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:567:  More than one command on the same line  [whitespace/newline] [4]
ERROR: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:570:  More than one command on the same line  [whitespace/newline] [4]
ERROR: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:571:  More than one command on the same line  [whitespace/newline] [4]
ERROR: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:572:  More than one command on the same line  [whitespace/newline] [4]
ERROR: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:573:  More than one command on the same line  [whitespace/newline] [4]
ERROR: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:574:  More than one command on the same line  [whitespace/newline] [4]
ERROR: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:575:  More than one command on the same line  [whitespace/newline] [4]
ERROR: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:601:  More than one command on the same line  [whitespace/newline] [4]
ERROR: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:604:  More than one command on the same line  [whitespace/newline] [4]
ERROR: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:607:  More than one command on the same line  [whitespace/newline] [4]
ERROR: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:609:  More than one command on the same line  [whitespace/newline] [4]
ERROR: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:643:  More than one command on the same line  [whitespace/newline] [4]
ERROR: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:645:  More than one command on the same line  [whitespace/newline] [4]
ERROR: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:647:  More than one command on the same line  [whitespace/newline] [4]
ERROR: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:650:  More than one command on the same line  [whitespace/newline] [4]
Total errors found: 16 in 8 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 8 Chris Dumez 2017-04-28 13:52:32 PDT
Comment on attachment 308490 [details]
Patch

Clearing flags on attachment: 308490

Committed r215943: <http://trac.webkit.org/changeset/215943>
Comment 9 Chris Dumez 2017-04-28 13:52:35 PDT
All reviewed patches have been landed.  Closing bug.