diff options
author | davve <davve@opera.com> | 2016-03-07 05:53:33 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-07 13:55:29 +0000 |
commit | 8cc8a0e9395a2fc70d1a048e7e2862a9081cc70d (patch) | |
tree | 9a960758bcd593db5b70e6f92f43d1e158f8d1d1 | |
parent | df73c0f1ff73cd83009a654afa1d04561ef573d4 (diff) | |
download | chromium_src-8cc8a0e9395a2fc70d1a048e7e2862a9081cc70d.zip chromium_src-8cc8a0e9395a2fc70d1a048e7e2862a9081cc70d.tar.gz chromium_src-8cc8a0e9395a2fc70d1a048e7e2862a9081cc70d.tar.bz2 |
Shortcut ImageResource::canRender()
Move the little work ImageResource::canRender() does out of fetch/ and
into the respective call sites. A small step towards getting rid of
ImageResource::imageSize() and limiting ImageResource to fetch related
functionality.
It's assumed that ImageResource::image() never returns the nullptr and
that !errorOccurred() implies the an image or the nullImage if no
image is available.
BUG=581357
Review URL: https://codereview.chromium.org/1773503002
Cr-Commit-Position: refs/heads/master@{#379549}
4 files changed, 3 insertions, 6 deletions
diff --git a/third_party/WebKit/Source/core/css/CSSCrossfadeValue.cpp b/third_party/WebKit/Source/core/css/CSSCrossfadeValue.cpp index f852653..426c6b5 100644 --- a/third_party/WebKit/Source/core/css/CSSCrossfadeValue.cpp +++ b/third_party/WebKit/Source/core/css/CSSCrossfadeValue.cpp @@ -88,7 +88,7 @@ static Image* renderableImageForCSSValue(CSSValue* value, const LayoutObject* la { ImageResource* cachedImage = cachedImageForCSSValue(value, &layoutObject->document()); - if (!cachedImage || !cachedImage->canRender()) + if (!cachedImage || cachedImage->errorOccurred() || cachedImage->image()->isNull()) return nullptr; return cachedImage->image(); diff --git a/third_party/WebKit/Source/core/fetch/ImageResource.h b/third_party/WebKit/Source/core/fetch/ImageResource.h index c17849a..afbd05f 100644 --- a/third_party/WebKit/Source/core/fetch/ImageResource.h +++ b/third_party/WebKit/Source/core/fetch/ImageResource.h @@ -71,9 +71,6 @@ public: static std::pair<blink::Image*, float> brokenImage(float deviceScaleFactor); // Returns an image and the image's resolution scale factor. bool willPaintBrokenImage() const; - // Assumes that image rotation or scale doesn't effect the image size being empty or not. - bool canRender() { return !errorOccurred() && !imageSize(DoNotRespectImageOrientation, 1).isEmpty(); } - bool usesImageContainerSize() const; bool imageHasRelativeSize() const; // The device pixel ratio we got from the server for this image, or 1.0. diff --git a/third_party/WebKit/Source/core/style/StyleFetchedImage.cpp b/third_party/WebKit/Source/core/style/StyleFetchedImage.cpp index f2e15b3..938f53e 100644 --- a/third_party/WebKit/Source/core/style/StyleFetchedImage.cpp +++ b/third_party/WebKit/Source/core/style/StyleFetchedImage.cpp @@ -78,7 +78,7 @@ PassRefPtrWillBeRawPtr<CSSValue> StyleFetchedImage::computedCSSValue() const bool StyleFetchedImage::canRender() const { - return m_image->canRender(); + return !m_image->errorOccurred() && !m_image->image()->isNull(); } bool StyleFetchedImage::isLoaded() const diff --git a/third_party/WebKit/Source/core/style/StyleFetchedImageSet.cpp b/third_party/WebKit/Source/core/style/StyleFetchedImageSet.cpp index 0eeb5bb..e42aefb 100644 --- a/third_party/WebKit/Source/core/style/StyleFetchedImageSet.cpp +++ b/third_party/WebKit/Source/core/style/StyleFetchedImageSet.cpp @@ -80,7 +80,7 @@ PassRefPtrWillBeRawPtr<CSSValue> StyleFetchedImageSet::computedCSSValue() const bool StyleFetchedImageSet::canRender() const { - return m_bestFitImage->canRender(); + return !m_bestFitImage->errorOccurred() && !m_bestFitImage->image()->isNull(); } bool StyleFetchedImageSet::isLoaded() const |