Skip to content
Permalink
Browse files
Accept Settings object in ImageBitmapRenderingContext constructor and…
… getContext

https://bugs.webkit.org/show_bug.cgi?id=179075
<rdar://problem/35279965>

Reviewed by Sam Weinig.

Allow getContext("bitmaprenderer") to take a dictionary as another argument, and
pass that on to the ImageBitmapRenderingContext constructor.

Unfortunately this meant having to move ImageBitmapRenderingContext::Settings out into
a stand-alone struct, since it needs to be defined in HTMLCanvasElement, which itself
needs to be defined for ImageBitmapRenderingContext.

* DerivedSources.make: Add new IDL.
* WebCore.xcodeproj/project.pbxproj: New files.

* html/HTMLCanvasElement.cpp:
(WebCore::HTMLCanvasElement::createContextBitmapRenderer):
(WebCore::HTMLCanvasElement::getContextBitmapRenderer):

    Accept the ImageBitmapRenderingContextSettings object, and pass it on.

* html/HTMLCanvasElement.h:
* html/canvas/ImageBitmapRenderingContext.cpp:
(WebCore::ImageBitmapRenderingContext::ImageBitmapRenderingContext):
* html/canvas/ImageBitmapRenderingContext.h:
* html/canvas/ImageBitmapRenderingContext.idl:
* html/canvas/ImageBitmapRenderingContextSettings.h: Copied from Source/WebCore/html/canvas/ImageBitmapRenderingContext.idl.
* html/canvas/ImageBitmapRenderingContextSettings.idl: Added.

Canonical link: https://commits.webkit.org/195208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224255 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
grorg committed Oct 31, 2017
1 parent 904d951 commit 06e374975a4d1099ccb8732778d869a0197145dc
Showing 10 changed files with 113 additions and 16 deletions.
@@ -1,3 +1,35 @@
2017-10-31 Dean Jackson <dino@apple.com>

Accept Settings object in ImageBitmapRenderingContext constructor and getContext
https://bugs.webkit.org/show_bug.cgi?id=179075
<rdar://problem/35279965>

Reviewed by Sam Weinig.

Allow getContext("bitmaprenderer") to take a dictionary as another argument, and
pass that on to the ImageBitmapRenderingContext constructor.

Unfortunately this meant having to move ImageBitmapRenderingContext::Settings out into
a stand-alone struct, since it needs to be defined in HTMLCanvasElement, which itself
needs to be defined for ImageBitmapRenderingContext.

* DerivedSources.make: Add new IDL.
* WebCore.xcodeproj/project.pbxproj: New files.

* html/HTMLCanvasElement.cpp:
(WebCore::HTMLCanvasElement::createContextBitmapRenderer):
(WebCore::HTMLCanvasElement::getContextBitmapRenderer):

Accept the ImageBitmapRenderingContextSettings object, and pass it on.

* html/HTMLCanvasElement.h:
* html/canvas/ImageBitmapRenderingContext.cpp:
(WebCore::ImageBitmapRenderingContext::ImageBitmapRenderingContext):
* html/canvas/ImageBitmapRenderingContext.h:
* html/canvas/ImageBitmapRenderingContext.idl:
* html/canvas/ImageBitmapRenderingContextSettings.h: Copied from Source/WebCore/html/canvas/ImageBitmapRenderingContext.idl.
* html/canvas/ImageBitmapRenderingContextSettings.idl: Added.

2017-10-31 Tim Horton <timothy_horton@apple.com>

Fix up some content filtering feature flags
@@ -643,6 +643,7 @@ JS_BINDING_IDLS = \
$(WebCore)/html/canvas/EXTTextureFilterAnisotropic.idl \
$(WebCore)/html/canvas/EXTsRGB.idl \
$(WebCore)/html/canvas/ImageBitmapRenderingContext.idl \
$(WebCore)/html/canvas/ImageBitmapRenderingContextSettings.idl \
$(WebCore)/html/canvas/ImageSmoothingQuality.idl \
$(WebCore)/html/canvas/OESElementIndexUint.idl \
$(WebCore)/html/canvas/OESStandardDerivatives.idl \
@@ -870,6 +870,7 @@
31741AAD16636609008A5B7E /* SimulatedClickOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 31741AAB16635E45008A5B7E /* SimulatedClickOptions.h */; settings = {ATTRIBUTES = (Private, ); }; };
31815A311F9A6C8F00FCBF89 /* ImageBitmap.h in Headers */ = {isa = PBXBuildFile; fileRef = 31D26BBF1F86D189008FF255 /* ImageBitmap.h */; settings = {ATTRIBUTES = (Private, ); }; };
318891611AB7EEA100EA627B /* missingImage@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = CDF419991AB0DA14004E64E1 /* missingImage@3x.png */; };
318EAD4D1FA91380008CEF86 /* ImageBitmapRenderingContextSettings.h in Headers */ = {isa = PBXBuildFile; fileRef = 318EAD4A1FA91157008CEF86 /* ImageBitmapRenderingContextSettings.h */; settings = {ATTRIBUTES = (Private, ); }; };
31955A88160D199200858025 /* RenderSnapshottedPlugIn.h in Headers */ = {isa = PBXBuildFile; fileRef = 31E8D8BB160BC94C004CE8F5 /* RenderSnapshottedPlugIn.h */; settings = {ATTRIBUTES = (Private, ); }; };
319848011A1D817B00A13318 /* AnimationEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 319847FF1A1D816700A13318 /* AnimationEvent.h */; };
3198480C1A1E6CE800A13318 /* JSAnimationEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 319848041A1E6B5D00A13318 /* JSAnimationEvent.h */; };
@@ -6594,6 +6595,8 @@
316FE1100E6E1DA700BF6088 /* KeyframeAnimation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KeyframeAnimation.h; sourceTree = "<group>"; };
31741AAB16635E45008A5B7E /* SimulatedClickOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SimulatedClickOptions.h; sourceTree = "<group>"; };
3189E6DB16B2103500386EA3 /* plugIns.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.css; path = plugIns.css; sourceTree = "<group>"; };
318EAD4A1FA91157008CEF86 /* ImageBitmapRenderingContextSettings.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ImageBitmapRenderingContextSettings.h; sourceTree = "<group>"; };
318EAD4C1FA91352008CEF86 /* ImageBitmapRenderingContextSettings.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = ImageBitmapRenderingContextSettings.idl; sourceTree = "<group>"; };
319847FE1A1D816700A13318 /* AnimationEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AnimationEvent.cpp; sourceTree = "<group>"; };
319847FF1A1D816700A13318 /* AnimationEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AnimationEvent.h; sourceTree = "<group>"; };
319848001A1D816700A13318 /* AnimationEvent.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = AnimationEvent.idl; sourceTree = "<group>"; };
@@ -16586,6 +16589,8 @@
7C7903B11F86F95C00463A70 /* ImageBitmapRenderingContext.cpp */,
7C7903B01F86F95C00463A70 /* ImageBitmapRenderingContext.h */,
7C7903B21F86F95C00463A70 /* ImageBitmapRenderingContext.idl */,
318EAD4A1FA91157008CEF86 /* ImageBitmapRenderingContextSettings.h */,
318EAD4C1FA91352008CEF86 /* ImageBitmapRenderingContextSettings.idl */,
7C193BAF1F5E0EB40088F3E6 /* ImageSmoothingQuality.h */,
7C193BA81F5E0EAF0088F3E6 /* ImageSmoothingQuality.idl */,
7E5D7A73161D3F8F00896C34 /* OESElementIndexUint.cpp */,
@@ -27056,6 +27061,7 @@
55A336F91D821E3C0022C4C7 /* ImageBackingStore.h in Headers */,
31815A311F9A6C8F00FCBF89 /* ImageBitmap.h in Headers */,
7C7903B31F86F95C00463A70 /* ImageBitmapRenderingContext.h in Headers */,
318EAD4D1FA91380008CEF86 /* ImageBitmapRenderingContextSettings.h in Headers */,
B2A10B920B3818BD00099AA4 /* ImageBuffer.h in Headers */,
22BD9F7F1353625C009BD102 /* ImageBufferData.h in Headers */,
22BD9F81135364FE009BD102 /* ImageBufferDataCG.h in Headers */,
@@ -504,13 +504,12 @@ bool HTMLCanvasElement::isBitmapRendererType(const String& type)
return type == "bitmaprenderer";
}

// FIXME: Needs to accept ImageBitmapRenderingContext::Settings.
ImageBitmapRenderingContext* HTMLCanvasElement::createContextBitmapRenderer(const String& type)
ImageBitmapRenderingContext* HTMLCanvasElement::createContextBitmapRenderer(const String& type, ImageBitmapRenderingContextSettings&& settings)
{
ASSERT_UNUSED(type, HTMLCanvasElement::isBitmapRendererType(type));
ASSERT(!m_context);

m_context = std::make_unique<ImageBitmapRenderingContext>(*this);
m_context = std::make_unique<ImageBitmapRenderingContext>(*this, WTFMove(settings));

#if USE(IOSURFACE_CANVAS_BACKING_STORE) || ENABLE(ACCELERATED_2D_CANVAS)
// Need to make sure a RenderLayer and compositing layer get created for the Canvas.
@@ -520,11 +519,11 @@ ImageBitmapRenderingContext* HTMLCanvasElement::createContextBitmapRenderer(cons
return static_cast<ImageBitmapRenderingContext*>(m_context.get());
}

ImageBitmapRenderingContext* HTMLCanvasElement::getContextBitmapRenderer(const String& type)
ImageBitmapRenderingContext* HTMLCanvasElement::getContextBitmapRenderer(const String& type, ImageBitmapRenderingContextSettings&& settings)
{
ASSERT_UNUSED(type, HTMLCanvasElement::isBitmapRendererType(type));
if (!m_context)
return createContextBitmapRenderer(type);
return createContextBitmapRenderer(type, WTFMove(settings));
return static_cast<ImageBitmapRenderingContext*>(m_context.get());
}

@@ -29,6 +29,7 @@

#include "FloatRect.h"
#include "HTMLElement.h"
#include "ImageBitmapRenderingContextSettings.h"
#include "IntSize.h"
#include <memory>
#include <wtf/Forward.h>
@@ -119,8 +120,8 @@ class HTMLCanvasElement final : public HTMLElement {
#endif

static bool isBitmapRendererType(const String&);
ImageBitmapRenderingContext* createContextBitmapRenderer(const String&);
ImageBitmapRenderingContext* getContextBitmapRenderer(const String&);
ImageBitmapRenderingContext* createContextBitmapRenderer(const String&, ImageBitmapRenderingContextSettings&& = { });
ImageBitmapRenderingContext* getContextBitmapRenderer(const String&, ImageBitmapRenderingContextSettings&& = { });

WEBCORE_EXPORT ExceptionOr<UncachedString> toDataURL(const String& mimeType, JSC::JSValue quality);
WEBCORE_EXPORT ExceptionOr<UncachedString> toDataURL(const String& mimeType);
@@ -37,8 +37,9 @@ static RenderingMode bufferRenderingMode = Accelerated;
static RenderingMode bufferRenderingMode = Unaccelerated;
#endif

ImageBitmapRenderingContext::ImageBitmapRenderingContext(HTMLCanvasElement& canvas)
ImageBitmapRenderingContext::ImageBitmapRenderingContext(HTMLCanvasElement& canvas, ImageBitmapRenderingContextSettings&& settings)
: CanvasRenderingContext(canvas)
, m_settings(WTFMove(settings))
{
setOutputBitmap(nullptr);
}
@@ -28,6 +28,7 @@
#include "CanvasRenderingContext.h"

#include "ExceptionOr.h"
#include "ImageBitmapRenderingContextSettings.h"
#include "ImageBufferData.h"
#include <wtf/RefPtr.h>

@@ -38,16 +39,13 @@ class ImageBuffer;

class ImageBitmapRenderingContext final : public CanvasRenderingContext {
public:
struct Settings {
bool alpha = true;
};

enum class BitmapMode {
Valid,
Blank
};

ImageBitmapRenderingContext(HTMLCanvasElement&);
ImageBitmapRenderingContext(HTMLCanvasElement&, ImageBitmapRenderingContextSettings&&);
~ImageBitmapRenderingContext();

ExceptionOr<void> transferFromImageBitmap(RefPtr<ImageBitmap>);
@@ -62,7 +60,7 @@ class ImageBitmapRenderingContext final : public CanvasRenderingContext {
void setOutputBitmap(RefPtr<ImageBitmap>);

BitmapMode m_bitmapMode { BitmapMode::Blank };
Settings m_settings;
ImageBitmapRenderingContextSettings m_settings;
};

}
@@ -31,6 +31,3 @@
[MayThrowException] void transferFromImageBitmap(ImageBitmap? bitmap);
};

dictionary ImageBitmapRenderingContextSettings {
boolean alpha = true;
};
@@ -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.
*/

#pragma once

namespace WebCore {

struct ImageBitmapRenderingContextSettings {
bool alpha = true;
};

}
@@ -0,0 +1,28 @@
/*
* 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.
*/

dictionary ImageBitmapRenderingContextSettings {
boolean alpha = true;
};

0 comments on commit 06e3749

Please sign in to comment.