Title: [222986] trunk
Revision
222986
Author
[email protected]
Date
2017-10-06 09:51:47 -0700 (Fri, 06 Oct 2017)

Log Message

ImageBitmap API stubs
https://bugs.webkit.org/show_bug.cgi?id=177984
<rdar://problem/34848023>

Patch by Sam and Dean.
Reviewed by Dean and Sam.

Source/WebCore:

Add the IDL for ImageBitmap and ImageBitmapOptions, plus some
stub implementations (complete with all the algorithms from
the HTML specification as comments).

* CMakeLists.txt: Add the new files.
* DerivedSources.make: Create the JS bindings for ImageBitmap and ImageBitmapOptions.
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/CallTracerTypes.h:
* html/ImageBitmap.cpp: Added.
(WebCore::ImageBitmap::create):
(WebCore::ImageBitmap::createPromise):
(WebCore::ImageBitmap::ImageBitmap):
(WebCore::ImageBitmap::~ImageBitmap):
(WebCore::ImageBitmap::width const):
(WebCore::ImageBitmap::height const):
(WebCore::ImageBitmap::close):
* html/ImageBitmap.h: Added.
(WebCore::ImageBitmap::isDetached const):
* html/ImageBitmap.idl: Copied from Source/WebCore/html/canvas/CanvasDrawImage.idl.
* html/ImageBitmapOptions.h: Copied from Source/WebCore/html/canvas/CanvasDrawImage.idl.
* html/ImageBitmapOptions.idl: Copied from Source/WebCore/html/canvas/CanvasDrawImage.idl.
* html/canvas/CanvasDrawImage.idl:
* html/canvas/CanvasFillStrokeStyles.idl:
* html/canvas/CanvasRenderingContext2D.cpp:
(WebCore::size):
(WebCore::CanvasRenderingContext2D::drawImage):
(WebCore::CanvasRenderingContext2D::createPattern):
* html/canvas/CanvasRenderingContext2D.h:
* inspector/InspectorCanvas.cpp:
(WebCore::InspectorCanvas::indexForData):
(WebCore::InspectorCanvas::buildAction):
(WebCore::InspectorCanvas::buildArrayForImageBitmap):
* inspector/InspectorCanvas.h:
* inspector/RecordingSwizzleTypes.h:

LayoutTests:

New global constructors, so go through the pain of updating all
the platform results :(

* js/dom/global-constructors-attributes-expected.txt:
* platform/gtk/js/dom/global-constructors-attributes-expected.txt:
* platform/mac-elcapitan-wk2/js/dom/global-constructors-attributes-expected.txt:
* platform/mac-elcapitan/js/dom/global-constructors-attributes-expected.txt:
* platform/mac-sierra-wk2/js/dom/global-constructors-attributes-expected.txt:
* platform/mac-sierra/js/dom/global-constructors-attributes-expected.txt:
* platform/mac-wk1/js/dom/global-constructors-attributes-expected.txt:
* platform/mac-wk2/js/dom/global-constructors-attributes-expected.txt:
* platform/mac-yosemite/js/dom/global-constructors-attributes-expected.txt:
* platform/mac/js/dom/global-constructors-attributes-expected.txt:
* platform/win/js/dom/global-constructors-attributes-expected.txt:
* platform/wpe/js/dom/global-constructors-attributes-expected.txt:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (222985 => 222986)


--- trunk/LayoutTests/ChangeLog	2017-10-06 16:49:50 UTC (rev 222985)
+++ trunk/LayoutTests/ChangeLog	2017-10-06 16:51:47 UTC (rev 222986)
@@ -1,3 +1,28 @@
+2017-10-05  Dean Jackson  <[email protected]>
+
+        ImageBitmap API stubs
+        https://bugs.webkit.org/show_bug.cgi?id=177984
+        <rdar://problem/34848023>
+
+        Patch by Sam and Dean.
+        Reviewed by Dean and Sam.
+
+        New global constructors, so go through the pain of updating all
+        the platform results :(
+
+        * js/dom/global-constructors-attributes-expected.txt:
+        * platform/gtk/js/dom/global-constructors-attributes-expected.txt:
+        * platform/mac-elcapitan-wk2/js/dom/global-constructors-attributes-expected.txt:
+        * platform/mac-elcapitan/js/dom/global-constructors-attributes-expected.txt:
+        * platform/mac-sierra-wk2/js/dom/global-constructors-attributes-expected.txt:
+        * platform/mac-sierra/js/dom/global-constructors-attributes-expected.txt:
+        * platform/mac-wk1/js/dom/global-constructors-attributes-expected.txt:
+        * platform/mac-wk2/js/dom/global-constructors-attributes-expected.txt:
+        * platform/mac-yosemite/js/dom/global-constructors-attributes-expected.txt:
+        * platform/mac/js/dom/global-constructors-attributes-expected.txt:
+        * platform/win/js/dom/global-constructors-attributes-expected.txt:
+        * platform/wpe/js/dom/global-constructors-attributes-expected.txt:
+
 2017-10-06  Brady Eidson  <[email protected]>
 
         Add (entirely incorrect) fetching of ServiceWorker scripts.

Modified: trunk/LayoutTests/js/dom/global-constructors-attributes-dedicated-worker-expected.txt (222985 => 222986)


--- trunk/LayoutTests/js/dom/global-constructors-attributes-dedicated-worker-expected.txt	2017-10-06 16:49:50 UTC (rev 222985)
+++ trunk/LayoutTests/js/dom/global-constructors-attributes-dedicated-worker-expected.txt	2017-10-06 16:51:47 UTC (rev 222986)
@@ -189,6 +189,11 @@
 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'Headers').hasOwnProperty('set') is false
 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'Headers').enumerable is false
 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'Headers').configurable is true
+PASS [Worker] Object.getOwnPropertyDescriptor(global, 'ImageBitmap').value is ImageBitmap
+PASS [Worker] Object.getOwnPropertyDescriptor(global, 'ImageBitmap').hasOwnProperty('get') is false
+PASS [Worker] Object.getOwnPropertyDescriptor(global, 'ImageBitmap').hasOwnProperty('set') is false
+PASS [Worker] Object.getOwnPropertyDescriptor(global, 'ImageBitmap').enumerable is false
+PASS [Worker] Object.getOwnPropertyDescriptor(global, 'ImageBitmap').configurable is true
 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'ImageData').value is ImageData
 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'ImageData').hasOwnProperty('get') is false
 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'ImageData').hasOwnProperty('set') is false

Modified: trunk/LayoutTests/js/dom/global-constructors-attributes-expected.txt (222985 => 222986)


--- trunk/LayoutTests/js/dom/global-constructors-attributes-expected.txt	2017-10-06 16:49:50 UTC (rev 222985)
+++ trunk/LayoutTests/js/dom/global-constructors-attributes-expected.txt	2017-10-06 16:51:47 UTC (rev 222986)
@@ -823,6 +823,11 @@
 PASS Object.getOwnPropertyDescriptor(global, 'Image').hasOwnProperty('set') is false
 PASS Object.getOwnPropertyDescriptor(global, 'Image').enumerable is false
 PASS Object.getOwnPropertyDescriptor(global, 'Image').configurable is true
+PASS Object.getOwnPropertyDescriptor(global, 'ImageBitmap').value is ImageBitmap
+PASS Object.getOwnPropertyDescriptor(global, 'ImageBitmap').hasOwnProperty('get') is false
+PASS Object.getOwnPropertyDescriptor(global, 'ImageBitmap').hasOwnProperty('set') is false
+PASS Object.getOwnPropertyDescriptor(global, 'ImageBitmap').enumerable is false
+PASS Object.getOwnPropertyDescriptor(global, 'ImageBitmap').configurable is true
 PASS Object.getOwnPropertyDescriptor(global, 'ImageData').value is ImageData
 PASS Object.getOwnPropertyDescriptor(global, 'ImageData').hasOwnProperty('get') is false
 PASS Object.getOwnPropertyDescriptor(global, 'ImageData').hasOwnProperty('set') is false

Modified: trunk/LayoutTests/platform/gtk/js/dom/global-constructors-attributes-expected.txt (222985 => 222986)


--- trunk/LayoutTests/platform/gtk/js/dom/global-constructors-attributes-expected.txt	2017-10-06 16:49:50 UTC (rev 222985)
+++ trunk/LayoutTests/platform/gtk/js/dom/global-constructors-attributes-expected.txt	2017-10-06 16:51:47 UTC (rev 222986)
@@ -983,6 +983,11 @@
 PASS Object.getOwnPropertyDescriptor(global, 'Image').hasOwnProperty('set') is false
 PASS Object.getOwnPropertyDescriptor(global, 'Image').enumerable is false
 PASS Object.getOwnPropertyDescriptor(global, 'Image').configurable is true
+PASS Object.getOwnPropertyDescriptor(global, 'ImageBitmap').value is ImageBitmap
+PASS Object.getOwnPropertyDescriptor(global, 'ImageBitmap').hasOwnProperty('get') is false
+PASS Object.getOwnPropertyDescriptor(global, 'ImageBitmap').hasOwnProperty('set') is false
+PASS Object.getOwnPropertyDescriptor(global, 'ImageBitmap').enumerable is false
+PASS Object.getOwnPropertyDescriptor(global, 'ImageBitmap').configurable is true
 PASS Object.getOwnPropertyDescriptor(global, 'ImageData').value is ImageData
 PASS Object.getOwnPropertyDescriptor(global, 'ImageData').hasOwnProperty('get') is false
 PASS Object.getOwnPropertyDescriptor(global, 'ImageData').hasOwnProperty('set') is false

Modified: trunk/LayoutTests/platform/mac/js/dom/global-constructors-attributes-expected.txt (222985 => 222986)


--- trunk/LayoutTests/platform/mac/js/dom/global-constructors-attributes-expected.txt	2017-10-06 16:49:50 UTC (rev 222985)
+++ trunk/LayoutTests/platform/mac/js/dom/global-constructors-attributes-expected.txt	2017-10-06 16:51:47 UTC (rev 222986)
@@ -1008,6 +1008,11 @@
 PASS Object.getOwnPropertyDescriptor(global, 'Image').hasOwnProperty('set') is false
 PASS Object.getOwnPropertyDescriptor(global, 'Image').enumerable is false
 PASS Object.getOwnPropertyDescriptor(global, 'Image').configurable is true
+PASS Object.getOwnPropertyDescriptor(global, 'ImageBitmap').value is ImageBitmap
+PASS Object.getOwnPropertyDescriptor(global, 'ImageBitmap').hasOwnProperty('get') is false
+PASS Object.getOwnPropertyDescriptor(global, 'ImageBitmap').hasOwnProperty('set') is false
+PASS Object.getOwnPropertyDescriptor(global, 'ImageBitmap').enumerable is false
+PASS Object.getOwnPropertyDescriptor(global, 'ImageBitmap').configurable is true
 PASS Object.getOwnPropertyDescriptor(global, 'ImageData').value is ImageData
 PASS Object.getOwnPropertyDescriptor(global, 'ImageData').hasOwnProperty('get') is false
 PASS Object.getOwnPropertyDescriptor(global, 'ImageData').hasOwnProperty('set') is false

Modified: trunk/LayoutTests/platform/mac-elcapitan/js/dom/global-constructors-attributes-expected.txt (222985 => 222986)


--- trunk/LayoutTests/platform/mac-elcapitan/js/dom/global-constructors-attributes-expected.txt	2017-10-06 16:49:50 UTC (rev 222985)
+++ trunk/LayoutTests/platform/mac-elcapitan/js/dom/global-constructors-attributes-expected.txt	2017-10-06 16:51:47 UTC (rev 222986)
@@ -958,6 +958,11 @@
 PASS Object.getOwnPropertyDescriptor(global, 'Image').hasOwnProperty('set') is false
 PASS Object.getOwnPropertyDescriptor(global, 'Image').enumerable is false
 PASS Object.getOwnPropertyDescriptor(global, 'Image').configurable is true
+PASS Object.getOwnPropertyDescriptor(global, 'ImageBitmap').value is ImageBitmap
+PASS Object.getOwnPropertyDescriptor(global, 'ImageBitmap').hasOwnProperty('get') is false
+PASS Object.getOwnPropertyDescriptor(global, 'ImageBitmap').hasOwnProperty('set') is false
+PASS Object.getOwnPropertyDescriptor(global, 'ImageBitmap').enumerable is false
+PASS Object.getOwnPropertyDescriptor(global, 'ImageBitmap').configurable is true
 PASS Object.getOwnPropertyDescriptor(global, 'ImageData').value is ImageData
 PASS Object.getOwnPropertyDescriptor(global, 'ImageData').hasOwnProperty('get') is false
 PASS Object.getOwnPropertyDescriptor(global, 'ImageData').hasOwnProperty('set') is false

Modified: trunk/LayoutTests/platform/mac-elcapitan-wk2/js/dom/global-constructors-attributes-expected.txt (222985 => 222986)


--- trunk/LayoutTests/platform/mac-elcapitan-wk2/js/dom/global-constructors-attributes-expected.txt	2017-10-06 16:49:50 UTC (rev 222985)
+++ trunk/LayoutTests/platform/mac-elcapitan-wk2/js/dom/global-constructors-attributes-expected.txt	2017-10-06 16:51:47 UTC (rev 222986)
@@ -998,6 +998,11 @@
 PASS Object.getOwnPropertyDescriptor(global, 'Image').hasOwnProperty('set') is false
 PASS Object.getOwnPropertyDescriptor(global, 'Image').enumerable is false
 PASS Object.getOwnPropertyDescriptor(global, 'Image').configurable is true
+PASS Object.getOwnPropertyDescriptor(global, 'ImageBitmap').value is ImageBitmap
+PASS Object.getOwnPropertyDescriptor(global, 'ImageBitmap').hasOwnProperty('get') is false
+PASS Object.getOwnPropertyDescriptor(global, 'ImageBitmap').hasOwnProperty('set') is false
+PASS Object.getOwnPropertyDescriptor(global, 'ImageBitmap').enumerable is false
+PASS Object.getOwnPropertyDescriptor(global, 'ImageBitmap').configurable is true
 PASS Object.getOwnPropertyDescriptor(global, 'ImageData').value is ImageData
 PASS Object.getOwnPropertyDescriptor(global, 'ImageData').hasOwnProperty('get') is false
 PASS Object.getOwnPropertyDescriptor(global, 'ImageData').hasOwnProperty('set') is false

Modified: trunk/LayoutTests/platform/mac-sierra/js/dom/global-constructors-attributes-expected.txt (222985 => 222986)


--- trunk/LayoutTests/platform/mac-sierra/js/dom/global-constructors-attributes-expected.txt	2017-10-06 16:49:50 UTC (rev 222985)
+++ trunk/LayoutTests/platform/mac-sierra/js/dom/global-constructors-attributes-expected.txt	2017-10-06 16:51:47 UTC (rev 222986)
@@ -1003,6 +1003,11 @@
 PASS Object.getOwnPropertyDescriptor(global, 'Image').hasOwnProperty('set') is false
 PASS Object.getOwnPropertyDescriptor(global, 'Image').enumerable is false
 PASS Object.getOwnPropertyDescriptor(global, 'Image').configurable is true
+PASS Object.getOwnPropertyDescriptor(global, 'ImageBitmap').value is ImageBitmap
+PASS Object.getOwnPropertyDescriptor(global, 'ImageBitmap').hasOwnProperty('get') is false
+PASS Object.getOwnPropertyDescriptor(global, 'ImageBitmap').hasOwnProperty('set') is false
+PASS Object.getOwnPropertyDescriptor(global, 'ImageBitmap').enumerable is false
+PASS Object.getOwnPropertyDescriptor(global, 'ImageBitmap').configurable is true
 PASS Object.getOwnPropertyDescriptor(global, 'ImageData').value is ImageData
 PASS Object.getOwnPropertyDescriptor(global, 'ImageData').hasOwnProperty('get') is false
 PASS Object.getOwnPropertyDescriptor(global, 'ImageData').hasOwnProperty('set') is false

Modified: trunk/LayoutTests/platform/mac-sierra-wk1/js/dom/global-constructors-attributes-expected.txt (222985 => 222986)


--- trunk/LayoutTests/platform/mac-sierra-wk1/js/dom/global-constructors-attributes-expected.txt	2017-10-06 16:49:50 UTC (rev 222985)
+++ trunk/LayoutTests/platform/mac-sierra-wk1/js/dom/global-constructors-attributes-expected.txt	2017-10-06 16:51:47 UTC (rev 222986)
@@ -988,6 +988,11 @@
 PASS Object.getOwnPropertyDescriptor(global, 'Image').hasOwnProperty('set') is false
 PASS Object.getOwnPropertyDescriptor(global, 'Image').enumerable is false
 PASS Object.getOwnPropertyDescriptor(global, 'Image').configurable is true
+PASS Object.getOwnPropertyDescriptor(global, 'ImageBitmap').value is ImageBitmap
+PASS Object.getOwnPropertyDescriptor(global, 'ImageBitmap').hasOwnProperty('get') is false
+PASS Object.getOwnPropertyDescriptor(global, 'ImageBitmap').hasOwnProperty('set') is false
+PASS Object.getOwnPropertyDescriptor(global, 'ImageBitmap').enumerable is false
+PASS Object.getOwnPropertyDescriptor(global, 'ImageBitmap').configurable is true
 PASS Object.getOwnPropertyDescriptor(global, 'ImageData').value is ImageData
 PASS Object.getOwnPropertyDescriptor(global, 'ImageData').hasOwnProperty('get') is false
 PASS Object.getOwnPropertyDescriptor(global, 'ImageData').hasOwnProperty('set') is false

Modified: trunk/LayoutTests/platform/mac-wk1/js/dom/global-constructors-attributes-dedicated-worker-expected.txt (222985 => 222986)


--- trunk/LayoutTests/platform/mac-wk1/js/dom/global-constructors-attributes-dedicated-worker-expected.txt	2017-10-06 16:49:50 UTC (rev 222985)
+++ trunk/LayoutTests/platform/mac-wk1/js/dom/global-constructors-attributes-dedicated-worker-expected.txt	2017-10-06 16:51:47 UTC (rev 222986)
@@ -179,6 +179,11 @@
 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'Headers').hasOwnProperty('set') is false
 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'Headers').enumerable is false
 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'Headers').configurable is true
+PASS [Worker] Object.getOwnPropertyDescriptor(global, 'ImageBitmap').value is ImageBitmap
+PASS [Worker] Object.getOwnPropertyDescriptor(global, 'ImageBitmap').hasOwnProperty('get') is false
+PASS [Worker] Object.getOwnPropertyDescriptor(global, 'ImageBitmap').hasOwnProperty('set') is false
+PASS [Worker] Object.getOwnPropertyDescriptor(global, 'ImageBitmap').enumerable is false
+PASS [Worker] Object.getOwnPropertyDescriptor(global, 'ImageBitmap').configurable is true
 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'ImageData').value is ImageData
 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'ImageData').hasOwnProperty('get') is false
 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'ImageData').hasOwnProperty('set') is false

Modified: trunk/LayoutTests/platform/mac-wk1/js/dom/global-constructors-attributes-expected.txt (222985 => 222986)


--- trunk/LayoutTests/platform/mac-wk1/js/dom/global-constructors-attributes-expected.txt	2017-10-06 16:49:50 UTC (rev 222985)
+++ trunk/LayoutTests/platform/mac-wk1/js/dom/global-constructors-attributes-expected.txt	2017-10-06 16:51:47 UTC (rev 222986)
@@ -993,6 +993,11 @@
 PASS Object.getOwnPropertyDescriptor(global, 'Image').hasOwnProperty('set') is false
 PASS Object.getOwnPropertyDescriptor(global, 'Image').enumerable is false
 PASS Object.getOwnPropertyDescriptor(global, 'Image').configurable is true
+PASS Object.getOwnPropertyDescriptor(global, 'ImageBitmap').value is ImageBitmap
+PASS Object.getOwnPropertyDescriptor(global, 'ImageBitmap').hasOwnProperty('get') is false
+PASS Object.getOwnPropertyDescriptor(global, 'ImageBitmap').hasOwnProperty('set') is false
+PASS Object.getOwnPropertyDescriptor(global, 'ImageBitmap').enumerable is false
+PASS Object.getOwnPropertyDescriptor(global, 'ImageBitmap').configurable is true
 PASS Object.getOwnPropertyDescriptor(global, 'ImageData').value is ImageData
 PASS Object.getOwnPropertyDescriptor(global, 'ImageData').hasOwnProperty('get') is false
 PASS Object.getOwnPropertyDescriptor(global, 'ImageData').hasOwnProperty('set') is false

Modified: trunk/LayoutTests/platform/mac-yosemite/js/dom/global-constructors-attributes-expected.txt (222985 => 222986)


--- trunk/LayoutTests/platform/mac-yosemite/js/dom/global-constructors-attributes-expected.txt	2017-10-06 16:49:50 UTC (rev 222985)
+++ trunk/LayoutTests/platform/mac-yosemite/js/dom/global-constructors-attributes-expected.txt	2017-10-06 16:51:47 UTC (rev 222986)
@@ -943,6 +943,11 @@
 PASS Object.getOwnPropertyDescriptor(global, 'Image').hasOwnProperty('set') is false
 PASS Object.getOwnPropertyDescriptor(global, 'Image').enumerable is false
 PASS Object.getOwnPropertyDescriptor(global, 'Image').configurable is true
+PASS Object.getOwnPropertyDescriptor(global, 'ImageBitmap').value is ImageBitmap
+PASS Object.getOwnPropertyDescriptor(global, 'ImageBitmap').hasOwnProperty('get') is false
+PASS Object.getOwnPropertyDescriptor(global, 'ImageBitmap').hasOwnProperty('set') is false
+PASS Object.getOwnPropertyDescriptor(global, 'ImageBitmap').enumerable is false
+PASS Object.getOwnPropertyDescriptor(global, 'ImageBitmap').configurable is true
 PASS Object.getOwnPropertyDescriptor(global, 'ImageData').value is ImageData
 PASS Object.getOwnPropertyDescriptor(global, 'ImageData').hasOwnProperty('get') is false
 PASS Object.getOwnPropertyDescriptor(global, 'ImageData').hasOwnProperty('set') is false

Modified: trunk/LayoutTests/platform/win/js/dom/global-constructors-attributes-expected.txt (222985 => 222986)


--- trunk/LayoutTests/platform/win/js/dom/global-constructors-attributes-expected.txt	2017-10-06 16:49:50 UTC (rev 222985)
+++ trunk/LayoutTests/platform/win/js/dom/global-constructors-attributes-expected.txt	2017-10-06 16:51:47 UTC (rev 222986)
@@ -748,6 +748,11 @@
 PASS Object.getOwnPropertyDescriptor(global, 'Image').hasOwnProperty('set') is false
 PASS Object.getOwnPropertyDescriptor(global, 'Image').enumerable is false
 PASS Object.getOwnPropertyDescriptor(global, 'Image').configurable is true
+PASS Object.getOwnPropertyDescriptor(global, 'ImageBitmap').value is ImageBitmap
+PASS Object.getOwnPropertyDescriptor(global, 'ImageBitmap').hasOwnProperty('get') is false
+PASS Object.getOwnPropertyDescriptor(global, 'ImageBitmap').hasOwnProperty('set') is false
+PASS Object.getOwnPropertyDescriptor(global, 'ImageBitmap').enumerable is false
+PASS Object.getOwnPropertyDescriptor(global, 'ImageBitmap').configurable is true
 PASS Object.getOwnPropertyDescriptor(global, 'ImageData').value is ImageData
 PASS Object.getOwnPropertyDescriptor(global, 'ImageData').hasOwnProperty('get') is false
 PASS Object.getOwnPropertyDescriptor(global, 'ImageData').hasOwnProperty('set') is false

Modified: trunk/LayoutTests/platform/wpe/js/dom/global-constructors-attributes-expected.txt (222985 => 222986)


--- trunk/LayoutTests/platform/wpe/js/dom/global-constructors-attributes-expected.txt	2017-10-06 16:49:50 UTC (rev 222985)
+++ trunk/LayoutTests/platform/wpe/js/dom/global-constructors-attributes-expected.txt	2017-10-06 16:51:47 UTC (rev 222986)
@@ -978,6 +978,11 @@
 PASS Object.getOwnPropertyDescriptor(global, 'Image').hasOwnProperty('set') is false
 PASS Object.getOwnPropertyDescriptor(global, 'Image').enumerable is false
 PASS Object.getOwnPropertyDescriptor(global, 'Image').configurable is true
+PASS Object.getOwnPropertyDescriptor(global, 'ImageBitmap').value is ImageBitmap
+PASS Object.getOwnPropertyDescriptor(global, 'ImageBitmap').hasOwnProperty('get') is false
+PASS Object.getOwnPropertyDescriptor(global, 'ImageBitmap').hasOwnProperty('set') is false
+PASS Object.getOwnPropertyDescriptor(global, 'ImageBitmap').enumerable is false
+PASS Object.getOwnPropertyDescriptor(global, 'ImageBitmap').configurable is true
 PASS Object.getOwnPropertyDescriptor(global, 'ImageData').value is ImageData
 PASS Object.getOwnPropertyDescriptor(global, 'ImageData').hasOwnProperty('get') is false
 PASS Object.getOwnPropertyDescriptor(global, 'ImageData').hasOwnProperty('set') is false

Modified: trunk/Source/WebCore/CMakeLists.txt (222985 => 222986)


--- trunk/Source/WebCore/CMakeLists.txt	2017-10-06 16:49:50 UTC (rev 222985)
+++ trunk/Source/WebCore/CMakeLists.txt	2017-10-06 16:51:47 UTC (rev 222986)
@@ -679,6 +679,8 @@
     html/HTMLUListElement.idl
     html/HTMLUnknownElement.idl
     html/HTMLVideoElement.idl
+    html/ImageBitmap.idl
+    html/ImageBitmapOptions.idl
     html/ImageData.idl
     html/MediaController.idl
     html/MediaError.idl
@@ -1938,6 +1940,7 @@
     html/HTMLVideoElement.cpp
     html/HTMLWBRElement.cpp
     html/HiddenInputType.cpp
+    html/ImageBitmap.cpp
     html/ImageData.cpp
     html/ImageDocument.cpp
     html/ImageInputType.cpp

Modified: trunk/Source/WebCore/ChangeLog (222985 => 222986)


--- trunk/Source/WebCore/ChangeLog	2017-10-06 16:49:50 UTC (rev 222985)
+++ trunk/Source/WebCore/ChangeLog	2017-10-06 16:51:47 UTC (rev 222986)
@@ -1,3 +1,47 @@
+2017-10-05  Dean Jackson  <[email protected]>
+
+        ImageBitmap API stubs
+        https://bugs.webkit.org/show_bug.cgi?id=177984
+        <rdar://problem/34848023>
+
+        Patch by Sam and Dean.
+        Reviewed by Dean and Sam.
+
+        Add the IDL for ImageBitmap and ImageBitmapOptions, plus some
+        stub implementations (complete with all the algorithms from
+        the HTML specification as comments).
+
+        * CMakeLists.txt: Add the new files.
+        * DerivedSources.make: Create the JS bindings for ImageBitmap and ImageBitmapOptions.
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/CallTracerTypes.h:
+        * html/ImageBitmap.cpp: Added.
+        (WebCore::ImageBitmap::create):
+        (WebCore::ImageBitmap::createPromise):
+        (WebCore::ImageBitmap::ImageBitmap):
+        (WebCore::ImageBitmap::~ImageBitmap):
+        (WebCore::ImageBitmap::width const):
+        (WebCore::ImageBitmap::height const):
+        (WebCore::ImageBitmap::close):
+        * html/ImageBitmap.h: Added.
+        (WebCore::ImageBitmap::isDetached const):
+        * html/ImageBitmap.idl: Copied from Source/WebCore/html/canvas/CanvasDrawImage.idl.
+        * html/ImageBitmapOptions.h: Copied from Source/WebCore/html/canvas/CanvasDrawImage.idl.
+        * html/ImageBitmapOptions.idl: Copied from Source/WebCore/html/canvas/CanvasDrawImage.idl.
+        * html/canvas/CanvasDrawImage.idl:
+        * html/canvas/CanvasFillStrokeStyles.idl:
+        * html/canvas/CanvasRenderingContext2D.cpp:
+        (WebCore::size):
+        (WebCore::CanvasRenderingContext2D::drawImage):
+        (WebCore::CanvasRenderingContext2D::createPattern):
+        * html/canvas/CanvasRenderingContext2D.h:
+        * inspector/InspectorCanvas.cpp:
+        (WebCore::InspectorCanvas::indexForData):
+        (WebCore::InspectorCanvas::buildAction):
+        (WebCore::InspectorCanvas::buildArrayForImageBitmap):
+        * inspector/InspectorCanvas.h:
+        * inspector/RecordingSwizzleTypes.h:
+
 2017-10-06  Ms2ger  <[email protected]>
 
         Create bindings for WebGL2's versions of texImage2D.

Modified: trunk/Source/WebCore/DerivedSources.make (222985 => 222986)


--- trunk/Source/WebCore/DerivedSources.make	2017-10-06 16:49:50 UTC (rev 222985)
+++ trunk/Source/WebCore/DerivedSources.make	2017-10-06 16:51:47 UTC (rev 222986)
@@ -596,6 +596,8 @@
     $(WebCore)/html/HTMLUListElement.idl \
     $(WebCore)/html/HTMLUnknownElement.idl \
     $(WebCore)/html/HTMLVideoElement.idl \
+    $(WebCore)/html/ImageBitmap.idl \
+    $(WebCore)/html/ImageBitmapOptions.idl \
     $(WebCore)/html/ImageData.idl \
     $(WebCore)/html/MediaController.idl \
     $(WebCore)/html/MediaEncryptedEvent.idl \

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (222985 => 222986)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2017-10-06 16:49:50 UTC (rev 222985)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2017-10-06 16:51:47 UTC (rev 222986)
@@ -1561,6 +1561,9 @@
 		31C0FF3E0E4CEFAC007D6FE5 /* JSWebKitAnimationEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 31C0FF3A0E4CEFAC007D6FE5 /* JSWebKitAnimationEvent.h */; };
 		31C0FF3F0E4CEFAC007D6FE5 /* JSWebKitTransitionEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 31C0FF3B0E4CEFAC007D6FE5 /* JSWebKitTransitionEvent.cpp */; };
 		31C0FF400E4CEFAC007D6FE5 /* JSWebKitTransitionEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 31C0FF3C0E4CEFAC007D6FE5 /* JSWebKitTransitionEvent.h */; };
+		31D26BC81F87063D008FF255 /* JSImageBitmap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 31D26BC61F86D269008FF255 /* JSImageBitmap.cpp */; };
+		31D26BCA1F870645008FF255 /* JSImageBitmapOptions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 31D26BC41F86D266008FF255 /* JSImageBitmapOptions.cpp */; };
+		31D26BCB1F87065B008FF255 /* ImageBitmap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 31D26BC21F86D18C008FF255 /* ImageBitmap.cpp */; };
 		31D591B316697A6C00E6BF02 /* PlugInClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 31D591B116697A6C00E6BF02 /* PlugInClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		31DCD29D1AB4FBDE0072E817 /* AnimationTrigger.h in Headers */ = {isa = PBXBuildFile; fileRef = 31DCD29C1AB4FBDE0072E817 /* AnimationTrigger.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		31DCDF431DA1C45400EA5B93 /* ExtendedColor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 31DCDF411DA1C45400EA5B93 /* ExtendedColor.cpp */; };
@@ -9368,6 +9371,15 @@
 		31C0FF3A0E4CEFAC007D6FE5 /* JSWebKitAnimationEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWebKitAnimationEvent.h; sourceTree = "<group>"; };
 		31C0FF3B0E4CEFAC007D6FE5 /* JSWebKitTransitionEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebKitTransitionEvent.cpp; sourceTree = "<group>"; };
 		31C0FF3C0E4CEFAC007D6FE5 /* JSWebKitTransitionEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWebKitTransitionEvent.h; sourceTree = "<group>"; };
+		31D26BBD1F86D187008FF255 /* ImageBitmapOptions.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ImageBitmapOptions.idl; sourceTree = "<group>"; };
+		31D26BBF1F86D189008FF255 /* ImageBitmap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageBitmap.h; sourceTree = "<group>"; };
+		31D26BC01F86D18A008FF255 /* ImageBitmapOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageBitmapOptions.h; sourceTree = "<group>"; };
+		31D26BC11F86D18B008FF255 /* ImageBitmap.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ImageBitmap.idl; sourceTree = "<group>"; };
+		31D26BC21F86D18C008FF255 /* ImageBitmap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ImageBitmap.cpp; sourceTree = "<group>"; };
+		31D26BC31F86D265008FF255 /* JSImageBitmap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSImageBitmap.h; sourceTree = "<group>"; };
+		31D26BC41F86D266008FF255 /* JSImageBitmapOptions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSImageBitmapOptions.cpp; sourceTree = "<group>"; };
+		31D26BC51F86D268008FF255 /* JSImageBitmapOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSImageBitmapOptions.h; sourceTree = "<group>"; };
+		31D26BC61F86D269008FF255 /* JSImageBitmap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSImageBitmap.cpp; sourceTree = "<group>"; };
 		31D591B116697A6C00E6BF02 /* PlugInClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlugInClient.h; sourceTree = "<group>"; };
 		31DCD29C1AB4FBDE0072E817 /* AnimationTrigger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AnimationTrigger.h; sourceTree = "<group>"; };
 		31DCDF411DA1C45400EA5B93 /* ExtendedColor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ExtendedColor.cpp; sourceTree = "<group>"; };
@@ -21061,6 +21073,11 @@
 				E446139A0CD6331000FADA75 /* HTMLVideoElement.idl */,
 				839AAFEA1A0C0C8D00605F99 /* HTMLWBRElement.cpp */,
 				839AAFEB1A0C0C8D00605F99 /* HTMLWBRElement.h */,
+				31D26BC21F86D18C008FF255 /* ImageBitmap.cpp */,
+				31D26BBF1F86D189008FF255 /* ImageBitmap.h */,
+				31D26BC11F86D18B008FF255 /* ImageBitmap.idl */,
+				31D26BC01F86D18A008FF255 /* ImageBitmapOptions.h */,
+				31D26BBD1F86D187008FF255 /* ImageBitmapOptions.idl */,
 				A77979130D6B9D0C003851B9 /* ImageData.cpp */,
 				A77979140D6B9D0C003851B9 /* ImageData.h */,
 				A77979150D6B9D0C003851B9 /* ImageData.idl */,
@@ -22138,6 +22155,10 @@
 				6E4ABCD3138EA0B70071D291 /* JSHTMLUnknownElement.h */,
 				E446140E0CD6826900FADA75 /* JSHTMLVideoElement.cpp */,
 				E446140F0CD6826900FADA75 /* JSHTMLVideoElement.h */,
+				31D26BC61F86D269008FF255 /* JSImageBitmap.cpp */,
+				31D26BC31F86D265008FF255 /* JSImageBitmap.h */,
+				31D26BC41F86D266008FF255 /* JSImageBitmapOptions.cpp */,
+				31D26BC51F86D268008FF255 /* JSImageBitmapOptions.h */,
 				A77979240D6B9E64003851B9 /* JSImageData.cpp */,
 				A77979250D6B9E64003851B9 /* JSImageData.h */,
 				7C193BFB1F5E10C40088F3E6 /* JSImageSmoothingQuality.cpp */,
@@ -32350,6 +32371,7 @@
 				C3CF17A415B0063F00276D39 /* IdTargetObserver.cpp in Sources */,
 				C3CF17A615B0063F00276D39 /* IdTargetObserverRegistry.cpp in Sources */,
 				B275356F0B053814002CE64F /* Image.cpp in Sources */,
+				31D26BCB1F87065B008FF255 /* ImageBitmap.cpp in Sources */,
 				43D2597713C816F400608559 /* ImageBuffer.cpp in Sources */,
 				B2A10B940B3818D700099AA4 /* ImageBufferCG.cpp in Sources */,
 				2292B27C1356669400CF11EF /* ImageBufferDataCG.cpp in Sources */,
@@ -32819,6 +32841,8 @@
 				51E269331DD3BC4E006B6A58 /* JSIDBTransactionCustom.cpp in Sources */,
 				838EF53B1DC14A7C008F0C39 /* JSIDBTransactionMode.cpp in Sources */,
 				511EF2CB17F0FD3500E4FA16 /* JSIDBVersionChangeEvent.cpp in Sources */,
+				31D26BC81F87063D008FF255 /* JSImageBitmap.cpp in Sources */,
+				31D26BCA1F870645008FF255 /* JSImageBitmapOptions.cpp in Sources */,
 				A77979280D6B9E64003851B9 /* JSImageData.cpp in Sources */,
 				A7D0318E0E93540300E24ACD /* JSImageDataCustom.cpp in Sources */,
 				7C193C001F5E11050088F3E6 /* JSImageSmoothingQuality.cpp in Sources */,

Modified: trunk/Source/WebCore/bindings/js/CallTracerTypes.h (222985 => 222986)


--- trunk/Source/WebCore/bindings/js/CallTracerTypes.h	2017-10-06 16:49:50 UTC (rev 222985)
+++ trunk/Source/WebCore/bindings/js/CallTracerTypes.h	2017-10-06 16:51:47 UTC (rev 222986)
@@ -33,6 +33,7 @@
 #include "HTMLCanvasElement.h"
 #include "HTMLImageElement.h"
 #include "HTMLVideoElement.h"
+#include "ImageBitmap.h"
 #include "ImageData.h"
 #include "Path2D.h"
 #include <runtime/ArrayBuffer.h>
@@ -88,6 +89,7 @@
 #if ENABLE(VIDEO)
     RefPtr<HTMLVideoElement>,
 #endif
+    RefPtr<ImageBitmap>,
     RefPtr<ImageData>,
     RefPtr<Int32Array>,
     Vector<float>,

Added: trunk/Source/WebCore/html/ImageBitmap.cpp (0 => 222986)


--- trunk/Source/WebCore/html/ImageBitmap.cpp	                        (rev 0)
+++ trunk/Source/WebCore/html/ImageBitmap.cpp	2017-10-06 16:51:47 UTC (rev 222986)
@@ -0,0 +1,360 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ImageBitmap.h"
+
+#include "BitmapImage.h"
+#include "Blob.h"
+#include "CachedImage.h"
+#include "ExceptionOr.h"
+#include "FileReaderLoader.h"
+#include "FileReaderLoaderClient.h"
+#include "HTMLCanvasElement.h"
+#include "HTMLImageElement.h"
+#include "HTMLVideoElement.h"
+#include "ImageBitmapOptions.h"
+#include "ImageBuffer.h"
+#include "ImageData.h"
+#include "IntRect.h"
+#include "JSImageBitmap.h"
+#include "LayoutSize.h"
+#include "SharedBuffer.h"
+#include <wtf/StdLibExtras.h>
+
+namespace WebCore {
+
+Ref<ImageBitmap> ImageBitmap::create()
+{
+    return adoptRef(*new ImageBitmap);
+}
+
+void ImageBitmap::createPromise(ScriptExecutionContext& scriptExecutionContext, ImageBitmap::Source&& source, ImageBitmapOptions&& options, ImageBitmap::Promise&& promise)
+{
+    WTF::switchOn(source,
+        [&] (auto& specificSource) {
+            createPromise(scriptExecutionContext, specificSource, WTFMove(options), std::nullopt, WTFMove(promise));
+        }
+    );
+}
+
+void ImageBitmap::createPromise(ScriptExecutionContext& scriptExecutionContext, ImageBitmap::Source&& source, ImageBitmapOptions&& options, int sx, int sy, int sw, int sh, ImageBitmap::Promise&& promise)
+{
+    // 1. If either the sw or sh arguments are specified but zero, return a promise
+    //    rejected with an "RangeError" DOMException and abort these steps.
+    if (!sw || !sh) {
+        promise.reject(RangeError, "Cannot create ImageBitmap with a width or height of 0");
+        return;
+    }
+
+    WTF::switchOn(source,
+        [&] (auto& specificSource) {
+            createPromise(scriptExecutionContext, specificSource, WTFMove(options), IntRect { sx, sy, sw, sh }, WTFMove(promise));
+        }
+    );
+}
+
+void ImageBitmap::createPromise(ScriptExecutionContext&, RefPtr<HTMLImageElement>& imageElement, ImageBitmapOptions&& options, std::optional<IntRect> rect, ImageBitmap::Promise&& promise)
+{
+    UNUSED_PARAM(imageElement);
+    UNUSED_PARAM(options);
+    UNUSED_PARAM(rect);
+
+    // 2. If image is not completely available, then return a promise rejected with
+    // an "InvalidStateError" DOMException and abort these steps.
+
+    // 3. If image's media data has no intrinsic dimensions (e.g. it's a vector graphic
+    //    with no specified content size), and both or either of the resizeWidth and
+    //    resizeHeight options are not specified, then return a promise rejected with
+    //    an "InvalidStateError" DOMException and abort these steps.
+
+    // 4. If image's media data has no intrinsic dimensions (e.g. it's a vector graphics
+    //    with no specified content size), it should be rendered to a bitmap of the size
+    //    specified by the resizeWidth and the resizeHeight options.
+
+    // 5. If the sw and sh arguments are not specified and image's media data has both or
+    //    either of its intrinsic width and intrinsic height values equal to 0, then return
+    //    a promise rejected with an "InvalidStateError" DOMException and abort these steps.
+
+    // 6. If the sh argument is not specified and image's media data has an intrinsic height
+    //    of 0, then return a promise rejected with an "InvalidStateError" DOMException and
+    //    abort these steps.
+
+    // 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
+    //    one that the format defines is to be used when animation is not supported or is disabled),
+    //    or, if there is no such image, the first frame of the animation.
+
+    // 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
+    //    bitmap to false.
+
+    // 10. Return a new promise, but continue running these steps in parallel.
+
+    // 11. Resolve the promise with the new ImageBitmap object as the value.
+    return promise.resolve(WTFMove(imageBitmap));
+}
+
+void ImageBitmap::createPromise(ScriptExecutionContext&, RefPtr<HTMLCanvasElement>& canvasElement, ImageBitmapOptions&& options, std::optional<IntRect> rect, ImageBitmap::Promise&& promise)
+{
+    UNUSED_PARAM(canvasElement);
+    UNUSED_PARAM(options);
+    UNUSED_PARAM(rect);
+
+    // 2. If the canvas element's bitmap has either a horizontal dimension or a vertical
+    //    dimension equal to zero, then return a promise rejected with an "InvalidStateError"
+    //    DOMException and abort these steps.
+
+    // 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.
+
+    // 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.
+
+    // 6. Return a new promise, but continue running these steps in parallel.
+
+    // 7. Resolve the promise with the new ImageBitmap object as the value.
+    return promise.resolve(WTFMove(imageBitmap));
+}
+
+void ImageBitmap::createPromise(ScriptExecutionContext&, RefPtr<HTMLVideoElement>& videoElement, ImageBitmapOptions&& options, std::optional<IntRect> rect, ImageBitmap::Promise&& promise)
+{
+    UNUSED_PARAM(videoElement);
+    UNUSED_PARAM(options);
+    UNUSED_PARAM(rect);
+
+    // 2. If the video element's networkState attribute is NETWORK_EMPTY, then return
+    //    a promise rejected with an "InvalidStateError" DOMException and abort these
+    //    steps.
+
+    // 3. If the video element's readyState attribute is either HAVE_NOTHING or
+    //    HAVE_METADATA, then return a promise rejected with an "InvalidStateError"
+    //    DOMException and abort these steps.
+
+    // 4. Create a new ImageBitmap object.
+    auto imageBitmap = create();
+
+    // 5. Let the ImageBitmap object's bitmap data be a copy of the frame at the current
+    //    playback position, at the media resource's intrinsic width and intrinsic height
+    //    (i.e. after any aspect-ratio correction has been applied), cropped to the source
+    //    rectangle with formatting.
+
+    // 6. If the origin of the video element 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 bitmap to false.
+
+    // 7. Return a new promise, but continue running these steps in parallel.
+
+    // 8. Resolve the promise with the new ImageBitmap object as the value.
+    return promise.resolve(WTFMove(imageBitmap));
+}
+
+void ImageBitmap::createPromise(ScriptExecutionContext&, RefPtr<ImageBitmap>& existingImageBitmap, ImageBitmapOptions&& options, std::optional<IntRect> rect, ImageBitmap::Promise&& promise)
+{
+    UNUSED_PARAM(existingImageBitmap);
+    UNUSED_PARAM(options);
+    UNUSED_PARAM(rect);
+
+    // 2. If image's [[Detached]] internal slot value is true, return a promise
+    //    rejected with an "InvalidStateError" DOMException and abort these steps.
+
+    // 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.
+
+    // 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.
+
+    // 6. Return a new promise, but continue running these steps in parallel.
+
+    // 7. Resolve the promise with the new ImageBitmap object as the value.
+    return promise.resolve(WTFMove(imageBitmap));
+}
+
+class PendingImageBitmap final : public ActiveDOMObject, public FileReaderLoaderClient {
+public:
+    static void fetch(ScriptExecutionContext& scriptExecutionContext, RefPtr<Blob>&& blob, ImageBitmapOptions&& options, std::optional<IntRect> rect, ImageBitmap::Promise&& promise)
+    {
+        auto pendingImageBitmap = new PendingImageBitmap(scriptExecutionContext, WTFMove(blob), WTFMove(options), WTFMove(rect), WTFMove(promise));
+        pendingImageBitmap->start(scriptExecutionContext);
+    }
+
+private:
+    PendingImageBitmap(ScriptExecutionContext& scriptExecutionContext, RefPtr<Blob>&& blob, ImageBitmapOptions&& options, std::optional<IntRect> rect, ImageBitmap::Promise&& promise)
+        : ActiveDOMObject(&scriptExecutionContext)
+        , m_blobLoader(FileReaderLoader::ReadAsArrayBuffer, this)
+        , m_blob(WTFMove(blob))
+        , m_options(WTFMove(options))
+        , m_rect(WTFMove(rect))
+        , m_promise(WTFMove(promise))
+    {
+    }
+
+    void start(ScriptExecutionContext& scriptExecutionContext)
+    {
+        m_blobLoader.start(&scriptExecutionContext, *m_blob);
+    }
+
+    // ActiveDOMObject
+
+    const char* activeDOMObjectName() const override
+    {
+        return "PendingImageBitmap";
+    }
+
+    bool canSuspendForDocumentSuspension() const override
+    {
+        // FIXME: Deal with suspension.
+        return false;
+    }
+
+    // FileReaderLoaderClient
+
+    void didStartLoading() override
+    {
+    }
+
+    void didReceiveData() override
+    {
+    }
+
+    void didFinishLoading() override
+    {
+        createImageBitmap(m_blobLoader.arrayBufferResult());
+        delete this;
+    }
+
+    void didFail(int) override
+    {
+        createImageBitmap(nullptr);
+        delete this;
+    }
+
+    void createImageBitmap(RefPtr<ArrayBuffer> arrayBuffer)
+    {
+        UNUSED_PARAM(arrayBuffer);
+
+        // 3. Read the Blob object's data. If an error occurs during reading of the object,
+        //    then reject the promise with an "InvalidStateError" DOMException, and abort
+        //    these steps.
+
+        // 4. Apply the image sniffing rules to determine the file format of the image data,
+        //    with MIME type of the Blob (as given by the Blob object's type attribute) giving
+        //    the official type.
+
+        // 5. If the image data is not in a supported image file format (e.g. it's not an image
+        //    at all), or if the image data is corrupted in some fatal way such that the image
+        //    dimensions cannot be obtained (e.g. a vector graphic with no intrinsic size), then
+        //    reject the promise with an "InvalidStateError" DOMException, and abort these steps.
+
+        // 6. Create a new ImageBitmap object.
+        auto imageBitmap = ImageBitmap::create();
+
+        // 7. Let the ImageBitmap object's bitmap data be the image data read from the Blob object,
+        //    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 one that the format defines is to be used when animation is not supported
+        //    or is disabled), or, if there is no such image, the first frame of the animation.
+
+        // 8. Resolve the promise with the new ImageBitmap object as the value.
+        m_promise.resolve(WTFMove(imageBitmap));
+    }
+
+    FileReaderLoader m_blobLoader;
+    RefPtr<Blob> m_blob;
+    ImageBitmapOptions m_options;
+    std::optional<IntRect> m_rect;
+    ImageBitmap::Promise m_promise;
+};
+
+void ImageBitmap::createPromise(ScriptExecutionContext& scriptExecutionContext, RefPtr<Blob>& blob, ImageBitmapOptions&& options, std::optional<IntRect> rect, ImageBitmap::Promise&& promise)
+{
+    // 2. Return a new promise, but continue running these steps in parallel.
+    PendingImageBitmap::fetch(scriptExecutionContext, WTFMove(blob), WTFMove(options), WTFMove(rect), WTFMove(promise));
+}
+
+void ImageBitmap::createPromise(ScriptExecutionContext&, RefPtr<ImageData>& imageData, ImageBitmapOptions&& options, std::optional<IntRect> rect, ImageBitmap::Promise&& promise)
+{
+    UNUSED_PARAM(imageData);
+    UNUSED_PARAM(options);
+    UNUSED_PARAM(rect);
+
+    // 2. If the image object's data attribute value's [[Detached]] internal slot value
+    //    is true, return a promise rejected with an "InvalidStateError" DOMException
+    //    and abort these steps.
+
+    // 3. Create a new ImageBitmap object.
+    auto imageBitmap = create();
+
+    // 4. Let the ImageBitmap object's bitmap data be the image data given by the ImageData
+    //    object, cropped to the source rectangle with formatting.
+
+    // 5. Return a new promise, but continue running these steps in parallel.
+    // 6. Resolve the promise with the new ImageBitmap object as the value.
+    promise.resolve(imageBitmap);
+}
+
+ImageBitmap::ImageBitmap()
+{
+}
+
+ImageBitmap::~ImageBitmap()
+{
+}
+
+unsigned ImageBitmap::width() const
+{
+    if (m_detached || !m_bitmapData)
+        return 0;
+
+    // FIXME: Is this the right width?
+    return m_bitmapData->logicalSize().width();
+}
+
+unsigned ImageBitmap::height() const
+{
+    if (m_detached || !m_bitmapData)
+        return 0;
+
+    // FIXME: Is this the right height?
+    return m_bitmapData->logicalSize().height();
+}
+
+void ImageBitmap::close()
+{
+    m_detached = true;
+    m_bitmapData = nullptr;
+}
+
+}
Property changes on: trunk/Source/WebCore/html/ImageBitmap.cpp
___________________________________________________________________

Added: svn:eol-style

+native \ No newline at end of property

Added: svn:keywords

+Date Author Id Revision HeadURL \ No newline at end of property

Added: trunk/Source/WebCore/html/ImageBitmap.h (0 => 222986)


--- trunk/Source/WebCore/html/ImageBitmap.h	                        (rev 0)
+++ trunk/Source/WebCore/html/ImageBitmap.h	2017-10-06 16:51:47 UTC (rev 222986)
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "JSDOMPromiseDeferred.h"
+#include "ScriptWrappable.h"
+#include <wtf/Optional.h>
+#include <wtf/RefCounted.h>
+#include <wtf/Variant.h>
+
+namespace WebCore {
+
+class Blob;
+class HTMLCanvasElement;
+class HTMLImageElement;
+class HTMLVideoElement;
+class ImageBuffer;
+class ImageData;
+class IntRect;
+class PendingImageBitmap;
+class ScriptExecutionContext;
+struct ImageBitmapOptions;
+
+class ImageBitmap : public ScriptWrappable, public RefCounted<ImageBitmap> {
+public:
+    using Source = Variant<
+        RefPtr<HTMLImageElement>,
+        RefPtr<HTMLCanvasElement>,
+        RefPtr<HTMLVideoElement>, // FIXME: Make conditional
+        RefPtr<ImageBitmap>,
+        RefPtr<Blob>,
+        RefPtr<ImageData>
+    >;
+
+    using Promise = DOMPromiseDeferred<IDLInterface<ImageBitmap>>;
+
+    static void createPromise(ScriptExecutionContext&, Source&&, ImageBitmapOptions&&, Promise&&);
+    static void createPromise(ScriptExecutionContext&, Source&&, ImageBitmapOptions&&, int sx, int sy, int sw, int sh, Promise&&);
+
+    ~ImageBitmap();
+
+    unsigned width() const;
+    unsigned height() const;
+    void close();
+
+    bool isDetached() const { return m_detached; }
+
+private:
+    friend class PendingImageBitmap;
+
+    static Ref<ImageBitmap> create();
+    ImageBitmap();
+
+    static void createPromise(ScriptExecutionContext&, RefPtr<HTMLImageElement>&, ImageBitmapOptions&&, std::optional<IntRect>, Promise&&);
+    static void createPromise(ScriptExecutionContext&, RefPtr<HTMLCanvasElement>&, ImageBitmapOptions&&, std::optional<IntRect>, Promise&&);
+    static void createPromise(ScriptExecutionContext&, RefPtr<HTMLVideoElement>&, ImageBitmapOptions&&, std::optional<IntRect>, Promise&&);
+    static void createPromise(ScriptExecutionContext&, RefPtr<ImageBitmap>&, ImageBitmapOptions&&, std::optional<IntRect>, Promise&&);
+    static void createPromise(ScriptExecutionContext&, RefPtr<Blob>&, ImageBitmapOptions&&, std::optional<IntRect>, Promise&&);
+    static void createPromise(ScriptExecutionContext&, RefPtr<ImageData>&, ImageBitmapOptions&&, std::optional<IntRect>, Promise&&);
+
+    std::unique_ptr<ImageBuffer> m_bitmapData;
+    bool m_detached { false };
+};
+
+}
Property changes on: trunk/Source/WebCore/html/ImageBitmap.h
___________________________________________________________________

Added: svn:eol-style

+native \ No newline at end of property

Added: svn:keywords

+Date Author Id Revision HeadURL \ No newline at end of property

Copied: trunk/Source/WebCore/html/ImageBitmap.idl (from rev 222985, trunk/Source/WebCore/html/canvas/CanvasDrawImage.idl) (0 => 222986)


--- trunk/Source/WebCore/html/ImageBitmap.idl	                        (rev 0)
+++ trunk/Source/WebCore/html/ImageBitmap.idl	2017-10-06 16:51:47 UTC (rev 222986)
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+[
+    Exposed=(Window,Worker),
+    ImplementationLacksVTable
+] interface ImageBitmap {
+    readonly attribute unsigned long width;
+    readonly attribute unsigned long height;
+    void close();
+};
+

Copied: trunk/Source/WebCore/html/ImageBitmapOptions.h (from rev 222985, trunk/Source/WebCore/html/canvas/CanvasDrawImage.idl) (0 => 222986)


--- trunk/Source/WebCore/html/ImageBitmapOptions.h	                        (rev 0)
+++ trunk/Source/WebCore/html/ImageBitmapOptions.h	2017-10-06 16:51:47 UTC (rev 222986)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <wtf/Optional.h>
+
+namespace WebCore {
+
+struct ImageBitmapOptions {
+    enum class Orientation { None, FlipY };
+    enum class PremultiplyAlpha { None, Premultiply, Default };
+    enum class ColorSpaceConversion { None, Default };
+    enum class ResizeQuality { Pixelated, Low, Medium, High };
+
+    Orientation imageOrientation { Orientation::None };
+    PremultiplyAlpha premultiplyAlpha { PremultiplyAlpha::Default };
+    ColorSpaceConversion colorSpaceConversion { ColorSpaceConversion::Default };
+    std::optional<unsigned> resizeWidth;
+    std::optional<unsigned> resizeHeight;
+    ResizeQuality resizeQuality { ResizeQuality::Low };
+};
+
+}

Copied: trunk/Source/WebCore/html/ImageBitmapOptions.idl (from rev 222985, trunk/Source/WebCore/html/canvas/CanvasDrawImage.idl) (0 => 222986)


--- trunk/Source/WebCore/html/ImageBitmapOptions.idl	                        (rev 0)
+++ trunk/Source/WebCore/html/ImageBitmapOptions.idl	2017-10-06 16:51:47 UTC (rev 222986)
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+enum ImageOrientation { "none", "flipY" };
+enum PremultiplyAlpha { "none", "premultiply", "default" };
+enum ColorSpaceConversion { "none", "default" };
+enum ResizeQuality { "pixelated", "low", "medium", "high" };
+
+dictionary ImageBitmapOptions {
+    ImageOrientation imageOrientation = "none";
+    PremultiplyAlpha premultiplyAlpha = "default";
+    ColorSpaceConversion colorSpaceConversion = "default";
+    [EnforceRange] unsigned long resizeWidth;
+    [EnforceRange] unsigned long resizeHeight;
+    ResizeQuality resizeQuality = "low";
+};

Modified: trunk/Source/WebCore/html/canvas/CanvasDrawImage.idl (222985 => 222986)


--- trunk/Source/WebCore/html/canvas/CanvasDrawImage.idl	2017-10-06 16:49:50 UTC (rev 222985)
+++ trunk/Source/WebCore/html/canvas/CanvasDrawImage.idl	2017-10-06 16:51:47 UTC (rev 222986)
@@ -25,9 +25,9 @@
 
 // FIXME: This should include SVGImageElement and ImageBitmap.
 #if defined(ENABLE_VIDEO) && ENABLE_VIDEO
-typedef (HTMLImageElement or HTMLVideoElement or HTMLCanvasElement) CanvasImageSource;
+typedef (HTMLImageElement or HTMLVideoElement or HTMLCanvasElement or ImageBitmap) CanvasImageSource;
 #else
-typedef (HTMLImageElement or HTMLCanvasElement) CanvasImageSource;
+typedef (HTMLImageElement or HTMLCanvasElement or ImageBitmap) CanvasImageSource;
 #endif
 
 [

Modified: trunk/Source/WebCore/html/canvas/CanvasFillStrokeStyles.idl (222985 => 222986)


--- trunk/Source/WebCore/html/canvas/CanvasFillStrokeStyles.idl	2017-10-06 16:49:50 UTC (rev 222985)
+++ trunk/Source/WebCore/html/canvas/CanvasFillStrokeStyles.idl	2017-10-06 16:51:47 UTC (rev 222986)
@@ -25,9 +25,9 @@
 
 // FIXME: This should include SVGImageElement and ImageBitmap.
 #if defined(ENABLE_VIDEO) && ENABLE_VIDEO
-typedef (HTMLImageElement or HTMLVideoElement or HTMLCanvasElement) CanvasImageSource;
+typedef (HTMLImageElement or HTMLVideoElement or HTMLCanvasElement or ImageBitmap) CanvasImageSource;
 #else
-typedef (HTMLImageElement or HTMLCanvasElement) CanvasImageSource;
+typedef (HTMLImageElement or HTMLCanvasElement or ImageBitmap) CanvasImageSource;
 #endif
 
 [

Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp (222985 => 222986)


--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp	2017-10-06 16:49:50 UTC (rev 222985)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp	2017-10-06 16:51:47 UTC (rev 222986)
@@ -47,6 +47,7 @@
 #include "FloatQuad.h"
 #include "HTMLImageElement.h"
 #include "HTMLVideoElement.h"
+#include "ImageBitmap.h"
 #include "ImageBuffer.h"
 #include "ImageData.h"
 #include "Path2D.h"
@@ -1421,6 +1422,11 @@
     return canvasElement.size();
 }
 
+static inline FloatSize size(ImageBitmap& imageBitmap)
+{
+    return FloatSize { static_cast<float>(imageBitmap.width()), static_cast<float>(imageBitmap.height()) };
+}
+
 #if ENABLE(VIDEO)
 
 static inline FloatSize size(HTMLVideoElement& video)
@@ -1663,6 +1669,12 @@
 
 #endif
 
+ExceptionOr<void> CanvasRenderingContext2D::drawImage(ImageBitmap&, const FloatRect&, const FloatRect&)
+{
+    // FIXME: Implement.
+    return Exception { TypeError };
+}
+
 void CanvasRenderingContext2D::drawImageFromRect(HTMLImageElement& imageElement, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh, const String& compositeOperation)
 {
     CompositeOperator op;
@@ -1923,6 +1935,12 @@
 
 #endif
 
+ExceptionOr<RefPtr<CanvasPattern>> CanvasRenderingContext2D::createPattern(ImageBitmap&, bool, bool)
+{
+    // FIXME: Implement.
+    return Exception { TypeError };
+}
+
 void CanvasRenderingContext2D::didDrawEntireCanvas()
 {
     didDraw(FloatRect(FloatPoint::zero(), canvas().size()), CanvasDidDrawApplyClip);

Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h (222985 => 222986)


--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h	2017-10-06 16:49:50 UTC (rev 222985)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h	2017-10-06 16:51:47 UTC (rev 222986)
@@ -58,6 +58,7 @@
 class HTMLCanvasElement;
 class HTMLImageElement;
 class HTMLVideoElement;
+class ImageBitmap;
 class ImageData;
 class Path2D;
 class TextMetrics;
@@ -65,9 +66,9 @@
 struct DOMMatrix2DInit;
 
 #if ENABLE(VIDEO)
-using CanvasImageSource = Variant<RefPtr<HTMLImageElement>, RefPtr<HTMLVideoElement>, RefPtr<HTMLCanvasElement>>;
+using CanvasImageSource = Variant<RefPtr<HTMLImageElement>, RefPtr<HTMLVideoElement>, RefPtr<HTMLCanvasElement>, RefPtr<ImageBitmap>>;
 #else
-using CanvasImageSource = Variant<RefPtr<HTMLImageElement>, RefPtr<HTMLCanvasElement>>;
+using CanvasImageSource = Variant<RefPtr<HTMLImageElement>, RefPtr<HTMLCanvasElement>, RefPtr<ImageBitmap>>;
 #endif
 
 class CanvasRenderingContext2D final : public CanvasRenderingContext, public CanvasPath {
@@ -333,6 +334,7 @@
 #if ENABLE(VIDEO)
     ExceptionOr<RefPtr<CanvasPattern>> createPattern(HTMLVideoElement&, bool repeatX, bool repeatY);
 #endif
+    ExceptionOr<RefPtr<CanvasPattern>> createPattern(ImageBitmap&, bool repeatX, bool repeatY);
 
     ExceptionOr<void> drawImage(HTMLImageElement&, const FloatRect& srcRect, const FloatRect& dstRect);
     ExceptionOr<void> drawImage(HTMLImageElement&, const FloatRect& srcRect, const FloatRect& dstRect, const CompositeOperator&, const BlendMode&);
@@ -340,6 +342,7 @@
 #if ENABLE(VIDEO)
     ExceptionOr<void> drawImage(HTMLVideoElement&, const FloatRect& srcRect, const FloatRect& dstRect);
 #endif
+    ExceptionOr<void> drawImage(ImageBitmap&, const FloatRect& srcRect, const FloatRect& dstRect);
 
     void drawTextInternal(const String& text, float x, float y, bool fill, std::optional<float> maxWidth = std::nullopt);
 

Modified: trunk/Source/WebCore/inspector/InspectorCanvas.cpp (222985 => 222986)


--- trunk/Source/WebCore/inspector/InspectorCanvas.cpp	2017-10-06 16:49:50 UTC (rev 222985)
+++ trunk/Source/WebCore/inspector/InspectorCanvas.cpp	2017-10-06 16:51:47 UTC (rev 222986)
@@ -39,6 +39,7 @@
 #include "HTMLImageElement.h"
 #include "HTMLVideoElement.h"
 #include "Image.h"
+#include "ImageBitmap.h"
 #include "ImageBuffer.h"
 #include "ImageData.h"
 #include "InspectorDOMAgent.h"
@@ -344,6 +345,7 @@
         [&] (const CanvasGradient* canvasGradient) { item = buildArrayForCanvasGradient(*canvasGradient); },
         [&] (const CanvasPattern* canvasPattern) { item = buildArrayForCanvasPattern(*canvasPattern); },
         [&] (const ImageData* imageData) { item = buildArrayForImageData(*imageData); },
+        [&] (const ImageBitmap* imageBitmap) { item = buildArrayForImageBitmap(*imageBitmap); },
         [&] (const ScriptCallFrame& scriptCallFrame) {
             auto array = Inspector::Protocol::Array<double>::create();
             array->addItem(indexForData(scriptCallFrame.functionName()));
@@ -538,6 +540,7 @@
 #if ENABLE(VIDEO)
             [&] (RefPtr<HTMLVideoElement>& value) { addParameter(indexForData(value.get()), RecordingSwizzleTypes::Image); },
 #endif
+            [&] (const RefPtr<ImageBitmap>& value) { addParameter(indexForData(value.get()), RecordingSwizzleTypes::ImageBitmap); },
             [&] (const RefPtr<ImageData>& value) { addParameter(indexForData(value.get()), RecordingSwizzleTypes::ImageData); },
             [&] (const RefPtr<Int32Array>&) { addParameter(0, RecordingSwizzleTypes::TypedArray); },
             [&] (const Vector<float>& value) { addParameter(buildArrayForVector(value), RecordingSwizzleTypes::Array); },
@@ -647,5 +650,14 @@
     return array;
 }
 
+RefPtr<Inspector::Protocol::Array<InspectorValue>> InspectorCanvas::buildArrayForImageBitmap(const ImageBitmap& imageBitmap)
+{
+    // FIXME: Needs to include the data somehow.
+    RefPtr<Inspector::Protocol::Array<Inspector::InspectorValue>> array = Inspector::Protocol::Array<Inspector::InspectorValue>::create();
+    array->addItem(static_cast<int>(imageBitmap.width()));
+    array->addItem(static_cast<int>(imageBitmap.height()));
+    return array;
+}
+
 } // namespace WebCore
 

Modified: trunk/Source/WebCore/inspector/InspectorCanvas.h (222985 => 222986)


--- trunk/Source/WebCore/inspector/InspectorCanvas.h	2017-10-06 16:49:50 UTC (rev 222985)
+++ trunk/Source/WebCore/inspector/InspectorCanvas.h	2017-10-06 16:51:47 UTC (rev 222986)
@@ -43,6 +43,7 @@
 class HTMLCanvasElement;
 class HTMLImageElement;
 class HTMLVideoElement;
+class ImageBitmap;
 class ImageData;
 class InstrumentingAgents;
 
@@ -91,6 +92,7 @@
         HTMLVideoElement*,
 #endif
         ImageData*,
+        ImageBitmap*,
         Inspector::ScriptCallFrame,
         String
     > DuplicateDataVariant;
@@ -101,6 +103,7 @@
     RefPtr<Inspector::Protocol::Array<Inspector::InspectorValue>> buildArrayForCanvasGradient(const CanvasGradient&);
     RefPtr<Inspector::Protocol::Array<Inspector::InspectorValue>> buildArrayForCanvasPattern(const CanvasPattern&);
     RefPtr<Inspector::Protocol::Array<Inspector::InspectorValue>> buildArrayForImageData(const ImageData&);
+    RefPtr<Inspector::Protocol::Array<Inspector::InspectorValue>> buildArrayForImageBitmap(const ImageBitmap&);
 
     String m_identifier;
     HTMLCanvasElement& m_canvas;

Modified: trunk/Source/WebCore/inspector/RecordingSwizzleTypes.h (222985 => 222986)


--- trunk/Source/WebCore/inspector/RecordingSwizzleTypes.h	2017-10-06 16:49:50 UTC (rev 222985)
+++ trunk/Source/WebCore/inspector/RecordingSwizzleTypes.h	2017-10-06 16:51:47 UTC (rev 222986)
@@ -48,6 +48,7 @@
     WebGLShader = 16,
     WebGLProgram = 17,
     WebGLUniformLocation = 18,
+    ImageBitmap = 19,
 };
 
 } // namespace WebCore
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to