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

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

Issue 1104103002: Add <meta viewport> support to the preloader (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: moved CachedDocumentParameters constructor to private Created 5 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 10 matching lines...) Expand all
21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */ 25 */
26 26
27 #ifndef HTMLPreloadScanner_h 27 #ifndef HTMLPreloadScanner_h
28 #define HTMLPreloadScanner_h 28 #define HTMLPreloadScanner_h
29 29
30 #include "core/css/MediaValues.h" 30 #include "core/css/MediaValues.h"
31 #include "core/dom/ViewportDescription.h"
31 #include "core/html/parser/CSSPreloadScanner.h" 32 #include "core/html/parser/CSSPreloadScanner.h"
32 #include "core/html/parser/CompactHTMLToken.h" 33 #include "core/html/parser/CompactHTMLToken.h"
33 #include "core/html/parser/HTMLToken.h" 34 #include "core/html/parser/HTMLToken.h"
34 #include "platform/text/SegmentedString.h" 35 #include "platform/text/SegmentedString.h"
36 #include "wtf/RefCounted.h"
35 #include "wtf/Vector.h" 37 #include "wtf/Vector.h"
36 38
37 namespace blink { 39 namespace blink {
38 40
39 typedef size_t TokenPreloadScannerCheckpoint; 41 typedef size_t TokenPreloadScannerCheckpoint;
40 42
41 class HTMLParserOptions; 43 class HTMLParserOptions;
42 class HTMLTokenizer; 44 class HTMLTokenizer;
43 class SegmentedString; 45 class SegmentedString;
44 46
47 struct CachedDocumentParameters {
48 static PassOwnPtr<CachedDocumentParameters> create(Document* document, PassR efPtr<MediaValues> mediaValues = nullptr)
49 {
50 return adoptPtr(new CachedDocumentParameters(document, mediaValues));
51 }
52
53 RefPtr<MediaValues> mediaValues;
54 Length defaultViewportMinWidth;
55 bool viewportMetaZeroValuesQuirk;
56
57 private:
58 CachedDocumentParameters(Document*, PassRefPtr<MediaValues>);
59 };
60
45 class TokenPreloadScanner { 61 class TokenPreloadScanner {
46 WTF_MAKE_NONCOPYABLE(TokenPreloadScanner); WTF_MAKE_FAST_ALLOCATED(TokenPrel oadScanner); 62 WTF_MAKE_NONCOPYABLE(TokenPreloadScanner); WTF_MAKE_FAST_ALLOCATED(TokenPrel oadScanner);
47 public: 63 public:
48 TokenPreloadScanner(const KURL& documentURL, PassRefPtr<MediaValues>); 64 TokenPreloadScanner(const KURL& documentURL, PassOwnPtr<CachedDocumentParame ters>);
49 ~TokenPreloadScanner(); 65 ~TokenPreloadScanner();
50 66
51 void scan(const HTMLToken&, const SegmentedString&, PreloadRequestStream& re quests); 67 void scan(const HTMLToken&, const SegmentedString&, PreloadRequestStream& re quests);
52 void scan(const CompactHTMLToken&, const SegmentedString&, PreloadRequestStr eam& requests); 68 void scan(const CompactHTMLToken&, const SegmentedString&, PreloadRequestStr eam& requests);
53 69
54 void setPredictedBaseElementURL(const KURL& url) { m_predictedBaseElementURL = url; } 70 void setPredictedBaseElementURL(const KURL& url) { m_predictedBaseElementURL = url; }
55 71
56 // A TokenPreloadScannerCheckpoint is valid until the next call to rewindTo, 72 // A TokenPreloadScannerCheckpoint is valid until the next call to rewindTo,
57 // at which point all outstanding checkpoints are invalidated. 73 // at which point all outstanding checkpoints are invalidated.
58 TokenPreloadScannerCheckpoint createCheckpoint(); 74 TokenPreloadScannerCheckpoint createCheckpoint();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 108
93 CSSPreloadScanner m_cssScanner; 109 CSSPreloadScanner m_cssScanner;
94 const KURL m_documentURL; 110 const KURL m_documentURL;
95 KURL m_predictedBaseElementURL; 111 KURL m_predictedBaseElementURL;
96 bool m_inStyle; 112 bool m_inStyle;
97 bool m_inPicture; 113 bool m_inPicture;
98 bool m_isAppCacheEnabled; 114 bool m_isAppCacheEnabled;
99 bool m_isCSPEnabled; 115 bool m_isCSPEnabled;
100 String m_pictureSourceURL; 116 String m_pictureSourceURL;
101 size_t m_templateCount; 117 size_t m_templateCount;
102 RefPtr<MediaValues> m_mediaValues; 118 OwnPtr<CachedDocumentParameters> m_documentParameters;
103 119
104 Vector<Checkpoint> m_checkpoints; 120 Vector<Checkpoint> m_checkpoints;
105 }; 121 };
106 122
107 class HTMLPreloadScanner { 123 class HTMLPreloadScanner {
108 WTF_MAKE_NONCOPYABLE(HTMLPreloadScanner); WTF_MAKE_FAST_ALLOCATED(HTMLPreloa dScanner); 124 WTF_MAKE_NONCOPYABLE(HTMLPreloadScanner); WTF_MAKE_FAST_ALLOCATED(HTMLPreloa dScanner);
109 public: 125 public:
110 static PassOwnPtr<HTMLPreloadScanner> create(const HTMLParserOptions& option s, const KURL& documentURL, PassRefPtr<MediaValues> mediaValues) 126 static PassOwnPtr<HTMLPreloadScanner> create(const HTMLParserOptions& option s, const KURL& documentURL, PassOwnPtr<CachedDocumentParameters> documentParamet ers)
111 { 127 {
112 return adoptPtr(new HTMLPreloadScanner(options, documentURL, mediaValues )); 128 return adoptPtr(new HTMLPreloadScanner(options, documentURL, documentPar ameters));
113 } 129 }
114 130
115 131
116 HTMLPreloadScanner(const HTMLParserOptions&, const KURL& documentURL, PassRe fPtr<MediaValues>); 132 HTMLPreloadScanner(const HTMLParserOptions&, const KURL& documentURL, PassOw nPtr<CachedDocumentParameters>);
117 ~HTMLPreloadScanner(); 133 ~HTMLPreloadScanner();
118 134
119 void appendToEnd(const SegmentedString&); 135 void appendToEnd(const SegmentedString&);
120 void scan(ResourcePreloader*, const KURL& documentBaseElementURL); 136 void scan(ResourcePreloader*, const KURL& documentBaseElementURL);
121 137
122 private: 138 private:
123 TokenPreloadScanner m_scanner; 139 TokenPreloadScanner m_scanner;
124 SegmentedString m_source; 140 SegmentedString m_source;
125 HTMLToken m_token; 141 HTMLToken m_token;
126 OwnPtr<HTMLTokenizer> m_tokenizer; 142 OwnPtr<HTMLTokenizer> m_tokenizer;
127 }; 143 };
128 144
129 } 145 }
130 146
131 #endif 147 #endif
OLDNEW
« no previous file with comments | « Source/core/html/parser/HTMLDocumentParser.cpp ('k') | Source/core/html/parser/HTMLPreloadScanner.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698