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

Side by Side Diff: Source/core/html/parser/CSSPreloadScanner.cpp

Issue 457413002: Defer late and async scripts (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Lower priorities for late/async scripts Created 6 years, 4 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008, 2010 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008, 2010 Apple Inc. All Rights Reserved.
3 * Copyright (C) 2009 Torch Mobile, Inc. http://www.torchmobile.com/ 3 * Copyright (C) 2009 Torch Mobile, Inc. http://www.torchmobile.com/
4 * Copyright (C) 2010 Google Inc. All Rights Reserved. 4 * Copyright (C) 2010 Google Inc. All Rights Reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 18 matching lines...) Expand all
29 #include "core/html/parser/CSSPreloadScanner.h" 29 #include "core/html/parser/CSSPreloadScanner.h"
30 30
31 #include "core/FetchInitiatorTypeNames.h" 31 #include "core/FetchInitiatorTypeNames.h"
32 #include "core/html/parser/HTMLParserIdioms.h" 32 #include "core/html/parser/HTMLParserIdioms.h"
33 #include "platform/text/SegmentedString.h" 33 #include "platform/text/SegmentedString.h"
34 34
35 namespace blink { 35 namespace blink {
36 36
37 CSSPreloadScanner::CSSPreloadScanner() 37 CSSPreloadScanner::CSSPreloadScanner()
38 : m_state(Initial) 38 : m_state(Initial)
39 , m_isBeforeBody(true)
39 , m_requests(0) 40 , m_requests(0)
40 { 41 {
41 } 42 }
42 43
43 CSSPreloadScanner::~CSSPreloadScanner() 44 CSSPreloadScanner::~CSSPreloadScanner()
44 { 45 {
45 } 46 }
46 47
47 void CSSPreloadScanner::reset() 48 void CSSPreloadScanner::reset()
48 { 49 {
49 m_state = Initial; 50 m_state = Initial;
50 m_rule.clear(); 51 m_rule.clear();
51 m_ruleValue.clear(); 52 m_ruleValue.clear();
53 m_isBeforeBody = true;
52 } 54 }
53 55
54 template<typename Char> 56 template<typename Char>
55 void CSSPreloadScanner::scanCommon(const Char* begin, const Char* end, const Seg mentedString& source, PreloadRequestStream& requests) 57 void CSSPreloadScanner::scanCommon(const Char* begin, const Char* end, const Seg mentedString& source, PreloadRequestStream& requests)
56 { 58 {
57 m_requests = &requests; 59 m_requests = &requests;
58 for (const Char* it = begin; it != end && m_state != DoneParsingImportRules; ++it) 60 for (const Char* it = begin; it != end && m_state != DoneParsingImportRules; ++it)
59 tokenize(*it, source); 61 tokenize(*it, source);
60 m_requests = 0; 62 m_requests = 0;
61 } 63 }
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 } 211 }
210 212
211 void CSSPreloadScanner::emitRule(const SegmentedString& source) 213 void CSSPreloadScanner::emitRule(const SegmentedString& source)
212 { 214 {
213 if (equalIgnoringCase(m_rule, "import")) { 215 if (equalIgnoringCase(m_rule, "import")) {
214 String url = parseCSSStringOrURL(m_ruleValue.toString()); 216 String url = parseCSSStringOrURL(m_ruleValue.toString());
215 if (!url.isEmpty()) { 217 if (!url.isEmpty()) {
216 KURL baseElementURL; // FIXME: This should be passed in from the HTM LPreloadScaner via scan()! 218 KURL baseElementURL; // FIXME: This should be passed in from the HTM LPreloadScaner via scan()!
217 TextPosition position = TextPosition(source.currentLine(), source.cu rrentColumn()); 219 TextPosition position = TextPosition(source.currentLine(), source.cu rrentColumn());
218 OwnPtr<PreloadRequest> request = PreloadRequest::create(FetchInitiat orTypeNames::css, position, url, baseElementURL, Resource::CSSStyleSheet); 220 OwnPtr<PreloadRequest> request = PreloadRequest::create(FetchInitiat orTypeNames::css, position, url, baseElementURL, Resource::CSSStyleSheet);
221 request->setIsBeforeBody(m_isBeforeBody);
219 // FIXME: Should this be including the charset in the preload reques t? 222 // FIXME: Should this be including the charset in the preload reques t?
220 m_requests->append(request.release()); 223 m_requests->append(request.release());
221 } 224 }
222 m_state = Initial; 225 m_state = Initial;
223 } else if (equalIgnoringCase(m_rule, "charset")) 226 } else if (equalIgnoringCase(m_rule, "charset"))
224 m_state = Initial; 227 m_state = Initial;
225 else 228 else
226 m_state = DoneParsingImportRules; 229 m_state = DoneParsingImportRules;
227 m_rule.clear(); 230 m_rule.clear();
228 m_ruleValue.clear(); 231 m_ruleValue.clear();
229 } 232 }
230 233
231 } 234 }
OLDNEW
« no previous file with comments | « Source/core/html/parser/CSSPreloadScanner.h ('k') | Source/core/html/parser/HTMLPreloadScanner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698