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

Unified Diff: third_party/WebKit/Source/core/dom/SpaceSplitString.cpp

Issue 2903803002: DOMTokenList should unify duplicated tokens. (Closed)
Patch Set: Update a -expected.txt Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/frames/sandboxed-iframe-attribute-parsing-03-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/dom/SpaceSplitString.cpp
diff --git a/third_party/WebKit/Source/core/dom/SpaceSplitString.cpp b/third_party/WebKit/Source/core/dom/SpaceSplitString.cpp
index 9f4b94c66d95c5e869291bf13f07aec88a277076..79eae89657561295cbb4807fa39a1871f3b335f6 100644
--- a/third_party/WebKit/Source/core/dom/SpaceSplitString.cpp
+++ b/third_party/WebKit/Source/core/dom/SpaceSplitString.cpp
@@ -23,6 +23,7 @@
#include "core/html/parser/HTMLParserIdioms.h"
#include "platform/wtf/ASCIICType.h"
#include "platform/wtf/HashMap.h"
+#include "platform/wtf/HashSet.h"
#include "platform/wtf/text/AtomicStringHash.h"
namespace blink {
@@ -48,10 +49,12 @@ static inline bool HasNonASCIIOrUpper(const String& string) {
return HasNonASCIIOrUpper(string.Characters16(), length);
}
+// https://dom.spec.whatwg.org/#concept-ordered-set-parser
template <typename CharacterType>
inline void SpaceSplitString::Data::CreateVector(
const CharacterType* characters,
unsigned length) {
+ HashSet<AtomicString> token_set;
unsigned start = 0;
while (true) {
while (start < length && IsHTMLSpace<CharacterType>(characters[start]))
@@ -62,7 +65,11 @@ inline void SpaceSplitString::Data::CreateVector(
while (end < length && IsNotHTMLSpace<CharacterType>(characters[end]))
++end;
- vector_.push_back(AtomicString(characters + start, end - start));
+ AtomicString token(characters + start, end - start);
+ if (!token_set.Contains(token)) {
+ token_set.insert(token);
+ vector_.push_back(token);
+ }
start = end + 1;
}
@@ -110,7 +117,6 @@ void SpaceSplitString::Data::Remove(unsigned index) {
}
void SpaceSplitString::Add(const AtomicString& string) {
- // FIXME: add() does not allow duplicates but createVector() does.
if (Contains(string))
return;
EnsureUnique();
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/frames/sandboxed-iframe-attribute-parsing-03-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698