Title: [224407] trunk
Revision
224407
Author
[email protected]
Date
2017-11-03 11:05:13 -0700 (Fri, 03 Nov 2017)

Log Message

Add basic OffscreenCanvas interface
https://bugs.webkit.org/show_bug.cgi?id=179213
<rdar://problem/35326778>

Reviewed by Sam Weinig.

Source/WebCore:

Add the basic infrastructure for the OffscreenCanvas
object, so it can be created from script.

Test: http/wpt/offscreen-canvas/offscreencanvas.constructor.html

* DerivedSources.make:
* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSEventTargetCustom.cpp:
* dom/EventTargetFactory.in:
* html/OffscreenCanvas.cpp: Added.
(WebCore::OffscreenCanvas::create):
(WebCore::OffscreenCanvas::OffscreenCanvas):
(WebCore::OffscreenCanvas::width const):
(WebCore::OffscreenCanvas::setWidth):
(WebCore::OffscreenCanvas::height const):
(WebCore::OffscreenCanvas::setHeight):
* html/OffscreenCanvas.h: Added.
* html/OffscreenCanvas.idl: Added.

LayoutTests:

Very basic test that exercises object construction.

* http/wpt/offscreen-canvas/offscreencanvas.constructor-expected.txt: Added.
* http/wpt/offscreen-canvas/offscreencanvas.constructor.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (224406 => 224407)


--- trunk/LayoutTests/ChangeLog	2017-11-03 18:03:51 UTC (rev 224406)
+++ trunk/LayoutTests/ChangeLog	2017-11-03 18:05:13 UTC (rev 224407)
@@ -1,3 +1,16 @@
+2017-11-02  Dean Jackson  <[email protected]>
+
+        Add basic OffscreenCanvas interface
+        https://bugs.webkit.org/show_bug.cgi?id=179213
+        <rdar://problem/35326778>
+
+        Reviewed by Sam Weinig.
+
+        Very basic test that exercises object construction.
+
+        * http/wpt/offscreen-canvas/offscreencanvas.constructor-expected.txt: Added.
+        * http/wpt/offscreen-canvas/offscreencanvas.constructor.html: Added.
+
 2017-11-03  Ryosuke Niwa  <[email protected]>
 
         Crash inside ChildListMutationAccumulator::enqueueMutationRecord()

Modified: trunk/LayoutTests/fast/mediacapturefromelement/CanvasCaptureMediaStream-imagebitmaprenderingcontext-expected.txt (224406 => 224407)


--- trunk/LayoutTests/fast/mediacapturefromelement/CanvasCaptureMediaStream-imagebitmaprenderingcontext-expected.txt	2017-11-03 18:03:51 UTC (rev 224406)
+++ trunk/LayoutTests/fast/mediacapturefromelement/CanvasCaptureMediaStream-imagebitmaprenderingcontext-expected.txt	2017-11-03 18:05:13 UTC (rev 224407)
@@ -1,4 +1,4 @@
 
-FAIL Untitled Can't find variable: OffscreenCanvas
-FAIL Untitled 1 Can't find variable: OffscreenCanvas
+FAIL Untitled Can't find variable: MediaRecorder
+FAIL Untitled 1 Can't find variable: MediaRecorder
 

Added: trunk/LayoutTests/http/wpt/offscreen-canvas/offscreencanvas.constructor-expected.txt (0 => 224407)


--- trunk/LayoutTests/http/wpt/offscreen-canvas/offscreencanvas.constructor-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/wpt/offscreen-canvas/offscreencanvas.constructor-expected.txt	2017-11-03 18:05:13 UTC (rev 224407)
@@ -0,0 +1,4 @@
+
+PASS Test that calling OffscreenCanvas's constructor generates correct width and height. 
+PASS Test that OffscreenCanvas constructor handles invalid arguments correctly 
+
Property changes on: trunk/LayoutTests/http/wpt/offscreen-canvas/offscreencanvas.constructor-expected.txt
___________________________________________________________________

Added: svn:eol-style

+native \ No newline at end of property

Added: svn:keywords

+Date Revision \ No newline at end of property

Added: svn:mime-type

+text/plain \ No newline at end of property

Added: trunk/LayoutTests/http/wpt/offscreen-canvas/offscreencanvas.constructor.html (0 => 224407)


--- trunk/LayoutTests/http/wpt/offscreen-canvas/offscreencanvas.constructor.html	                        (rev 0)
+++ trunk/LayoutTests/http/wpt/offscreen-canvas/offscreencanvas.constructor.html	2017-11-03 18:05:13 UTC (rev 224407)
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<script src=""
+<script src=""
+<script src=""
+<link rel="help" href=""
+<script>
+
+test(function() {
+    var offscreenCanvas = new OffscreenCanvas(100, 50);
+    assert_equals(offscreenCanvas.width, 100);
+    assert_equals(offscreenCanvas.height, 50);
+
+    offscreenCanvas.width = 50;
+    offscreenCanvas.height = 100;
+    assert_equals(offscreenCanvas.width, 50);
+    assert_equals(offscreenCanvas.height, 100);
+}, "Test that calling OffscreenCanvas's constructor generates correct width and height.");
+
+test(function() {
+    var offscreenCanvas1 = new OffscreenCanvas(1, 1);
+
+    offscreenCanvas1.width = null;
+    offscreenCanvas1.height = null;
+    assert_equals(offscreenCanvas1.width, 0);
+    assert_equals(offscreenCanvas1.height, 0);
+
+    assert_throws(new TypeError(), function() { new OffscreenCanvas(-1, -1); });
+
+    var offscreenCanvas2 = new OffscreenCanvas(null, null);
+    assert_equals(offscreenCanvas2.width, 0);
+    assert_equals(offscreenCanvas2.height, 0);
+
+    assert_throws(new TypeError(), function() { offscreenCanvas2.width = -1; });
+    assert_throws(new TypeError(), function() { offscreenCanvas2.height = -1; });
+
+    var obj = {Name: "John Doe", Age: 30};
+    assert_throws(new TypeError(), function() { offscreenCanvas2.width = obj; });
+    assert_throws(new TypeError(), function() { offscreenCanvas2.height = obj; });
+    assert_throws(new TypeError(), function() { new OffscreenCanvas(obj, obj); });
+}, "Test that OffscreenCanvas constructor handles invalid arguments correctly");
+
+</script>
+
Property changes on: trunk/LayoutTests/http/wpt/offscreen-canvas/offscreencanvas.constructor.html
___________________________________________________________________

Added: svn:eol-style

+native \ No newline at end of property

Added: svn:keywords

+Date Revision \ No newline at end of property

Added: svn:mime-type

+text/html \ No newline at end of property

Modified: trunk/Source/WebCore/CMakeLists.txt (224406 => 224407)


--- trunk/Source/WebCore/CMakeLists.txt	2017-11-03 18:03:51 UTC (rev 224406)
+++ trunk/Source/WebCore/CMakeLists.txt	2017-11-03 18:05:13 UTC (rev 224407)
@@ -690,6 +690,7 @@
     html/ImageData.idl
     html/MediaController.idl
     html/MediaError.idl
+    html/OffscreenCanvas.idl
     html/RadioNodeList.idl
     html/TextMetrics.idl
     html/TimeRanges.idl

Modified: trunk/Source/WebCore/ChangeLog (224406 => 224407)


--- trunk/Source/WebCore/ChangeLog	2017-11-03 18:03:51 UTC (rev 224406)
+++ trunk/Source/WebCore/ChangeLog	2017-11-03 18:05:13 UTC (rev 224407)
@@ -1,3 +1,31 @@
+2017-11-02  Dean Jackson  <[email protected]>
+
+        Add basic OffscreenCanvas interface
+        https://bugs.webkit.org/show_bug.cgi?id=179213
+        <rdar://problem/35326778>
+
+        Reviewed by Sam Weinig.
+
+        Add the basic infrastructure for the OffscreenCanvas
+        object, so it can be created from script.
+
+        Test: http/wpt/offscreen-canvas/offscreencanvas.constructor.html
+
+        * DerivedSources.make:
+        * Sources.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/JSEventTargetCustom.cpp:
+        * dom/EventTargetFactory.in:
+        * html/OffscreenCanvas.cpp: Added.
+        (WebCore::OffscreenCanvas::create):
+        (WebCore::OffscreenCanvas::OffscreenCanvas):
+        (WebCore::OffscreenCanvas::width const):
+        (WebCore::OffscreenCanvas::setWidth):
+        (WebCore::OffscreenCanvas::height const):
+        (WebCore::OffscreenCanvas::setHeight):
+        * html/OffscreenCanvas.h: Added.
+        * html/OffscreenCanvas.idl: Added.
+
 2017-11-03  Ryosuke Niwa  <[email protected]>
 
         Crash inside ChildListMutationAccumulator::enqueueMutationRecord()

Modified: trunk/Source/WebCore/DerivedSources.make (224406 => 224407)


--- trunk/Source/WebCore/DerivedSources.make	2017-11-03 18:03:51 UTC (rev 224406)
+++ trunk/Source/WebCore/DerivedSources.make	2017-11-03 18:05:13 UTC (rev 224407)
@@ -604,6 +604,7 @@
     $(WebCore)/html/MediaController.idl \
     $(WebCore)/html/MediaEncryptedEvent.idl \
     $(WebCore)/html/MediaError.idl \
+    $(WebCore)/html/OffscreenCanvas.idl \
     $(WebCore)/html/RadioNodeList.idl \
     $(WebCore)/html/TextMetrics.idl \
     $(WebCore)/html/TimeRanges.idl \

Modified: trunk/Source/WebCore/Sources.txt (224406 => 224407)


--- trunk/Source/WebCore/Sources.txt	2017-11-03 18:03:51 UTC (rev 224406)
+++ trunk/Source/WebCore/Sources.txt	2017-11-03 18:05:13 UTC (rev 224407)
@@ -1012,6 +1012,7 @@
 html/MediaFragmentURIParser.cpp
 html/MonthInputType.cpp
 html/NumberInputType.cpp
+html/OffscreenCanvas.cpp
 html/PasswordInputType.cpp
 html/PluginDocument.cpp
 html/PublicURLManager.cpp
@@ -2622,6 +2623,7 @@
 JSNotificationPermissionCallback.cpp
 JSOfflineAudioCompletionEvent.cpp
 JSOfflineAudioContext.cpp
+JSOffscreenCanvas.cpp
 JSOscillatorNode.cpp
 JSOverconstrainedError.cpp
 JSOverconstrainedErrorEvent.cpp

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (224406 => 224407)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2017-11-03 18:03:51 UTC (rev 224406)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2017-11-03 18:05:13 UTC (rev 224407)
@@ -829,6 +829,8 @@
 		3146FE6E184420A8001A937C /* OESTextureFloatLinear.h in Headers */ = {isa = PBXBuildFile; fileRef = 3146FE6618442087001A937C /* OESTextureFloatLinear.h */; };
 		3146FE6F184420AA001A937C /* OESTextureFloatLinear.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3146FE6518442087001A937C /* OESTextureFloatLinear.cpp */; };
 		3146FE7518442370001A937C /* JSOESTextureFloatLinear.h in Headers */ = {isa = PBXBuildFile; fileRef = 3146FE7118442367001A937C /* JSOESTextureFloatLinear.h */; };
+		314877E31FAA8FE900C05759 /* OffscreenCanvas.h in Headers */ = {isa = PBXBuildFile; fileRef = 314877E11FAA8FE900C05759 /* OffscreenCanvas.h */; };
+		314877E61FAAB02500C05759 /* JSOffscreenCanvas.h in Headers */ = {isa = PBXBuildFile; fileRef = 314877E41FAAB02200C05759 /* JSOffscreenCanvas.h */; };
 		314BE3A11B30F6B700141982 /* CSSNamedImageValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 314BE3A01B30F6B700141982 /* CSSNamedImageValue.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		314BE3A71B3103FB00141982 /* NamedImageGeneratedImage.h in Headers */ = {isa = PBXBuildFile; fileRef = 314BE3A51B3103FB00141982 /* NamedImageGeneratedImage.h */; };
 		316BDB861E6E0A2700DE0D5A /* GPUDevice.h in Headers */ = {isa = PBXBuildFile; fileRef = 316BDB851E6E0A2100DE0D5A /* GPUDevice.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -6486,6 +6488,11 @@
 		3146FE6718442087001A937C /* OESTextureFloatLinear.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = OESTextureFloatLinear.idl; sourceTree = "<group>"; };
 		3146FE7018442367001A937C /* JSOESTextureFloatLinear.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSOESTextureFloatLinear.cpp; sourceTree = "<group>"; };
 		3146FE7118442367001A937C /* JSOESTextureFloatLinear.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSOESTextureFloatLinear.h; sourceTree = "<group>"; };
+		314877D91FAA870600C05759 /* OffscreenCanvas.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = OffscreenCanvas.idl; sourceTree = "<group>"; };
+		314877E01FAA8FE900C05759 /* OffscreenCanvas.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = OffscreenCanvas.cpp; sourceTree = "<group>"; };
+		314877E11FAA8FE900C05759 /* OffscreenCanvas.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OffscreenCanvas.h; sourceTree = "<group>"; };
+		314877E41FAAB02200C05759 /* JSOffscreenCanvas.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSOffscreenCanvas.h; sourceTree = "<group>"; };
+		314877E51FAAB02400C05759 /* JSOffscreenCanvas.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSOffscreenCanvas.cpp; sourceTree = "<group>"; };
 		314BE3A01B30F6B700141982 /* CSSNamedImageValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSNamedImageValue.h; sourceTree = "<group>"; };
 		314BE3A21B30F6D100141982 /* CSSNamedImageValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSNamedImageValue.cpp; sourceTree = "<group>"; };
 		314BE3A41B3103FB00141982 /* NamedImageGeneratedImage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NamedImageGeneratedImage.cpp; sourceTree = "<group>"; };
@@ -19773,6 +19780,9 @@
 				F55B3D921251F12D003EF269 /* MonthInputType.h */,
 				F55B3D931251F12D003EF269 /* NumberInputType.cpp */,
 				F55B3D941251F12D003EF269 /* NumberInputType.h */,
+				314877E01FAA8FE900C05759 /* OffscreenCanvas.cpp */,
+				314877E11FAA8FE900C05759 /* OffscreenCanvas.h */,
+				314877D91FAA870600C05759 /* OffscreenCanvas.idl */,
 				F55B3D951251F12D003EF269 /* PasswordInputType.cpp */,
 				F55B3D961251F12D003EF269 /* PasswordInputType.h */,
 				97205AB91239292700B17380 /* PluginDocument.cpp */,
@@ -20924,6 +20934,8 @@
 				31078CC61880AAAA008099DC /* JSOESTextureHalfFloatLinear.h */,
 				77A17AA212F28B2A004E02F6 /* JSOESVertexArrayObject.cpp */,
 				77A17AA312F28B2A004E02F6 /* JSOESVertexArrayObject.h */,
+				314877E51FAAB02400C05759 /* JSOffscreenCanvas.cpp */,
+				314877E41FAAB02200C05759 /* JSOffscreenCanvas.h */,
 				7C193BFD1F5E10D60088F3E6 /* JSPath2D.cpp */,
 				7C193BFE1F5E10D70088F3E6 /* JSPath2D.h */,
 				B658FF9F1522EF3A00DD5595 /* JSRadioNodeList.cpp */,
@@ -27636,6 +27648,7 @@
 				77A17AA712F28B2A004E02F6 /* JSOESVertexArrayObject.h in Headers */,
 				FDF6BAF9134A4C9800822920 /* JSOfflineAudioCompletionEvent.h in Headers */,
 				FDA9326716703BA9008982DC /* JSOfflineAudioContext.h in Headers */,
+				314877E61FAAB02500C05759 /* JSOffscreenCanvas.h in Headers */,
 				57E233651DC7DB1F00F28D01 /* JsonWebKey.h in Headers */,
 				FDEA6243152102E200479DF0 /* JSOscillatorNode.h in Headers */,
 				0704A40C1D6DFC690086DCDB /* JSOverconstrainedError.h in Headers */,
@@ -28325,6 +28338,7 @@
 				FDA3E95A134A49EF008D4B5A /* OfflineAudioCompletionEvent.h in Headers */,
 				FDA9325E16703B2A008982DC /* OfflineAudioContext.h in Headers */,
 				FDA3E95C134A49EF008D4B5A /* OfflineAudioDestinationNode.h in Headers */,
+				314877E31FAA8FE900C05759 /* OffscreenCanvas.h in Headers */,
 				B2D3DA650D006CD600EF6F3A /* OpenTypeCG.h in Headers */,
 				B2D3DA650D006CD600EF6F27 /* OpenTypeMathData.h in Headers */,
 				B2D3EA650D006CD600EF6F28 /* OpenTypeTypes.h in Headers */,

Modified: trunk/Source/WebCore/bindings/js/JSEventTargetCustom.cpp (224406 => 224407)


--- trunk/Source/WebCore/bindings/js/JSEventTargetCustom.cpp	2017-11-03 18:03:51 UTC (rev 224406)
+++ trunk/Source/WebCore/bindings/js/JSEventTargetCustom.cpp	2017-11-03 18:05:13 UTC (rev 224407)
@@ -34,9 +34,9 @@
 #include "JSDOMWindowProxy.h"
 #include "JSEventListener.h"
 #include "JSWorkerGlobalScope.h"
+#include "OffscreenCanvas.h"
 #include "WorkerGlobalScope.h"
 
-
 namespace WebCore {
 using namespace JSC;
 

Modified: trunk/Source/WebCore/dom/EventTargetFactory.in (224406 => 224407)


--- trunk/Source/WebCore/dom/EventTargetFactory.in	2017-11-03 18:03:51 UTC (rev 224406)
+++ trunk/Source/WebCore/dom/EventTargetFactory.in	2017-11-03 18:05:13 UTC (rev 224407)
@@ -25,6 +25,7 @@
 MessagePort
 Node
 Notification conditional=NOTIFICATIONS
+OffscreenCanvas
 PaymentRequest conditional=PAYMENT_REQUEST
 Performance
 RTCDataChannel conditional=WEB_RTC

Added: trunk/Source/WebCore/html/OffscreenCanvas.cpp (0 => 224407)


--- trunk/Source/WebCore/html/OffscreenCanvas.cpp	                        (rev 0)
+++ trunk/Source/WebCore/html/OffscreenCanvas.cpp	2017-11-03 18:05:13 UTC (rev 224407)
@@ -0,0 +1,64 @@
+/*
+ * 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 "OffscreenCanvas.h"
+
+namespace WebCore {
+
+Ref<OffscreenCanvas> OffscreenCanvas::create(ScriptExecutionContext& context, unsigned width, unsigned height)
+{
+    return adoptRef(*new OffscreenCanvas(context, width, height));
+}
+
+OffscreenCanvas::OffscreenCanvas(ScriptExecutionContext& context, unsigned width, unsigned height)
+    : m_size(width, height)
+    , m_scriptExecutionContext(context)
+{
+}
+
+OffscreenCanvas::~OffscreenCanvas() = default;
+
+unsigned OffscreenCanvas::width() const
+{
+    return m_size.width();
+}
+
+void OffscreenCanvas::setWidth(unsigned newWidth)
+{
+    return m_size.setWidth(newWidth);
+}
+
+unsigned OffscreenCanvas::height() const
+{
+    return m_size.height();
+}
+
+void OffscreenCanvas::setHeight(unsigned newHeight)
+{
+    return m_size.setHeight(newHeight);
+}
+
+}
Property changes on: trunk/Source/WebCore/html/OffscreenCanvas.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/OffscreenCanvas.h (0 => 224407)


--- trunk/Source/WebCore/html/OffscreenCanvas.h	                        (rev 0)
+++ trunk/Source/WebCore/html/OffscreenCanvas.h	2017-11-03 18:05:13 UTC (rev 224407)
@@ -0,0 +1,81 @@
+/*
+ * 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 "EventTarget.h"
+#include "IntSize.h"
+#include "JSDOMPromiseDeferred.h"
+#include "ScriptWrappable.h"
+#include <wtf/RefCounted.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+class OffscreenCanvas : public RefCounted<OffscreenCanvas>, public EventTargetWithInlineData {
+    WTF_MAKE_FAST_ALLOCATED;
+public:
+
+    struct ImageEncodeOptions {
+        String type = "image/png";
+        double quality = 1.0;
+    };
+
+    enum class RenderingContextType {
+        _2d,
+        Webgl
+    };
+
+    static Ref<OffscreenCanvas> create(ScriptExecutionContext&, unsigned width, unsigned height);
+    ~OffscreenCanvas();
+
+    unsigned width() const;
+    void setWidth(unsigned);
+    unsigned height() const;
+    void setHeight(unsigned);
+
+    // The currently unimplemented OffscreenCanvas methods.
+    // OffscreenRenderingContext? getContext(OffscreenRenderingContextType contextType, any... arguments);
+    // ImageBitmap transferToImageBitmap();
+    // void convertToBlob(ImageEncodeOptions options);
+
+    using RefCounted::ref;
+    using RefCounted::deref;
+
+private:
+
+    OffscreenCanvas(ScriptExecutionContext&, unsigned width, unsigned height);
+
+    // EventTargetWithInlineData.
+    ScriptExecutionContext* scriptExecutionContext() const final { return &m_scriptExecutionContext; }
+    EventTargetInterface eventTargetInterface() const final { return OffscreenCanvasEventTargetInterfaceType; }
+    void refEventTarget() final { ref(); }
+    void derefEventTarget() final { deref(); }
+
+    IntSize m_size;
+    ScriptExecutionContext& m_scriptExecutionContext;
+};
+
+}
Property changes on: trunk/Source/WebCore/html/OffscreenCanvas.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

Added: trunk/Source/WebCore/html/OffscreenCanvas.idl (0 => 224407)


--- trunk/Source/WebCore/html/OffscreenCanvas.idl	                        (rev 0)
+++ trunk/Source/WebCore/html/OffscreenCanvas.idl	2017-11-03 18:05:13 UTC (rev 224407)
@@ -0,0 +1,52 @@
+/*
+* 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.
+*/
+
+// typedef (OffscreenCanvasRenderingContext2D or WebGLRenderingContext) OffscreenRenderingContext;
+
+dictionary ImageEncodeOptions
+{
+   DOMString type = "image/png";
+   unrestricted double quality = 1.0;
+};
+
+enum OffscreenRenderingContextType
+{
+   "2d",
+   "webgl"
+};
+
+[
+    ConstructorCallWith=ScriptExecutionContext,
+    Constructor([EnforceRange] unsigned long width, [EnforceRange] unsigned long height),
+    Exposed=(Window)
+] interface OffscreenCanvas : EventTarget {
+    attribute [EnforceRange] unsigned long width;
+    attribute [EnforceRange] unsigned long height;
+
+    // [CallWith=ScriptState, MayThrowException] OffscreenRenderingContext? getContext(OffscreenRenderingContextType contextType, any... arguments);
+    // ImageBitmap transferToImageBitmap();
+    // Promise<Blob> convertToBlob(optional ImageEncodeOptions options);
+
+};
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to