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

Unified Diff: third_party/WebKit/Source/core/frame/ImageBitmap.cpp

Issue 1532473002: Add a origin clean flag in ImageBitmap class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix compilation error Created 4 years, 11 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/frame/ImageBitmap.cpp
diff --git a/third_party/WebKit/Source/core/frame/ImageBitmap.cpp b/third_party/WebKit/Source/core/frame/ImageBitmap.cpp
index 2d42f461bf49503a4ec7e1c1d82b4fc10b5c63db..8b15261e63ae2965a1dc172c04c2f1c6d0f94da7 100644
--- a/third_party/WebKit/Source/core/frame/ImageBitmap.cpp
+++ b/third_party/WebKit/Source/core/frame/ImageBitmap.cpp
@@ -45,12 +45,13 @@ static PassRefPtr<StaticBitmapImage> cropImage(Image* image, const IntRect& crop
return StaticBitmapImage::create(adoptRef(surface->newImageSnapshot()));
}
-ImageBitmap::ImageBitmap(HTMLImageElement* image, const IntRect& cropRect)
+ImageBitmap::ImageBitmap(HTMLImageElement* image, const IntRect& cropRect, Document* document)
{
m_image = cropImage(image->cachedImage()->image(), cropRect);
+ m_image->setOriginClean(!image->wouldTaintOrigin(document->securityOrigin()));
}
-ImageBitmap::ImageBitmap(HTMLVideoElement* video, const IntRect& cropRect)
+ImageBitmap::ImageBitmap(HTMLVideoElement* video, const IntRect& cropRect, Document* document)
{
IntSize playerSize;
if (video->webMediaPlayer())
@@ -65,12 +66,14 @@ ImageBitmap::ImageBitmap(HTMLVideoElement* video, const IntRect& cropRect)
IntPoint dstPoint = IntPoint(std::max(0, -cropRect.x()), std::max(0, -cropRect.y()));
video->paintCurrentFrame(buffer->canvas(), IntRect(dstPoint, srcRect.size()), nullptr);
m_image = StaticBitmapImage::create(buffer->newSkImageSnapshot(PreferNoAcceleration));
+ m_image->setOriginClean(!video->wouldTaintOrigin(document->securityOrigin()));
}
ImageBitmap::ImageBitmap(HTMLCanvasElement* canvas, const IntRect& cropRect)
{
ASSERT(canvas->isPaintable());
m_image = cropImage(canvas->copiedImage(BackBuffer, PreferAcceleration).get(), cropRect);
+ m_image->setOriginClean(canvas->originClean());
}
ImageBitmap::ImageBitmap(ImageData* data, const IntRect& cropRect)
@@ -98,11 +101,13 @@ ImageBitmap::ImageBitmap(ImageData* data, const IntRect& cropRect)
ImageBitmap::ImageBitmap(ImageBitmap* bitmap, const IntRect& cropRect)
{
m_image = cropImage(bitmap->bitmapImage(), cropRect);
+ m_image->setOriginClean(bitmap->originClean());
}
-ImageBitmap::ImageBitmap(Image* image, const IntRect& cropRect)
+ImageBitmap::ImageBitmap(PassRefPtr<StaticBitmapImage> image, const IntRect& cropRect)
{
- m_image = cropImage(image, cropRect);
+ m_image = cropImage(image.get(), cropRect);
+ m_image->setOriginClean(image->originClean());
}
ImageBitmap::ImageBitmap(PassRefPtr<StaticBitmapImage> image)
@@ -121,16 +126,16 @@ ImageBitmap::~ImageBitmap()
{
}
-PassRefPtrWillBeRawPtr<ImageBitmap> ImageBitmap::create(HTMLImageElement* image, const IntRect& cropRect)
+PassRefPtrWillBeRawPtr<ImageBitmap> ImageBitmap::create(HTMLImageElement* image, const IntRect& cropRect, Document* document)
{
IntRect normalizedCropRect = normalizeRect(cropRect);
- return adoptRefWillBeNoop(new ImageBitmap(image, normalizedCropRect));
+ return adoptRefWillBeNoop(new ImageBitmap(image, normalizedCropRect, document));
}
-PassRefPtrWillBeRawPtr<ImageBitmap> ImageBitmap::create(HTMLVideoElement* video, const IntRect& cropRect)
+PassRefPtrWillBeRawPtr<ImageBitmap> ImageBitmap::create(HTMLVideoElement* video, const IntRect& cropRect, Document* document)
{
IntRect normalizedCropRect = normalizeRect(cropRect);
- return adoptRefWillBeNoop(new ImageBitmap(video, normalizedCropRect));
+ return adoptRefWillBeNoop(new ImageBitmap(video, normalizedCropRect, document));
}
PassRefPtrWillBeRawPtr<ImageBitmap> ImageBitmap::create(HTMLCanvasElement* canvas, const IntRect& cropRect)
@@ -151,7 +156,7 @@ PassRefPtrWillBeRawPtr<ImageBitmap> ImageBitmap::create(ImageBitmap* bitmap, con
return adoptRefWillBeNoop(new ImageBitmap(bitmap, normalizedCropRect));
}
-PassRefPtrWillBeRawPtr<ImageBitmap> ImageBitmap::create(Image* image, const IntRect& cropRect)
+PassRefPtrWillBeRawPtr<ImageBitmap> ImageBitmap::create(PassRefPtr<StaticBitmapImage> image, const IntRect& cropRect)
{
IntRect normalizedCropRect = normalizeRect(cropRect);
return adoptRefWillBeNoop(new ImageBitmap(image, normalizedCropRect));
« no previous file with comments | « third_party/WebKit/Source/core/frame/ImageBitmap.h ('k') | third_party/WebKit/Source/core/frame/ImageBitmapTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698