Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(409)

Side by Side Diff: Source/core/html/HTMLImageElement.cpp

Issue 1374793005: Single image reload fix (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/html/HTMLImageElement.h ('k') | Source/core/html/HTMLObjectElement.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 ImageCandidate candidate = findBestFitImageFromPictureParent(); 388 ImageCandidate candidate = findBestFitImageFromPictureParent();
389 if (!candidate.isEmpty()) { 389 if (!candidate.isEmpty()) {
390 setBestFitURLAndDPRFromImageCandidate(candidate); 390 setBestFitURLAndDPRFromImageCandidate(candidate);
391 imageWasModified = true; 391 imageWasModified = true;
392 } 392 }
393 } 393 }
394 394
395 // If we have been inserted from a layoutObject-less document, 395 // If we have been inserted from a layoutObject-less document,
396 // our loader may have not fetched the image, so do it now. 396 // our loader may have not fetched the image, so do it now.
397 if ((insertionPoint->inDocument() && !imageLoader().image()) || imageWasModi fied) 397 if ((insertionPoint->inDocument() && !imageLoader().image()) || imageWasModi fied)
398 imageLoader().updateFromElement(ImageLoader::UpdateNormal, m_referrerPol icy); 398 imageLoader().updateFromElement(0, ImageLoader::UpdateNormal, m_referrer Policy);
399 399
400 return HTMLElement::insertedInto(insertionPoint); 400 return HTMLElement::insertedInto(insertionPoint);
401 } 401 }
402 402
403 void HTMLImageElement::removedFrom(ContainerNode* insertionPoint) 403 void HTMLImageElement::removedFrom(ContainerNode* insertionPoint)
404 { 404 {
405 if (!m_form || NodeTraversal::highestAncestorOrSelf(*m_form.get()) != NodeTr aversal::highestAncestorOrSelf(*this)) 405 if (!m_form || NodeTraversal::highestAncestorOrSelf(*m_form.get()) != NodeTr aversal::highestAncestorOrSelf(*this))
406 resetFormOwner(); 406 resetFormOwner();
407 if (m_listener) 407 if (m_listener)
408 document().mediaQueryMatcher().removeViewportListener(m_listener); 408 document().mediaQueryMatcher().removeViewportListener(m_listener);
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 657
658 float HTMLImageElement::sourceSize(Element& element) 658 float HTMLImageElement::sourceSize(Element& element)
659 { 659 {
660 float value; 660 float value;
661 // We don't care here if the sizes attribute exists, so we ignore the return value. 661 // We don't care here if the sizes attribute exists, so we ignore the return value.
662 // If it doesn't exist, we just return the default. 662 // If it doesn't exist, we just return the default.
663 sourceSizeValue(element, document(), value); 663 sourceSizeValue(element, document(), value);
664 return value; 664 return value;
665 } 665 }
666 666
667 void HTMLImageElement::forceReload() const 667 void HTMLImageElement::forceReload(WebURLRequest::ExtraData* extraData) const
668 { 668 {
669 imageLoader().updateFromElement(ImageLoader::UpdateForcedReload, m_referrerP olicy); 669 imageLoader().updateFromElement(extraData, ImageLoader::UpdateForcedReload, m_referrerPolicy);
670 } 670 }
671 671
672 void HTMLImageElement::selectSourceURL(ImageLoader::UpdateFromElementBehavior be havior) 672 void HTMLImageElement::selectSourceURL(ImageLoader::UpdateFromElementBehavior be havior)
673 { 673 {
674 if (!document().isActive()) 674 if (!document().isActive())
675 return; 675 return;
676 676
677 bool foundURL = false; 677 bool foundURL = false;
678 ImageCandidate candidate = findBestFitImageFromPictureParent(); 678 ImageCandidate candidate = findBestFitImageFromPictureParent();
679 if (!candidate.isEmpty()) { 679 if (!candidate.isEmpty()) {
680 setBestFitURLAndDPRFromImageCandidate(candidate); 680 setBestFitURLAndDPRFromImageCandidate(candidate);
681 foundURL = true; 681 foundURL = true;
682 } 682 }
683 683
684 if (!foundURL) { 684 if (!foundURL) {
685 candidate = bestFitSourceForImageAttributes(document().devicePixelRatio( ), sourceSize(*this), fastGetAttribute(srcAttr), fastGetAttribute(srcsetAttr), & document()); 685 candidate = bestFitSourceForImageAttributes(document().devicePixelRatio( ), sourceSize(*this), fastGetAttribute(srcAttr), fastGetAttribute(srcsetAttr), & document());
686 setBestFitURLAndDPRFromImageCandidate(candidate); 686 setBestFitURLAndDPRFromImageCandidate(candidate);
687 } 687 }
688 if (m_intrinsicSizingViewportDependant && !m_listener) { 688 if (m_intrinsicSizingViewportDependant && !m_listener) {
689 m_listener = ViewportChangeListener::create(this); 689 m_listener = ViewportChangeListener::create(this);
690 document().mediaQueryMatcher().addViewportListener(m_listener); 690 document().mediaQueryMatcher().addViewportListener(m_listener);
691 } 691 }
692 imageLoader().updateFromElement(behavior, m_referrerPolicy); 692 imageLoader().updateFromElement(0, behavior, m_referrerPolicy);
693 693
694 if (imageLoader().image() || (imageLoader().hasPendingActivity() && !imageSo urceURL().isEmpty())) 694 if (imageLoader().image() || (imageLoader().hasPendingActivity() && !imageSo urceURL().isEmpty()))
695 ensurePrimaryContent(); 695 ensurePrimaryContent();
696 else 696 else
697 ensureFallbackContent(); 697 ensureFallbackContent();
698 } 698 }
699 699
700 const KURL& HTMLImageElement::sourceURL() const 700 const KURL& HTMLImageElement::sourceURL() const
701 { 701 {
702 return cachedImage()->response().url(); 702 return cachedImage()->response().url();
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 ensureUserAgentShadowRoot(); 759 ensureUserAgentShadowRoot();
760 } 760 }
761 761
762 bool HTMLImageElement::isOpaque() const 762 bool HTMLImageElement::isOpaque() const
763 { 763 {
764 Image* image = const_cast<HTMLImageElement*>(this)->imageContents(); 764 Image* image = const_cast<HTMLImageElement*>(this)->imageContents();
765 return image && image->currentFrameKnownToBeOpaque(); 765 return image && image->currentFrameKnownToBeOpaque();
766 } 766 }
767 767
768 } 768 }
OLDNEW
« no previous file with comments | « Source/core/html/HTMLImageElement.h ('k') | Source/core/html/HTMLObjectElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698