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

Side by Side Diff: third_party/WebKit/Source/core/html/parser/HTMLPreloadScanner.h

Issue 2843013002: Revert of Don't lower priority for scripts inserted by doc.write (Closed)
Patch Set: 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
3 * Copyright (C) 2010 Google Inc. All Rights Reserved. 3 * Copyright (C) 2010 Google Inc. All Rights Reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 private: 75 private:
76 explicit CachedDocumentParameters(Document*); 76 explicit CachedDocumentParameters(Document*);
77 CachedDocumentParameters() = default; 77 CachedDocumentParameters() = default;
78 }; 78 };
79 79
80 class TokenPreloadScanner { 80 class TokenPreloadScanner {
81 WTF_MAKE_NONCOPYABLE(TokenPreloadScanner); 81 WTF_MAKE_NONCOPYABLE(TokenPreloadScanner);
82 USING_FAST_MALLOC(TokenPreloadScanner); 82 USING_FAST_MALLOC(TokenPreloadScanner);
83 83
84 public: 84 public:
85 enum class ScannerType { kMainDocument, kInsertion };
86
87 TokenPreloadScanner(const KURL& document_url, 85 TokenPreloadScanner(const KURL& document_url,
88 std::unique_ptr<CachedDocumentParameters>, 86 std::unique_ptr<CachedDocumentParameters>,
89 const MediaValuesCached::MediaValuesCachedData&, 87 const MediaValuesCached::MediaValuesCachedData&);
90 const ScannerType);
91 ~TokenPreloadScanner(); 88 ~TokenPreloadScanner();
92 89
93 void Scan(const HTMLToken&, 90 void Scan(const HTMLToken&,
94 const SegmentedString&, 91 const SegmentedString&,
95 PreloadRequestStream& requests, 92 PreloadRequestStream& requests,
96 ViewportDescriptionWrapper*, 93 ViewportDescriptionWrapper*,
97 bool* is_csp_meta_tag); 94 bool* is_csp_meta_tag);
98 void Scan(const CompactHTMLToken&, 95 void Scan(const CompactHTMLToken&,
99 const SegmentedString&, 96 const SegmentedString&,
100 PreloadRequestStream& requests, 97 PreloadRequestStream& requests,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 const KURL document_url_; 155 const KURL document_url_;
159 KURL predicted_base_element_url_; 156 KURL predicted_base_element_url_;
160 bool in_style_; 157 bool in_style_;
161 bool in_picture_; 158 bool in_picture_;
162 bool in_script_; 159 bool in_script_;
163 PictureData picture_data_; 160 PictureData picture_data_;
164 size_t template_count_; 161 size_t template_count_;
165 std::unique_ptr<CachedDocumentParameters> document_parameters_; 162 std::unique_ptr<CachedDocumentParameters> document_parameters_;
166 Persistent<MediaValuesCached> media_values_; 163 Persistent<MediaValuesCached> media_values_;
167 ClientHintsPreferences client_hints_preferences_; 164 ClientHintsPreferences client_hints_preferences_;
168 ScannerType scanner_type_;
169 165
170 bool did_rewind_ = false; 166 bool did_rewind_ = false;
171 167
172 Vector<Checkpoint> checkpoints_; 168 Vector<Checkpoint> checkpoints_;
173 }; 169 };
174 170
175 class CORE_EXPORT HTMLPreloadScanner { 171 class CORE_EXPORT HTMLPreloadScanner {
176 WTF_MAKE_NONCOPYABLE(HTMLPreloadScanner); 172 WTF_MAKE_NONCOPYABLE(HTMLPreloadScanner);
177 USING_FAST_MALLOC(HTMLPreloadScanner); 173 USING_FAST_MALLOC(HTMLPreloadScanner);
178 174
179 public: 175 public:
180 static std::unique_ptr<HTMLPreloadScanner> Create( 176 static std::unique_ptr<HTMLPreloadScanner> Create(
181 const HTMLParserOptions& options, 177 const HTMLParserOptions& options,
182 const KURL& document_url, 178 const KURL& document_url,
183 std::unique_ptr<CachedDocumentParameters> document_parameters, 179 std::unique_ptr<CachedDocumentParameters> document_parameters,
184 const MediaValuesCached::MediaValuesCachedData& media_values_cached_data, 180 const MediaValuesCached::MediaValuesCachedData&
185 const TokenPreloadScanner::ScannerType scanner_type) { 181 media_values_cached_data) {
186 return WTF::WrapUnique(new HTMLPreloadScanner( 182 return WTF::WrapUnique(new HTMLPreloadScanner(
187 options, document_url, std::move(document_parameters), 183 options, document_url, std::move(document_parameters),
188 media_values_cached_data, scanner_type)); 184 media_values_cached_data));
189 } 185 }
190 186
191 ~HTMLPreloadScanner(); 187 ~HTMLPreloadScanner();
192 188
193 void AppendToEnd(const SegmentedString&); 189 void AppendToEnd(const SegmentedString&);
194 PreloadRequestStream Scan(const KURL& document_base_element_url, 190 PreloadRequestStream Scan(const KURL& document_base_element_url,
195 ViewportDescriptionWrapper*); 191 ViewportDescriptionWrapper*);
196 192
197 private: 193 private:
198 HTMLPreloadScanner(const HTMLParserOptions&, 194 HTMLPreloadScanner(const HTMLParserOptions&,
199 const KURL& document_url, 195 const KURL& document_url,
200 std::unique_ptr<CachedDocumentParameters>, 196 std::unique_ptr<CachedDocumentParameters>,
201 const MediaValuesCached::MediaValuesCachedData&, 197 const MediaValuesCached::MediaValuesCachedData&);
202 const TokenPreloadScanner::ScannerType);
203 198
204 TokenPreloadScanner scanner_; 199 TokenPreloadScanner scanner_;
205 SegmentedString source_; 200 SegmentedString source_;
206 HTMLToken token_; 201 HTMLToken token_;
207 std::unique_ptr<HTMLTokenizer> tokenizer_; 202 std::unique_ptr<HTMLTokenizer> tokenizer_;
208 }; 203 };
209 204
210 } // namespace blink 205 } // namespace blink
211 206
212 #endif 207 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698