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(); | |
737 | 736 |
738 // Icky special case for deferred images: | 737 // Icky special case for deferred images: |
739 // A deferred image is not loading, does have pending activity, does not | 738 // A deferred image is not loading, does have pending activity, does not |
740 // have an error, but it does have an ImageResource associated | 739 // have an error, but it does have an ImageResource associated |
741 // with it, so imageHasLoaded will be true even though the image hasn't | 740 // with it, so imageHasLoaded will be true even though the image hasn't |
742 // actually loaded. Fixing the definition of imageHasLoaded isn't | 741 // actually loaded. Fixing the definition of imageHasLoaded isn't |
743 // sufficient, because a deferred image does have pending activity, does not | 742 // sufficient, because a deferred image does have pending activity, does not |
744 // have a pending error, and does have a source URL, so if imageHasLoaded | 743 // have a pending error, and does have a source URL, so if imageHasLoaded |
745 // was correct, imageStillLoading would become wrong. | 744 // was correct, imageStillLoading would become wrong. |
746 // | 745 // |
747 // Instead of dealing with that, there's a separate check that the | 746 // Instead of dealing with that, there's a separate check that the |
748 // ImageResource has non-null image data associated with it, which isn't | 747 // ImageResource has non-null image data associated with it, which isn't |
749 // folded into imageHasLoaded above. | 748 // folded into imageHasLoaded above. |
750 if ((imageHasLoaded && imageHasImage) || imageStillLoading || imageIsDocumen
t) | 749 if ((imageHasLoaded && imageHasImage) || imageStillLoading) |
751 ensurePrimaryContent(); | 750 ensurePrimaryContent(); |
752 else | 751 else |
753 ensureFallbackContent(); | 752 ensureFallbackContent(); |
754 } | 753 } |
755 | 754 |
756 const KURL& HTMLImageElement::sourceURL() const | 755 const KURL& HTMLImageElement::sourceURL() const |
757 { | 756 { |
758 return cachedImage()->response().url(); | 757 return cachedImage()->response().url(); |
759 } | 758 } |
760 | 759 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
841 { | 840 { |
842 ImageResource* image = cachedImage(); | 841 ImageResource* image = cachedImage(); |
843 if (!image) | 842 if (!image) |
844 return IntSize(); | 843 return IntSize(); |
845 LayoutSize lSize = image->imageSize(LayoutObject::shouldRespectImageOrientat
ion(layoutObject()), 1.0f); | 844 LayoutSize lSize = image->imageSize(LayoutObject::shouldRespectImageOrientat
ion(layoutObject()), 1.0f); |
846 DCHECK(lSize.fraction().isZero()); | 845 DCHECK(lSize.fraction().isZero()); |
847 return IntSize(lSize.width().toInt(), lSize.height().toInt()); | 846 return IntSize(lSize.width().toInt(), lSize.height().toInt()); |
848 } | 847 } |
849 | 848 |
850 } // namespace blink | 849 } // namespace blink |
OLD | NEW |