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

Unified Diff: Source/core/html/parser/HTMLParserIdioms.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/html/parser/HTMLParserIdioms.h
diff --git a/Source/core/html/parser/HTMLParserIdioms.h b/Source/core/html/parser/HTMLParserIdioms.h
index 68c7ded17985dfa94a42bba0132c8fdb1b417210..8be23681fad4789b8fba1b5f0e15602ccd029eac 100644
--- a/Source/core/html/parser/HTMLParserIdioms.h
+++ b/Source/core/html/parser/HTMLParserIdioms.h
@@ -67,7 +67,8 @@ bool parseHTMLNonNegativeInteger(const String&, unsigned int&);
// Inline implementations of some of the functions declared above.
-inline bool isHTMLSpace(UChar character)
+template<typename CharType>
+inline bool isHTMLSpace(CharType character)
{
// Histogram from Apple's page load test combined with some ad hoc browsing some other test suites.
//
@@ -82,6 +83,17 @@ inline bool isHTMLSpace(UChar character)
return character <= ' ' && (character == ' ' || character == '\n' || character == '\t' || character == '\r' || character == '\f');
}
+inline bool isHTMLSpace(UChar character)
+{
+ return isHTMLSpace<UChar>(character);
+}
abarth-chromium 2013/09/19 18:09:52 Why is this needed?
+
+template<typename CharType>
+inline bool isHTMLSpaceOrComma(CharType character)
+{
+ return isHTMLSpace(character) || character == ',';
+}
+
inline bool isHTMLLineBreak(UChar character)
{
return character <= '\r' && (character == '\n' || character == '\r');
@@ -89,7 +101,13 @@ inline bool isHTMLLineBreak(UChar character)
inline bool isNotHTMLSpace(UChar character)
{
- return !isHTMLSpace(character);
+ return !isHTMLSpace<UChar>(character);
+}
abarth-chromium 2013/09/19 18:09:52 Why do you need these concrete specializations?
Yoav Weiss 2013/09/20 04:54:27 I've added that to avoid changing the calls to isH
abarth-chromium 2013/09/20 16:08:07 Most of the callers should be able to infer the ty
+
+template<typename CharType>
+inline bool isNotHTMLSpace(CharType character)
+{
+ return !isHTMLSpace<CharType>(character);
}
bool threadSafeMatch(const QualifiedName&, const QualifiedName&);

Powered by Google App Engine
This is Rietveld 408576698