| 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 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 726 if (!foundURL) { | 726 if (!foundURL) { |
| 727 candidate = bestFitSourceForImageAttributes(document().devicePixelRatio(
), sourceSize(*this), fastGetAttribute(srcAttr), fastGetAttribute(srcsetAttr), &
document()); | 727 candidate = bestFitSourceForImageAttributes(document().devicePixelRatio(
), sourceSize(*this), fastGetAttribute(srcAttr), fastGetAttribute(srcsetAttr), &
document()); |
| 728 setBestFitURLAndDPRFromImageCandidate(candidate); | 728 setBestFitURLAndDPRFromImageCandidate(candidate); |
| 729 } | 729 } |
| 730 imageLoader().updateFromElement(behavior, m_referrerPolicy); | 730 imageLoader().updateFromElement(behavior, m_referrerPolicy); |
| 731 | 731 |
| 732 // Images such as data: uri's can return immediately and may already have er
rored out. | 732 // Images such as data: uri's can return immediately and may already have er
rored out. |
| 733 bool imageHasLoaded = imageLoader().image() && !imageLoader().image()->isLoa
ding() && !imageLoader().image()->errorOccurred(); | 733 bool imageHasLoaded = imageLoader().image() && !imageLoader().image()->isLoa
ding() && !imageLoader().image()->errorOccurred(); |
| 734 bool imageStillLoading = !imageHasLoaded && imageLoader().hasPendingActivity
() && !imageLoader().hasPendingError() && !imageSourceURL().isEmpty(); | 734 bool imageStillLoading = !imageHasLoaded && imageLoader().hasPendingActivity
() && !imageLoader().hasPendingError() && !imageSourceURL().isEmpty(); |
| 735 bool imageHasImage = imageLoader().image() && imageLoader().image()->hasImag
e(); | 735 bool imageHasImage = imageLoader().image() && imageLoader().image()->hasImag
e(); |
| 736 bool imageIsDocument = imageLoader().isLoadingImageDocument() && imageLoader
().image() && !imageLoader().image()->errorOccurred(); |
| 736 | 737 |
| 737 // Icky special case for deferred images: | 738 // Icky special case for deferred images: |
| 738 // A deferred image is not loading, does have pending activity, does not | 739 // A deferred image is not loading, does have pending activity, does not |
| 739 // have an error, but it does have an ImageResource associated | 740 // have an error, but it does have an ImageResource associated |
| 740 // with it, so imageHasLoaded will be true even though the image hasn't | 741 // with it, so imageHasLoaded will be true even though the image hasn't |
| 741 // actually loaded. Fixing the definition of imageHasLoaded isn't | 742 // actually loaded. Fixing the definition of imageHasLoaded isn't |
| 742 // sufficient, because a deferred image does have pending activity, does not | 743 // sufficient, because a deferred image does have pending activity, does not |
| 743 // have a pending error, and does have a source URL, so if imageHasLoaded | 744 // have a pending error, and does have a source URL, so if imageHasLoaded |
| 744 // was correct, imageStillLoading would become wrong. | 745 // was correct, imageStillLoading would become wrong. |
| 745 // | 746 // |
| 746 // Instead of dealing with that, there's a separate check that the | 747 // Instead of dealing with that, there's a separate check that the |
| 747 // ImageResource has non-null image data associated with it, which isn't | 748 // ImageResource has non-null image data associated with it, which isn't |
| 748 // folded into imageHasLoaded above. | 749 // folded into imageHasLoaded above. |
| 749 if ((imageHasLoaded && imageHasImage) || imageStillLoading) | 750 if ((imageHasLoaded && imageHasImage) || imageStillLoading || imageIsDocumen
t) |
| 750 ensurePrimaryContent(); | 751 ensurePrimaryContent(); |
| 751 else | 752 else |
| 752 ensureFallbackContent(); | 753 ensureFallbackContent(); |
| 753 } | 754 } |
| 754 | 755 |
| 755 const KURL& HTMLImageElement::sourceURL() const | 756 const KURL& HTMLImageElement::sourceURL() const |
| 756 { | 757 { |
| 757 return cachedImage()->response().url(); | 758 return cachedImage()->response().url(); |
| 758 } | 759 } |
| 759 | 760 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 840 { | 841 { |
| 841 ImageResource* image = cachedImage(); | 842 ImageResource* image = cachedImage(); |
| 842 if (!image) | 843 if (!image) |
| 843 return IntSize(); | 844 return IntSize(); |
| 844 LayoutSize lSize = image->imageSize(LayoutObject::shouldRespectImageOrientat
ion(layoutObject()), 1.0f); | 845 LayoutSize lSize = image->imageSize(LayoutObject::shouldRespectImageOrientat
ion(layoutObject()), 1.0f); |
| 845 DCHECK(lSize.fraction().isZero()); | 846 DCHECK(lSize.fraction().isZero()); |
| 846 return IntSize(lSize.width().toInt(), lSize.height().toInt()); | 847 return IntSize(lSize.width().toInt(), lSize.height().toInt()); |
| 847 } | 848 } |
| 848 | 849 |
| 849 } // namespace blink | 850 } // namespace blink |
| OLD | NEW |