Commit 0b2bc0cd authored by Amos Lim's avatar Amos Lim Committed by Commit Bot

Merge ImageBitmapFactories into WindowOrWorkerGlobalScope mix-in

According to the spec, the createImageBitmap should be moved
to WindowOrWorkerGlobalScope mix-in.

They were moved from the ImageBitmapFactories mix-in
to the WindowOrWorkerGlobalScope mix-in[1].

[1]: https://github.com/whatwg/html/commit/cdd48e1f570c817402bf62108847c4a9f4b00b1e
[2]: https://html.spec.whatwg.org/multipage/webappapis.html#windoworworkerglobalscope-mixin

This CL has no behavior changes.

Bug: 701457
Change-Id: Idbf0cf3e22019cc24384ab3c409e202343eb1d5a
Reviewed-on: https://chromium-review.googlesource.com/c/1349160
Commit-Queue: Amos Lim <eui-sang.lim@samsung.com>
Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Reviewed-by: default avatarYuki Shiino <yukishiino@chromium.org>
Reviewed-by: default avatarFernando Serboncini <fserb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#612095}
parent 32be36c3
...@@ -441,7 +441,7 @@ def shorten_union_name(union_type): ...@@ -441,7 +441,7 @@ def shorten_union_name(union_type):
'CanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2RenderingContextOrWebGL2ComputeRenderingContextOrImageBitmapRenderingContextOrXRPresentationContext': 'RenderingContext', 'CanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2RenderingContextOrWebGL2ComputeRenderingContextOrImageBitmapRenderingContextOrXRPresentationContext': 'RenderingContext',
# modules/canvas/htmlcanvas/html_canvas_element_module.idl # modules/canvas/htmlcanvas/html_canvas_element_module.idl
'CanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2RenderingContextOrImageBitmapRenderingContextOrXRPresentationContext': 'RenderingContext', 'CanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2RenderingContextOrImageBitmapRenderingContextOrXRPresentationContext': 'RenderingContext',
# core/imagebitmap/ImageBitmapFactories.idl # core/frame/window_or_worker_global_scope.idl
'HTMLImageElementOrSVGImageElementOrHTMLVideoElementOrHTMLCanvasElementOrBlobOrImageDataOrImageBitmapOrOffscreenCanvas': 'ImageBitmapSource', 'HTMLImageElementOrSVGImageElementOrHTMLVideoElementOrHTMLCanvasElementOrBlobOrImageDataOrImageBitmapOrOffscreenCanvas': 'ImageBitmapSource',
# bindings/tests/idls/core/TestTypedefs.idl # bindings/tests/idls/core/TestTypedefs.idl
'NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord': 'NestedUnionType', 'NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord': 'NestedUnionType',
......
...@@ -545,7 +545,6 @@ core_dependency_idl_files = ...@@ -545,7 +545,6 @@ core_dependency_idl_files =
"fullscreen/document_fullscreen.idl", "fullscreen/document_fullscreen.idl",
"fullscreen/element_fullscreen.idl", "fullscreen/element_fullscreen.idl",
"html/html_hyperlink_element_utils.idl", "html/html_hyperlink_element_utils.idl",
"imagebitmap/image_bitmap_factories.idl",
"layout/custom/css_layout_worklet.idl", "layout/custom/css_layout_worklet.idl",
"svg/svg_document.idl", "svg/svg_document.idl",
"svg/svg_filter_primitive_standard_attributes.idl", "svg/svg_filter_primitive_standard_attributes.idl",
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include "third_party/blink/renderer/core/frame/csp/content_security_policy.h" #include "third_party/blink/renderer/core/frame/csp/content_security_policy.h"
#include "third_party/blink/renderer/core/frame/dom_timer.h" #include "third_party/blink/renderer/core/frame/dom_timer.h"
#include "third_party/blink/renderer/core/html/parser/html_parser_idioms.h" #include "third_party/blink/renderer/core/html/parser/html_parser_idioms.h"
#include "third_party/blink/renderer/core/imagebitmap/image_bitmap_factories.h"
#include "third_party/blink/renderer/core/trustedtypes/trusted_types_util.h" #include "third_party/blink/renderer/core/trustedtypes/trusted_types_util.h"
#include "third_party/blink/renderer/core/workers/worker_global_scope.h" #include "third_party/blink/renderer/core/workers/worker_global_scope.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h" #include "third_party/blink/renderer/platform/bindings/exception_state.h"
...@@ -252,4 +253,26 @@ void WindowOrWorkerGlobalScope::clearInterval(EventTarget& event_target, ...@@ -252,4 +253,26 @@ void WindowOrWorkerGlobalScope::clearInterval(EventTarget& event_target,
DOMTimer::RemoveByID(context, timeout_id); DOMTimer::RemoveByID(context, timeout_id);
} }
ScriptPromise WindowOrWorkerGlobalScope::createImageBitmap(
ScriptState* script_state,
EventTarget& event_target,
const ImageBitmapSourceUnion& bitmap_source,
const ImageBitmapOptions* options) {
return ImageBitmapFactories::CreateImageBitmap(script_state, event_target,
bitmap_source, options);
}
ScriptPromise WindowOrWorkerGlobalScope::createImageBitmap(
ScriptState* script_state,
EventTarget& event_target,
const ImageBitmapSourceUnion& bitmap_source,
int sx,
int sy,
int sw,
int sh,
const ImageBitmapOptions* options) {
return ImageBitmapFactories::CreateImageBitmap(
script_state, event_target, bitmap_source, sx, sy, sw, sh, options);
}
} // namespace blink } // namespace blink
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_FRAME_WINDOW_OR_WORKER_GLOBAL_SCOPE_H_ #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_FRAME_WINDOW_OR_WORKER_GLOBAL_SCOPE_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_FRAME_WINDOW_OR_WORKER_GLOBAL_SCOPE_H_ #define THIRD_PARTY_BLINK_RENDERER_CORE_FRAME_WINDOW_OR_WORKER_GLOBAL_SCOPE_H_
#include "third_party/blink/renderer/bindings/core/v8/image_bitmap_source.h"
#include "third_party/blink/renderer/platform/wtf/allocator.h" #include "third_party/blink/renderer/platform/wtf/allocator.h"
#include "third_party/blink/renderer/platform/wtf/forward.h" #include "third_party/blink/renderer/platform/wtf/forward.h"
#include "third_party/blink/renderer/platform/wtf/vector.h" #include "third_party/blink/renderer/platform/wtf/vector.h"
...@@ -41,10 +42,15 @@ namespace blink { ...@@ -41,10 +42,15 @@ namespace blink {
class EventTarget; class EventTarget;
class ExceptionState; class ExceptionState;
class ImageBitmapOptions;
class ScriptPromise;
class ScriptState; class ScriptState;
class ScriptValue; class ScriptValue;
class StringOrTrustedScript; class StringOrTrustedScript;
typedef HTMLImageElementOrSVGImageElementOrHTMLVideoElementOrHTMLCanvasElementOrBlobOrImageDataOrImageBitmapOrOffscreenCanvas
ImageBitmapSourceUnion;
class WindowOrWorkerGlobalScope { class WindowOrWorkerGlobalScope {
STATIC_ONLY(WindowOrWorkerGlobalScope); STATIC_ONLY(WindowOrWorkerGlobalScope);
...@@ -90,6 +96,19 @@ class WindowOrWorkerGlobalScope { ...@@ -90,6 +96,19 @@ class WindowOrWorkerGlobalScope {
const Vector<ScriptValue>&); const Vector<ScriptValue>&);
static void clearTimeout(EventTarget&, int timeout_id); static void clearTimeout(EventTarget&, int timeout_id);
static void clearInterval(EventTarget&, int timeout_id); static void clearInterval(EventTarget&, int timeout_id);
static ScriptPromise createImageBitmap(ScriptState*,
EventTarget&,
const ImageBitmapSourceUnion&,
const ImageBitmapOptions*);
static ScriptPromise createImageBitmap(ScriptState*,
EventTarget&,
const ImageBitmapSourceUnion&,
int sx,
int sy,
int sw,
int sh,
const ImageBitmapOptions*);
}; };
} // namespace blink } // namespace blink
......
...@@ -28,6 +28,16 @@ ...@@ -28,6 +28,16 @@
// https://html.spec.whatwg.org/C/webappapis.html#windoworworkerglobalscope-mixin // https://html.spec.whatwg.org/C/webappapis.html#windoworworkerglobalscope-mixin
// https://html.spec.whatwg.org/C/timers-and-user-prompts.html#timers // https://html.spec.whatwg.org/C/timers-and-user-prompts.html#timers
// https://html.spec.whatwg.org/#imagebitmapsource
typedef (HTMLImageElement or
SVGImageElement or
HTMLVideoElement or
HTMLCanvasElement or
Blob or
ImageData or
ImageBitmap or
OffscreenCanvas) ImageBitmapSource;
[ [
LegacyTreatAsPartialInterface, LegacyTreatAsPartialInterface,
NoInterfaceObject, // Always used on target of 'implements' NoInterfaceObject, // Always used on target of 'implements'
...@@ -46,4 +56,10 @@ ...@@ -46,4 +56,10 @@
[CallWith=ScriptState] long setInterval(CallbackFunctionTreatedAsScriptValue handler, optional long timeout = 0, any... arguments); [CallWith=ScriptState] long setInterval(CallbackFunctionTreatedAsScriptValue handler, optional long timeout = 0, any... arguments);
[CallWith=ScriptState, RaisesException] long setInterval(ScriptString handler, optional long timeout = 0, any... arguments); [CallWith=ScriptState, RaisesException] long setInterval(ScriptString handler, optional long timeout = 0, any... arguments);
void clearInterval(optional long handle = 0); void clearInterval(optional long handle = 0);
// ImageBitmap
[CallWith=ScriptState] Promise createImageBitmap(
ImageBitmapSource imageBitmap, optional ImageBitmapOptions options);
[CallWith=ScriptState] Promise createImageBitmap(
ImageBitmapSource imageBitmap, long sx, long sy, long sw, long sh, optional ImageBitmapOptions options);
}; };
...@@ -46,7 +46,6 @@ ...@@ -46,7 +46,6 @@
#include "third_party/blink/renderer/core/imagebitmap/image_bitmap.h" #include "third_party/blink/renderer/core/imagebitmap/image_bitmap.h"
#include "third_party/blink/renderer/core/imagebitmap/image_bitmap_options.h" #include "third_party/blink/renderer/core/imagebitmap/image_bitmap_options.h"
#include "third_party/blink/renderer/core/offscreencanvas/offscreen_canvas.h" #include "third_party/blink/renderer/core/offscreencanvas/offscreen_canvas.h"
#include "third_party/blink/renderer/core/svg/graphics/svg_image.h"
#include "third_party/blink/renderer/core/svg/svg_image_element.h" #include "third_party/blink/renderer/core/svg/svg_image_element.h"
#include "third_party/blink/renderer/core/workers/worker_global_scope.h" #include "third_party/blink/renderer/core/workers/worker_global_scope.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h" #include "third_party/blink/renderer/platform/bindings/exception_state.h"
...@@ -139,7 +138,7 @@ ScriptPromise ImageBitmapFactories::CreateImageBitmapFromBlob( ...@@ -139,7 +138,7 @@ ScriptPromise ImageBitmapFactories::CreateImageBitmapFromBlob(
return promise; return promise;
} }
ScriptPromise ImageBitmapFactories::createImageBitmap( ScriptPromise ImageBitmapFactories::CreateImageBitmap(
ScriptState* script_state, ScriptState* script_state,
EventTarget& event_target, EventTarget& event_target,
const ImageBitmapSourceUnion& bitmap_source, const ImageBitmapSourceUnion& bitmap_source,
...@@ -150,11 +149,11 @@ ScriptPromise ImageBitmapFactories::createImageBitmap( ...@@ -150,11 +149,11 @@ ScriptPromise ImageBitmapFactories::createImageBitmap(
ToImageBitmapSourceInternal(bitmap_source, options, false); ToImageBitmapSourceInternal(bitmap_source, options, false);
if (!bitmap_source_internal) if (!bitmap_source_internal)
return ScriptPromise(); return ScriptPromise();
return createImageBitmap(script_state, event_target, bitmap_source_internal, return CreateImageBitmap(script_state, event_target, bitmap_source_internal,
base::Optional<IntRect>(), options); base::Optional<IntRect>(), options);
} }
ScriptPromise ImageBitmapFactories::createImageBitmap( ScriptPromise ImageBitmapFactories::CreateImageBitmap(
ScriptState* script_state, ScriptState* script_state,
EventTarget& event_target, EventTarget& event_target,
const ImageBitmapSourceUnion& bitmap_source, const ImageBitmapSourceUnion& bitmap_source,
...@@ -170,11 +169,11 @@ ScriptPromise ImageBitmapFactories::createImageBitmap( ...@@ -170,11 +169,11 @@ ScriptPromise ImageBitmapFactories::createImageBitmap(
if (!bitmap_source_internal) if (!bitmap_source_internal)
return ScriptPromise(); return ScriptPromise();
base::Optional<IntRect> crop_rect = IntRect(sx, sy, sw, sh); base::Optional<IntRect> crop_rect = IntRect(sx, sy, sw, sh);
return createImageBitmap(script_state, event_target, bitmap_source_internal, return CreateImageBitmap(script_state, event_target, bitmap_source_internal,
crop_rect, options); crop_rect, options);
} }
ScriptPromise ImageBitmapFactories::createImageBitmap( ScriptPromise ImageBitmapFactories::CreateImageBitmap(
ScriptState* script_state, ScriptState* script_state,
EventTarget& event_target, EventTarget& event_target,
ImageBitmapSource* bitmap_source, ImageBitmapSource* bitmap_source,
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#define THIRD_PARTY_BLINK_RENDERER_CORE_IMAGEBITMAP_IMAGE_BITMAP_FACTORIES_H_ #define THIRD_PARTY_BLINK_RENDERER_CORE_IMAGEBITMAP_IMAGE_BITMAP_FACTORIES_H_
#include <memory> #include <memory>
#include "base/single_thread_task_runner.h" #include "base/single_thread_task_runner.h"
#include "third_party/blink/renderer/bindings/core/v8/image_bitmap_source.h" #include "third_party/blink/renderer/bindings/core/v8/image_bitmap_source.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise.h" #include "third_party/blink/renderer/bindings/core/v8/script_promise.h"
...@@ -39,6 +40,7 @@ ...@@ -39,6 +40,7 @@
#include "third_party/blink/renderer/core/fileapi/file_reader_loader.h" #include "third_party/blink/renderer/core/fileapi/file_reader_loader.h"
#include "third_party/blink/renderer/core/fileapi/file_reader_loader_client.h" #include "third_party/blink/renderer/core/fileapi/file_reader_loader_client.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h" #include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/window_or_worker_global_scope.h"
#include "third_party/blink/renderer/core/imagebitmap/image_bitmap_options.h" #include "third_party/blink/renderer/core/imagebitmap/image_bitmap_options.h"
#include "third_party/blink/renderer/core/workers/worker_global_scope.h" #include "third_party/blink/renderer/core/workers/worker_global_scope.h"
#include "third_party/blink/renderer/platform/bindings/name_client.h" #include "third_party/blink/renderer/platform/bindings/name_client.h"
...@@ -56,9 +58,6 @@ class EventTarget; ...@@ -56,9 +58,6 @@ class EventTarget;
class ImageBitmapSource; class ImageBitmapSource;
class ImageBitmapOptions; class ImageBitmapOptions;
typedef HTMLImageElementOrSVGImageElementOrHTMLVideoElementOrHTMLCanvasElementOrBlobOrImageDataOrImageBitmapOrOffscreenCanvas
ImageBitmapSourceUnion;
class ImageBitmapFactories final class ImageBitmapFactories final
: public GarbageCollectedFinalized<ImageBitmapFactories>, : public GarbageCollectedFinalized<ImageBitmapFactories>,
public Supplement<LocalDOMWindow>, public Supplement<LocalDOMWindow>,
...@@ -69,11 +68,11 @@ class ImageBitmapFactories final ...@@ -69,11 +68,11 @@ class ImageBitmapFactories final
public: public:
static const char kSupplementName[]; static const char kSupplementName[];
static ScriptPromise createImageBitmap(ScriptState*, static ScriptPromise CreateImageBitmap(ScriptState*,
EventTarget&, EventTarget&,
const ImageBitmapSourceUnion&, const ImageBitmapSourceUnion&,
const ImageBitmapOptions*); const ImageBitmapOptions*);
static ScriptPromise createImageBitmap(ScriptState*, static ScriptPromise CreateImageBitmap(ScriptState*,
EventTarget&, EventTarget&,
const ImageBitmapSourceUnion&, const ImageBitmapSourceUnion&,
int sx, int sx,
...@@ -81,7 +80,7 @@ class ImageBitmapFactories final ...@@ -81,7 +80,7 @@ class ImageBitmapFactories final
int sw, int sw,
int sh, int sh,
const ImageBitmapOptions*); const ImageBitmapOptions*);
static ScriptPromise createImageBitmap(ScriptState*, static ScriptPromise CreateImageBitmap(ScriptState*,
EventTarget&, EventTarget&,
ImageBitmapSource*, ImageBitmapSource*,
base::Optional<IntRect> crop_rect, base::Optional<IntRect> crop_rect,
......
/*
* Copyright (c) 2013, Google 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:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * 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.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
* OWNER OR 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.
*/
// https://html.spec.whatwg.org/#imagebitmapfactories
typedef (HTMLImageElement or
SVGImageElement or
HTMLVideoElement or
HTMLCanvasElement or
Blob or
ImageData or
ImageBitmap or
OffscreenCanvas) ImageBitmapSource;
[
LegacyTreatAsPartialInterface,
NoInterfaceObject, // Always used on target of 'implements'
Exposed=(Window,Worker)
] interface ImageBitmapFactories {
[CallWith=ScriptState] Promise createImageBitmap(
ImageBitmapSource imageBitmap, optional ImageBitmapOptions options);
[CallWith=ScriptState] Promise createImageBitmap(
ImageBitmapSource imageBitmap, long sx, long sy, long sw, long sh, optional ImageBitmapOptions options);
};
Window implements ImageBitmapFactories;
WorkerGlobalScope implements ImageBitmapFactories;
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include "skia/public/interfaces/bitmap.mojom-blink.h" #include "skia/public/interfaces/bitmap.mojom-blink.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise.h" #include "third_party/blink/renderer/bindings/core/v8/script_promise.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h" #include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h"
#include "third_party/blink/renderer/core/imagebitmap/image_bitmap_factories.h" #include "third_party/blink/renderer/core/frame/window_or_worker_global_scope.h"
#include "third_party/blink/renderer/modules/canvas/canvas2d/canvas_rendering_context_2d.h" #include "third_party/blink/renderer/modules/canvas/canvas2d/canvas_rendering_context_2d.h"
#include "third_party/blink/renderer/modules/modules_export.h" #include "third_party/blink/renderer/modules/modules_export.h"
#include "third_party/blink/renderer/platform/bindings/script_wrappable.h" #include "third_party/blink/renderer/platform/bindings/script_wrappable.h"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment