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) 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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 137 | 137 |
| 138 public: | 138 public: |
| 139 StartTagScanner(const StringImpl* tag_impl, MediaValuesCached* media_values) | 139 StartTagScanner(const StringImpl* tag_impl, MediaValuesCached* media_values) |
| 140 : tag_impl_(tag_impl), | 140 : tag_impl_(tag_impl), |
| 141 link_is_style_sheet_(false), | 141 link_is_style_sheet_(false), |
| 142 link_is_preconnect_(false), | 142 link_is_preconnect_(false), |
| 143 link_is_preload_(false), | 143 link_is_preload_(false), |
| 144 link_is_import_(false), | 144 link_is_import_(false), |
| 145 matched_(true), | 145 matched_(true), |
| 146 input_is_image_(false), | 146 input_is_image_(false), |
| 147 nomodule_attribute_value_(false), | |
| 147 source_size_(0), | 148 source_size_(0), |
| 148 source_size_set_(false), | 149 source_size_set_(false), |
| 149 defer_(FetchParameters::kNoDefer), | 150 defer_(FetchParameters::kNoDefer), |
| 150 cross_origin_(kCrossOriginAttributeNotSet), | 151 cross_origin_(kCrossOriginAttributeNotSet), |
| 151 media_values_(media_values), | 152 media_values_(media_values), |
| 152 referrer_policy_set_(false), | 153 referrer_policy_set_(false), |
| 153 referrer_policy_(kReferrerPolicyDefault) { | 154 referrer_policy_(kReferrerPolicyDefault) { |
| 154 if (Match(tag_impl_, imgTag) || Match(tag_impl_, sourceTag)) { | 155 if (Match(tag_impl_, imgTag) || Match(tag_impl_, sourceTag)) { |
| 155 source_size_ = SizesAttributeParser(media_values_, String()).length(); | 156 source_size_ = SizesAttributeParser(media_values_, String()).length(); |
| 156 return; | 157 return; |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 282 // different metadata (including empty) from the metadata on the request. | 283 // different metadata (including empty) from the metadata on the request. |
| 283 // See the comment before the call to mustRefetchDueToIntegrityMismatch() in | 284 // See the comment before the call to mustRefetchDueToIntegrityMismatch() in |
| 284 // Source/core/fetch/ResourceFetcher.cpp for a more complete explanation. | 285 // Source/core/fetch/ResourceFetcher.cpp for a more complete explanation. |
| 285 else if (Match(attribute_name, integrityAttr)) | 286 else if (Match(attribute_name, integrityAttr)) |
| 286 SubresourceIntegrity::ParseIntegrityAttribute(attribute_value, | 287 SubresourceIntegrity::ParseIntegrityAttribute(attribute_value, |
| 287 integrity_metadata_); | 288 integrity_metadata_); |
| 288 else if (Match(attribute_name, typeAttr)) | 289 else if (Match(attribute_name, typeAttr)) |
| 289 type_attribute_value_ = attribute_value; | 290 type_attribute_value_ = attribute_value; |
| 290 else if (Match(attribute_name, languageAttr)) | 291 else if (Match(attribute_name, languageAttr)) |
| 291 language_attribute_value_ = attribute_value; | 292 language_attribute_value_ = attribute_value; |
| 293 else if (Match(attribute_name, nomoduleAttr)) | |
| 294 nomodule_attribute_value_ = true; | |
| 292 } | 295 } |
| 293 | 296 |
| 294 template <typename NameType> | 297 template <typename NameType> |
| 295 void ProcessImgAttribute(const NameType& attribute_name, | 298 void ProcessImgAttribute(const NameType& attribute_name, |
| 296 const String& attribute_value) { | 299 const String& attribute_value) { |
| 297 if (Match(attribute_name, srcAttr) && img_src_url_.IsNull()) { | 300 if (Match(attribute_name, srcAttr) && img_src_url_.IsNull()) { |
| 298 img_src_url_ = attribute_value; | 301 img_src_url_ = attribute_value; |
| 299 SetUrlToLoad(BestFitSourceForImageAttributes( | 302 SetUrlToLoad(BestFitSourceForImageAttributes( |
| 300 media_values_->DevicePixelRatio(), source_size_, | 303 media_values_->DevicePixelRatio(), source_size_, |
| 301 attribute_value, srcset_image_candidate_), | 304 attribute_value, srcset_image_candidate_), |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 514 | 517 |
| 515 bool ShouldPreload(WTF::Optional<Resource::Type>& type) const { | 518 bool ShouldPreload(WTF::Optional<Resource::Type>& type) const { |
| 516 if (url_to_load_.IsEmpty()) | 519 if (url_to_load_.IsEmpty()) |
| 517 return false; | 520 return false; |
| 518 if (!matched_) | 521 if (!matched_) |
| 519 return false; | 522 return false; |
| 520 if (Match(tag_impl_, linkTag)) | 523 if (Match(tag_impl_, linkTag)) |
| 521 return ShouldPreloadLink(type); | 524 return ShouldPreloadLink(type); |
| 522 if (Match(tag_impl_, inputTag) && !input_is_image_) | 525 if (Match(tag_impl_, inputTag) && !input_is_image_) |
| 523 return false; | 526 return false; |
| 524 ScriptType script_type = ScriptType::kClassic; | 527 ScriptType script_type = ScriptType::kClassic; |
|
hiroshige
2017/04/19 21:15:33
nit: this declaration can be moved inside if() blo
Nate Chapin
2017/04/19 21:54:32
Done.
| |
| 525 if (Match(tag_impl_, scriptTag) && | 528 if (Match(tag_impl_, scriptTag)) { |
| 526 !ScriptLoader::IsValidScriptTypeAndLanguage( | 529 if (!ScriptLoader::IsValidScriptTypeAndLanguage( |
| 527 type_attribute_value_, language_attribute_value_, | 530 type_attribute_value_, language_attribute_value_, |
| 528 ScriptLoader::kAllowLegacyTypeInTypeAttribute, script_type)) { | 531 ScriptLoader::kAllowLegacyTypeInTypeAttribute, script_type)) { |
| 529 return false; | 532 return false; |
| 533 } | |
| 534 if (ScriptLoader::BlockForNoModule(script_type, | |
| 535 nomodule_attribute_value_)) { | |
| 536 return false; | |
| 537 } | |
| 530 } | 538 } |
| 531 return true; | 539 return true; |
| 532 } | 540 } |
| 533 | 541 |
| 534 void SetCrossOrigin(const String& cors_setting) { | 542 void SetCrossOrigin(const String& cors_setting) { |
| 535 cross_origin_ = GetCrossOriginAttributeValue(cors_setting); | 543 cross_origin_ = GetCrossOriginAttributeValue(cors_setting); |
| 536 } | 544 } |
| 537 | 545 |
| 538 void SetNonce(const String& nonce) { nonce_ = nonce; } | 546 void SetNonce(const String& nonce) { nonce_ = nonce; } |
| 539 | 547 |
| 540 void SetDefer(FetchParameters::DeferOption defer) { defer_ = defer; } | 548 void SetDefer(FetchParameters::DeferOption defer) { defer_ = defer; } |
| 541 | 549 |
| 542 bool Defer() const { return defer_; } | 550 bool Defer() const { return defer_; } |
| 543 | 551 |
| 544 const StringImpl* tag_impl_; | 552 const StringImpl* tag_impl_; |
| 545 String url_to_load_; | 553 String url_to_load_; |
| 546 ImageCandidate srcset_image_candidate_; | 554 ImageCandidate srcset_image_candidate_; |
| 547 String charset_; | 555 String charset_; |
| 548 bool link_is_style_sheet_; | 556 bool link_is_style_sheet_; |
| 549 bool link_is_preconnect_; | 557 bool link_is_preconnect_; |
| 550 bool link_is_preload_; | 558 bool link_is_preload_; |
| 551 bool link_is_import_; | 559 bool link_is_import_; |
| 552 bool matched_; | 560 bool matched_; |
| 553 bool input_is_image_; | 561 bool input_is_image_; |
| 554 String img_src_url_; | 562 String img_src_url_; |
| 555 String srcset_attribute_value_; | 563 String srcset_attribute_value_; |
| 556 String as_attribute_value_; | 564 String as_attribute_value_; |
| 557 String type_attribute_value_; | 565 String type_attribute_value_; |
| 558 String language_attribute_value_; | 566 String language_attribute_value_; |
| 567 bool nomodule_attribute_value_; | |
| 559 float source_size_; | 568 float source_size_; |
| 560 bool source_size_set_; | 569 bool source_size_set_; |
| 561 FetchParameters::DeferOption defer_; | 570 FetchParameters::DeferOption defer_; |
| 562 CrossOriginAttributeValue cross_origin_; | 571 CrossOriginAttributeValue cross_origin_; |
| 563 String nonce_; | 572 String nonce_; |
| 564 Member<MediaValuesCached> media_values_; | 573 Member<MediaValuesCached> media_values_; |
| 565 bool referrer_policy_set_; | 574 bool referrer_policy_set_; |
| 566 ReferrerPolicy referrer_policy_; | 575 ReferrerPolicy referrer_policy_; |
| 567 IntegrityMetadataSet integrity_metadata_; | 576 IntegrityMetadataSet integrity_metadata_; |
| 568 }; | 577 }; |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 936 default_viewport_min_width = document->ViewportDefaultMinWidth(); | 945 default_viewport_min_width = document->ViewportDefaultMinWidth(); |
| 937 viewport_meta_zero_values_quirk = | 946 viewport_meta_zero_values_quirk = |
| 938 document->GetSettings() && | 947 document->GetSettings() && |
| 939 document->GetSettings()->GetViewportMetaZeroValuesQuirk(); | 948 document->GetSettings()->GetViewportMetaZeroValuesQuirk(); |
| 940 viewport_meta_enabled = document->GetSettings() && | 949 viewport_meta_enabled = document->GetSettings() && |
| 941 document->GetSettings()->GetViewportMetaEnabled(); | 950 document->GetSettings()->GetViewportMetaEnabled(); |
| 942 referrer_policy = document->GetReferrerPolicy(); | 951 referrer_policy = document->GetReferrerPolicy(); |
| 943 } | 952 } |
| 944 | 953 |
| 945 } // namespace blink | 954 } // namespace blink |
| OLD | NEW |