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

Unified Diff: third_party/WebKit/Source/core/svg/SVGImageElement.cpp

Issue 2723093004: Adds SVGImageElement as a CanvasImageSource (Closed)
Patch Set: Tests added Created 3 years, 10 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/svg/SVGImageElement.cpp
diff --git a/third_party/WebKit/Source/core/svg/SVGImageElement.cpp b/third_party/WebKit/Source/core/svg/SVGImageElement.cpp
index 99f083eae214dccc6296751d4afa06fb065655c7..3d8e11104862edc759b4922f1e8e7e44d7a3c401 100644
--- a/third_party/WebKit/Source/core/svg/SVGImageElement.cpp
+++ b/third_party/WebKit/Source/core/svg/SVGImageElement.cpp
@@ -204,4 +204,53 @@ void SVGImageElement::didMoveToNewDocument(Document& oldDocument) {
SVGGraphicsElement::didMoveToNewDocument(oldDocument);
}
+PassRefPtr<Image> SVGImageElement::getSourceImageForCanvas(
fs 2017/03/01 21:20:41 This (and other method implementations) appear to
fserb 2017/03/06 21:05:13 Done.
+ SourceImageStatus* status,
+ AccelerationHint hint,
+ SnapshotReason reason,
+ const FloatSize& defaultObjectSize) const {
+ if (!imageLoader().imageComplete() || !cachedImage()) {
+ *status = IncompleteSourceImageStatus;
+ return nullptr;
+ }
+
+ if (cachedImage()->errorOccurred()) {
+ *status = UndecodableSourceImageStatus;
+ return nullptr;
+ }
+
+ *status = NormalSourceImageStatus;
+ return cachedImage()->getImage()->imageForDefaultFrame();
+}
+
+bool SVGImageElement::wouldTaintOrigin(
+ SecurityOrigin* destinationSecurityOrigin) const {
+ if (!cachedImage())
+ return false;
+ return !cachedImage()->isAccessAllowed(destinationSecurityOrigin);
+}
+
+FloatSize SVGImageElement::elementSize(
+ const FloatSize& defaultObjectSize) const {
+ if (!cachedImage())
+ return FloatSize();
+ return FloatSize(cachedImage()->getImage()->size());
+}
+
+bool SVGImageElement::isAccelerated() const {
+ return false;
+}
+
+int SVGImageElement::sourceWidth() {
+ if (!cachedImage())
+ return 0;
+ return cachedImage()->getImage()->width();
+}
+
+int SVGImageElement::sourceHeight() {
+ if (!cachedImage())
+ return 0;
+ return cachedImage()->getImage()->height();
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698