| 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) 2009 Torch Mobile, Inc. http://www.torchmobile.com/ | 3 * Copyright (C) 2009 Torch Mobile, Inc. http://www.torchmobile.com/ |
| 4 * Copyright (C) 2010 Google Inc. All Rights Reserved. | 4 * Copyright (C) 2010 Google Inc. All Rights Reserved. |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 StartTagScanner(const StringImpl* tagImpl, PassRefPtr<MediaValues> mediaValu
es) | 112 StartTagScanner(const StringImpl* tagImpl, PassRefPtr<MediaValues> mediaValu
es) |
| 113 : m_tagImpl(tagImpl) | 113 : m_tagImpl(tagImpl) |
| 114 , m_linkIsStyleSheet(false) | 114 , m_linkIsStyleSheet(false) |
| 115 , m_linkIsPreconnect(false) | 115 , m_linkIsPreconnect(false) |
| 116 , m_linkIsImport(false) | 116 , m_linkIsImport(false) |
| 117 , m_matchedMediaAttribute(true) | 117 , m_matchedMediaAttribute(true) |
| 118 , m_inputIsImage(false) | 118 , m_inputIsImage(false) |
| 119 , m_sourceSize(0) | 119 , m_sourceSize(0) |
| 120 , m_sourceSizeSet(false) | 120 , m_sourceSizeSet(false) |
| 121 , m_isCORSEnabled(false) | 121 , m_isCORSEnabled(false) |
| 122 , m_widthValue(0) | |
| 123 , m_widthValueSet(false) | |
| 124 , m_widthPresent(false) | |
| 125 , m_defer(FetchRequest::NoDefer) | 122 , m_defer(FetchRequest::NoDefer) |
| 126 , m_allowCredentials(DoNotAllowStoredCredentials) | 123 , m_allowCredentials(DoNotAllowStoredCredentials) |
| 127 , m_mediaValues(mediaValues) | 124 , m_mediaValues(mediaValues) |
| 128 { | 125 { |
| 129 ASSERT(m_mediaValues->isCached()); | 126 ASSERT(m_mediaValues->isCached()); |
| 130 if (match(m_tagImpl, imgTag) | 127 if (match(m_tagImpl, imgTag) |
| 131 || match(m_tagImpl, sourceTag)) { | 128 || match(m_tagImpl, sourceTag)) { |
| 132 m_sourceSize = SizesAttributeParser(m_mediaValues, String()).length(
); | 129 m_sourceSize = SizesAttributeParser(m_mediaValues, String()).length(
); |
| 133 return; | 130 return; |
| 134 } | 131 } |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 FetchRequest::ResourceWidth resourceWidth; | 185 FetchRequest::ResourceWidth resourceWidth; |
| 189 float sourceSize = m_sourceSize; | 186 float sourceSize = m_sourceSize; |
| 190 bool sourceSizeSet = m_sourceSizeSet; | 187 bool sourceSizeSet = m_sourceSizeSet; |
| 191 if (pictureData.picked) { | 188 if (pictureData.picked) { |
| 192 sourceSizeSet = pictureData.sourceSizeSet; | 189 sourceSizeSet = pictureData.sourceSizeSet; |
| 193 sourceSize = pictureData.sourceSize; | 190 sourceSize = pictureData.sourceSize; |
| 194 } | 191 } |
| 195 if (sourceSizeSet) { | 192 if (sourceSizeSet) { |
| 196 resourceWidth.width = sourceSize; | 193 resourceWidth.width = sourceSize; |
| 197 resourceWidth.isSet = true; | 194 resourceWidth.isSet = true; |
| 198 } else { | |
| 199 resourceWidth.isSet = m_widthValueSet; | |
| 200 resourceWidth.width = m_widthValue; | |
| 201 } | 195 } |
| 202 | 196 |
| 203 OwnPtr<PreloadRequest> request = PreloadRequest::create(initiatorFor(m_t
agImpl), position, m_urlToLoad, predictedBaseURL, resourceType(), resourceWidth,
clientHintsPreferences, requestType); | 197 OwnPtr<PreloadRequest> request = PreloadRequest::create(initiatorFor(m_t
agImpl), position, m_urlToLoad, predictedBaseURL, resourceType(), resourceWidth,
clientHintsPreferences, requestType); |
| 204 if (isCORSEnabled()) | 198 if (isCORSEnabled()) |
| 205 request->setCrossOriginEnabled(allowStoredCredentials()); | 199 request->setCrossOriginEnabled(allowStoredCredentials()); |
| 206 request->setCharset(charset()); | 200 request->setCharset(charset()); |
| 207 request->setDefer(m_defer); | 201 request->setDefer(m_defer); |
| 208 return request.release(); | 202 return request.release(); |
| 209 } | 203 } |
| 210 | 204 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 235 m_srcsetAttributeValue = attributeValue; | 229 m_srcsetAttributeValue = attributeValue; |
| 236 m_srcsetImageCandidate = bestFitSourceForSrcsetAttribute(m_mediaValu
es->devicePixelRatio(), m_sourceSize, attributeValue); | 230 m_srcsetImageCandidate = bestFitSourceForSrcsetAttribute(m_mediaValu
es->devicePixelRatio(), m_sourceSize, attributeValue); |
| 237 setUrlToLoad(bestFitSourceForImageAttributes(m_mediaValues->devicePi
xelRatio(), m_sourceSize, m_imgSrcUrl, m_srcsetImageCandidate), AllowURLReplacem
ent); | 231 setUrlToLoad(bestFitSourceForImageAttributes(m_mediaValues->devicePi
xelRatio(), m_sourceSize, m_imgSrcUrl, m_srcsetImageCandidate), AllowURLReplacem
ent); |
| 238 } else if (match(attributeName, sizesAttr) && !m_sourceSizeSet) { | 232 } else if (match(attributeName, sizesAttr) && !m_sourceSizeSet) { |
| 239 m_sourceSize = SizesAttributeParser(m_mediaValues, attributeValue).l
ength(); | 233 m_sourceSize = SizesAttributeParser(m_mediaValues, attributeValue).l
ength(); |
| 240 m_sourceSizeSet = true; | 234 m_sourceSizeSet = true; |
| 241 if (!m_srcsetImageCandidate.isEmpty()) { | 235 if (!m_srcsetImageCandidate.isEmpty()) { |
| 242 m_srcsetImageCandidate = bestFitSourceForSrcsetAttribute(m_media
Values->devicePixelRatio(), m_sourceSize, m_srcsetAttributeValue); | 236 m_srcsetImageCandidate = bestFitSourceForSrcsetAttribute(m_media
Values->devicePixelRatio(), m_sourceSize, m_srcsetAttributeValue); |
| 243 setUrlToLoad(bestFitSourceForImageAttributes(m_mediaValues->devi
cePixelRatio(), m_sourceSize, m_imgSrcUrl, m_srcsetImageCandidate), AllowURLRepl
acement); | 237 setUrlToLoad(bestFitSourceForImageAttributes(m_mediaValues->devi
cePixelRatio(), m_sourceSize, m_imgSrcUrl, m_srcsetImageCandidate), AllowURLRepl
acement); |
| 244 } | 238 } |
| 245 } else if (match(attributeName, widthAttr) && !m_widthPresent) { | |
| 246 m_widthPresent = true; | |
| 247 m_widthValue = HTMLImageElement::widthAttributeToInt(attributeValue,
m_widthValueSet); | |
| 248 } | 239 } |
| 249 } | 240 } |
| 250 | 241 |
| 251 template<typename NameType> | 242 template<typename NameType> |
| 252 void processLinkAttribute(const NameType& attributeName, const String& attri
buteValue) | 243 void processLinkAttribute(const NameType& attributeName, const String& attri
buteValue) |
| 253 { | 244 { |
| 254 // FIXME - Don't set rel/media/crossorigin multiple times. | 245 // FIXME - Don't set rel/media/crossorigin multiple times. |
| 255 if (match(attributeName, hrefAttr)) { | 246 if (match(attributeName, hrefAttr)) { |
| 256 setUrlToLoad(attributeValue, DisallowURLReplacement); | 247 setUrlToLoad(attributeValue, DisallowURLReplacement); |
| 257 } else if (match(attributeName, relAttr)) { | 248 } else if (match(attributeName, relAttr)) { |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 bool m_linkIsStyleSheet; | 400 bool m_linkIsStyleSheet; |
| 410 bool m_linkIsPreconnect; | 401 bool m_linkIsPreconnect; |
| 411 bool m_linkIsImport; | 402 bool m_linkIsImport; |
| 412 bool m_matchedMediaAttribute; | 403 bool m_matchedMediaAttribute; |
| 413 bool m_inputIsImage; | 404 bool m_inputIsImage; |
| 414 String m_imgSrcUrl; | 405 String m_imgSrcUrl; |
| 415 String m_srcsetAttributeValue; | 406 String m_srcsetAttributeValue; |
| 416 float m_sourceSize; | 407 float m_sourceSize; |
| 417 bool m_sourceSizeSet; | 408 bool m_sourceSizeSet; |
| 418 bool m_isCORSEnabled; | 409 bool m_isCORSEnabled; |
| 419 int m_widthValue; | |
| 420 bool m_widthValueSet; | |
| 421 bool m_widthPresent; | |
| 422 FetchRequest::DeferOption m_defer; | 410 FetchRequest::DeferOption m_defer; |
| 423 StoredCredentials m_allowCredentials; | 411 StoredCredentials m_allowCredentials; |
| 424 RefPtr<MediaValues> m_mediaValues; | 412 RefPtr<MediaValues> m_mediaValues; |
| 425 }; | 413 }; |
| 426 | 414 |
| 427 TokenPreloadScanner::TokenPreloadScanner(const KURL& documentURL, PassOwnPtr<Cac
hedDocumentParameters> documentParameters) | 415 TokenPreloadScanner::TokenPreloadScanner(const KURL& documentURL, PassOwnPtr<Cac
hedDocumentParameters> documentParameters) |
| 428 : m_documentURL(documentURL) | 416 : m_documentURL(documentURL) |
| 429 , m_inStyle(false) | 417 , m_inStyle(false) |
| 430 , m_inPicture(false) | 418 , m_inPicture(false) |
| 431 , m_isAppCacheEnabled(false) | 419 , m_isAppCacheEnabled(false) |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 mediaValues = givenMediaValues; | 633 mediaValues = givenMediaValues; |
| 646 else | 634 else |
| 647 mediaValues = MediaValuesCached::create(*document); | 635 mediaValues = MediaValuesCached::create(*document); |
| 648 ASSERT(mediaValues->isSafeToSendToAnotherThread()); | 636 ASSERT(mediaValues->isSafeToSendToAnotherThread()); |
| 649 defaultViewportMinWidth = document->viewportDefaultMinWidth(); | 637 defaultViewportMinWidth = document->viewportDefaultMinWidth(); |
| 650 viewportMetaZeroValuesQuirk = document->settings() && document->settings()->
viewportMetaZeroValuesQuirk(); | 638 viewportMetaZeroValuesQuirk = document->settings() && document->settings()->
viewportMetaZeroValuesQuirk(); |
| 651 viewportMetaEnabled = document->settings() && document->settings()->viewport
MetaEnabled(); | 639 viewportMetaEnabled = document->settings() && document->settings()->viewport
MetaEnabled(); |
| 652 } | 640 } |
| 653 | 641 |
| 654 } | 642 } |
| OLD | NEW |