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