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

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

Issue 2723093004: Adds SVGImageElement as a CanvasImageSource (Closed)
Patch Set: y 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..d2efdee99bdcd176ed9584731398d9576f65f1ec 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(
+ SourceImageStatus* status,
+ AccelerationHint hint,
+ SnapshotReason reason,
+ const FloatSize& defaultObjectSize) const {
+ if (!cachedImage()) {
Justin Novosad 2017/03/01 20:56:29 What happened to that extra check I saw you put in
fserb 2017/03/06 21:05:13 it's there. :)
+ *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);
Justin Novosad 2017/03/01 20:56:30 This needs to be tested in a layout test. Example
fserb 2017/03/06 21:05:13 done.
+}
+
+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 width();
+ return cachedImage()->getImage()->width();
+}
+
+int SVGImageElement::sourceHeight() {
+ if (!cachedImage())
+ return height();
+ return cachedImage()->getImage()->height();
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698