From 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c Mon Sep 17 00:00:00 2001 From: Lorry Tar Creator Date: Tue, 27 Jun 2017 06:07:23 +0000 Subject: webkitgtk-2.16.5 --- Source/WebCore/html/parser/CSSPreloadScanner.cpp | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) (limited to 'Source/WebCore/html/parser/CSSPreloadScanner.cpp') diff --git a/Source/WebCore/html/parser/CSSPreloadScanner.cpp b/Source/WebCore/html/parser/CSSPreloadScanner.cpp index 75a7a93b1..8027948b1 100644 --- a/Source/WebCore/html/parser/CSSPreloadScanner.cpp +++ b/Source/WebCore/html/parser/CSSPreloadScanner.cpp @@ -29,7 +29,7 @@ #include "CSSPreloadScanner.h" #include "HTMLParserIdioms.h" -#include +#include namespace WebCore { @@ -53,7 +53,7 @@ void CSSPreloadScanner::reset() void CSSPreloadScanner::scan(const HTMLToken::DataVector& data, PreloadRequestStream& requests) { ASSERT(!m_requests); - TemporaryChange change(m_requests, &requests); + SetForScope change(m_requests, &requests); for (UChar c : data) { if (m_state == DoneParsingImportRules) @@ -97,7 +97,7 @@ inline void CSSPreloadScanner::tokenize(UChar c) m_state = Comment; break; case RuleStart: - if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')) { + if (isASCIIAlpha(c)) { m_rule.clear(); m_ruleValue.clear(); m_rule.append(c); @@ -195,25 +195,18 @@ static String parseCSSStringOrURL(const UChar* characters, size_t length) return String(characters + offset, reducedLength); } -template -static inline bool ruleEqualIgnoringCase(const Vector& rule, const char (&reference)[referenceLength]) -{ - unsigned referenceCharactersLength = referenceLength - 1; - return rule.size() == referenceCharactersLength && equalIgnoringCase(reference, rule.data(), referenceCharactersLength); -} - void CSSPreloadScanner::emitRule() { - if (ruleEqualIgnoringCase(m_rule, "import")) { + StringView rule(m_rule.data(), m_rule.size()); + if (equalLettersIgnoringASCIICase(rule, "import")) { String url = parseCSSStringOrURL(m_ruleValue.data(), m_ruleValue.size()); if (!url.isEmpty()) { - URL baseElementURL; // FIXME: This should be passed in from the HTMLPreloadScaner via scan()! - + URL baseElementURL; // FIXME: This should be passed in from the HTMLPreloadScanner via scan(): without it we will get relative URLs wrong. // FIXME: Should this be including the charset in the preload request? - m_requests->append(std::make_unique("css", url, baseElementURL, CachedResource::CSSStyleSheet, String())); + m_requests->append(std::make_unique("css", url, baseElementURL, CachedResource::CSSStyleSheet, String(), PreloadRequest::ModuleScript::No)); } m_state = Initial; - } else if (ruleEqualIgnoringCase(m_rule, "charset")) + } else if (equalLettersIgnoringASCIICase(rule, "charset")) m_state = Initial; else m_state = DoneParsingImportRules; -- cgit v1.2.1