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