| 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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 } | 157 } |
| 158 | 158 |
| 159 void processAttributes(const Vector<CompactHTMLToken::Attribute>& attributes
) | 159 void processAttributes(const Vector<CompactHTMLToken::Attribute>& attributes
) |
| 160 { | 160 { |
| 161 if (!m_tagImpl) | 161 if (!m_tagImpl) |
| 162 return; | 162 return; |
| 163 for (const CompactHTMLToken::Attribute& htmlTokenAttribute : attributes) | 163 for (const CompactHTMLToken::Attribute& htmlTokenAttribute : attributes) |
| 164 processAttribute(htmlTokenAttribute.name, htmlTokenAttribute.value); | 164 processAttribute(htmlTokenAttribute.name, htmlTokenAttribute.value); |
| 165 } | 165 } |
| 166 | 166 |
| 167 void handlePictureSourceURL(String& sourceURL) | 167 void handlePictureSourceURL(PictureData& pictureData) |
| 168 { | 168 { |
| 169 if (match(m_tagImpl, sourceTag) && m_matchedMediaAttribute && sourceURL.
isEmpty()) | 169 if (match(m_tagImpl, sourceTag) && m_matchedMediaAttribute && pictureDat
a.sourceURL.isEmpty()) { |
| 170 sourceURL = m_srcsetImageCandidate.toString(); | 170 pictureData.sourceURL = m_srcsetImageCandidate.toString(); |
| 171 else if (match(m_tagImpl, imgTag) && !sourceURL.isEmpty()) | 171 pictureData.sourceSizeSet = m_sourceSizeSet; |
| 172 setUrlToLoad(sourceURL, AllowURLReplacement); | 172 pictureData.sourceSize = m_sourceSize; |
| 173 pictureData.picked = true; |
| 174 } else if (match(m_tagImpl, imgTag) && !pictureData.sourceURL.isEmpty())
{ |
| 175 setUrlToLoad(pictureData.sourceURL, AllowURLReplacement); |
| 176 } |
| 173 } | 177 } |
| 174 | 178 |
| 175 PassOwnPtr<PreloadRequest> createPreloadRequest(const KURL& predictedBaseURL
, const SegmentedString& source, const ClientHintsPreferences& clientHintsPrefer
ences) | 179 PassOwnPtr<PreloadRequest> createPreloadRequest(const KURL& predictedBaseURL
, const SegmentedString& source, const ClientHintsPreferences& clientHintsPrefer
ences, const PictureData& pictureData) |
| 176 { | 180 { |
| 177 PreloadRequest::RequestType requestType = PreloadRequest::RequestTypePre
load; | 181 PreloadRequest::RequestType requestType = PreloadRequest::RequestTypePre
load; |
| 178 if (shouldPreconnect()) | 182 if (shouldPreconnect()) |
| 179 requestType = PreloadRequest::RequestTypePreconnect; | 183 requestType = PreloadRequest::RequestTypePreconnect; |
| 180 else if (!shouldPreload() || !m_matchedMediaAttribute) | 184 else if (!shouldPreload() || !m_matchedMediaAttribute) |
| 181 return nullptr; | 185 return nullptr; |
| 182 | 186 |
| 183 TextPosition position = TextPosition(source.currentLine(), source.curren
tColumn()); | 187 TextPosition position = TextPosition(source.currentLine(), source.curren
tColumn()); |
| 184 FetchRequest::ResourceWidth resourceWidth; | 188 FetchRequest::ResourceWidth resourceWidth; |
| 185 if (m_sourceSizeSet) { | 189 float sourceSize = m_sourceSize; |
| 186 resourceWidth.width = m_sourceSize; | 190 bool sourceSizeSet = m_sourceSizeSet; |
| 191 if (pictureData.picked) { |
| 192 sourceSizeSet = pictureData.sourceSizeSet; |
| 193 sourceSize = pictureData.sourceSize; |
| 194 } |
| 195 if (sourceSizeSet) { |
| 196 resourceWidth.width = sourceSize; |
| 187 resourceWidth.isSet = true; | 197 resourceWidth.isSet = true; |
| 188 } else { | 198 } else { |
| 189 resourceWidth.isSet = m_widthValueSet; | 199 resourceWidth.isSet = m_widthValueSet; |
| 190 resourceWidth.width = m_widthValue; | 200 resourceWidth.width = m_widthValue; |
| 191 } | 201 } |
| 192 | 202 |
| 193 OwnPtr<PreloadRequest> request = PreloadRequest::create(initiatorFor(m_t
agImpl), position, m_urlToLoad, predictedBaseURL, resourceType(), resourceWidth,
clientHintsPreferences, requestType); | 203 OwnPtr<PreloadRequest> request = PreloadRequest::create(initiatorFor(m_t
agImpl), position, m_urlToLoad, predictedBaseURL, resourceType(), resourceWidth,
clientHintsPreferences, requestType); |
| 194 if (isCORSEnabled()) | 204 if (isCORSEnabled()) |
| 195 request->setCrossOriginEnabled(allowStoredCredentials()); | 205 request->setCrossOriginEnabled(allowStoredCredentials()); |
| 196 request->setCharset(charset()); | 206 request->setCharset(charset()); |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 if (nameAttribute && equalIgnoringCase(String(nameAttribute->value),
"viewport")) { | 563 if (nameAttribute && equalIgnoringCase(String(nameAttribute->value),
"viewport")) { |
| 554 const typename Token::Attribute* contentAttribute = token.getAtt
ributeItem(contentAttr); | 564 const typename Token::Attribute* contentAttribute = token.getAtt
ributeItem(contentAttr); |
| 555 if (contentAttribute) | 565 if (contentAttribute) |
| 556 handleMetaViewport(String(contentAttribute->value), m_docume
ntParameters.get()); | 566 handleMetaViewport(String(contentAttribute->value), m_docume
ntParameters.get()); |
| 557 return; | 567 return; |
| 558 } | 568 } |
| 559 } | 569 } |
| 560 | 570 |
| 561 if (match(tagImpl, pictureTag)) { | 571 if (match(tagImpl, pictureTag)) { |
| 562 m_inPicture = true; | 572 m_inPicture = true; |
| 563 m_pictureSourceURL = String(); | 573 m_pictureData = PictureData(); |
| 564 return; | 574 return; |
| 565 } | 575 } |
| 566 | 576 |
| 567 StartTagScanner scanner(tagImpl, m_documentParameters->mediaValues); | 577 StartTagScanner scanner(tagImpl, m_documentParameters->mediaValues); |
| 568 scanner.processAttributes(token.attributes()); | 578 scanner.processAttributes(token.attributes()); |
| 569 if (m_inPicture) | 579 if (m_inPicture) |
| 570 scanner.handlePictureSourceURL(m_pictureSourceURL); | 580 scanner.handlePictureSourceURL(m_pictureData); |
| 571 OwnPtr<PreloadRequest> request = scanner.createPreloadRequest(m_predicte
dBaseElementURL, source, m_clientHintsPreferences); | 581 OwnPtr<PreloadRequest> request = scanner.createPreloadRequest(m_predicte
dBaseElementURL, source, m_clientHintsPreferences, m_pictureData); |
| 572 if (request) | 582 if (request) |
| 573 requests.append(request.release()); | 583 requests.append(request.release()); |
| 574 return; | 584 return; |
| 575 } | 585 } |
| 576 default: { | 586 default: { |
| 577 return; | 587 return; |
| 578 } | 588 } |
| 579 } | 589 } |
| 580 } | 590 } |
| 581 | 591 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 mediaValues = givenMediaValues; | 645 mediaValues = givenMediaValues; |
| 636 else | 646 else |
| 637 mediaValues = MediaValuesCached::create(*document); | 647 mediaValues = MediaValuesCached::create(*document); |
| 638 ASSERT(mediaValues->isSafeToSendToAnotherThread()); | 648 ASSERT(mediaValues->isSafeToSendToAnotherThread()); |
| 639 defaultViewportMinWidth = document->viewportDefaultMinWidth(); | 649 defaultViewportMinWidth = document->viewportDefaultMinWidth(); |
| 640 viewportMetaZeroValuesQuirk = document->settings() && document->settings()->
viewportMetaZeroValuesQuirk(); | 650 viewportMetaZeroValuesQuirk = document->settings() && document->settings()->
viewportMetaZeroValuesQuirk(); |
| 641 viewportMetaEnabled = document->settings() && document->settings()->viewport
MetaEnabled(); | 651 viewportMetaEnabled = document->settings() && document->settings()->viewport
MetaEnabled(); |
| 642 } | 652 } |
| 643 | 653 |
| 644 } | 654 } |
| OLD | NEW |