| 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 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 const Checkpoint& checkpoint = m_checkpoints[checkpointIndex]; | 443 const Checkpoint& checkpoint = m_checkpoints[checkpointIndex]; |
| 444 m_predictedBaseElementURL = checkpoint.predictedBaseElementURL; | 444 m_predictedBaseElementURL = checkpoint.predictedBaseElementURL; |
| 445 m_inStyle = checkpoint.inStyle; | 445 m_inStyle = checkpoint.inStyle; |
| 446 m_isAppCacheEnabled = checkpoint.isAppCacheEnabled; | 446 m_isAppCacheEnabled = checkpoint.isAppCacheEnabled; |
| 447 m_isCSPEnabled = checkpoint.isCSPEnabled; | 447 m_isCSPEnabled = checkpoint.isCSPEnabled; |
| 448 m_templateCount = checkpoint.templateCount; | 448 m_templateCount = checkpoint.templateCount; |
| 449 m_cssScanner.reset(); | 449 m_cssScanner.reset(); |
| 450 m_checkpoints.clear(); | 450 m_checkpoints.clear(); |
| 451 } | 451 } |
| 452 | 452 |
| 453 void TokenPreloadScanner::scan(const HTMLToken& token, const SegmentedString& so
urce, PreloadRequestStream& requests) | 453 void TokenPreloadScanner::scan(const HTMLToken& token, const SegmentedString& so
urce, PreloadRequestStream& requests, String* preloadedReferrerPolicy) |
| 454 { | 454 { |
| 455 scanCommon(token, source, requests); | 455 scanCommon(token, source, requests, preloadedReferrerPolicy); |
| 456 } | 456 } |
| 457 | 457 |
| 458 void TokenPreloadScanner::scan(const CompactHTMLToken& token, const SegmentedStr
ing& source, PreloadRequestStream& requests) | 458 void TokenPreloadScanner::scan(const CompactHTMLToken& token, const SegmentedStr
ing& source, PreloadRequestStream& requests, String* preloadedReferrerPolicy) |
| 459 { | 459 { |
| 460 scanCommon(token, source, requests); | 460 scanCommon(token, source, requests, preloadedReferrerPolicy); |
| 461 } | 461 } |
| 462 | 462 |
| 463 static void handleMetaViewport(const String& attributeValue, CachedDocumentParam
eters* documentParameters) | 463 static void handleMetaViewport(const String& attributeValue, CachedDocumentParam
eters* documentParameters) |
| 464 { | 464 { |
| 465 if (!documentParameters->viewportMetaEnabled) | 465 if (!documentParameters->viewportMetaEnabled) |
| 466 return; | 466 return; |
| 467 ViewportDescription description(ViewportDescription::ViewportMeta); | 467 ViewportDescription description(ViewportDescription::ViewportMeta); |
| 468 HTMLMetaElement::getViewportDescriptionFromContentAttribute(attributeValue,
description, nullptr, documentParameters->viewportMetaZeroValuesQuirk); | 468 HTMLMetaElement::getViewportDescriptionFromContentAttribute(attributeValue,
description, nullptr, documentParameters->viewportMetaZeroValuesQuirk); |
| 469 FloatSize initialViewport(documentParameters->mediaValues->viewportHeight(),
documentParameters->mediaValues->viewportWidth()); | 469 FloatSize initialViewport(documentParameters->mediaValues->viewportHeight(),
documentParameters->mediaValues->viewportWidth()); |
| 470 PageScaleConstraints constraints = description.resolve(initialViewport, docu
mentParameters->defaultViewportMinWidth); | 470 PageScaleConstraints constraints = description.resolve(initialViewport, docu
mentParameters->defaultViewportMinWidth); |
| 471 MediaValuesCached* cachedMediaValues = static_cast<MediaValuesCached*>(docum
entParameters->mediaValues.get()); | 471 MediaValuesCached* cachedMediaValues = static_cast<MediaValuesCached*>(docum
entParameters->mediaValues.get()); |
| 472 cachedMediaValues->setViewportHeight(constraints.layoutSize.height()); | 472 cachedMediaValues->setViewportHeight(constraints.layoutSize.height()); |
| 473 cachedMediaValues->setViewportWidth(constraints.layoutSize.width()); | 473 cachedMediaValues->setViewportWidth(constraints.layoutSize.width()); |
| 474 } | 474 } |
| 475 | 475 |
| 476 template<typename Token> | 476 template <typename Token> |
| 477 void TokenPreloadScanner::scanCommon(const Token& token, const SegmentedString&
source, PreloadRequestStream& requests) | 477 void TokenPreloadScanner::scanCommon(const Token& token, const SegmentedString&
source, PreloadRequestStream& requests, String* preloadedReferrerPolicy) |
| 478 { | 478 { |
| 479 if (!m_documentParameters->doHtmlPreloadScanning) | 479 if (!m_documentParameters->doHtmlPreloadScanning) |
| 480 return; | 480 return; |
| 481 | 481 |
| 482 // Disable preload for documents with AppCache. | 482 // Disable preload for documents with AppCache. |
| 483 if (m_isAppCacheEnabled) | 483 if (m_isAppCacheEnabled) |
| 484 return; | 484 return; |
| 485 | 485 |
| 486 // http://crbug.com/434230 Disable preload for documents with CSP <meta> tag
s | 486 // http://crbug.com/434230 Disable preload for documents with CSP <meta> tag
s |
| 487 if (m_isCSPEnabled) | 487 if (m_isCSPEnabled) |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 } | 547 } |
| 548 return; | 548 return; |
| 549 } | 549 } |
| 550 const typename Token::Attribute* nameAttribute = token.getAttributeI
tem(nameAttr); | 550 const typename Token::Attribute* nameAttribute = token.getAttributeI
tem(nameAttr); |
| 551 if (nameAttribute && equalIgnoringCase(String(nameAttribute->value),
"viewport")) { | 551 if (nameAttribute && equalIgnoringCase(String(nameAttribute->value),
"viewport")) { |
| 552 const typename Token::Attribute* contentAttribute = token.getAtt
ributeItem(contentAttr); | 552 const typename Token::Attribute* contentAttribute = token.getAtt
ributeItem(contentAttr); |
| 553 if (contentAttribute) | 553 if (contentAttribute) |
| 554 handleMetaViewport(String(contentAttribute->value), m_docume
ntParameters.get()); | 554 handleMetaViewport(String(contentAttribute->value), m_docume
ntParameters.get()); |
| 555 return; | 555 return; |
| 556 } | 556 } |
| 557 if (nameAttribute && equalIgnoringCase(String(nameAttribute->value),
"referrer")) { |
| 558 const typename Token::Attribute* contentAttribute = token.getAtt
ributeItem(contentAttr); |
| 559 if (contentAttribute) |
| 560 *preloadedReferrerPolicy = String(contentAttribute->value).i
solatedCopy(); |
| 561 } |
| 557 } | 562 } |
| 558 | 563 |
| 559 if (match(tagImpl, pictureTag)) { | 564 if (match(tagImpl, pictureTag)) { |
| 560 m_inPicture = true; | 565 m_inPicture = true; |
| 561 m_pictureData = PictureData(); | 566 m_pictureData = PictureData(); |
| 562 return; | 567 return; |
| 563 } | 568 } |
| 564 | 569 |
| 565 StartTagScanner scanner(tagImpl, m_documentParameters->mediaValues); | 570 StartTagScanner scanner(tagImpl, m_documentParameters->mediaValues); |
| 566 scanner.processAttributes(token.attributes()); | 571 scanner.processAttributes(token.attributes()); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 { | 611 { |
| 607 ASSERT(isMainThread()); // HTMLTokenizer::updateStateFor only works on the m
ain thread. | 612 ASSERT(isMainThread()); // HTMLTokenizer::updateStateFor only works on the m
ain thread. |
| 608 | 613 |
| 609 TRACE_EVENT1("blink", "HTMLPreloadScanner::scan", "source_length", m_source.
length()); | 614 TRACE_EVENT1("blink", "HTMLPreloadScanner::scan", "source_length", m_source.
length()); |
| 610 | 615 |
| 611 // When we start scanning, our best prediction of the baseElementURL is the
real one! | 616 // When we start scanning, our best prediction of the baseElementURL is the
real one! |
| 612 if (!startingBaseElementURL.isEmpty()) | 617 if (!startingBaseElementURL.isEmpty()) |
| 613 m_scanner.setPredictedBaseElementURL(startingBaseElementURL); | 618 m_scanner.setPredictedBaseElementURL(startingBaseElementURL); |
| 614 | 619 |
| 615 PreloadRequestStream requests; | 620 PreloadRequestStream requests; |
| 621 String preloadedReferrerPolicy; |
| 616 | 622 |
| 617 while (m_tokenizer->nextToken(m_source, m_token)) { | 623 while (m_tokenizer->nextToken(m_source, m_token)) { |
| 618 if (m_token.type() == HTMLToken::StartTag) | 624 if (m_token.type() == HTMLToken::StartTag) |
| 619 m_tokenizer->updateStateFor(attemptStaticStringCreation(m_token.name
(), Likely8Bit)); | 625 m_tokenizer->updateStateFor(attemptStaticStringCreation(m_token.name
(), Likely8Bit)); |
| 620 m_scanner.scan(m_token, m_source, requests); | 626 m_scanner.scan(m_token, m_source, requests, &preloadedReferrerPolicy); |
| 621 m_token.clear(); | 627 m_token.clear(); |
| 622 } | 628 } |
| 623 | 629 |
| 630 if (!preloadedReferrerPolicy.isEmpty()) |
| 631 preloader->preloadReferrerPolicy(preloadedReferrerPolicy); |
| 632 |
| 624 preloader->takeAndPreload(requests); | 633 preloader->takeAndPreload(requests); |
| 625 } | 634 } |
| 626 | 635 |
| 627 CachedDocumentParameters::CachedDocumentParameters(Document* document, PassRefPt
r<MediaValues> givenMediaValues) | 636 CachedDocumentParameters::CachedDocumentParameters(Document* document, PassRefPt
r<MediaValues> givenMediaValues) |
| 628 { | 637 { |
| 629 ASSERT(isMainThread()); | 638 ASSERT(isMainThread()); |
| 630 ASSERT(document); | 639 ASSERT(document); |
| 631 doHtmlPreloadScanning = !document->settings() || document->settings()->doHtm
lPreloadScanning(); | 640 doHtmlPreloadScanning = !document->settings() || document->settings()->doHtm
lPreloadScanning(); |
| 632 if (givenMediaValues) | 641 if (givenMediaValues) |
| 633 mediaValues = givenMediaValues; | 642 mediaValues = givenMediaValues; |
| 634 else | 643 else |
| 635 mediaValues = MediaValuesCached::create(*document); | 644 mediaValues = MediaValuesCached::create(*document); |
| 636 ASSERT(mediaValues->isSafeToSendToAnotherThread()); | 645 ASSERT(mediaValues->isSafeToSendToAnotherThread()); |
| 637 defaultViewportMinWidth = document->viewportDefaultMinWidth(); | 646 defaultViewportMinWidth = document->viewportDefaultMinWidth(); |
| 638 viewportMetaZeroValuesQuirk = document->settings() && document->settings()->
viewportMetaZeroValuesQuirk(); | 647 viewportMetaZeroValuesQuirk = document->settings() && document->settings()->
viewportMetaZeroValuesQuirk(); |
| 639 viewportMetaEnabled = document->settings() && document->settings()->viewport
MetaEnabled(); | 648 viewportMetaEnabled = document->settings() && document->settings()->viewport
MetaEnabled(); |
| 640 } | 649 } |
| 641 | 650 |
| 642 } | 651 } |
| OLD | NEW |