Chromium Code Reviews| 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 10 matching lines...) Expand all Loading... | |
| 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 CachedDocumentParameters(Document*, PassRefPtr<MediaValues>); | |
|
Nate Chapin
2015/05/01 22:10:28
We should either just call the constructor directl
| |
| 54 | |
| 55 RefPtr<MediaValues> mediaValues; | |
| 56 Length defaultViewportMinWidth; | |
| 57 bool viewportMetaZeroValuesQuirk; | |
| 58 }; | |
| 59 | |
| 45 class TokenPreloadScanner { | 60 class TokenPreloadScanner { |
| 46 WTF_MAKE_NONCOPYABLE(TokenPreloadScanner); WTF_MAKE_FAST_ALLOCATED(TokenPrel oadScanner); | 61 WTF_MAKE_NONCOPYABLE(TokenPreloadScanner); WTF_MAKE_FAST_ALLOCATED(TokenPrel oadScanner); |
| 47 public: | 62 public: |
| 48 TokenPreloadScanner(const KURL& documentURL, PassRefPtr<MediaValues>); | 63 TokenPreloadScanner(const KURL& documentURL, PassOwnPtr<CachedDocumentParame ters>); |
| 49 ~TokenPreloadScanner(); | 64 ~TokenPreloadScanner(); |
| 50 | 65 |
| 51 void scan(const HTMLToken&, const SegmentedString&, PreloadRequestStream& re quests); | 66 void scan(const HTMLToken&, const SegmentedString&, PreloadRequestStream& re quests); |
| 52 void scan(const CompactHTMLToken&, const SegmentedString&, PreloadRequestStr eam& requests); | 67 void scan(const CompactHTMLToken&, const SegmentedString&, PreloadRequestStr eam& requests); |
| 53 | 68 |
| 54 void setPredictedBaseElementURL(const KURL& url) { m_predictedBaseElementURL = url; } | 69 void setPredictedBaseElementURL(const KURL& url) { m_predictedBaseElementURL = url; } |
| 55 | 70 |
| 56 // A TokenPreloadScannerCheckpoint is valid until the next call to rewindTo, | 71 // A TokenPreloadScannerCheckpoint is valid until the next call to rewindTo, |
| 57 // at which point all outstanding checkpoints are invalidated. | 72 // at which point all outstanding checkpoints are invalidated. |
| 58 TokenPreloadScannerCheckpoint createCheckpoint(); | 73 TokenPreloadScannerCheckpoint createCheckpoint(); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 92 | 107 |
| 93 CSSPreloadScanner m_cssScanner; | 108 CSSPreloadScanner m_cssScanner; |
| 94 const KURL m_documentURL; | 109 const KURL m_documentURL; |
| 95 KURL m_predictedBaseElementURL; | 110 KURL m_predictedBaseElementURL; |
| 96 bool m_inStyle; | 111 bool m_inStyle; |
| 97 bool m_inPicture; | 112 bool m_inPicture; |
| 98 bool m_isAppCacheEnabled; | 113 bool m_isAppCacheEnabled; |
| 99 bool m_isCSPEnabled; | 114 bool m_isCSPEnabled; |
| 100 String m_pictureSourceURL; | 115 String m_pictureSourceURL; |
| 101 size_t m_templateCount; | 116 size_t m_templateCount; |
| 102 RefPtr<MediaValues> m_mediaValues; | 117 OwnPtr<CachedDocumentParameters> m_documentParameters; |
| 103 | 118 |
| 104 Vector<Checkpoint> m_checkpoints; | 119 Vector<Checkpoint> m_checkpoints; |
| 105 }; | 120 }; |
| 106 | 121 |
| 107 class HTMLPreloadScanner { | 122 class HTMLPreloadScanner { |
| 108 WTF_MAKE_NONCOPYABLE(HTMLPreloadScanner); WTF_MAKE_FAST_ALLOCATED(HTMLPreloa dScanner); | 123 WTF_MAKE_NONCOPYABLE(HTMLPreloadScanner); WTF_MAKE_FAST_ALLOCATED(HTMLPreloa dScanner); |
| 109 public: | 124 public: |
| 110 static PassOwnPtr<HTMLPreloadScanner> create(const HTMLParserOptions& option s, const KURL& documentURL, PassRefPtr<MediaValues> mediaValues) | 125 static PassOwnPtr<HTMLPreloadScanner> create(const HTMLParserOptions& option s, const KURL& documentURL, PassOwnPtr<CachedDocumentParameters> documentParamet ers) |
| 111 { | 126 { |
| 112 return adoptPtr(new HTMLPreloadScanner(options, documentURL, mediaValues )); | 127 return adoptPtr(new HTMLPreloadScanner(options, documentURL, documentPar ameters)); |
| 113 } | 128 } |
| 114 | 129 |
| 115 | 130 |
| 116 HTMLPreloadScanner(const HTMLParserOptions&, const KURL& documentURL, PassRe fPtr<MediaValues>); | 131 HTMLPreloadScanner(const HTMLParserOptions&, const KURL& documentURL, PassOw nPtr<CachedDocumentParameters>); |
| 117 ~HTMLPreloadScanner(); | 132 ~HTMLPreloadScanner(); |
| 118 | 133 |
| 119 void appendToEnd(const SegmentedString&); | 134 void appendToEnd(const SegmentedString&); |
| 120 void scan(ResourcePreloader*, const KURL& documentBaseElementURL); | 135 void scan(ResourcePreloader*, const KURL& documentBaseElementURL); |
| 121 | 136 |
| 122 private: | 137 private: |
| 123 TokenPreloadScanner m_scanner; | 138 TokenPreloadScanner m_scanner; |
| 124 SegmentedString m_source; | 139 SegmentedString m_source; |
| 125 HTMLToken m_token; | 140 HTMLToken m_token; |
| 126 OwnPtr<HTMLTokenizer> m_tokenizer; | 141 OwnPtr<HTMLTokenizer> m_tokenizer; |
| 127 }; | 142 }; |
| 128 | 143 |
| 129 } | 144 } |
| 130 | 145 |
| 131 #endif | 146 #endif |
| OLD | NEW |