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

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

Issue 2035113002: Implement ImageBitmapOptions resize (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 4 years, 5 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/ImageBitmapTest.cpp
diff --git a/third_party/WebKit/Source/core/frame/ImageBitmapTest.cpp b/third_party/WebKit/Source/core/frame/ImageBitmapTest.cpp
index 6027353a939d720107784093797dbf7ef63a31a0..6919c835615110439bccbdc5d81ed46fba7b08da 100644
--- a/third_party/WebKit/Source/core/frame/ImageBitmapTest.cpp
+++ b/third_party/WebKit/Source/core/frame/ImageBitmapTest.cpp
@@ -84,18 +84,18 @@ TEST_F(ImageBitmapTest, ImageResourceConsistency)
ImageResource* image = ImageResource::create(StaticBitmapImage::create(m_image).get());
imageElement->setImageResource(image);
+ Optional<IntRect> cropRect = IntRect(0, 0, m_image->width(), m_image->height());
ImageBitmap* imageBitmapNoCrop = ImageBitmap::create(imageElement,
- IntRect(0, 0, m_image->width(), m_image->height()),
- &(imageElement->document()), defaultOptions);
+ cropRect, &(imageElement->document()), defaultOptions);
+ cropRect = IntRect(m_image->width() / 2, m_image->height() / 2, m_image->width() / 2, m_image->height() / 2);
ImageBitmap* imageBitmapInteriorCrop = ImageBitmap::create(imageElement,
- IntRect(m_image->width() / 2, m_image->height() / 2, m_image->width() / 2, m_image->height() / 2),
- &(imageElement->document()), defaultOptions);
+ cropRect, &(imageElement->document()), defaultOptions);
+ cropRect = IntRect(-m_image->width() / 2, -m_image->height() / 2, m_image->width(), m_image->height());
ImageBitmap* imageBitmapExteriorCrop = ImageBitmap::create(imageElement,
- IntRect(-m_image->width() / 2, -m_image->height() / 2, m_image->width(), m_image->height()),
- &(imageElement->document()), defaultOptions);
+ cropRect, &(imageElement->document()), defaultOptions);
+ cropRect = IntRect(-m_image->width(), -m_image->height(), m_image->width(), m_image->height());
ImageBitmap* imageBitmapOutsideCrop = ImageBitmap::create(imageElement,
- IntRect(-m_image->width(), -m_image->height(), m_image->width(), m_image->height()),
- &(imageElement->document()), defaultOptions);
+ cropRect, &(imageElement->document()), defaultOptions);
ASSERT_EQ(imageBitmapNoCrop->bitmapImage()->imageForCurrentFrame(), imageElement->cachedImage()->getImage()->imageForCurrentFrame());
ASSERT_NE(imageBitmapInteriorCrop->bitmapImage()->imageForCurrentFrame(), imageElement->cachedImage()->getImage()->imageForCurrentFrame());
@@ -114,9 +114,9 @@ TEST_F(ImageBitmapTest, ImageBitmapSourceChanged)
image->setImageResource(originalImageResource);
const ImageBitmapOptions defaultOptions;
+ Optional<IntRect> cropRect = IntRect(0, 0, m_image->width(), m_image->height());
ImageBitmap* imageBitmap = ImageBitmap::create(image,
- IntRect(0, 0, m_image->width(), m_image->height()),
- &(image->document()), defaultOptions);
+ cropRect, &(image->document()), defaultOptions);
ASSERT_EQ(imageBitmap->bitmapImage()->imageForCurrentFrame(), originalImageResource->getImage()->imageForCurrentFrame());
ImageResource* newImageResource = ImageResource::create(
« no previous file with comments | « third_party/WebKit/Source/core/frame/ImageBitmap.cpp ('k') | third_party/WebKit/Source/core/html/HTMLCanvasElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698