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

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

Issue 1738133002: Add support for media attribute on link (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 9 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 27 matching lines...) Expand all
38 #include "wtf/Vector.h" 38 #include "wtf/Vector.h"
39 39
40 namespace blink { 40 namespace blink {
41 41
42 typedef size_t TokenPreloadScannerCheckpoint; 42 typedef size_t TokenPreloadScannerCheckpoint;
43 43
44 class HTMLParserOptions; 44 class HTMLParserOptions;
45 class HTMLTokenizer; 45 class HTMLTokenizer;
46 class SegmentedString; 46 class SegmentedString;
47 47
48 struct ViewportDescriptionWrapper {
sof 2016/03/18 20:03:42 Is there some alternative way of exposing this ext
Yoav Weiss 2016/03/18 22:02:49 Any specific suggestions?
49 ViewportDescription description;
50 bool set;
51 ViewportDescriptionWrapper()
52 : set(false)
53 {
54 }
55 };
56
48 struct CORE_EXPORT CachedDocumentParameters { 57 struct CORE_EXPORT CachedDocumentParameters {
49 USING_FAST_MALLOC(CachedDocumentParameters); 58 USING_FAST_MALLOC(CachedDocumentParameters);
50 public: 59 public:
51 static PassOwnPtr<CachedDocumentParameters> create(Document* document) 60 static PassOwnPtr<CachedDocumentParameters> create(Document* document)
52 { 61 {
53 return adoptPtr(new CachedDocumentParameters(document)); 62 return adoptPtr(new CachedDocumentParameters(document));
54 } 63 }
55 64
56 bool doHtmlPreloadScanning; 65 bool doHtmlPreloadScanning;
57 Length defaultViewportMinWidth; 66 Length defaultViewportMinWidth;
58 bool viewportMetaZeroValuesQuirk; 67 bool viewportMetaZeroValuesQuirk;
59 bool viewportMetaEnabled; 68 bool viewportMetaEnabled;
60 ReferrerPolicy referrerPolicy; 69 ReferrerPolicy referrerPolicy;
61 70
62 private: 71 private:
63 explicit CachedDocumentParameters(Document*); 72 explicit CachedDocumentParameters(Document*);
64 }; 73 };
65 74
66 class TokenPreloadScanner { 75 class TokenPreloadScanner {
67 WTF_MAKE_NONCOPYABLE(TokenPreloadScanner); USING_FAST_MALLOC(TokenPreloadSca nner); 76 WTF_MAKE_NONCOPYABLE(TokenPreloadScanner); USING_FAST_MALLOC(TokenPreloadSca nner);
68 public: 77 public:
69 TokenPreloadScanner(const KURL& documentURL, PassOwnPtr<CachedDocumentParame ters>, const MediaValuesCached::MediaValuesCachedData&); 78 TokenPreloadScanner(const KURL& documentURL, PassOwnPtr<CachedDocumentParame ters>, const MediaValuesCached::MediaValuesCachedData&);
70 ~TokenPreloadScanner(); 79 ~TokenPreloadScanner();
71 80
72 void scan(const HTMLToken&, const SegmentedString&, PreloadRequestStream& re quests); 81 void scan(const HTMLToken&, const SegmentedString&, PreloadRequestStream& re quests, ViewportDescriptionWrapper*);
73 void scan(const CompactHTMLToken&, const SegmentedString&, PreloadRequestStr eam& requests); 82 void scan(const CompactHTMLToken&, const SegmentedString&, PreloadRequestStr eam& requests, ViewportDescriptionWrapper*);
74 83
75 void setPredictedBaseElementURL(const KURL& url) { m_predictedBaseElementURL = url; } 84 void setPredictedBaseElementURL(const KURL& url) { m_predictedBaseElementURL = url; }
76 85
77 // A TokenPreloadScannerCheckpoint is valid until the next call to rewindTo, 86 // A TokenPreloadScannerCheckpoint is valid until the next call to rewindTo,
78 // at which point all outstanding checkpoints are invalidated. 87 // at which point all outstanding checkpoints are invalidated.
79 TokenPreloadScannerCheckpoint createCheckpoint(); 88 TokenPreloadScannerCheckpoint createCheckpoint();
80 void rewindTo(TokenPreloadScannerCheckpoint); 89 void rewindTo(TokenPreloadScannerCheckpoint);
81 90
82 private: 91 private:
83 class StartTagScanner; 92 class StartTagScanner;
84 93
85 template <typename Token> 94 template <typename Token>
86 inline void scanCommon(const Token&, const SegmentedString&, PreloadRequestS tream& requests); 95 inline void scanCommon(const Token&, const SegmentedString&, PreloadRequestS tream& requests, ViewportDescriptionWrapper*);
87 96
88 template<typename Token> 97 template<typename Token>
89 void updatePredictedBaseURL(const Token&); 98 void updatePredictedBaseURL(const Token&);
90 99
91 struct Checkpoint { 100 struct Checkpoint {
92 Checkpoint(const KURL& predictedBaseElementURL, bool inStyle, bool isApp CacheEnabled, bool isCSPEnabled, size_t templateCount) 101 Checkpoint(const KURL& predictedBaseElementURL, bool inStyle, bool isApp CacheEnabled, bool isCSPEnabled, size_t templateCount)
93 : predictedBaseElementURL(predictedBaseElementURL) 102 : predictedBaseElementURL(predictedBaseElementURL)
94 , inStyle(inStyle) 103 , inStyle(inStyle)
95 , isAppCacheEnabled(isAppCacheEnabled) 104 , isAppCacheEnabled(isAppCacheEnabled)
96 , isCSPEnabled(isCSPEnabled) 105 , isCSPEnabled(isCSPEnabled)
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 public: 148 public:
140 static PassOwnPtr<HTMLPreloadScanner> create(const HTMLParserOptions& option s, const KURL& documentURL, PassOwnPtr<CachedDocumentParameters> documentParamet ers, const MediaValuesCached::MediaValuesCachedData& mediaValuesCachedData) 149 static PassOwnPtr<HTMLPreloadScanner> create(const HTMLParserOptions& option s, const KURL& documentURL, PassOwnPtr<CachedDocumentParameters> documentParamet ers, const MediaValuesCached::MediaValuesCachedData& mediaValuesCachedData)
141 { 150 {
142 return adoptPtr(new HTMLPreloadScanner(options, documentURL, documentPar ameters, mediaValuesCachedData)); 151 return adoptPtr(new HTMLPreloadScanner(options, documentURL, documentPar ameters, mediaValuesCachedData));
143 } 152 }
144 153
145 154
146 ~HTMLPreloadScanner(); 155 ~HTMLPreloadScanner();
147 156
148 void appendToEnd(const SegmentedString&); 157 void appendToEnd(const SegmentedString&);
149 void scan(ResourcePreloader*, const KURL& documentBaseElementURL); 158 void scan(ResourcePreloader*, const KURL& documentBaseElementURL, ViewportDe scriptionWrapper*);
150 159
151 private: 160 private:
152 HTMLPreloadScanner(const HTMLParserOptions&, const KURL& documentURL, PassOw nPtr<CachedDocumentParameters>, const MediaValuesCached::MediaValuesCachedData&) ; 161 HTMLPreloadScanner(const HTMLParserOptions&, const KURL& documentURL, PassOw nPtr<CachedDocumentParameters>, const MediaValuesCached::MediaValuesCachedData&) ;
153 162
154 TokenPreloadScanner m_scanner; 163 TokenPreloadScanner m_scanner;
155 SegmentedString m_source; 164 SegmentedString m_source;
156 HTMLToken m_token; 165 HTMLToken m_token;
157 OwnPtr<HTMLTokenizer> m_tokenizer; 166 OwnPtr<HTMLTokenizer> m_tokenizer;
158 }; 167 };
159 168
160 } // namespace blink 169 } // namespace blink
161 170
162 #endif 171 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698