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