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

Unified Diff: third_party/WebKit/Source/core/css/cssom/CSSStyleImageValue.cpp

Issue 2351363002: Make CSSStyleImageValue a member of CanvasImageSource. (Closed)
Patch Set: added additional nullptr checks to getSourceImageForCanvas, changed toImageSourceInternal to includ… Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/css/cssom/CSSStyleImageValue.cpp
diff --git a/third_party/WebKit/Source/core/css/cssom/CSSStyleImageValue.cpp b/third_party/WebKit/Source/core/css/cssom/CSSStyleImageValue.cpp
index 3f6a5c0ba3b60ddc465ce67fd99193080fca459a..c1d006916364b5b78c69ab8f7240d1fb1b087c97 100644
--- a/third_party/WebKit/Source/core/css/cssom/CSSStyleImageValue.cpp
+++ b/third_party/WebKit/Source/core/css/cssom/CSSStyleImageValue.cpp
@@ -6,7 +6,7 @@
namespace blink {
-double CSSStyleImageValue::intrinsicWidth(bool& isNull)
+double CSSStyleImageValue::intrinsicWidth(bool& isNull) const
{
isNull = isCachePending();
if (isNull)
@@ -14,7 +14,7 @@ double CSSStyleImageValue::intrinsicWidth(bool& isNull)
return imageLayoutSize().width().toDouble();
}
-double CSSStyleImageValue::intrinsicHeight(bool& isNull)
+double CSSStyleImageValue::intrinsicHeight(bool& isNull) const
{
isNull = isCachePending();
if (isNull)
@@ -35,4 +35,36 @@ double CSSStyleImageValue::intrinsicRatio(bool& isNull)
return intrinsicWidth(isNull) / intrinsicHeight(isNull);
}
+FloatSize CSSStyleImageValue::elementSize(const FloatSize& defaultObjectSize) const
+{
+ bool notUsed;
+ return FloatSize(intrinsicWidth(notUsed), intrinsicHeight(notUsed));
+}
+
+int CSSStyleImageValue::sourceHeight()
+{
+ bool notUsed;
+ return intrinsicHeight(notUsed);
+}
+
+int CSSStyleImageValue::sourceWidth()
+{
+ bool notUsed;
+ return intrinsicWidth(notUsed);
+}
+
+PassRefPtr<Image> CSSStyleImageValue::getSourceImageForCanvas(SourceImageStatus* status, AccelerationHint, SnapshotReason,
+ const FloatSize&) const
+{
+ if (isCachePending())
+ return nullptr;
+ // cachedImage can be null if image is StyleInvalidImage
+ ImageResource* cachedImage = m_imageValue->cachedImage()->cachedImage();
+ if (cachedImage) {
+ // getImage() returns the nullImage() if the image is not available yet
+ return cachedImage->getImage()->imageForDefaultFrame();
+ }
+ return nullptr;
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698