Diff
Modified: trunk/Source/WebCore/ChangeLog (224928 => 224929)
--- trunk/Source/WebCore/ChangeLog 2017-11-16 19:13:42 UTC (rev 224928)
+++ trunk/Source/WebCore/ChangeLog 2017-11-16 19:19:39 UTC (rev 224929)
@@ -1,3 +1,138 @@
+2017-11-14 Dean Jackson <[email protected]>
+
+ Add a base class for HTMLCanvasElement and OffscreenCanvas
+ https://bugs.webkit.org/show_bug.cgi?id=179701
+ <rdar://problem/35545195>
+
+ Reviewed by Sam Weinig.
+
+ In order for OffscreenCanvas to be able to create a WebGLRenderingContext,
+ there needs to be a shared base class with HTMLCanvasElement. Add such a
+ class called CanvasBase.
+
+ There is a lot of potential for functionality to move into the base class, but
+ unfortunately HTMLCanvasElement is a bit messy. It implements a lot of the 2d
+ rendering context functionality, and also many const functions that actually
+ cause changes. Thus, things like the canvas size have to remain in the subclasses
+ for now.
+
+ The existence of the new base class meant the canvas() accessor in CanvasRenderingContext
+ had to move out into the subclasses, and do the correct casting. Eventually, at least
+ for WebGLRenderingContext, this will have a change in behaviour, but for now we only
+ ever use HTMLCanvasElements, so most of these changes are just for the sake of
+ compilation.
+
+ No behaviour change - covered by existing tests.
+
+ * Sources.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ * html/CanvasBase.cpp: Copied from Source/WebCore/html/canvas/GPUBasedCanvasRenderingContext.h.
+ (WebCore::CanvasBase::CanvasBase): New base class.
+ (WebCore::CanvasBase::asHTMLCanvasElement): Casts to an HTMLCanvasElement*, which many of the
+ rendering context code uses.
+ * html/CanvasBase.h: Copied from Source/WebCore/html/canvas/GPUBasedCanvasRenderingContext.h.
+ (WebCore::CanvasBase::isHTMLCanvasElement const):
+ (WebCore::CanvasBase::isOffscreenCanvas const):
+ (WebCore::CanvasBase::setOriginClean):
+ (WebCore::CanvasBase::setOriginTainted):
+ (WebCore::CanvasBase::originClean const):
+ (WebCore::CanvasBase::securityOrigin const):
+ (WebCore::CanvasBase::scriptExecutionContext const):
+
+ * html/HTMLCanvasElement.cpp: Use the base class methods where possible.
+ (WebCore::HTMLCanvasElement::HTMLCanvasElement):
+ (WebCore::HTMLCanvasElement::toDataURL):
+ (WebCore::HTMLCanvasElement::toBlob):
+ (WebCore::HTMLCanvasElement::createImageBuffer const): Be explict as to
+ which of the derived classes scriptExecutionContext() method we are calling.
+
+ * html/HTMLCanvasElement.h: Use the base class, mark a few things as virtual,
+ and remove the parts that are now in CanvasBase.
+
+ * html/OffscreenCanvas.cpp: Use the base class.
+ (WebCore::OffscreenCanvas::OffscreenCanvas):
+ (WebCore::OffscreenCanvas::size const):
+ (WebCore::OffscreenCanvas::setSize):
+ * html/OffscreenCanvas.h:
+
+ * html/canvas/CanvasRenderingContext.cpp:
+ (WebCore::CanvasRenderingContext::CanvasRenderingContext):
+ (WebCore::CanvasRenderingContext::ref): Call the correct ref/deref functions, depending
+ on the base class type.
+ (WebCore::CanvasRenderingContext::deref):
+ (WebCore::CanvasRenderingContext::wouldTaintOrigin): We no longer have a canvas() method.
+ (WebCore::CanvasRenderingContext::checkOrigin):
+
+ * html/canvas/CanvasRenderingContext.h:
+ (WebCore::CanvasRenderingContext::canvasBase const): Add this accessor to the base canvas object
+ to replace the canvas() call.
+ (WebCore::CanvasRenderingContext::checkOrigin):
+ (WebCore::CanvasRenderingContext::ref): Deleted.
+ (WebCore::CanvasRenderingContext::deref): Deleted.
+ (WebCore::CanvasRenderingContext::canvas const): Deleted.
+
+ * html/canvas/CanvasRenderingContext2D.cpp: Use the base class.
+ (WebCore::CanvasRenderingContext2D::CanvasRenderingContext2D):
+ * html/canvas/CanvasRenderingContext2D.h:
+ * html/canvas/GPUBasedCanvasRenderingContext.h:
+ (WebCore::GPUBasedCanvasRenderingContext::GPUBasedCanvasRenderingContext):
+ * html/canvas/ImageBitmapRenderingContext.cpp:
+ (WebCore::ImageBitmapRenderingContext::ImageBitmapRenderingContext):
+ (WebCore::ImageBitmapRenderingContext::canvas const):
+ (WebCore::ImageBitmapRenderingContext::setOutputBitmap):
+ * html/canvas/ImageBitmapRenderingContext.h:
+ * html/canvas/PlaceholderRenderingContext.cpp:
+ (WebCore::PlaceholderRenderingContext::PlaceholderRenderingContext):
+ * html/canvas/PlaceholderRenderingContext.h:
+ * html/canvas/WebGL2RenderingContext.cpp:
+ (WebCore::WebGL2RenderingContext::WebGL2RenderingContext):
+ * html/canvas/WebGL2RenderingContext.h:
+ * html/canvas/WebGLRenderingContext.cpp:
+ (WebCore::WebGLRenderingContext::WebGLRenderingContext):
+
+ * html/canvas/WebGLRenderingContext.h:
+ * html/canvas/WebGLRenderingContextBase.cpp:
+ (WebCore::WebGLRenderingContextBase::create): Assume that we're still getting an HTMLCanvasElement,
+ but protect some of the logic just in case we don't.
+ (WebCore::WebGLRenderingContextBase::WebGLRenderingContextBase):
+ (WebCore::WebGLRenderingContextBase::canvas):
+ (WebCore::WebGLRenderingContextBase::checkForContextLossHandling):
+ (WebCore::WebGLRenderingContextBase::registerWithWebGLStateTracker):
+ (WebCore::WebGLRenderingContextBase::setupFlags):
+ (WebCore::WebGLRenderingContextBase::addActivityStateChangeObserverIfNecessary):
+ (WebCore::WebGLRenderingContextBase::removeActivityStateChangeObserver):
+ (WebCore::WebGLRenderingContextBase::markContextChanged):
+ (WebCore::WebGLRenderingContextBase::markContextChangedAndNotifyCanvasObserver):
+ (WebCore::WebGLRenderingContextBase::paintRenderingResultsToCanvas):
+ (WebCore::WebGLRenderingContextBase::reshape):
+ (WebCore::WebGLRenderingContextBase::compileShader):
+ (WebCore::WebGLRenderingContextBase::isContextLostOrPending):
+ (WebCore::WebGLRenderingContextBase::readPixels):
+ (WebCore::WebGLRenderingContextBase::loseContextImpl):
+ (WebCore::WebGLRenderingContextBase::printToConsole):
+ (WebCore::WebGLRenderingContextBase::dispatchContextLostEvent):
+ (WebCore::WebGLRenderingContextBase::maybeRestoreContext):
+ (WebCore::WebGLRenderingContextBase::dispatchContextChangedEvent):
+ (WebCore::WebGLRenderingContextBase::clampedCanvasSize):
+ * html/canvas/WebGLRenderingContextBase.h:
+ * html/canvas/WebGLRenderingContextBase.idl:
+ * html/canvas/WebGPURenderingContext.cpp:
+ (WebCore::WebGPURenderingContext::create):
+ (WebCore::WebGPURenderingContext::WebGPURenderingContext):
+ (WebCore::WebGPURenderingContext::canvas const):
+ (WebCore::WebGPURenderingContext::clampedCanvasSize const):
+ * html/canvas/WebGPURenderingContext.h:
+ * inspector/InspectorInstrumentation.h:
+ (WebCore::InspectorInstrumentation::recordCanvasAction):
+ (WebCore::InspectorInstrumentation::didEnableExtension):
+ (WebCore::InspectorInstrumentation::didCreateProgram):
+ (WebCore::InspectorInstrumentation::willDeleteProgram):
+ (WebCore::InspectorInstrumentation::isShaderProgramDisabled):
+ * inspector/agents/InspectorCanvasAgent.cpp:
+ (WebCore::InspectorCanvasAgent::recordCanvasAction):
+ (WebCore::InspectorCanvasAgent::didEnableExtension):
+ (WebCore::InspectorCanvasAgent::didCreateProgram):
+
2017-11-16 Colin Bendell <[email protected]>
Added mime type check to the picture source preloader to avoid downloading incompatible resources.
Modified: trunk/Source/WebCore/Sources.txt (224928 => 224929)
--- trunk/Source/WebCore/Sources.txt 2017-11-16 19:13:42 UTC (rev 224928)
+++ trunk/Source/WebCore/Sources.txt 2017-11-16 19:19:39 UTC (rev 224929)
@@ -890,6 +890,7 @@
html/BaseDateAndTimeInputType.cpp
html/BaseTextInputType.cpp
html/ButtonInputType.cpp
+html/CanvasBase.cpp
html/CheckboxInputType.cpp
html/ColorInputType.cpp
html/DOMFormData.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (224928 => 224929)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2017-11-16 19:13:42 UTC (rev 224928)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2017-11-16 19:19:39 UTC (rev 224929)
@@ -815,6 +815,7 @@
3128CA6B147331630074C72A /* NotificationController.h in Headers */ = {isa = PBXBuildFile; fileRef = 3128CA6A147331630074C72A /* NotificationController.h */; settings = {ATTRIBUTES = (Private, ); }; };
312C0C41146DC6CC0016C911 /* Notification.h in Headers */ = {isa = PBXBuildFile; fileRef = 333F704F0FB49CA2008E12A6 /* Notification.h */; settings = {ATTRIBUTES = (Private, ); }; };
31313F661443B35F006E2A90 /* FilterEffectRenderer.h in Headers */ = {isa = PBXBuildFile; fileRef = 31313F641443B35E006E2A90 /* FilterEffectRenderer.h */; };
+ 313171561FB079E5008D91FC /* CanvasBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 313171541FB079D1008D91FC /* CanvasBase.h */; settings = {ATTRIBUTES = (Private, ); }; };
313591061E7DDC7300F30630 /* RTCIceConnectionState.h in Headers */ = {isa = PBXBuildFile; fileRef = 313591001E7DDC6000F30630 /* RTCIceConnectionState.h */; };
313591071E7DDC7300F30630 /* RTCIceGatheringState.h in Headers */ = {isa = PBXBuildFile; fileRef = 313591011E7DDC6000F30630 /* RTCIceGatheringState.h */; };
313591081E7DDC7300F30630 /* RTCIceTransportPolicy.h in Headers */ = {isa = PBXBuildFile; fileRef = 313591021E7DDC6000F30630 /* RTCIceTransportPolicy.h */; };
@@ -6474,6 +6475,8 @@
3128CA6A147331630074C72A /* NotificationController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NotificationController.h; sourceTree = "<group>"; };
31313F631443B35E006E2A90 /* FilterEffectRenderer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FilterEffectRenderer.cpp; sourceTree = "<group>"; };
31313F641443B35E006E2A90 /* FilterEffectRenderer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FilterEffectRenderer.h; sourceTree = "<group>"; };
+ 313171541FB079D1008D91FC /* CanvasBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CanvasBase.h; sourceTree = "<group>"; };
+ 313171571FB0969E008D91FC /* CanvasBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CanvasBase.cpp; sourceTree = "<group>"; };
313591001E7DDC6000F30630 /* RTCIceConnectionState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCIceConnectionState.h; sourceTree = "<group>"; };
313591011E7DDC6000F30630 /* RTCIceGatheringState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCIceGatheringState.h; sourceTree = "<group>"; };
313591021E7DDC6000F30630 /* RTCIceTransportPolicy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCIceTransportPolicy.h; sourceTree = "<group>"; };
@@ -19455,6 +19458,8 @@
F55B3D7B1251F12D003EF269 /* ButtonInputType.cpp */,
F55B3D7C1251F12D003EF269 /* ButtonInputType.h */,
830030F71B7D398800ED3AAC /* CachedHTMLCollection.h */,
+ 313171571FB0969E008D91FC /* CanvasBase.cpp */,
+ 313171541FB079D1008D91FC /* CanvasBase.h */,
F55B3D7D1251F12D003EF269 /* CheckboxInputType.cpp */,
F55B3D7E1251F12D003EF269 /* CheckboxInputType.h */,
46EBEA011B7D4D5D00BE4941 /* CollectionTraversal.h */,
@@ -26195,6 +26200,7 @@
7C1E8D011ED0C2DA00B1D983 /* CallbackResult.h in Headers */,
952076051F2675FE007D2AAB /* CallTracer.h in Headers */,
952076061F2675FE007D2AAB /* CallTracerTypes.h in Headers */,
+ 313171561FB079E5008D91FC /* CanvasBase.h in Headers */,
415CDAF51E6B8F8B004F11EE /* CanvasCaptureMediaStreamTrack.h in Headers */,
7C193BBB1F5E0EED0088F3E6 /* CanvasDirection.h in Headers */,
7C193BBC1F5E0EED0088F3E6 /* CanvasFillRule.h in Headers */,
Copied: trunk/Source/WebCore/html/CanvasBase.cpp (from rev 224928, trunk/Source/WebCore/html/canvas/GPUBasedCanvasRenderingContext.h) (0 => 224929)
--- trunk/Source/WebCore/html/CanvasBase.cpp (rev 0)
+++ trunk/Source/WebCore/html/CanvasBase.cpp 2017-11-16 19:19:39 UTC (rev 224929)
@@ -0,0 +1,45 @@
+/*
+ * 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. ``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
+ * 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 "CanvasBase.h"
+
+#include "HTMLCanvasElement.h"
+
+namespace WebCore {
+
+CanvasBase::CanvasBase(ScriptExecutionContext* scriptExecutionContext)
+ : m_scriptExecutionContext(scriptExecutionContext)
+{
+}
+
+HTMLCanvasElement* CanvasBase::asHTMLCanvasElement()
+{
+ if (!isHTMLCanvasElement())
+ return nullptr;
+ return static_cast<HTMLCanvasElement*>(this);
+}
+
+}
Copied: trunk/Source/WebCore/html/CanvasBase.h (from rev 224928, trunk/Source/WebCore/html/canvas/GPUBasedCanvasRenderingContext.h) (0 => 224929)
--- trunk/Source/WebCore/html/CanvasBase.h (rev 0)
+++ trunk/Source/WebCore/html/CanvasBase.h 2017-11-16 19:19:39 UTC (rev 224929)
@@ -0,0 +1,71 @@
+/*
+ * 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. ``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
+ * 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/TypeCasts.h>
+
+namespace WebCore {
+
+class HTMLCanvasElement;
+class IntSize;
+class ScriptExecutionContext;
+class SecurityOrigin;
+
+class CanvasBase {
+public:
+ virtual ~CanvasBase() = default;
+
+ virtual bool isHTMLCanvasElement() const { return false; }
+ virtual bool isOffscreenCanvas() const { return false; }
+
+ HTMLCanvasElement* asHTMLCanvasElement();
+
+ virtual unsigned width() const = 0;
+ virtual unsigned height() const = 0;
+ virtual const IntSize& size() const = 0;
+ virtual void setSize(const IntSize&) = 0;
+
+ void setOriginClean() { m_originClean = true; }
+ void setOriginTainted() { m_originClean = false; }
+ bool originClean() const { return m_originClean; }
+
+ virtual SecurityOrigin* securityOrigin() const { return nullptr; }
+ ScriptExecutionContext* scriptExecutionContext() const { return m_scriptExecutionContext; }
+
+protected:
+ CanvasBase(ScriptExecutionContext*);
+
+private:
+ bool m_originClean { true };
+ ScriptExecutionContext* m_scriptExecutionContext;
+};
+
+} // namespace WebCore
+
+#define SPECIALIZE_TYPE_TRAITS_CANVAS(ToValueTypeName, predicate) \
+SPECIALIZE_TYPE_TRAITS_BEGIN(ToValueTypeName) \
+static bool isType(const WebCore::CanvasBase& canvas) { return canvas.predicate; } \
+SPECIALIZE_TYPE_TRAITS_END()
Modified: trunk/Source/WebCore/html/HTMLCanvasElement.cpp (224928 => 224929)
--- trunk/Source/WebCore/html/HTMLCanvasElement.cpp 2017-11-16 19:13:42 UTC (rev 224928)
+++ trunk/Source/WebCore/html/HTMLCanvasElement.cpp 2017-11-16 19:19:39 UTC (rev 224929)
@@ -111,6 +111,7 @@
HTMLCanvasElement::HTMLCanvasElement(const QualifiedName& tagName, Document& document)
: HTMLElement(tagName, document)
+ , CanvasBase(&document)
, m_size(defaultWidth, defaultHeight)
{
ASSERT(hasTagName(canvasTag));
@@ -720,7 +721,7 @@
ExceptionOr<UncachedString> HTMLCanvasElement::toDataURL(const String& mimeType, JSC::JSValue qualityValue)
{
- if (!m_originClean)
+ if (!originClean())
return Exception { SecurityError };
if (m_size.isEmpty() || !buffer())
@@ -747,7 +748,7 @@
ExceptionOr<void> HTMLCanvasElement::toBlob(ScriptExecutionContext& context, Ref<BlobCallback>&& callback, const String& mimeType, JSC::JSValue qualityValue)
{
- if (!m_originClean)
+ if (!originClean())
return Exception { SecurityError };
if (m_size.isEmpty() || !buffer()) {
@@ -955,8 +956,8 @@
m_imageBuffer->context().setStrokeThickness(1);
m_contextStateSaver = std::make_unique<GraphicsContextStateSaver>(m_imageBuffer->context());
- JSC::JSLockHolder lock(scriptExecutionContext()->vm());
- scriptExecutionContext()->vm().heap.reportExtraMemoryAllocated(memoryCost());
+ JSC::JSLockHolder lock(HTMLElement::scriptExecutionContext()->vm());
+ HTMLElement::scriptExecutionContext()->vm().heap.reportExtraMemoryAllocated(memoryCost());
#if USE(IOSURFACE_CANVAS_BACKING_STORE) || ENABLE(ACCELERATED_2D_CANVAS)
if (m_context && m_context->is2d()) {
Modified: trunk/Source/WebCore/html/HTMLCanvasElement.h (224928 => 224929)
--- trunk/Source/WebCore/html/HTMLCanvasElement.h 2017-11-16 19:13:42 UTC (rev 224928)
+++ trunk/Source/WebCore/html/HTMLCanvasElement.h 2017-11-16 19:19:39 UTC (rev 224929)
@@ -27,6 +27,7 @@
#pragma once
+#include "CanvasBase.h"
#include "FloatRect.h"
#include "HTMLElement.h"
#include "ImageBitmapRenderingContextSettings.h"
@@ -71,7 +72,7 @@
virtual void canvasDestroyed(HTMLCanvasElement&) = 0;
};
-class HTMLCanvasElement final : public HTMLElement {
+class HTMLCanvasElement final : public HTMLElement, public CanvasBase {
public:
static Ref<HTMLCanvasElement> create(Document&);
static Ref<HTMLCanvasElement> create(const QualifiedName&, Document&);
@@ -81,15 +82,15 @@
void removeObserver(CanvasObserver&);
HashSet<Element*> cssCanvasClients() const;
- unsigned width() const { return size().width(); }
- unsigned height() const { return size().height(); }
+ unsigned width() const override { return size().width(); }
+ unsigned height() const override { return size().height(); }
WEBCORE_EXPORT ExceptionOr<void> setWidth(unsigned);
WEBCORE_EXPORT ExceptionOr<void> setHeight(unsigned);
- const IntSize& size() const { return m_size; }
+ const IntSize& size() const override { return m_size; }
- void setSize(const IntSize& newSize)
+ void setSize(const IntSize& newSize) override
{
if (newSize == size())
return;
@@ -100,6 +101,8 @@
reset();
}
+ bool isHTMLCanvasElement() const override { return true; }
+
ExceptionOr<std::optional<RenderingContext>> getContext(JSC::ExecState&, const String& contextId, Vector<JSC::Strong<JSC::Unknown>>&& arguments);
CanvasRenderingContext* getContext(const String&);
@@ -150,10 +153,7 @@
void makePresentationCopy();
void clearPresentationCopy();
- SecurityOrigin* securityOrigin() const;
- void setOriginClean() { m_originClean = true; }
- void setOriginTainted() { m_originClean = false; }
- bool originClean() const { return m_originClean; }
+ SecurityOrigin* securityOrigin() const override;
AffineTransform baseTransform() const;
@@ -202,7 +202,6 @@
FloatRect m_dirtyRect;
mutable IntSize m_size;
- bool m_originClean { true };
bool m_ignoreReset { false };
bool m_usesDisplayListDrawing { false };
Modified: trunk/Source/WebCore/html/OffscreenCanvas.cpp (224928 => 224929)
--- trunk/Source/WebCore/html/OffscreenCanvas.cpp 2017-11-16 19:13:42 UTC (rev 224928)
+++ trunk/Source/WebCore/html/OffscreenCanvas.cpp 2017-11-16 19:19:39 UTC (rev 224929)
@@ -37,8 +37,8 @@
}
OffscreenCanvas::OffscreenCanvas(ScriptExecutionContext& context, unsigned width, unsigned height)
- : m_size(width, height)
- , m_scriptExecutionContext(context)
+ : CanvasBase(&context)
+ , m_size(width, height)
{
}
@@ -64,6 +64,16 @@
return m_size.setHeight(newHeight);
}
+const IntSize& OffscreenCanvas::size() const
+{
+ return m_size;
+}
+
+void OffscreenCanvas::setSize(const IntSize& newSize)
+{
+ m_size = newSize;
+}
+
#if ENABLE(WEBGL)
ExceptionOr<RefPtr<WebGLRenderingContext>> OffscreenCanvas::getContext(JSC::ExecState&, RenderingContextType contextType, Vector<JSC::Strong<JSC::Unknown>>&& arguments)
{
Modified: trunk/Source/WebCore/html/OffscreenCanvas.h (224928 => 224929)
--- trunk/Source/WebCore/html/OffscreenCanvas.h 2017-11-16 19:13:42 UTC (rev 224928)
+++ trunk/Source/WebCore/html/OffscreenCanvas.h 2017-11-16 19:19:39 UTC (rev 224929)
@@ -25,6 +25,7 @@
#pragma once
+#include "CanvasBase.h"
#include "EventTarget.h"
#include "ExceptionOr.h"
#include "IntSize.h"
@@ -46,7 +47,7 @@
// RefPtr<OffscreenCanvasRenderingContext2D>
// >;
-class OffscreenCanvas : public RefCounted<OffscreenCanvas>, public EventTargetWithInlineData {
+class OffscreenCanvas : public RefCounted<OffscreenCanvas>, public CanvasBase, public EventTargetWithInlineData {
WTF_MAKE_FAST_ALLOCATED;
public:
@@ -63,11 +64,16 @@
static Ref<OffscreenCanvas> create(ScriptExecutionContext&, unsigned width, unsigned height);
~OffscreenCanvas();
- unsigned width() const;
+ unsigned width() const override;
void setWidth(unsigned);
- unsigned height() const;
+ unsigned height() const override;
void setHeight(unsigned);
+ const IntSize& size() const override;
+ void setSize(const IntSize&) override;
+
+ bool isOffscreenCanvas() const override { return true; }
+
#if ENABLE(WEBGL)
// FIXME: Should be optional<OffscreenRenderingContext> from above.
ExceptionOr<RefPtr<WebGLRenderingContext>> getContext(JSC::ExecState&, RenderingContextType, Vector<JSC::Strong<JSC::Unknown>>&& arguments);
@@ -82,14 +88,15 @@
OffscreenCanvas(ScriptExecutionContext&, unsigned width, unsigned height);
- // EventTargetWithInlineData.
- ScriptExecutionContext* scriptExecutionContext() const final { return &m_scriptExecutionContext; }
+ ScriptExecutionContext* scriptExecutionContext() const override { return CanvasBase::scriptExecutionContext(); }
+
EventTargetInterface eventTargetInterface() const final { return OffscreenCanvasEventTargetInterfaceType; }
void refEventTarget() final { ref(); }
void derefEventTarget() final { deref(); }
IntSize m_size;
- ScriptExecutionContext& m_scriptExecutionContext;
};
}
+
+SPECIALIZE_TYPE_TRAITS_CANVAS(WebCore::OffscreenCanvas, isOffscreenCanvas())
Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext.cpp (224928 => 224929)
--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext.cpp 2017-11-16 19:13:42 UTC (rev 224928)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext.cpp 2017-11-16 19:19:39 UTC (rev 224929)
@@ -32,19 +32,48 @@
#include "HTMLVideoElement.h"
#include "Image.h"
#include "ImageBitmap.h"
+#include "OffscreenCanvas.h"
#include "URL.h"
#include "SecurityOrigin.h"
namespace WebCore {
-CanvasRenderingContext::CanvasRenderingContext(HTMLCanvasElement& canvas)
+CanvasRenderingContext::CanvasRenderingContext(CanvasBase& canvas)
: m_canvas(canvas)
{
}
+void CanvasRenderingContext::ref()
+{
+ if (m_canvas.isHTMLCanvasElement()) {
+ auto* htmlCanvas = static_cast<HTMLCanvasElement*>(&m_canvas);
+ htmlCanvas->ref();
+ return;
+ }
+ if (is<OffscreenCanvas>(m_canvas)) {
+ auto* offscreenCanvas = static_cast<OffscreenCanvas*>(&m_canvas);
+ offscreenCanvas->ref();
+ return;
+ }
+}
+
+void CanvasRenderingContext::deref()
+{
+ if (m_canvas.isHTMLCanvasElement()) {
+ auto* htmlCanvas = static_cast<HTMLCanvasElement*>(&m_canvas);
+ htmlCanvas->deref();
+ return;
+ }
+ if (is<OffscreenCanvas>(m_canvas)) {
+ auto* offscreenCanvas = static_cast<OffscreenCanvas*>(&m_canvas);
+ offscreenCanvas->deref();
+ return;
+ }
+}
+
bool CanvasRenderingContext::wouldTaintOrigin(const CanvasPattern* pattern)
{
- if (canvas().originClean() && pattern && !pattern->originClean())
+ if (m_canvas.originClean() && pattern && !pattern->originClean())
return true;
return false;
}
@@ -51,7 +80,7 @@
bool CanvasRenderingContext::wouldTaintOrigin(const HTMLCanvasElement* sourceCanvas)
{
- if (canvas().originClean() && sourceCanvas && !sourceCanvas->originClean())
+ if (m_canvas.originClean() && sourceCanvas && !sourceCanvas->originClean())
return true;
return false;
}
@@ -58,7 +87,7 @@
bool CanvasRenderingContext::wouldTaintOrigin(const HTMLImageElement* element)
{
- if (!element || !canvas().originClean())
+ if (!element || !m_canvas.originClean())
return false;
auto* cachedImage = element->cachedImage();
@@ -75,9 +104,9 @@
if (!cachedImage->isCORSSameOrigin())
return true;
- ASSERT(canvas().securityOrigin());
+ ASSERT(m_canvas.securityOrigin());
ASSERT(cachedImage->origin());
- ASSERT(canvas().securityOrigin()->toString() == cachedImage->origin()->toString());
+ ASSERT(m_canvas.securityOrigin()->toString() == cachedImage->origin()->toString());
return false;
}
@@ -88,7 +117,7 @@
// to test the finalURL. Please be careful when fixing this issue not to
// make currentSrc be the final URL because then the
// HTMLMediaElement.currentSrc DOM API would leak redirect destinations!
- if (!video || !canvas().originClean())
+ if (!video || !m_canvas.originClean())
return false;
if (!video->hasSingleSecurityOrigin())
@@ -106,7 +135,7 @@
bool CanvasRenderingContext::wouldTaintOrigin(const ImageBitmap* imageBitmap)
{
- if (!imageBitmap || !canvas().originClean())
+ if (!imageBitmap || !m_canvas.originClean())
return false;
return !imageBitmap->originClean();
@@ -114,19 +143,19 @@
bool CanvasRenderingContext::wouldTaintOrigin(const URL& url)
{
- if (!canvas().originClean())
+ if (!m_canvas.originClean())
return false;
if (url.protocolIsData())
return false;
- return !canvas().securityOrigin()->canRequest(url);
+ return !m_canvas.securityOrigin()->canRequest(url);
}
void CanvasRenderingContext::checkOrigin(const URL& url)
{
if (wouldTaintOrigin(url))
- canvas().setOriginTainted();
+ m_canvas.setOriginTainted();
}
} // namespace WebCore
Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext.h (224928 => 224929)
--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext.h 2017-11-16 19:13:42 UTC (rev 224928)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext.h 2017-11-16 19:19:39 UTC (rev 224929)
@@ -46,10 +46,11 @@
public:
virtual ~CanvasRenderingContext() = default;
- void ref() { m_canvas.ref(); }
- void deref() { m_canvas.deref(); }
- HTMLCanvasElement& canvas() const { return m_canvas; }
+ void ref();
+ void deref();
+ CanvasBase& canvasBase() const { return m_canvas; }
+
virtual bool is2d() const { return false; }
virtual bool isWebGL1() const { return false; }
virtual bool isWebGL2() const { return false; }
@@ -69,7 +70,7 @@
void setCallTracingActive(bool callTracingActive) { m_callTracingActive = callTracingActive; }
protected:
- CanvasRenderingContext(HTMLCanvasElement&);
+ CanvasRenderingContext(CanvasBase&);
bool wouldTaintOrigin(const CanvasPattern*);
bool wouldTaintOrigin(const HTMLCanvasElement*);
bool wouldTaintOrigin(const HTMLImageElement*);
@@ -80,7 +81,7 @@
template<class T> void checkOrigin(const T* arg)
{
if (wouldTaintOrigin(arg))
- canvas().setOriginTainted();
+ m_canvas.setOriginTainted();
}
void checkOrigin(const URL&);
@@ -87,7 +88,7 @@
bool m_callTracingActive { false };
private:
- HTMLCanvasElement& m_canvas;
+ CanvasBase& m_canvas;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp (224928 => 224929)
--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp 2017-11-16 19:13:42 UTC (rev 224928)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp 2017-11-16 19:19:39 UTC (rev 224929)
@@ -131,7 +131,7 @@
CanvasRenderingContext2D* m_canvasContext;
};
-CanvasRenderingContext2D::CanvasRenderingContext2D(HTMLCanvasElement& canvas, bool usesCSSCompatibilityParseMode, bool usesDashboardCompatibilityMode)
+CanvasRenderingContext2D::CanvasRenderingContext2D(CanvasBase& canvas, bool usesCSSCompatibilityParseMode, bool usesDashboardCompatibilityMode)
: CanvasRenderingContext(canvas)
, m_stateStack(1)
, m_usesCSSCompatibilityParseMode(usesCSSCompatibilityParseMode)
Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h (224928 => 224929)
--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h 2017-11-16 19:13:42 UTC (rev 224928)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h 2017-11-16 19:19:39 UTC (rev 224929)
@@ -50,12 +50,12 @@
namespace WebCore {
+class CanvasBase;
class CanvasGradient;
class CanvasPattern;
class DOMMatrix;
class FloatRect;
class GraphicsContext;
-class HTMLCanvasElement;
class HTMLImageElement;
class HTMLVideoElement;
class ImageBitmap;
@@ -73,9 +73,11 @@
class CanvasRenderingContext2D final : public CanvasRenderingContext, public CanvasPath {
public:
- CanvasRenderingContext2D(HTMLCanvasElement&, bool usesCSSCompatibilityParseMode, bool usesDashboardCompatibilityMode);
+ CanvasRenderingContext2D(CanvasBase&, bool usesCSSCompatibilityParseMode, bool usesDashboardCompatibilityMode);
virtual ~CanvasRenderingContext2D();
+ HTMLCanvasElement& canvas() const { return static_cast<HTMLCanvasElement&>(canvasBase()); }
+
float lineWidth() const;
void setLineWidth(float);
Modified: trunk/Source/WebCore/html/canvas/GPUBasedCanvasRenderingContext.h (224928 => 224929)
--- trunk/Source/WebCore/html/canvas/GPUBasedCanvasRenderingContext.h 2017-11-16 19:13:42 UTC (rev 224928)
+++ trunk/Source/WebCore/html/canvas/GPUBasedCanvasRenderingContext.h 2017-11-16 19:19:39 UTC (rev 224929)
@@ -49,9 +49,9 @@
virtual void markLayerComposited() = 0;
protected:
- GPUBasedCanvasRenderingContext(HTMLCanvasElement& canvas)
+ GPUBasedCanvasRenderingContext(CanvasBase& canvas)
: CanvasRenderingContext(canvas)
- , ActiveDOMObject(&canvas.document())
+ , ActiveDOMObject(canvas.scriptExecutionContext())
{
}
};
Modified: trunk/Source/WebCore/html/canvas/ImageBitmapRenderingContext.cpp (224928 => 224929)
--- trunk/Source/WebCore/html/canvas/ImageBitmapRenderingContext.cpp 2017-11-16 19:13:42 UTC (rev 224928)
+++ trunk/Source/WebCore/html/canvas/ImageBitmapRenderingContext.cpp 2017-11-16 19:19:39 UTC (rev 224929)
@@ -37,7 +37,7 @@
static RenderingMode bufferRenderingMode = Unaccelerated;
#endif
-ImageBitmapRenderingContext::ImageBitmapRenderingContext(HTMLCanvasElement& canvas, ImageBitmapRenderingContextSettings&& settings)
+ImageBitmapRenderingContext::ImageBitmapRenderingContext(CanvasBase& canvas, ImageBitmapRenderingContextSettings&& settings)
: CanvasRenderingContext(canvas)
, m_settings(WTFMove(settings))
{
@@ -46,6 +46,11 @@
ImageBitmapRenderingContext::~ImageBitmapRenderingContext() = default;
+HTMLCanvasElement* ImageBitmapRenderingContext::canvas() const
+{
+ return canvasBase().asHTMLCanvasElement();
+}
+
bool ImageBitmapRenderingContext::isAccelerated() const
{
return bufferRenderingMode == Accelerated;
@@ -73,11 +78,11 @@
// only reason I can think of is toDataURL(), but that doesn't seem like
// a good enough argument to waste memory.
- canvas().setImageBufferAndMarkDirty(ImageBuffer::create(FloatSize(canvas().width(), canvas().height()), bufferRenderingMode));
+ canvas()->setImageBufferAndMarkDirty(ImageBuffer::create(FloatSize(canvas()->width(), canvas()->height()), bufferRenderingMode));
// 1.4. Set the output bitmap's origin-clean flag to true.
- canvas().setOriginClean();
+ canvas()->setOriginClean();
return;
}
@@ -93,10 +98,10 @@
// bitmap data to be referenced by context's output bitmap.
if (imageBitmap->originClean())
- canvas().setOriginClean();
+ canvas()->setOriginClean();
else
- canvas().setOriginTainted();
- canvas().setImageBufferAndMarkDirty(imageBitmap->transferOwnershipAndClose());
+ canvas()->setOriginTainted();
+ canvas()->setImageBufferAndMarkDirty(imageBitmap->transferOwnershipAndClose());
}
ExceptionOr<void> ImageBitmapRenderingContext::transferFromImageBitmap(RefPtr<ImageBitmap> imageBitmap)
Modified: trunk/Source/WebCore/html/canvas/ImageBitmapRenderingContext.h (224928 => 224929)
--- trunk/Source/WebCore/html/canvas/ImageBitmapRenderingContext.h 2017-11-16 19:13:42 UTC (rev 224928)
+++ trunk/Source/WebCore/html/canvas/ImageBitmapRenderingContext.h 2017-11-16 19:19:39 UTC (rev 224929)
@@ -45,9 +45,11 @@
Blank
};
- ImageBitmapRenderingContext(HTMLCanvasElement&, ImageBitmapRenderingContextSettings&&);
+ ImageBitmapRenderingContext(CanvasBase&, ImageBitmapRenderingContextSettings&&);
~ImageBitmapRenderingContext();
+ HTMLCanvasElement* canvas() const;
+
ExceptionOr<void> transferFromImageBitmap(RefPtr<ImageBitmap>);
BitmapMode bitmapMode() { return m_bitmapMode; }
Modified: trunk/Source/WebCore/html/canvas/PlaceholderRenderingContext.cpp (224928 => 224929)
--- trunk/Source/WebCore/html/canvas/PlaceholderRenderingContext.cpp 2017-11-16 19:13:42 UTC (rev 224928)
+++ trunk/Source/WebCore/html/canvas/PlaceholderRenderingContext.cpp 2017-11-16 19:19:39 UTC (rev 224929)
@@ -28,7 +28,7 @@
namespace WebCore {
-PlaceholderRenderingContext::PlaceholderRenderingContext(HTMLCanvasElement& canvas)
+PlaceholderRenderingContext::PlaceholderRenderingContext(CanvasBase& canvas)
: CanvasRenderingContext(canvas)
{
}
Modified: trunk/Source/WebCore/html/canvas/PlaceholderRenderingContext.h (224928 => 224929)
--- trunk/Source/WebCore/html/canvas/PlaceholderRenderingContext.h 2017-11-16 19:13:42 UTC (rev 224928)
+++ trunk/Source/WebCore/html/canvas/PlaceholderRenderingContext.h 2017-11-16 19:19:39 UTC (rev 224929)
@@ -31,7 +31,7 @@
class PlaceholderRenderingContext final : public CanvasRenderingContext {
public:
- PlaceholderRenderingContext(HTMLCanvasElement&);
+ PlaceholderRenderingContext(CanvasBase&);
private:
bool isPlaceholder() const final { return true; }
Modified: trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.cpp (224928 => 224929)
--- trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.cpp 2017-11-16 19:13:42 UTC (rev 224928)
+++ trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.cpp 2017-11-16 19:19:39 UTC (rev 224929)
@@ -60,13 +60,13 @@
namespace WebCore {
-WebGL2RenderingContext::WebGL2RenderingContext(HTMLCanvasElement& passedCanvas, GraphicsContext3DAttributes attributes)
- : WebGLRenderingContextBase(passedCanvas, attributes)
+WebGL2RenderingContext::WebGL2RenderingContext(CanvasBase& canvas, GraphicsContext3DAttributes attributes)
+ : WebGLRenderingContextBase(canvas, attributes)
{
}
-WebGL2RenderingContext::WebGL2RenderingContext(HTMLCanvasElement& passedCanvas, Ref<GraphicsContext3D>&& context, GraphicsContext3DAttributes attributes)
- : WebGLRenderingContextBase(passedCanvas, WTFMove(context), attributes)
+WebGL2RenderingContext::WebGL2RenderingContext(CanvasBase& canvas, Ref<GraphicsContext3D>&& context, GraphicsContext3DAttributes attributes)
+ : WebGLRenderingContextBase(canvas, WTFMove(context), attributes)
{
initializeShaderExtensions();
initializeVertexArrayObjects();
Modified: trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.h (224928 => 224929)
--- trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.h 2017-11-16 19:13:42 UTC (rev 224928)
+++ trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.h 2017-11-16 19:19:39 UTC (rev 224929)
@@ -39,8 +39,8 @@
class WebGL2RenderingContext final : public WebGLRenderingContextBase {
public:
- WebGL2RenderingContext(HTMLCanvasElement&, WebGLContextAttributes);
- WebGL2RenderingContext(HTMLCanvasElement&, Ref<GraphicsContext3D>&&, WebGLContextAttributes);
+ WebGL2RenderingContext(CanvasBase&, WebGLContextAttributes);
+ WebGL2RenderingContext(CanvasBase&, Ref<GraphicsContext3D>&&, WebGLContextAttributes);
// Buffer objects
using WebGLRenderingContextBase::bufferData;
Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp (224928 => 224929)
--- trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp 2017-11-16 19:13:42 UTC (rev 224928)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp 2017-11-16 19:19:39 UTC (rev 224929)
@@ -66,13 +66,13 @@
namespace WebCore {
-WebGLRenderingContext::WebGLRenderingContext(HTMLCanvasElement& passedCanvas, GraphicsContext3DAttributes attributes)
- : WebGLRenderingContextBase(passedCanvas, attributes)
+WebGLRenderingContext::WebGLRenderingContext(CanvasBase& canvas, GraphicsContext3DAttributes attributes)
+ : WebGLRenderingContextBase(canvas, attributes)
{
}
-WebGLRenderingContext::WebGLRenderingContext(HTMLCanvasElement& passedCanvas, Ref<GraphicsContext3D>&& context, GraphicsContext3DAttributes attributes)
- : WebGLRenderingContextBase(passedCanvas, WTFMove(context), attributes)
+WebGLRenderingContext::WebGLRenderingContext(CanvasBase& canvas, Ref<GraphicsContext3D>&& context, GraphicsContext3DAttributes attributes)
+ : WebGLRenderingContextBase(canvas, WTFMove(context), attributes)
{
initializeVertexArrayObjects();
}
Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContext.h (224928 => 224929)
--- trunk/Source/WebCore/html/canvas/WebGLRenderingContext.h 2017-11-16 19:13:42 UTC (rev 224928)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContext.h 2017-11-16 19:19:39 UTC (rev 224929)
@@ -33,8 +33,8 @@
class WebGLRenderingContext final : public WebGLRenderingContextBase {
public:
- WebGLRenderingContext(HTMLCanvasElement&, GraphicsContext3DAttributes);
- WebGLRenderingContext(HTMLCanvasElement&, Ref<GraphicsContext3D>&&, GraphicsContext3DAttributes);
+ WebGLRenderingContext(CanvasBase&, GraphicsContext3DAttributes);
+ WebGLRenderingContext(CanvasBase&, Ref<GraphicsContext3D>&&, GraphicsContext3DAttributes);
bool isWebGL1() const final { return true; }
Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp (224928 => 224929)
--- trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp 2017-11-16 19:13:42 UTC (rev 224928)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp 2017-11-16 19:19:39 UTC (rev 224929)
@@ -361,7 +361,7 @@
return context->powerPreferenceUsedForCreation() == WebGLPowerPreference::HighPerformance;
}
-std::unique_ptr<WebGLRenderingContextBase> WebGLRenderingContextBase::create(HTMLCanvasElement& canvas, WebGLContextAttributes& attributes, const String& type)
+std::unique_ptr<WebGLRenderingContextBase> WebGLRenderingContextBase::create(CanvasBase& canvas, WebGLContextAttributes& attributes, const String& type)
{
#if ENABLE(WEBGL2)
if (type == "webgl2" && !RuntimeEnabledFeatures::sharedFeatures().webGL2Enabled())
@@ -370,52 +370,62 @@
UNUSED_PARAM(type);
#endif
- Document& document = canvas.document();
- RefPtr<Frame> frame = document.frame();
- if (!frame)
- return nullptr;
-
- // The FrameLoaderClient might block creation of a new WebGL context despite the page settings; in
- // particular, if WebGL contexts were lost one or more times via the GL_ARB_robustness extension.
- if (!frame->loader().client().allowWebGL(frame->settings().webGLEnabled())) {
- canvas.dispatchEvent(WebGLContextEvent::create(eventNames().webglcontextcreationerrorEvent, false, true, "Web page was not allowed to create a WebGL context."));
- return nullptr;
- }
-
bool isPendingPolicyResolution = false;
- Document& topDocument = document.topDocument();
- Page* page = topDocument.page();
- bool forcingPendingPolicy = frame->settings().isForcePendingWebGLPolicy();
+ HostWindow* hostWindow = nullptr;
- if (forcingPendingPolicy || (page && !topDocument.url().isLocalFile())) {
- WebGLLoadPolicy policy = forcingPendingPolicy ? WebGLPendingCreation : page->mainFrame().loader().client().webGLPolicyForURL(topDocument.url());
+ auto* canvasElement = canvas.asHTMLCanvasElement();
- if (policy == WebGLBlockCreation) {
- LOG(WebGL, "The policy for this URL (%s) is to block WebGL.", topDocument.url().host().utf8().data());
+ if (canvasElement) {
+ Document& document = canvasElement->document();
+ RefPtr<Frame> frame = document.frame();
+ if (!frame)
return nullptr;
+
+ // The FrameLoaderClient might block creation of a new WebGL context despite the page settings; in
+ // particular, if WebGL contexts were lost one or more times via the GL_ARB_robustness extension.
+ if (!frame->loader().client().allowWebGL(frame->settings().webGLEnabled())) {
+ canvasElement->dispatchEvent(WebGLContextEvent::create(eventNames().webglcontextcreationerrorEvent, false, true, "Web page was not allowed to create a WebGL context."));
+ return nullptr;
}
- if (policy == WebGLPendingCreation) {
- LOG(WebGL, "WebGL policy is pending. May need to be resolved later.");
- isPendingPolicyResolution = true;
+ Document& topDocument = document.topDocument();
+ Page* page = topDocument.page();
+ bool forcingPendingPolicy = frame->settings().isForcePendingWebGLPolicy();
+
+ if (forcingPendingPolicy || (page && !topDocument.url().isLocalFile())) {
+ WebGLLoadPolicy policy = forcingPendingPolicy ? WebGLPendingCreation : page->mainFrame().loader().client().webGLPolicyForURL(topDocument.url());
+
+ if (policy == WebGLBlockCreation) {
+ LOG(WebGL, "The policy for this URL (%s) is to block WebGL.", topDocument.url().host().utf8().data());
+ return nullptr;
+ }
+
+ if (policy == WebGLPendingCreation) {
+ LOG(WebGL, "WebGL policy is pending. May need to be resolved later.");
+ isPendingPolicyResolution = true;
+ }
}
+
+ if (frame->settings().forceSoftwareWebGLRendering())
+ attributes.forceSoftwareRenderer = true;
+
+ if (frame->settings().forceWebGLUsesLowPower()) {
+ if (attributes.powerPreference == GraphicsContext3DPowerPreference::HighPerformance)
+ LOG(WebGL, "Overriding powerPreference from high-performance to low-power.");
+ attributes.powerPreference = GraphicsContext3DPowerPreference::LowPower;
+ }
+
+ if (page)
+ attributes.devicePixelRatio = page->deviceScaleFactor();
+
+ hostWindow = document.view()->root()->hostWindow();
}
attributes.noExtensions = true;
attributes.shareResources = false;
- if (frame->settings().forceSoftwareWebGLRendering())
- attributes.forceSoftwareRenderer = true;
-
attributes.initialPowerPreference = attributes.powerPreference;
- if (frame->settings().forceWebGLUsesLowPower()) {
- if (attributes.powerPreference == GraphicsContext3DPowerPreference::HighPerformance)
- LOG(WebGL, "Overriding powerPreference from high-performance to low-power.");
- attributes.powerPreference = GraphicsContext3DPowerPreference::LowPower;
- }
- if (page)
- attributes.devicePixelRatio = page->deviceScaleFactor();
#if ENABLE(WEBGL2)
if (type == "webgl2")
@@ -435,9 +445,10 @@
return renderingContext;
}
- auto context = GraphicsContext3D::create(attributes, document.view()->root()->hostWindow());
+ auto context = GraphicsContext3D::create(attributes, hostWindow);
if (!context || !context->makeContextCurrent()) {
- canvas.dispatchEvent(WebGLContextEvent::create(eventNames().webglcontextcreationerrorEvent, false, true, "Could not create a WebGL context."));
+ if (canvasElement)
+ canvasElement->dispatchEvent(WebGLContextEvent::create(eventNames().webglcontextcreationerrorEvent, false, true, "Could not create a WebGL context."));
return nullptr;
}
@@ -464,8 +475,8 @@
return renderingContext;
}
-WebGLRenderingContextBase::WebGLRenderingContextBase(HTMLCanvasElement& passedCanvas, WebGLContextAttributes attributes)
- : GPUBasedCanvasRenderingContext(passedCanvas)
+WebGLRenderingContextBase::WebGLRenderingContextBase(CanvasBase& canvas, WebGLContextAttributes attributes)
+ : GPUBasedCanvasRenderingContext(canvas)
, m_dispatchContextLostEventTimer(*this, &WebGLRenderingContextBase::dispatchContextLostEvent)
, m_restoreTimer(*this, &WebGLRenderingContextBase::maybeRestoreContext)
, m_attributes(attributes)
@@ -477,8 +488,8 @@
m_checkForContextLossHandlingTimer.startOneShot(checkContextLossHandlingDelay);
}
-WebGLRenderingContextBase::WebGLRenderingContextBase(HTMLCanvasElement& passedCanvas, Ref<GraphicsContext3D>&& context, WebGLContextAttributes attributes)
- : GPUBasedCanvasRenderingContext(passedCanvas)
+WebGLRenderingContextBase::WebGLRenderingContextBase(CanvasBase& canvas, Ref<GraphicsContext3D>&& context, WebGLContextAttributes attributes)
+ : GPUBasedCanvasRenderingContext(canvas)
, m_context(WTFMove(context))
, m_dispatchContextLostEventTimer(*this, &WebGLRenderingContextBase::dispatchContextLostEvent)
, m_restoreTimer(*this, &WebGLRenderingContextBase::maybeRestoreContext)
@@ -502,24 +513,29 @@
addActivityStateChangeObserverIfNecessary();
}
+HTMLCanvasElement* WebGLRenderingContextBase::canvas()
+{
+ return canvasBase().asHTMLCanvasElement();
+}
+
// We check for context loss handling after a few seconds to give the JS a chance to register the event listeners
// and to discard temporary GL contexts (e.g. feature detection).
void WebGLRenderingContextBase::checkForContextLossHandling()
{
- if (!canvas().renderer())
+ if (!canvas()->renderer())
return;
- auto* page = canvas().document().page();
+ auto* page = canvas()->document().page();
if (!page)
return;
- bool handlesContextLoss = canvas().hasEventListeners(eventNames().webglcontextlostEvent) && canvas().hasEventListeners(eventNames().webglcontextrestoredEvent);
+ bool handlesContextLoss = canvas()->hasEventListeners(eventNames().webglcontextlostEvent) && canvas()->hasEventListeners(eventNames().webglcontextrestoredEvent);
page->diagnosticLoggingClient().logDiagnosticMessage(DiagnosticLoggingKeys::pageHandlesWebGLContextLossKey(), handlesContextLoss ? DiagnosticLoggingKeys::yesKey() : DiagnosticLoggingKeys::noKey(), ShouldSample::No);
}
void WebGLRenderingContextBase::registerWithWebGLStateTracker()
{
- auto* page = canvas().document().page();
+ auto* page = canvas()->document().page();
if (!page)
return;
@@ -608,7 +624,7 @@
{
ASSERT(m_context);
- if (Page* page = canvas().document().page())
+ if (Page* page = canvas()->document().page())
m_synthesizedErrorsToConsole = page->settings().webGLErrorsToConsoleEnabled();
m_isGLES2Compliant = m_context->isGLES2Compliant();
@@ -635,7 +651,7 @@
if (!isHighPerformanceContext(m_context))
return;
- auto* page = canvas().document().page();
+ auto* page = canvas()->document().page();
if (!page)
return;
@@ -649,7 +665,7 @@
void WebGLRenderingContextBase::removeActivityStateChangeObserver()
{
- if (auto* page = canvas().document().page())
+ if (auto* page = canvas()->document().page())
page->removeActivityStateChangeObserver(*this);
}
@@ -702,15 +718,15 @@
m_context->markContextChanged();
m_layerCleared = false;
- RenderBox* renderBox = canvas().renderBox();
+ RenderBox* renderBox = canvas()->renderBox();
if (isAccelerated() && renderBox && renderBox->hasAcceleratedCompositing()) {
m_markedCanvasDirty = true;
- canvas().clearCopiedImage();
+ canvas()->clearCopiedImage();
renderBox->contentChanged(CanvasChanged);
} else {
if (!m_markedCanvasDirty) {
m_markedCanvasDirty = true;
- canvas().didDraw(FloatRect(FloatPoint(0, 0), clampedCanvasSize()));
+ canvas()->didDraw(FloatRect(FloatPoint(0, 0), clampedCanvasSize()));
}
}
}
@@ -721,9 +737,9 @@
if (!isAccelerated())
return;
- RenderBox* renderBox = canvas().renderBox();
+ RenderBox* renderBox = canvas()->renderBox();
if (renderBox && renderBox->hasAcceleratedCompositing())
- canvas().notifyObserversCanvasChanged(FloatRect(FloatPoint(0, 0), clampedCanvasSize()));
+ canvas()->notifyObserversCanvasChanged(FloatRect(FloatPoint(0, 0), clampedCanvasSize()));
}
bool WebGLRenderingContextBase::clearIfComposited(GC3Dbitfield mask)
@@ -805,26 +821,26 @@
if (isContextLostOrPending())
return;
- if (canvas().document().printing())
- canvas().clearPresentationCopy();
+ if (canvas()->document().printing())
+ canvas()->clearPresentationCopy();
// Until the canvas is written to by the application, the clear that
// happened after it was composited should be ignored by the compositor.
if (m_context->layerComposited() && !m_attributes.preserveDrawingBuffer) {
- m_context->paintCompositedResultsToCanvas(canvas().buffer());
+ m_context->paintCompositedResultsToCanvas(canvas()->buffer());
- canvas().makePresentationCopy();
+ canvas()->makePresentationCopy();
} else
- canvas().clearPresentationCopy();
+ canvas()->clearPresentationCopy();
clearIfComposited();
if (!m_markedCanvasDirty && !m_layerCleared)
return;
- canvas().clearCopiedImage();
+ canvas()->clearCopiedImage();
m_markedCanvasDirty = false;
- m_context->paintRenderingResultsToCanvas(canvas().buffer());
+ m_context->paintRenderingResultsToCanvas(canvas()->buffer());
}
RefPtr<ImageData> WebGLRenderingContextBase::paintRenderingResultsToImageData()
@@ -854,7 +870,7 @@
height = clamp(height, 1, maxHeight);
if (m_needsUpdate) {
- RenderBox* renderBox = canvas().renderBox();
+ RenderBox* renderBox = canvas()->renderBox();
if (renderBox && renderBox->hasAcceleratedCompositing())
renderBox->contentChanged(CanvasChanged);
m_needsUpdate = false;
@@ -1314,7 +1330,7 @@
Vector<String> errors;
getShaderInfoLog(shader).split("\n", errors);
for (String& error : errors)
- canvas().document().addConsoleMessage(std::make_unique<Inspector::ConsoleMessage>(MessageSource::Rendering, MessageType::Log, MessageLevel::Error, "WebGL: " + error, stackTrace.copyRef()));
+ canvas()->document().addConsoleMessage(std::make_unique<Inspector::ConsoleMessage>(MessageSource::Rendering, MessageType::Log, MessageLevel::Error, "WebGL: " + error, stackTrace.copyRef()));
}
}
@@ -2791,7 +2807,7 @@
{
if (m_isPendingPolicyResolution && !m_hasRequestedPolicyResolution) {
LOG(WebGL, "Context is being used. Attempt to resolve the policy.");
- Document& document = canvas().document().topDocument();
+ Document& document = canvas()->document().topDocument();
Page* page = document.page();
if (page && !document.url().isLocalFile())
page->mainFrame().loader().client().resolveWebGLPolicyForURL(document.url());
@@ -3116,7 +3132,7 @@
return;
// Due to WebGL's same-origin restrictions, it is not possible to
// taint the origin using the WebGL API.
- ASSERT(canvas().originClean());
+ ASSERT(canvas()->originClean());
GC3Denum internalFormat = 0;
if (m_framebufferBinding) {
@@ -4690,7 +4706,7 @@
if (mode == RealLostContext) {
// Inform the embedder that a lost context was received. In response, the embedder might
// decide to take action such as asking the user for permission to use WebGL again.
- if (RefPtr<Frame> frame = canvas().document().frame())
+ if (RefPtr<Frame> frame = canvas()->document().frame())
frame->loader().client().didLoseWebGLContext(m_context->getExtensions().getGraphicsResetStatusARB());
}
@@ -5314,7 +5330,7 @@
} else
consoleMessage = std::make_unique<Inspector::ConsoleMessage>(MessageSource::Rendering, MessageType::Log, level, message);
- canvas().document().addConsoleMessage(WTFMove(consoleMessage));
+ canvas()->document().addConsoleMessage(WTFMove(consoleMessage));
--m_numGLErrorsToConsoleAllowed;
if (!m_numGLErrorsToConsoleAllowed)
@@ -5660,7 +5676,7 @@
void WebGLRenderingContextBase::dispatchContextLostEvent()
{
Ref<WebGLContextEvent> event = WebGLContextEvent::create(eventNames().webglcontextlostEvent, false, true, emptyString());
- canvas().dispatchEvent(event);
+ canvas()->dispatchEvent(event);
m_restoreAllowed = event->defaultPrevented();
if (m_contextLostMode == RealLostContext && m_restoreAllowed)
m_restoreTimer.startOneShot(0_s);
@@ -5708,7 +5724,7 @@
break;
}
- RefPtr<Frame> frame = canvas().document().frame();
+ RefPtr<Frame> frame = canvas()->document().frame();
if (!frame)
return;
@@ -5741,12 +5757,12 @@
setupFlags();
initializeNewContext();
initializeVertexArrayObjects();
- canvas().dispatchEvent(WebGLContextEvent::create(eventNames().webglcontextrestoredEvent, false, true, emptyString()));
+ canvas()->dispatchEvent(WebGLContextEvent::create(eventNames().webglcontextrestoredEvent, false, true, emptyString()));
}
void WebGLRenderingContextBase::dispatchContextChangedEvent()
{
- canvas().dispatchEvent(WebGLContextEvent::create(eventNames().webglcontextchangedEvent, false, true, emptyString()));
+ canvas()->dispatchEvent(WebGLContextEvent::create(eventNames().webglcontextchangedEvent, false, true, emptyString()));
}
void WebGLRenderingContextBase::simulateContextChanged()
@@ -5856,8 +5872,8 @@
IntSize WebGLRenderingContextBase::clampedCanvasSize()
{
- return IntSize(clamp(canvas().width(), 1, m_maxViewportDims[0]),
- clamp(canvas().height(), 1, m_maxViewportDims[1]));
+ return IntSize(clamp(canvas()->width(), 1, m_maxViewportDims[0]),
+ clamp(canvas()->height(), 1, m_maxViewportDims[1]));
}
GC3Dint WebGLRenderingContextBase::getMaxDrawBuffers()
Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.h (224928 => 224929)
--- trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.h 2017-11-16 19:13:42 UTC (rev 224928)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.h 2017-11-16 19:19:39 UTC (rev 224929)
@@ -114,9 +114,11 @@
class WebGLRenderingContextBase : public GPUBasedCanvasRenderingContext, private ActivityStateChangeObserver {
public:
- static std::unique_ptr<WebGLRenderingContextBase> create(HTMLCanvasElement&, WebGLContextAttributes&, const String&);
+ static std::unique_ptr<WebGLRenderingContextBase> create(CanvasBase&, WebGLContextAttributes&, const String&);
virtual ~WebGLRenderingContextBase();
+ HTMLCanvasElement* canvas();
+
int drawingBufferWidth() const;
int drawingBufferHeight() const;
@@ -376,8 +378,8 @@
WEBCORE_EXPORT void setFailNextGPUStatusCheck();
protected:
- WebGLRenderingContextBase(HTMLCanvasElement&, WebGLContextAttributes);
- WebGLRenderingContextBase(HTMLCanvasElement&, Ref<GraphicsContext3D>&&, WebGLContextAttributes);
+ WebGLRenderingContextBase(CanvasBase&, WebGLContextAttributes);
+ WebGLRenderingContextBase(CanvasBase&, Ref<GraphicsContext3D>&&, WebGLContextAttributes);
friend class WebGLDrawBuffers;
friend class WebGLFramebuffer;
Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.idl (224928 => 224929)
--- trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.idl 2017-11-16 19:13:42 UTC (rev 224928)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.idl 2017-11-16 19:19:39 UTC (rev 224929)
@@ -58,7 +58,6 @@
ExportMacro=WEBCORE_EXPORT,
] interface WebGLRenderingContextBase {
- // back-reference to the canvas
readonly attribute HTMLCanvasElement canvas;
/* ClearBufferMask */
Modified: trunk/Source/WebCore/html/canvas/WebGPURenderingContext.cpp (224928 => 224929)
--- trunk/Source/WebCore/html/canvas/WebGPURenderingContext.cpp 2017-11-16 19:13:42 UTC (rev 224928)
+++ trunk/Source/WebCore/html/canvas/WebGPURenderingContext.cpp 2017-11-16 19:19:39 UTC (rev 224929)
@@ -71,7 +71,7 @@
static const int kMaxTextureSize = 4096;
-std::unique_ptr<WebGPURenderingContext> WebGPURenderingContext::create(HTMLCanvasElement& canvas)
+std::unique_ptr<WebGPURenderingContext> WebGPURenderingContext::create(CanvasBase& canvas)
{
RefPtr<GPUDevice> device(GPUDevice::create());
@@ -87,7 +87,7 @@
return renderingContext;
}
-WebGPURenderingContext::WebGPURenderingContext(HTMLCanvasElement& canvas, Ref<GPUDevice>&& device)
+WebGPURenderingContext::WebGPURenderingContext(CanvasBase& canvas, Ref<GPUDevice>&& device)
: GPUBasedCanvasRenderingContext(canvas)
, m_device(WTFMove(device))
{
@@ -94,6 +94,11 @@
initializeNewContext();
}
+HTMLCanvasElement* WebGPURenderingContext::canvas() const
+{
+ return canvasBase().asHTMLCanvasElement();
+}
+
void WebGPURenderingContext::initializeNewContext()
{
// FIXME: WebGPU - Maybe we should reset a bunch of stuff here.
@@ -104,8 +109,8 @@
IntSize WebGPURenderingContext::clampedCanvasSize() const
{
- return IntSize(clamp(canvas().width(), 1, kMaxTextureSize),
- clamp(canvas().height(), 1, kMaxTextureSize));
+ return IntSize(clamp(canvas()->width(), 1, kMaxTextureSize),
+ clamp(canvas()->height(), 1, kMaxTextureSize));
}
bool WebGPURenderingContext::hasPendingActivity() const
Modified: trunk/Source/WebCore/html/canvas/WebGPURenderingContext.h (224928 => 224929)
--- trunk/Source/WebCore/html/canvas/WebGPURenderingContext.h 2017-11-16 19:13:42 UTC (rev 224928)
+++ trunk/Source/WebCore/html/canvas/WebGPURenderingContext.h 2017-11-16 19:19:39 UTC (rev 224929)
@@ -50,8 +50,10 @@
class WebGPURenderingContext : public GPUBasedCanvasRenderingContext {
public:
- static std::unique_ptr<WebGPURenderingContext> create(HTMLCanvasElement&);
+ static std::unique_ptr<WebGPURenderingContext> create(CanvasBase&);
+ HTMLCanvasElement* canvas() const;
+
bool isWebGPU() const final { return true; }
void reshape(int width, int height) final;
@@ -91,7 +93,7 @@
void initializeNewContext();
private:
- WebGPURenderingContext(HTMLCanvasElement&, Ref<GPUDevice>&&);
+ WebGPURenderingContext(CanvasBase&, Ref<GPUDevice>&&);
RefPtr<GPUDevice> m_device;
};
Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.h (224928 => 224929)
--- trunk/Source/WebCore/inspector/InspectorInstrumentation.h 2017-11-16 19:13:42 UTC (rev 224928)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.h 2017-11-16 19:19:39 UTC (rev 224929)
@@ -1236,8 +1236,11 @@
inline void InspectorInstrumentation::recordCanvasAction(CanvasRenderingContext& canvasRenderingContext, const String& name, Vector<RecordCanvasActionVariant>&& parameters)
{
FAST_RETURN_IF_NO_FRONTENDS(void());
- if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(&canvasRenderingContext.canvas().document()))
- recordCanvasActionImpl(*instrumentingAgents, canvasRenderingContext, name, WTFMove(parameters));
+ auto* canvasElement = canvasRenderingContext.canvasBase().asHTMLCanvasElement();
+ if (canvasElement) {
+ if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(&canvasElement->document()))
+ recordCanvasActionImpl(*instrumentingAgents, canvasRenderingContext, name, WTFMove(parameters));
+ }
}
inline void InspectorInstrumentation::didFinishRecordingCanvasFrame(HTMLCanvasElement& canvasElement, bool forceDispatch)
@@ -1251,27 +1254,36 @@
inline void InspectorInstrumentation::didEnableExtension(WebGLRenderingContextBase& context, const String& extension)
{
FAST_RETURN_IF_NO_FRONTENDS(void());
- if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(context.canvas().document()))
- didEnableExtensionImpl(*instrumentingAgents, context, extension);
+
+ if (auto* canvasElement = context.canvas()) {
+ if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(canvasElement->document()))
+ didEnableExtensionImpl(*instrumentingAgents, context, extension);
+ }
}
inline void InspectorInstrumentation::didCreateProgram(WebGLRenderingContextBase& context, WebGLProgram& program)
{
- if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(context.canvas().document()))
- didCreateProgramImpl(*instrumentingAgents, context, program);
+ if (auto* canvasElement = context.canvas()) {
+ if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(canvasElement->document()))
+ didCreateProgramImpl(*instrumentingAgents, context, program);
+ }
}
inline void InspectorInstrumentation::willDeleteProgram(WebGLRenderingContextBase& context, WebGLProgram& program)
{
- if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(context.canvas().document()))
- willDeleteProgramImpl(*instrumentingAgents, program);
+ if (auto* canvasElement = context.canvas()) {
+ if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(canvasElement->document()))
+ willDeleteProgramImpl(*instrumentingAgents, program);
+ }
}
inline bool InspectorInstrumentation::isShaderProgramDisabled(WebGLRenderingContextBase& context, WebGLProgram& program)
{
FAST_RETURN_IF_NO_FRONTENDS(false);
- if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(context.canvas().document()))
- return isShaderProgramDisabledImpl(*instrumentingAgents, program);
+ if (auto* canvasElement = context.canvas()) {
+ if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(canvasElement->document()))
+ return isShaderProgramDisabledImpl(*instrumentingAgents, program);
+ }
return false;
}
#endif
Modified: trunk/Source/WebCore/inspector/agents/InspectorCanvasAgent.cpp (224928 => 224929)
--- trunk/Source/WebCore/inspector/agents/InspectorCanvasAgent.cpp 2017-11-16 19:13:42 UTC (rev 224928)
+++ trunk/Source/WebCore/inspector/agents/InspectorCanvasAgent.cpp 2017-11-16 19:19:39 UTC (rev 224929)
@@ -425,9 +425,11 @@
void InspectorCanvasAgent::recordCanvasAction(CanvasRenderingContext& canvasRenderingContext, const String& name, Vector<RecordCanvasActionVariant>&& parameters)
{
- HTMLCanvasElement& canvasElement = canvasRenderingContext.canvas();
+ auto* canvasElement = canvasRenderingContext.canvasBase().asHTMLCanvasElement();
+ if (!canvasElement)
+ return;
- auto* inspectorCanvas = findInspectorCanvas(canvasElement);
+ auto* inspectorCanvas = findInspectorCanvas(*canvasElement);
ASSERT(inspectorCanvas);
if (!inspectorCanvas)
return;
@@ -442,7 +444,7 @@
m_canvasRecordingTimer.startOneShot(0_s);
if (!inspectorCanvas->hasBufferSpace())
- didFinishRecordingCanvasFrame(canvasElement, true);
+ didFinishRecordingCanvasFrame(*canvasElement, true);
}
void InspectorCanvasAgent::canvasDestroyed(HTMLCanvasElement& canvasElement)
@@ -525,7 +527,7 @@
#if ENABLE(WEBGL)
void InspectorCanvasAgent::didEnableExtension(WebGLRenderingContextBase& context, const String& extension)
{
- auto* inspectorCanvas = findInspectorCanvas(context.canvas());
+ auto* inspectorCanvas = findInspectorCanvas(*context.canvas());
if (!inspectorCanvas)
return;
@@ -534,7 +536,7 @@
void InspectorCanvasAgent::didCreateProgram(WebGLRenderingContextBase& context, WebGLProgram& program)
{
- auto* inspectorCanvas = findInspectorCanvas(context.canvas());
+ auto* inspectorCanvas = findInspectorCanvas(*context.canvas());
ASSERT(inspectorCanvas);
if (!inspectorCanvas)
return;