OLD | NEW |
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 16 matching lines...) Expand all Loading... |
27 #ifndef HTMLPreloadScanner_h | 27 #ifndef HTMLPreloadScanner_h |
28 #define HTMLPreloadScanner_h | 28 #define HTMLPreloadScanner_h |
29 | 29 |
30 #include "core/CoreExport.h" | 30 #include "core/CoreExport.h" |
31 #include "core/css/MediaValuesCached.h" | 31 #include "core/css/MediaValuesCached.h" |
32 #include "core/dom/ViewportDescription.h" | 32 #include "core/dom/ViewportDescription.h" |
33 #include "core/html/parser/CSSPreloadScanner.h" | 33 #include "core/html/parser/CSSPreloadScanner.h" |
34 #include "core/html/parser/CompactHTMLToken.h" | 34 #include "core/html/parser/CompactHTMLToken.h" |
35 #include "core/html/parser/HTMLToken.h" | 35 #include "core/html/parser/HTMLToken.h" |
36 #include "platform/text/SegmentedString.h" | 36 #include "platform/text/SegmentedString.h" |
37 #include "wtf/PtrUtil.h" | |
38 #include "wtf/Vector.h" | 37 #include "wtf/Vector.h" |
39 #include <memory> | |
40 | 38 |
41 namespace blink { | 39 namespace blink { |
42 | 40 |
43 typedef size_t TokenPreloadScannerCheckpoint; | 41 typedef size_t TokenPreloadScannerCheckpoint; |
44 | 42 |
45 class HTMLParserOptions; | 43 class HTMLParserOptions; |
46 class HTMLTokenizer; | 44 class HTMLTokenizer; |
47 class SegmentedString; | 45 class SegmentedString; |
48 | 46 |
49 struct ViewportDescriptionWrapper { | 47 struct ViewportDescriptionWrapper { |
50 ViewportDescription description; | 48 ViewportDescription description; |
51 bool set; | 49 bool set; |
52 ViewportDescriptionWrapper() | 50 ViewportDescriptionWrapper() |
53 : set(false) | 51 : set(false) |
54 { | 52 { |
55 } | 53 } |
56 }; | 54 }; |
57 | 55 |
58 struct CORE_EXPORT CachedDocumentParameters { | 56 struct CORE_EXPORT CachedDocumentParameters { |
59 USING_FAST_MALLOC(CachedDocumentParameters); | 57 USING_FAST_MALLOC(CachedDocumentParameters); |
60 public: | 58 public: |
61 static std::unique_ptr<CachedDocumentParameters> create(Document* document) | 59 static PassOwnPtr<CachedDocumentParameters> create(Document* document) |
62 { | 60 { |
63 return wrapUnique(new CachedDocumentParameters(document)); | 61 return adoptPtr(new CachedDocumentParameters(document)); |
64 } | 62 } |
65 | 63 |
66 bool doHtmlPreloadScanning; | 64 bool doHtmlPreloadScanning; |
67 bool doDocumentWritePreloadScanning; | 65 bool doDocumentWritePreloadScanning; |
68 Length defaultViewportMinWidth; | 66 Length defaultViewportMinWidth; |
69 bool viewportMetaZeroValuesQuirk; | 67 bool viewportMetaZeroValuesQuirk; |
70 bool viewportMetaEnabled; | 68 bool viewportMetaEnabled; |
71 ReferrerPolicy referrerPolicy; | 69 ReferrerPolicy referrerPolicy; |
72 | 70 |
73 private: | 71 private: |
74 explicit CachedDocumentParameters(Document*); | 72 explicit CachedDocumentParameters(Document*); |
75 }; | 73 }; |
76 | 74 |
77 class TokenPreloadScanner { | 75 class TokenPreloadScanner { |
78 WTF_MAKE_NONCOPYABLE(TokenPreloadScanner); USING_FAST_MALLOC(TokenPreloadSca
nner); | 76 WTF_MAKE_NONCOPYABLE(TokenPreloadScanner); USING_FAST_MALLOC(TokenPreloadSca
nner); |
79 public: | 77 public: |
80 TokenPreloadScanner(const KURL& documentURL, std::unique_ptr<CachedDocumentP
arameters>, const MediaValuesCached::MediaValuesCachedData&); | 78 TokenPreloadScanner(const KURL& documentURL, PassOwnPtr<CachedDocumentParame
ters>, const MediaValuesCached::MediaValuesCachedData&); |
81 ~TokenPreloadScanner(); | 79 ~TokenPreloadScanner(); |
82 | 80 |
83 void scan(const HTMLToken&, const SegmentedString&, PreloadRequestStream& re
quests, ViewportDescriptionWrapper*); | 81 void scan(const HTMLToken&, const SegmentedString&, PreloadRequestStream& re
quests, ViewportDescriptionWrapper*); |
84 void scan(const CompactHTMLToken&, const SegmentedString&, PreloadRequestStr
eam& requests, ViewportDescriptionWrapper*, bool* likelyDocumentWriteScript); | 82 void scan(const CompactHTMLToken&, const SegmentedString&, PreloadRequestStr
eam& requests, ViewportDescriptionWrapper*, bool* likelyDocumentWriteScript); |
85 | 83 |
86 void setPredictedBaseElementURL(const KURL& url) { m_predictedBaseElementURL
= url; } | 84 void setPredictedBaseElementURL(const KURL& url) { m_predictedBaseElementURL
= url; } |
87 | 85 |
88 // A TokenPreloadScannerCheckpoint is valid until the next call to rewindTo, | 86 // A TokenPreloadScannerCheckpoint is valid until the next call to rewindTo, |
89 // at which point all outstanding checkpoints are invalidated. | 87 // at which point all outstanding checkpoints are invalidated. |
90 TokenPreloadScannerCheckpoint createCheckpoint(); | 88 TokenPreloadScannerCheckpoint createCheckpoint(); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 CSSPreloadScanner m_cssScanner; | 135 CSSPreloadScanner m_cssScanner; |
138 const KURL m_documentURL; | 136 const KURL m_documentURL; |
139 KURL m_predictedBaseElementURL; | 137 KURL m_predictedBaseElementURL; |
140 bool m_inStyle; | 138 bool m_inStyle; |
141 bool m_inPicture; | 139 bool m_inPicture; |
142 bool m_inScript; | 140 bool m_inScript; |
143 bool m_isAppCacheEnabled; | 141 bool m_isAppCacheEnabled; |
144 bool m_isCSPEnabled; | 142 bool m_isCSPEnabled; |
145 PictureData m_pictureData; | 143 PictureData m_pictureData; |
146 size_t m_templateCount; | 144 size_t m_templateCount; |
147 std::unique_ptr<CachedDocumentParameters> m_documentParameters; | 145 OwnPtr<CachedDocumentParameters> m_documentParameters; |
148 Persistent<MediaValuesCached> m_mediaValues; | 146 Persistent<MediaValuesCached> m_mediaValues; |
149 ClientHintsPreferences m_clientHintsPreferences; | 147 ClientHintsPreferences m_clientHintsPreferences; |
150 | 148 |
151 bool m_didRewind = false; | 149 bool m_didRewind = false; |
152 | 150 |
153 Vector<Checkpoint> m_checkpoints; | 151 Vector<Checkpoint> m_checkpoints; |
154 }; | 152 }; |
155 | 153 |
156 class CORE_EXPORT HTMLPreloadScanner { | 154 class CORE_EXPORT HTMLPreloadScanner { |
157 WTF_MAKE_NONCOPYABLE(HTMLPreloadScanner); USING_FAST_MALLOC(HTMLPreloadScann
er); | 155 WTF_MAKE_NONCOPYABLE(HTMLPreloadScanner); USING_FAST_MALLOC(HTMLPreloadScann
er); |
158 public: | 156 public: |
159 static std::unique_ptr<HTMLPreloadScanner> create(const HTMLParserOptions& o
ptions, const KURL& documentURL, std::unique_ptr<CachedDocumentParameters> docum
entParameters, const MediaValuesCached::MediaValuesCachedData& mediaValuesCached
Data) | 157 static PassOwnPtr<HTMLPreloadScanner> create(const HTMLParserOptions& option
s, const KURL& documentURL, PassOwnPtr<CachedDocumentParameters> documentParamet
ers, const MediaValuesCached::MediaValuesCachedData& mediaValuesCachedData) |
160 { | 158 { |
161 return wrapUnique(new HTMLPreloadScanner(options, documentURL, std::move
(documentParameters), mediaValuesCachedData)); | 159 return adoptPtr(new HTMLPreloadScanner(options, documentURL, std::move(d
ocumentParameters), mediaValuesCachedData)); |
162 } | 160 } |
163 | 161 |
164 | 162 |
165 ~HTMLPreloadScanner(); | 163 ~HTMLPreloadScanner(); |
166 | 164 |
167 void appendToEnd(const SegmentedString&); | 165 void appendToEnd(const SegmentedString&); |
168 void scanAndPreload(ResourcePreloader*, const KURL& documentBaseElementURL,
ViewportDescriptionWrapper*); | 166 void scanAndPreload(ResourcePreloader*, const KURL& documentBaseElementURL,
ViewportDescriptionWrapper*); |
169 | 167 |
170 private: | 168 private: |
171 HTMLPreloadScanner(const HTMLParserOptions&, const KURL& documentURL, std::u
nique_ptr<CachedDocumentParameters>, const MediaValuesCached::MediaValuesCachedD
ata&); | 169 HTMLPreloadScanner(const HTMLParserOptions&, const KURL& documentURL, PassOw
nPtr<CachedDocumentParameters>, const MediaValuesCached::MediaValuesCachedData&)
; |
172 | 170 |
173 TokenPreloadScanner m_scanner; | 171 TokenPreloadScanner m_scanner; |
174 SegmentedString m_source; | 172 SegmentedString m_source; |
175 HTMLToken m_token; | 173 HTMLToken m_token; |
176 std::unique_ptr<HTMLTokenizer> m_tokenizer; | 174 OwnPtr<HTMLTokenizer> m_tokenizer; |
177 }; | 175 }; |
178 | 176 |
179 } // namespace blink | 177 } // namespace blink |
180 | 178 |
181 #endif | 179 #endif |
OLD | NEW |