Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Apple Inc. All rights reserv ed. | 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Apple Inc. All rights reserv ed. |
| 5 * Copyright (C) 2010 Google Inc. All rights reserved. | 5 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 6 * | 6 * |
| 7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
| 9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 44 #include "core/html/parser/HTMLSrcsetParser.h" | 44 #include "core/html/parser/HTMLSrcsetParser.h" |
| 45 #include "core/inspector/ConsoleMessage.h" | 45 #include "core/inspector/ConsoleMessage.h" |
| 46 #include "core/layout/LayoutBlockFlow.h" | 46 #include "core/layout/LayoutBlockFlow.h" |
| 47 #include "core/layout/LayoutImage.h" | 47 #include "core/layout/LayoutImage.h" |
| 48 #include "core/page/Page.h" | 48 #include "core/page/Page.h" |
| 49 #include "core/style/ContentData.h" | 49 #include "core/style/ContentData.h" |
| 50 #include "platform/ContentType.h" | 50 #include "platform/ContentType.h" |
| 51 #include "platform/EventDispatchForbiddenScope.h" | 51 #include "platform/EventDispatchForbiddenScope.h" |
| 52 #include "platform/MIMETypeRegistry.h" | 52 #include "platform/MIMETypeRegistry.h" |
| 53 #include "platform/RuntimeEnabledFeatures.h" | 53 #include "platform/RuntimeEnabledFeatures.h" |
| 54 #include "platform/weborigin/SecurityPolicy.h" | |
| 54 | 55 |
| 55 namespace blink { | 56 namespace blink { |
| 56 | 57 |
| 57 using namespace HTMLNames; | 58 using namespace HTMLNames; |
| 58 | 59 |
| 59 class HTMLImageElement::ViewportChangeListener final : public MediaQueryListList ener { | 60 class HTMLImageElement::ViewportChangeListener final : public MediaQueryListList ener { |
| 60 public: | 61 public: |
| 61 static RefPtrWillBeRawPtr<ViewportChangeListener> create(HTMLImageElement* e lement) | 62 static RefPtrWillBeRawPtr<ViewportChangeListener> create(HTMLImageElement* e lement) |
| 62 { | 63 { |
| 63 return adoptRefWillBeNoop(new ViewportChangeListener(element)); | 64 return adoptRefWillBeNoop(new ViewportChangeListener(element)); |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 378 ImageCandidate candidate = findBestFitImageFromPictureParent(); | 379 ImageCandidate candidate = findBestFitImageFromPictureParent(); |
| 379 if (!candidate.isEmpty()) { | 380 if (!candidate.isEmpty()) { |
| 380 setBestFitURLAndDPRFromImageCandidate(candidate); | 381 setBestFitURLAndDPRFromImageCandidate(candidate); |
| 381 imageWasModified = true; | 382 imageWasModified = true; |
| 382 } | 383 } |
| 383 } | 384 } |
| 384 | 385 |
| 385 // If we have been inserted from a layoutObject-less document, | 386 // If we have been inserted from a layoutObject-less document, |
| 386 // our loader may have not fetched the image, so do it now. | 387 // our loader may have not fetched the image, so do it now. |
| 387 if ((insertionPoint->inDocument() && !imageLoader().image()) || imageWasModi fied) | 388 if ((insertionPoint->inDocument() && !imageLoader().image()) || imageWasModi fied) |
| 388 imageLoader().updateFromElement(ImageLoader::UpdateNormal); | 389 imageLoader().updateFromElement(ImageLoader::UpdateNormal, referrerPolic y()); |
| 389 | 390 |
| 390 return HTMLElement::insertedInto(insertionPoint); | 391 return HTMLElement::insertedInto(insertionPoint); |
| 391 } | 392 } |
| 392 | 393 |
| 393 void HTMLImageElement::removedFrom(ContainerNode* insertionPoint) | 394 void HTMLImageElement::removedFrom(ContainerNode* insertionPoint) |
| 394 { | 395 { |
| 395 if (!m_form || NodeTraversal::highestAncestorOrSelf(*m_form.get()) != NodeTr aversal::highestAncestorOrSelf(*this)) | 396 if (!m_form || NodeTraversal::highestAncestorOrSelf(*m_form.get()) != NodeTr aversal::highestAncestorOrSelf(*this)) |
| 396 resetFormOwner(); | 397 resetFormOwner(); |
| 397 if (m_listener) | 398 if (m_listener) |
| 398 document().mediaQueryMatcher().removeViewportListener(m_listener); | 399 document().mediaQueryMatcher().removeViewportListener(m_listener); |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 653 { | 654 { |
| 654 float value; | 655 float value; |
| 655 // We don't care here if the sizes attribute exists, so we ignore the return value. | 656 // We don't care here if the sizes attribute exists, so we ignore the return value. |
| 656 // If it doesn't exist, we just return the default. | 657 // If it doesn't exist, we just return the default. |
| 657 sourceSizeValue(element, document(), value); | 658 sourceSizeValue(element, document(), value); |
| 658 return value; | 659 return value; |
| 659 } | 660 } |
| 660 | 661 |
| 661 void HTMLImageElement::forceReload() const | 662 void HTMLImageElement::forceReload() const |
| 662 { | 663 { |
| 663 imageLoader().updateFromElement(ImageLoader::UpdateForcedReload); | 664 imageLoader().updateFromElement(ImageLoader::UpdateForcedReload, referrerPol icy()); |
| 664 } | 665 } |
| 665 | 666 |
| 666 void HTMLImageElement::selectSourceURL(ImageLoader::UpdateFromElementBehavior be havior) | 667 void HTMLImageElement::selectSourceURL(ImageLoader::UpdateFromElementBehavior be havior) |
| 667 { | 668 { |
| 668 if (!document().isActive()) | 669 if (!document().isActive()) |
| 669 return; | 670 return; |
| 670 | 671 |
| 671 bool foundURL = false; | 672 bool foundURL = false; |
| 672 ImageCandidate candidate = findBestFitImageFromPictureParent(); | 673 ImageCandidate candidate = findBestFitImageFromPictureParent(); |
| 673 if (!candidate.isEmpty()) { | 674 if (!candidate.isEmpty()) { |
| 674 setBestFitURLAndDPRFromImageCandidate(candidate); | 675 setBestFitURLAndDPRFromImageCandidate(candidate); |
| 675 foundURL = true; | 676 foundURL = true; |
| 676 } | 677 } |
| 677 | 678 |
| 678 if (!foundURL) { | 679 if (!foundURL) { |
| 679 candidate = bestFitSourceForImageAttributes(document().devicePixelRatio( ), sourceSize(*this), fastGetAttribute(srcAttr), fastGetAttribute(srcsetAttr), & document()); | 680 candidate = bestFitSourceForImageAttributes(document().devicePixelRatio( ), sourceSize(*this), fastGetAttribute(srcAttr), fastGetAttribute(srcsetAttr), & document()); |
| 680 setBestFitURLAndDPRFromImageCandidate(candidate); | 681 setBestFitURLAndDPRFromImageCandidate(candidate); |
| 681 } | 682 } |
| 682 if (m_intrinsicSizingViewportDependant && !m_listener) { | 683 if (m_intrinsicSizingViewportDependant && !m_listener) { |
| 683 m_listener = ViewportChangeListener::create(this); | 684 m_listener = ViewportChangeListener::create(this); |
| 684 document().mediaQueryMatcher().addViewportListener(m_listener); | 685 document().mediaQueryMatcher().addViewportListener(m_listener); |
| 685 } | 686 } |
| 686 imageLoader().updateFromElement(behavior); | 687 imageLoader().updateFromElement(behavior, referrerPolicy()); |
| 687 | 688 |
| 688 if (imageLoader().image() || (imageLoader().hasPendingActivity() && !imageSo urceURL().isEmpty())) | 689 if (imageLoader().image() || (imageLoader().hasPendingActivity() && !imageSo urceURL().isEmpty())) |
| 689 ensurePrimaryContent(); | 690 ensurePrimaryContent(); |
| 690 else | 691 else |
| 691 ensureFallbackContent(); | 692 ensureFallbackContent(); |
| 692 } | 693 } |
| 693 | 694 |
| 694 const KURL& HTMLImageElement::sourceURL() const | 695 const KURL& HTMLImageElement::sourceURL() const |
| 695 { | 696 { |
| 696 return cachedImage()->response().url(); | 697 return cachedImage()->response().url(); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 752 EventDispatchForbiddenScope::AllowUserAgentEvents allowEvents; | 753 EventDispatchForbiddenScope::AllowUserAgentEvents allowEvents; |
| 753 ensureUserAgentShadowRoot(); | 754 ensureUserAgentShadowRoot(); |
| 754 } | 755 } |
| 755 | 756 |
| 756 bool HTMLImageElement::isOpaque() const | 757 bool HTMLImageElement::isOpaque() const |
| 757 { | 758 { |
| 758 Image* image = const_cast<HTMLImageElement*>(this)->imageContents(); | 759 Image* image = const_cast<HTMLImageElement*>(this)->imageContents(); |
| 759 return image && image->currentFrameKnownToBeOpaque(); | 760 return image && image->currentFrameKnownToBeOpaque(); |
| 760 } | 761 } |
| 761 | 762 |
| 763 ReferrerPolicy HTMLImageElement::referrerPolicy() const | |
| 764 { | |
| 765 ReferrerPolicy policy = ReferrerPolicyDefault; | |
| 766 if (RuntimeEnabledFeatures::referrerPolicyAttributeEnabled() && hasAttribute (referrerpolicyAttr)) { | |
| 767 SecurityPolicy::referrerPolicyFromString(fastGetAttribute(referrerpolicy Attr), &policy); | |
| 768 } | |
| 769 | |
| 770 return policy; | |
| 762 } | 771 } |
|
Yoav Weiss
2015/08/18 07:22:17
Processing the referrer every time referrerPolicy(
estark
2015/08/18 17:34:26
Done.
| |
| 772 } | |
| OLD | NEW |