Changeset 223775 in webkit


Ignore:
Timestamp:
Oct 20, 2017 10:47:09 AM (7 years ago)
Author:
dino@apple.com
Message:

Add createImageBitmap to Window and Worker
https://bugs.webkit.org/show_bug.cgi?id=178573
<rdar://problem/35092692>

Reviewed by Sam Weinig.

LayoutTests/imported/w3c:

Update the expected results now that createImageBitmap exists.

  • web-platform-tests/2dcontext/imagebitmap/createImageBitmap-drawImage-expected.txt:
  • web-platform-tests/2dcontext/imagebitmap/createImageBitmap-invalid-args-expected.txt:
  • web-platform-tests/2dcontext/imagebitmap/createImageBitmap-sizeOverflow-expected.txt:
  • web-platform-tests/imagebitmap-renderingcontext/bitmaprenderer-as-imagesource-expected.txt:
  • web-platform-tests/imagebitmap-renderingcontext/context-creation-with-alpha-expected.txt:
  • web-platform-tests/imagebitmap-renderingcontext/tranferFromImageBitmap-null-expected.txt:
  • web-platform-tests/imagebitmap-renderingcontext/transferFromImageBitmap-detached-expected.txt:

Source/WebCore:

Implement the createImageBitmap functions that are exposed on the Window
and Worker objects.

Covered by the Web Platform Tests.

  • html/ImageBitmap.cpp: Make sure to call suspendIfNeeded since this is

an ActiveDOMObject.

  • html/ImageBitmap.h: Change the order of the classes in the Variant

to match the order of definitions in the IDL.

  • page/DOMWindow.cpp:

(WebCore::DOMWindow::createImageBitmap): Call ImageBitmap::createPromise.

  • page/DOMWindow.h:
  • page/WindowOrWorkerGlobalScope.idl: Add the createImageBitmap methods.
  • workers/WorkerGlobalScope.cpp:

(WebCore::WorkerGlobalScope::createImageBitmap): Call ImageBitmap::createPromise.

  • workers/WorkerGlobalScope.h:
Location:
trunk
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r223748 r223775  
     12017-10-20  Dean Jackson  <dino@apple.com>
     2
     3        Add createImageBitmap to Window and Worker
     4        https://bugs.webkit.org/show_bug.cgi?id=178573
     5        <rdar://problem/35092692>
     6
     7        Reviewed by Sam Weinig.
     8
     9        Update the expected results now that createImageBitmap exists.
     10
     11        * web-platform-tests/2dcontext/imagebitmap/createImageBitmap-drawImage-expected.txt:
     12        * web-platform-tests/2dcontext/imagebitmap/createImageBitmap-invalid-args-expected.txt:
     13        * web-platform-tests/2dcontext/imagebitmap/createImageBitmap-sizeOverflow-expected.txt:
     14        * web-platform-tests/imagebitmap-renderingcontext/bitmaprenderer-as-imagesource-expected.txt:
     15        * web-platform-tests/imagebitmap-renderingcontext/context-creation-with-alpha-expected.txt:
     16        * web-platform-tests/imagebitmap-renderingcontext/tranferFromImageBitmap-null-expected.txt:
     17        * web-platform-tests/imagebitmap-renderingcontext/transferFromImageBitmap-detached-expected.txt:
     18
    1192017-10-19  Antti Koivisto  <antti@apple.com>
    220
  • trunk/LayoutTests/imported/w3c/web-platform-tests/2dcontext/imagebitmap/createImageBitmap-drawImage-expected.txt

    r223686 r223775  
    22Harness Error (TIMEOUT), message = null
    33
    4 FAIL createImageBitmap from a HTMLImageElement, and drawImage on the created ImageBitmap promise_test: Unhandled rejection with value: object "ReferenceError: Can't find variable: createImageBitmap"
    5 FAIL createImageBitmap from a Blob, and drawImage on the created ImageBitmap promise_test: Unhandled rejection with value: object "ReferenceError: Can't find variable: createImageBitmap"
    6 FAIL createImageBitmap from a HTMLCanvasElement, and drawImage on the created ImageBitmap Can't find variable: createImageBitmap
    7 FAIL createImageBitmap from an ImageBitmap, and drawImage on the created ImageBitmap promise_test: Unhandled rejection with value: object "ReferenceError: Can't find variable: createImageBitmap"
    8 FAIL createImageBitmap from an ImageData, and drawImage on the created ImageBitmap Can't find variable: createImageBitmap
     4FAIL createImageBitmap from a HTMLImageElement, and drawImage on the created ImageBitmap promise_test: Unhandled rejection with value: object "TypeError: Type error"
     5FAIL createImageBitmap from a Blob, and drawImage on the created ImageBitmap promise_test: Unhandled rejection with value: object "TypeError: Type error"
     6FAIL createImageBitmap from a HTMLCanvasElement, and drawImage on the created ImageBitmap promise_test: Unhandled rejection with value: object "TypeError: Type error"
     7FAIL createImageBitmap from an ImageBitmap, and drawImage on the created ImageBitmap promise_test: Unhandled rejection with value: object "TypeError: Type error"
     8FAIL createImageBitmap from an ImageData, and drawImage on the created ImageBitmap promise_test: Unhandled rejection with value: object "TypeError: Type error"
    99TIMEOUT createImageBitmap from a HTMLVideoElement, and drawImage on the created ImageBitmap Test timed out
    1010
  • trunk/LayoutTests/imported/w3c/web-platform-tests/2dcontext/imagebitmap/createImageBitmap-invalid-args-expected.txt

    r223686 r223775  
    22Harness Error (TIMEOUT), message = null
    33
    4 FAIL createImageBitmap with a HTMLImageElement source and sw set to 0 rejects with a RangeError. promise_test: Unhandled rejection with value: object "ReferenceError: Can't find variable: createImageBitmap"
    5 FAIL createImageBitmap with a HTMLImageElement source and sh set to 0 rejects with a RangeError. promise_test: Unhandled rejection with value: object "ReferenceError: Can't find variable: createImageBitmap"
    6 FAIL createImageBitmap with a HTMLImageElement source and oversized (unallocatable) crop region rejects with an InvalidStateError DOMException. promise_test: Unhandled rejection with value: object "ReferenceError: Can't find variable: createImageBitmap"
     4PASS createImageBitmap with a HTMLImageElement source and sw set to 0 rejects with a RangeError.
     5PASS createImageBitmap with a HTMLImageElement source and sh set to 0 rejects with a RangeError.
     6FAIL createImageBitmap with a HTMLImageElement source and oversized (unallocatable) crop region rejects with an InvalidStateError DOMException. assert_unreached: Should have rejected: undefined Reached unreachable code
    77TIMEOUT createImageBitmap with a HTMLVideoElement source and sw set to 0 rejects with a RangeError. Test timed out
    88NOTRUN createImageBitmap with a HTMLVideoElement source and sh set to 0 rejects with a RangeError.
  • trunk/LayoutTests/imported/w3c/web-platform-tests/2dcontext/imagebitmap/createImageBitmap-sizeOverflow-expected.txt

    r223686 r223775  
    11
    2 FAIL createImageBitmap does not crash or reject the promise when passing very large sx promise_test: Unhandled rejection with value: object "ReferenceError: Can't find variable: createImageBitmap"
    3 FAIL createImageBitmap does not crash or reject the promise when passing very large sy promise_test: Unhandled rejection with value: object "ReferenceError: Can't find variable: createImageBitmap"
    4 FAIL createImageBitmap does not crash or reject the promise when passing very large sw promise_test: Unhandled rejection with value: object "ReferenceError: Can't find variable: createImageBitmap"
    5 FAIL createImageBitmap does not crash or reject the promise when passing very large sh promise_test: Unhandled rejection with value: object "ReferenceError: Can't find variable: createImageBitmap"
    6 FAIL createImageBitmap does not crash or reject the promise when passing very large sx, sy, sw and sh promise_test: Unhandled rejection with value: object "ReferenceError: Can't find variable: createImageBitmap"
     2PASS createImageBitmap does not crash or reject the promise when passing very large sx
     3PASS createImageBitmap does not crash or reject the promise when passing very large sy
     4PASS createImageBitmap does not crash or reject the promise when passing very large sw
     5PASS createImageBitmap does not crash or reject the promise when passing very large sh
     6PASS createImageBitmap does not crash or reject the promise when passing very large sx, sy, sw and sh
    77
  • trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/bitmaprenderer-as-imagesource-expected.txt

    r223079 r223775  
    11
    2 FAIL Test that createImageBitmap from a bitmaprenderer canvas produces correct result Can't find variable: createImageBitmap
    3 FAIL Test that createImageBitmap on a bitmaprenderer canvas that never consumes any source produces correct result Can't find variable: createImageBitmap
     2FAIL Test that createImageBitmap from a bitmaprenderer canvas produces correct result myCtx.transferFromImageBitmap is not a function. (In 'myCtx.transferFromImageBitmap(image)', 'myCtx.transferFromImageBitmap' is undefined)
     3FAIL Test that createImageBitmap on a bitmaprenderer canvas that never consumes any source produces correct result assert_equals: expected 10 but got 0
    44FAIL Test that createImageBitmap on a bitmaprenderer canvas that consumes null produces correct result ctx.transferFromImageBitmap is not a function. (In 'ctx.transferFromImageBitmap(null)', 'ctx.transferFromImageBitmap' is undefined)
    55
  • trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/context-creation-with-alpha-expected.txt

    r223060 r223775  
    11
    2 FAIL Test that an ImageBitmapRenderingContext with alpha disabled makes the canvas opaque Can't find variable: createImageBitmap
    3 FAIL Test that an ImageBitmapRenderingContext with alpha enabled preserves the alpha Can't find variable: createImageBitmap
    4 FAIL Test that the 'alpha' context creation attribute is true by default Can't find variable: createImageBitmap
     2FAIL Test that an ImageBitmapRenderingContext with alpha disabled makes the canvas opaque promise_test: Unhandled rejection with value: object "TypeError: dstCtx.transferFromImageBitmap is not a function. (In 'dstCtx.transferFromImageBitmap(image)', 'dstCtx.transferFromImageBitmap' is undefined)"
     3FAIL Test that an ImageBitmapRenderingContext with alpha enabled preserves the alpha promise_test: Unhandled rejection with value: object "TypeError: dstCtx.transferFromImageBitmap is not a function. (In 'dstCtx.transferFromImageBitmap(image)', 'dstCtx.transferFromImageBitmap' is undefined)"
     4FAIL Test that the 'alpha' context creation attribute is true by default promise_test: Unhandled rejection with value: object "TypeError: dstCtx.transferFromImageBitmap is not a function. (In 'dstCtx.transferFromImageBitmap(image)', 'dstCtx.transferFromImageBitmap' is undefined)"
    55
  • trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/tranferFromImageBitmap-null-expected.txt

    r223060 r223775  
    11
    2 FAIL Test that transferFromImageBitmap(null) discards the previously transferred image Can't find variable: createImageBitmap
     2FAIL Test that transferFromImageBitmap(null) discards the previously transferred image promise_test: Unhandled rejection with value: object "TypeError: bitmapCtx.transferFromImageBitmap is not a function. (In 'bitmapCtx.transferFromImageBitmap(greenImage)', 'bitmapCtx.transferFromImageBitmap' is undefined)"
    33
  • trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/transferFromImageBitmap-detached-expected.txt

    r223060 r223775  
    11
    2 FAIL Test transferFromImageBitmap(image) with a detached image should throw InvalidStateError Can't find variable: createImageBitmap
     2FAIL Test transferFromImageBitmap(image) with a detached image should throw InvalidStateError promise_test: Unhandled rejection with value: object "TypeError: dstCtx.transferFromImageBitmap is not a function. (In 'dstCtx.transferFromImageBitmap(image)', 'dstCtx.transferFromImageBitmap' is undefined)"
    33
  • trunk/Source/WebCore/ChangeLog

    r223766 r223775  
     12017-10-20  Dean Jackson  <dino@apple.com>
     2
     3        Add createImageBitmap to Window and Worker
     4        https://bugs.webkit.org/show_bug.cgi?id=178573
     5        <rdar://problem/35092692>
     6
     7        Reviewed by Sam Weinig.
     8
     9        Implement the createImageBitmap functions that are exposed on the Window
     10        and Worker objects.
     11
     12        Covered by the Web Platform Tests.
     13
     14        * html/ImageBitmap.cpp: Make sure to call suspendIfNeeded since this is
     15        an ActiveDOMObject.
     16        * html/ImageBitmap.h: Change the order of the classes in the Variant
     17        to match the order of definitions in the IDL.
     18        * page/DOMWindow.cpp:
     19        (WebCore::DOMWindow::createImageBitmap): Call ImageBitmap::createPromise.
     20        * page/DOMWindow.h:
     21        * page/WindowOrWorkerGlobalScope.idl: Add the createImageBitmap methods.
     22        * workers/WorkerGlobalScope.cpp:
     23        (WebCore::WorkerGlobalScope::createImageBitmap): Call ImageBitmap::createPromise.
     24        * workers/WorkerGlobalScope.h:
     25
    1262017-10-20  Joanmarie Diggs  <jdiggs@igalia.com>
    227
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r223747 r223775  
    13051305                316FE11A0E6E1DA700BF6088 /* KeyframeAnimation.h in Headers */ = {isa = PBXBuildFile; fileRef = 316FE1100E6E1DA700BF6088 /* KeyframeAnimation.h */; };
    13061306                31741AAD16636609008A5B7E /* SimulatedClickOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 31741AAB16635E45008A5B7E /* SimulatedClickOptions.h */; settings = {ATTRIBUTES = (Private, ); }; };
     1307                31815A311F9A6C8F00FCBF89 /* ImageBitmap.h in Headers */ = {isa = PBXBuildFile; fileRef = 31D26BBF1F86D189008FF255 /* ImageBitmap.h */; settings = {ATTRIBUTES = (Private, ); }; };
    13071308                318891611AB7EEA100EA627B /* missingImage@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = CDF419991AB0DA14004E64E1 /* missingImage@3x.png */; };
    13081309                31955A86160D199000858025 /* RenderSnapshottedPlugIn.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 31E8D8BA160BC94B004CE8F5 /* RenderSnapshottedPlugIn.cpp */; };
     
    3022830229                                B2C3DA340D006C1D00EF6F26 /* TextBoundaries.h in Headers */,
    3022930230                                A7151BD812F1558F005A0F64 /* TextCheckerClient.h in Headers */,
     30231                                31815A311F9A6C8F00FCBF89 /* ImageBitmap.h in Headers */,
    3023030232                                A77D0012133B0AEB00D6658C /* TextChecking.h in Headers */,
    3023130233                                A7DBF8DE1276919C006B6008 /* TextCheckingHelper.h in Headers */,
  • trunk/Source/WebCore/html/ImageBitmap.cpp

    r223728 r223775  
    220220        , m_promise(WTFMove(promise))
    221221    {
     222        suspendIfNeeded();
    222223    }
    223224
  • trunk/Source/WebCore/html/ImageBitmap.h

    r222986 r223775  
    4949    using Source = Variant<
    5050        RefPtr<HTMLImageElement>,
     51#if ENABLE(VIDEO)
     52        RefPtr<HTMLVideoElement>,
     53#endif
    5154        RefPtr<HTMLCanvasElement>,
    52         RefPtr<HTMLVideoElement>, // FIXME: Make conditional
    5355        RefPtr<ImageBitmap>,
    5456        RefPtr<Blob>,
  • trunk/Source/WebCore/page/DOMWindow.cpp

    r223476 r223775  
    17441744}
    17451745
     1746void DOMWindow::createImageBitmap(ImageBitmap::Source&& source, ImageBitmapOptions&& options, ImageBitmap::Promise&& promise)
     1747{
     1748    auto* document = this->document();
     1749    if (!document) {
     1750        promise.reject(InvalidStateError);
     1751        return;
     1752    }
     1753    ImageBitmap::createPromise(*document, WTFMove(source), WTFMove(options), WTFMove(promise));
     1754}
     1755
     1756void DOMWindow::createImageBitmap(ImageBitmap::Source&& source, int sx, int sy, int sw, int sh, ImageBitmapOptions&& options, ImageBitmap::Promise&& promise)
     1757{
     1758    auto* document = this->document();
     1759    if (!document) {
     1760        promise.reject(InvalidStateError);
     1761        return;
     1762    }
     1763    ImageBitmap::createPromise(*document, WTFMove(source), WTFMove(options), sx, sy, sw, sh, WTFMove(promise));
     1764}
     1765
    17461766bool DOMWindow::isSecureContext() const
    17471767{
  • trunk/Source/WebCore/page/DOMWindow.h

    r222422 r223775  
    3232#include "ExceptionOr.h"
    3333#include "FrameDestructionObserver.h"
     34#include "ImageBitmap.h"
    3435#include "ScrollToOptions.h"
    3536#include "Supplementable.h"
     
    7980class WebKitPoint;
    8081
     82struct ImageBitmapOptions;
    8183struct WindowFeatures;
    8284
     
    249251    int webkitRequestAnimationFrame(Ref<RequestAnimationFrameCallback>&&);
    250252    void cancelAnimationFrame(int id);
     253
     254    // ImageBitmap
     255    void createImageBitmap(ImageBitmap::Source&&, ImageBitmapOptions&&, ImageBitmap::Promise&&);
     256    void createImageBitmap(ImageBitmap::Source&&, int sx, int sy, int sw, int sh, ImageBitmapOptions&&, ImageBitmap::Promise&&);
    251257
    252258    // Secure Contexts
  • trunk/Source/WebCore/page/WindowOrWorkerGlobalScope.idl

    r219873 r223775  
    2626 */
    2727
     28#if defined(ENABLE_VIDEO) && ENABLE_VIDEO
     29typedef (HTMLImageElement or HTMLVideoElement or HTMLCanvasElement or ImageBitmap) CanvasImageSource;
     30#else
     31typedef (HTMLImageElement or HTMLCanvasElement or ImageBitmap) CanvasImageSource;
     32#endif
     33
     34typedef (CanvasImageSource or Blob or ImageData) ImageBitmapSource;
     35
    2836[
    2937    NoInterfaceObject,
     
    4553    // Secure Contexts
    4654    [EnabledAtRuntime=IsSecureContextAttribute] readonly attribute boolean isSecureContext;
     55
     56    // ImageBitmap.
     57    Promise<ImageBitmap> createImageBitmap(ImageBitmapSource image, optional ImageBitmapOptions options);
     58    Promise<ImageBitmap> createImageBitmap(ImageBitmapSource image, long sx, long sy, long sw, long sh, optional ImageBitmapOptions options);
    4759};
  • trunk/Source/WebCore/workers/WorkerGlobalScope.cpp

    r223476 r223775  
    3232#include "Crypto.h"
    3333#include "IDBConnectionProxy.h"
     34#include "ImageBitmapOptions.h"
    3435#include "InspectorInstrumentation.h"
    3536#include "Performance.h"
     
    4950#include <inspector/ScriptCallStack.h>
    5051
    51 
    5252namespace WebCore {
    5353using namespace Inspector;
     
    395395}
    396396
     397void WorkerGlobalScope::createImageBitmap(ImageBitmap::Source&& source, ImageBitmapOptions&& options, ImageBitmap::Promise&& promise)
     398{
     399    ImageBitmap::createPromise(*this, WTFMove(source), WTFMove(options), WTFMove(promise));
     400}
     401
     402void WorkerGlobalScope::createImageBitmap(ImageBitmap::Source&& source, int sx, int sy, int sw, int sh, ImageBitmapOptions&& options, ImageBitmap::Promise&& promise)
     403{
     404    ImageBitmap::createPromise(*this, WTFMove(source), WTFMove(options), sx, sy, sw, sh, WTFMove(promise));
     405}
     406
    397407} // namespace WebCore
  • trunk/Source/WebCore/workers/WorkerGlobalScope.h

    r223277 r223775  
    3030#include "CacheStorageConnection.h"
    3131#include "EventTarget.h"
     32#include "ImageBitmap.h"
    3233#include "ScriptExecutionContext.h"
    3334#include "Supplementable.h"
     
    112113
    113114    void removeAllEventListeners() final;
     115
     116    void createImageBitmap(ImageBitmap::Source&&, ImageBitmapOptions&&, ImageBitmap::Promise&&);
     117    void createImageBitmap(ImageBitmap::Source&&, int sx, int sy, int sw, int sh, ImageBitmapOptions&&, ImageBitmap::Promise&&);
    114118
    115119protected:
Note: See TracChangeset for help on using the changeset viewer.