Modified: trunk/Source/WebCore/ChangeLog (228152 => 228153)
--- trunk/Source/WebCore/ChangeLog 2018-02-06 06:50:24 UTC (rev 228152)
+++ trunk/Source/WebCore/ChangeLog 2018-02-06 09:45:49 UTC (rev 228153)
@@ -1,3 +1,21 @@
+2018-02-06 Ms2ger <ms2...@igalia.com>
+
+ Initialize ImageBitmap::m_bitmapData in the constructor.
+ https://bugs.webkit.org/show_bug.cgi?id=182487
+
+ Reviewed by Sam Weinig.
+
+ This removes the span of time where an ImageBitmap object would exist
+ with a null m_bitmapData during its construction.
+
+ No new tests: no behavior changes.
+
+ * html/ImageBitmap.cpp:
+ (WebCore::ImageBitmap::create): update signature
+ (WebCore::ImageBitmap::createPromise): update callers
+ (WebCore::ImageBitmap::ImageBitmap): update signature
+ * html/ImageBitmap.h: update signatures
+
2018-02-05 Ryosuke Niwa <rn...@webkit.org>
Release assertion in inlineVideoFrame
Modified: trunk/Source/WebCore/html/ImageBitmap.cpp (228152 => 228153)
--- trunk/Source/WebCore/html/ImageBitmap.cpp 2018-02-06 06:50:24 UTC (rev 228152)
+++ trunk/Source/WebCore/html/ImageBitmap.cpp 2018-02-06 09:45:49 UTC (rev 228153)
@@ -56,14 +56,12 @@
Ref<ImageBitmap> ImageBitmap::create(IntSize size)
{
- auto imageBitmap = adoptRef(*new ImageBitmap);
- imageBitmap->m_bitmapData = ImageBuffer::create(FloatSize(size.width(), size.height()), bufferRenderingMode);
- return imageBitmap;
+ return create(ImageBuffer::create(FloatSize(size.width(), size.height()), bufferRenderingMode));
}
-Ref<ImageBitmap> ImageBitmap::create()
+Ref<ImageBitmap> ImageBitmap::create(std::unique_ptr<ImageBuffer>&& buffer)
{
- return adoptRef(*new ImageBitmap);
+ return adoptRef(*new ImageBitmap(WTFMove(buffer)));
}
void ImageBitmap::createPromise(ScriptExecutionContext& scriptExecutionContext, ImageBitmap::Source&& source, ImageBitmapOptions&& options, ImageBitmap::Promise&& promise)
@@ -281,10 +279,6 @@
return;
}
- // 7. Create a new ImageBitmap object.
-
- auto imageBitmap = create();
-
// 8. Let the ImageBitmap object's bitmap data be a copy of image's media data, cropped to
// the source rectangle with formatting. If this is an animated image, the ImageBitmap
// object's bitmap data must only be taken from the default image of the animation (the
@@ -312,7 +306,8 @@
bitmapData->context().drawImage(*imageForRender, destRect, sourceRectangle.releaseReturnValue(), paintingOptions);
- imageBitmap->m_bitmapData = WTFMove(bitmapData);
+ // 7. Create a new ImageBitmap object.
+ auto imageBitmap = create(WTFMove(bitmapData));
// 9. If the origin of image's image is not the same origin as the origin specified by the
// entry settings object, then set the origin-clean flag of the ImageBitmap object's
@@ -337,9 +332,6 @@
return;
}
- // 3. Create a new ImageBitmap object.
- auto imageBitmap = create();
-
// 4. Let the ImageBitmap object's bitmap data be a copy of the canvas element's bitmap
// data, cropped to the source rectangle with formatting.
@@ -364,7 +356,8 @@
bitmapData->context().drawImage(*imageForRender, destRect, sourceRectangle.releaseReturnValue(), paintingOptions);
- imageBitmap->m_bitmapData = WTFMove(bitmapData);
+ // 3. Create a new ImageBitmap object.
+ auto imageBitmap = create(WTFMove(bitmapData));
// 5. Set the origin-clean flag of the ImageBitmap object's bitmap to the same value as
// the origin-clean flag of the canvas element's bitmap.
@@ -393,9 +386,6 @@
return;
}
- // 5. Let imageBitmap be a new ImageBitmap object.
- auto imageBitmap = create();
-
// 6.1. If image's networkState attribute is NETWORK_EMPTY, then return p
// rejected with an "InvalidStateError" DOMException.
if (video->networkState() == HTMLMediaElement::NETWORK_EMPTY) {
@@ -429,7 +419,8 @@
video->paintCurrentFrameInContext(c, FloatRect(FloatPoint(), size));
}
- imageBitmap->m_bitmapData = WTFMove(bitmapData);
+ // 5. Let imageBitmap be a new ImageBitmap object.
+ auto imageBitmap = create(WTFMove(bitmapData));
// 6.3. If the origin of image's video is not same origin with entry
// settings object's origin, then set the origin-clean flag of
@@ -450,9 +441,6 @@
return;
}
- // 3. Create a new ImageBitmap object.
- auto imageBitmap = create();
-
// 4. Let the ImageBitmap object's bitmap data be a copy of the image argument's
// bitmap data, cropped to the source rectangle with formatting.
auto sourceRectangle = croppedSourceRectangleWithFormatting(existingImageBitmap->buffer()->logicalSize(), options, WTFMove(rect));
@@ -472,7 +460,8 @@
bitmapData->context().drawImage(*imageForRender, destRect, sourceRectangle.releaseReturnValue(), paintingOptions);
- imageBitmap->m_bitmapData = WTFMove(bitmapData);
+ // 3. Create a new ImageBitmap object.
+ auto imageBitmap = create(WTFMove(bitmapData));
// 5. Set the origin-clean flag of the ImageBitmap object's bitmap to the same
// value as the origin-clean flag of the bitmap of the image argument.
@@ -605,7 +594,11 @@
promise.reject(TypeError, "createImageBitmap with ImageData is not implemented");
}
-ImageBitmap::ImageBitmap() = default;
+ImageBitmap::ImageBitmap(std::unique_ptr<ImageBuffer>&& buffer)
+ : m_bitmapData(WTFMove(buffer))
+{
+ ASSERT(m_bitmapData);
+}
ImageBitmap::~ImageBitmap() = default;
Modified: trunk/Source/WebCore/html/ImageBitmap.h (228152 => 228153)
--- trunk/Source/WebCore/html/ImageBitmap.h 2018-02-06 06:50:24 UTC (rev 228152)
+++ trunk/Source/WebCore/html/ImageBitmap.h 2018-02-06 09:45:49 UTC (rev 228153)
@@ -82,8 +82,8 @@
private:
friend class PendingImageBitmap;
- static Ref<ImageBitmap> create();
- ImageBitmap();
+ static Ref<ImageBitmap> create(std::unique_ptr<ImageBuffer>&&);
+ ImageBitmap(std::unique_ptr<ImageBuffer>&&);
static void createPromise(ScriptExecutionContext&, RefPtr<HTMLImageElement>&, ImageBitmapOptions&&, std::optional<IntRect>, Promise&&);
#if ENABLE(VIDEO)