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

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

Issue 2242223003: Preload tokens even if a <meta> csp tag is found (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix up layout test Created 4 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 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 private: 73 private:
74 explicit CachedDocumentParameters(Document*); 74 explicit CachedDocumentParameters(Document*);
75 }; 75 };
76 76
77 class TokenPreloadScanner { 77 class TokenPreloadScanner {
78 WTF_MAKE_NONCOPYABLE(TokenPreloadScanner); USING_FAST_MALLOC(TokenPreloadSca nner); 78 WTF_MAKE_NONCOPYABLE(TokenPreloadScanner); USING_FAST_MALLOC(TokenPreloadSca nner);
79 public: 79 public:
80 TokenPreloadScanner(const KURL& documentURL, std::unique_ptr<CachedDocumentP arameters>, const MediaValuesCached::MediaValuesCachedData&); 80 TokenPreloadScanner(const KURL& documentURL, std::unique_ptr<CachedDocumentP arameters>, const MediaValuesCached::MediaValuesCachedData&);
81 ~TokenPreloadScanner(); 81 ~TokenPreloadScanner();
82 82
83 void scan(const HTMLToken&, const SegmentedString&, PreloadRequestStream& re quests, ViewportDescriptionWrapper*); 83 void scan(const HTMLToken&, const SegmentedString&, PreloadRequestStream& re quests, ViewportDescriptionWrapper*, bool* isCSPMetaTag);
84 void scan(const CompactHTMLToken&, const SegmentedString&, PreloadRequestStr eam& requests, ViewportDescriptionWrapper*, bool* likelyDocumentWriteScript); 84 void scan(const CompactHTMLToken&, const SegmentedString&, PreloadRequestStr eam& requests, ViewportDescriptionWrapper*, bool* isCSPMetaTag, bool* likelyDocu mentWriteScript);
85 85
86 void setPredictedBaseElementURL(const KURL& url) { m_predictedBaseElementURL = url; } 86 void setPredictedBaseElementURL(const KURL& url) { m_predictedBaseElementURL = url; }
87 87
88 // A TokenPreloadScannerCheckpoint is valid until the next call to rewindTo, 88 // A TokenPreloadScannerCheckpoint is valid until the next call to rewindTo,
89 // at which point all outstanding checkpoints are invalidated. 89 // at which point all outstanding checkpoints are invalidated.
90 TokenPreloadScannerCheckpoint createCheckpoint(); 90 TokenPreloadScannerCheckpoint createCheckpoint();
91 void rewindTo(TokenPreloadScannerCheckpoint); 91 void rewindTo(TokenPreloadScannerCheckpoint);
92 92
93 private: 93 private:
94 class StartTagScanner; 94 class StartTagScanner;
95 95
96 bool shouldEvaluateForDocumentWrite(const String& source); 96 bool shouldEvaluateForDocumentWrite(const String& source);
97 bool shouldEvaluateForDocumentWrite(const HTMLToken::DataVector& source) { r eturn false; } 97 bool shouldEvaluateForDocumentWrite(const HTMLToken::DataVector& source) { r eturn false; }
98 98
99 template <typename Token> 99 template <typename Token>
100 inline void scanCommon(const Token&, const SegmentedString&, PreloadRequestS tream& requests, ViewportDescriptionWrapper*, bool* likelyDocumentWriteScript); 100 inline void scanCommon(const Token&, const SegmentedString&, PreloadRequestS tream& requests, ViewportDescriptionWrapper*, bool* isCSPMetaTag, bool* likelyDo cumentWriteScript);
101 101
102 template<typename Token> 102 template<typename Token>
103 void updatePredictedBaseURL(const Token&); 103 void updatePredictedBaseURL(const Token&);
104 104
105 struct Checkpoint { 105 struct Checkpoint {
106 Checkpoint(const KURL& predictedBaseElementURL, bool inStyle, bool inScr ipt, bool isCSPEnabled, size_t templateCount) 106 Checkpoint(const KURL& predictedBaseElementURL, bool inStyle, bool inScr ipt, size_t templateCount)
107 : predictedBaseElementURL(predictedBaseElementURL) 107 : predictedBaseElementURL(predictedBaseElementURL)
108 , inStyle(inStyle) 108 , inStyle(inStyle)
109 , inScript(inScript) 109 , inScript(inScript)
110 , isCSPEnabled(isCSPEnabled)
111 , templateCount(templateCount) 110 , templateCount(templateCount)
112 { 111 {
113 } 112 }
114 113
115 KURL predictedBaseElementURL; 114 KURL predictedBaseElementURL;
116 bool inStyle; 115 bool inStyle;
117 bool inScript; 116 bool inScript;
118 bool isCSPEnabled;
119 size_t templateCount; 117 size_t templateCount;
120 }; 118 };
121 119
122 struct PictureData { 120 struct PictureData {
123 PictureData() 121 PictureData()
124 : sourceSize(0.0) 122 : sourceSize(0.0)
125 , sourceSizeSet(false) 123 , sourceSizeSet(false)
126 , picked(false) 124 , picked(false)
127 { 125 {
128 } 126 }
129 String sourceURL; 127 String sourceURL;
130 float sourceSize; 128 float sourceSize;
131 bool sourceSizeSet; 129 bool sourceSizeSet;
132 bool picked; 130 bool picked;
133 }; 131 };
134 132
135 CSSPreloadScanner m_cssScanner; 133 CSSPreloadScanner m_cssScanner;
136 const KURL m_documentURL; 134 const KURL m_documentURL;
137 KURL m_predictedBaseElementURL; 135 KURL m_predictedBaseElementURL;
138 bool m_inStyle; 136 bool m_inStyle;
139 bool m_inPicture; 137 bool m_inPicture;
140 bool m_inScript; 138 bool m_inScript;
141 bool m_isCSPEnabled;
142 PictureData m_pictureData; 139 PictureData m_pictureData;
143 size_t m_templateCount; 140 size_t m_templateCount;
144 std::unique_ptr<CachedDocumentParameters> m_documentParameters; 141 std::unique_ptr<CachedDocumentParameters> m_documentParameters;
145 Persistent<MediaValuesCached> m_mediaValues; 142 Persistent<MediaValuesCached> m_mediaValues;
146 ClientHintsPreferences m_clientHintsPreferences; 143 ClientHintsPreferences m_clientHintsPreferences;
147 144
148 bool m_didRewind = false; 145 bool m_didRewind = false;
149 146
150 Vector<Checkpoint> m_checkpoints; 147 Vector<Checkpoint> m_checkpoints;
151 }; 148 };
(...skipping 17 matching lines...) Expand all
169 166
170 TokenPreloadScanner m_scanner; 167 TokenPreloadScanner m_scanner;
171 SegmentedString m_source; 168 SegmentedString m_source;
172 HTMLToken m_token; 169 HTMLToken m_token;
173 std::unique_ptr<HTMLTokenizer> m_tokenizer; 170 std::unique_ptr<HTMLTokenizer> m_tokenizer;
174 }; 171 };
175 172
176 } // namespace blink 173 } // namespace blink
177 174
178 #endif 175 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698