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

Unified Diff: Source/core/platform/ParsingUtilities.h

Issue 23861003: Enable srcset support in HTMLImageElement (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rewrote HTMLSrcsetParser, making it more efficient and readable. Addressed abarth's review comments. Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/platform/ParsingUtilities.h
diff --git a/Source/core/platform/ParsingUtilities.h b/Source/core/platform/ParsingUtilities.h
new file mode 100644
index 0000000000000000000000000000000000000000..dbd9dca64a150612edc792b43f10336230b740cd
--- /dev/null
+++ b/Source/core/platform/ParsingUtilities.h
@@ -0,0 +1,50 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef ParsingUtilities_h
+#define ParsingUtilities_h
+
+template<typename CharType>
+bool skipExactly(const CharType*& position, const CharType* end, CharType delimiter)
+{
+ if (position < end && *position == delimiter) {
+ ++position;
+ return true;
+ }
+ return false;
+}
+
+template<typename CharType, bool characterPredicate(CharType)>
cbiesinger 2013/09/19 23:01:44 Couldn't you make CharType the second template arg
abarth-chromium 2013/09/20 16:08:07 +1
+bool skipExactly(const CharType*& position, const CharType* end)
+{
+ if (position < end && characterPredicate(*position)) {
+ ++position;
+ return true;
+ }
+ return false;
+}
+
+template<typename CharType>
+void skipUntil(const CharType*& position, const CharType* end, CharType delimiter)
+{
+ while (position < end && *position != delimiter)
+ ++position;
+}
+
+template<typename CharType, bool characterPredicate(CharType)>
+void skipUntil(const CharType*& position, const CharType* end)
+{
+ while (position < end && !characterPredicate(*position))
+ ++position;
+}
+
+template<typename CharType, bool characterPredicate(CharType)>
+void skipWhile(const CharType*& position, const CharType* end)
+{
+ while (position < end && characterPredicate(*position))
+ ++position;
+}
+
+#endif
+
« Source/core/html/parser/HTMLSrcsetParser.cpp ('K') | « Source/core/page/RuntimeEnabledFeatures.in ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698