Title: [225990] trunk
Revision
225990
Author
[email protected]
Date
2017-12-15 16:00:09 -0800 (Fri, 15 Dec 2017)

Log Message

Unreviewed, rolling out r225941.

This change introduced LayoutTest crashes and assertion
failures.

Reverted changeset:

"Web Inspector: replace HTMLCanvasElement with
CanvasRenderingContext for instrumentation logic"
https://bugs.webkit.org/show_bug.cgi?id=180770
https://trac.webkit.org/changeset/225941

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (225989 => 225990)


--- trunk/Source/_javascript_Core/ChangeLog	2017-12-15 23:14:33 UTC (rev 225989)
+++ trunk/Source/_javascript_Core/ChangeLog	2017-12-16 00:00:09 UTC (rev 225990)
@@ -1,3 +1,17 @@
+2017-12-15  Ryan Haddad  <[email protected]>
+
+        Unreviewed, rolling out r225941.
+
+        This change introduced LayoutTest crashes and assertion
+        failures.
+
+        Reverted changeset:
+
+        "Web Inspector: replace HTMLCanvasElement with
+        CanvasRenderingContext for instrumentation logic"
+        https://bugs.webkit.org/show_bug.cgi?id=180770
+        https://trac.webkit.org/changeset/225941
+
 2017-12-15  Yusuke Suzuki  <[email protected]>
 
         Unreviewed, 32bit JSEmpty is not nullptr + CellTag

Modified: trunk/Source/_javascript_Core/inspector/protocol/Canvas.json (225989 => 225990)


--- trunk/Source/_javascript_Core/inspector/protocol/Canvas.json	2017-12-15 23:14:33 UTC (rev 225989)
+++ trunk/Source/_javascript_Core/inspector/protocol/Canvas.json	2017-12-16 00:00:09 UTC (rev 225990)
@@ -46,6 +46,7 @@
             "properties": [
                 { "name": "canvasId", "$ref": "CanvasId", "description": "Canvas identifier." },
                 { "name": "contextType", "$ref": "ContextType", "description": "The type of rendering context backing the canvas." },
+                { "name": "frameId", "$ref": "Network.FrameId", "description": "Parent frame identifier." },
                 { "name": "nodeId", "$ref": "DOM.NodeId", "optional": true, "description": "The corresponding DOM node id." },
                 { "name": "cssCanvasName", "type": "string", "optional": true, "description": "The CSS canvas identifier, for canvases created with <code>document.getCSSCanvasContext</code>." },
                 { "name": "contextAttributes", "$ref": "ContextAttributes", "optional": true, "description": "Context attributes for rendering contexts." },

Modified: trunk/Source/WebCore/ChangeLog (225989 => 225990)


--- trunk/Source/WebCore/ChangeLog	2017-12-15 23:14:33 UTC (rev 225989)
+++ trunk/Source/WebCore/ChangeLog	2017-12-16 00:00:09 UTC (rev 225990)
@@ -1,3 +1,17 @@
+2017-12-15  Ryan Haddad  <[email protected]>
+
+        Unreviewed, rolling out r225941.
+
+        This change introduced LayoutTest crashes and assertion
+        failures.
+
+        Reverted changeset:
+
+        "Web Inspector: replace HTMLCanvasElement with
+        CanvasRenderingContext for instrumentation logic"
+        https://bugs.webkit.org/show_bug.cgi?id=180770
+        https://trac.webkit.org/changeset/225941
+
 2017-12-15  Ryosuke Niwa  <[email protected]>
 
         Add a release assert that Timer::m_wasDeleted is false in setNextFireTime

Modified: trunk/Source/WebCore/dom/Document.cpp (225989 => 225990)


--- trunk/Source/WebCore/dom/Document.cpp	2017-12-15 23:14:33 UTC (rev 225989)
+++ trunk/Source/WebCore/dom/Document.cpp	2017-12-16 00:00:09 UTC (rev 225990)
@@ -5699,20 +5699,13 @@
 HTMLCanvasElement* Document::getCSSCanvasElement(const String& name)
 {
     RefPtr<HTMLCanvasElement>& element = m_cssCanvasElements.add(name, nullptr).iterator->value;
-    if (!element)
+    if (!element) {
         element = HTMLCanvasElement::create(*this);
+        InspectorInstrumentation::didCreateCSSCanvas(*element, name);
+    }
     return element.get();
 }
 
-String Document::nameForCSSCanvasElement(const HTMLCanvasElement& canvasElement) const
-{
-    for (const auto& entry : m_cssCanvasElements) {
-        if (entry.value.get() == &canvasElement)
-            return entry.key;
-    }
-    return String();
-}
-
 #if ENABLE(TEXT_AUTOSIZING)
 TextAutoSizing& Document::textAutoSizing()
 {

Modified: trunk/Source/WebCore/dom/Document.h (225989 => 225990)


--- trunk/Source/WebCore/dom/Document.h	2017-12-15 23:14:33 UTC (rev 225989)
+++ trunk/Source/WebCore/dom/Document.h	2017-12-16 00:00:09 UTC (rev 225990)
@@ -988,7 +988,6 @@
     // Extension for manipulating canvas drawing contexts for use in CSS
     std::optional<RenderingContext> getCSSCanvasContext(const String& type, const String& name, int width, int height);
     HTMLCanvasElement* getCSSCanvasElement(const String& name);
-    String nameForCSSCanvasElement(const HTMLCanvasElement&) const;
 
     bool isDNSPrefetchEnabled() const { return m_isDNSPrefetchEnabled; }
     void parseDNSPrefetchControlHeader(const String&);

Modified: trunk/Source/WebCore/html/HTMLCanvasElement.cpp (225989 => 225990)


--- trunk/Source/WebCore/html/HTMLCanvasElement.cpp	2017-12-15 23:14:33 UTC (rev 225989)
+++ trunk/Source/WebCore/html/HTMLCanvasElement.cpp	2017-12-16 00:00:09 UTC (rev 225990)
@@ -370,11 +370,13 @@
         return nullptr;
     }
 
-    m_context = CanvasRenderingContext2D::create(*this, document().inQuirksMode(), usesDashboardCompatibilityMode);
+    m_context = std::make_unique<CanvasRenderingContext2D>(*this, document().inQuirksMode(), usesDashboardCompatibilityMode);
 
     downcast<CanvasRenderingContext2D>(*m_context).setUsesDisplayListDrawing(m_usesDisplayListDrawing);
     downcast<CanvasRenderingContext2D>(*m_context).setTracksDisplayListReplay(m_tracksDisplayListReplay);
 
+    InspectorInstrumentation::didCreateCanvasRenderingContext(*this);
+
 #if USE(IOSURFACE_CANVAS_BACKING_STORE) || ENABLE(ACCELERATED_2D_CANVAS)
     // Need to make sure a RenderLayer and compositing layer get created for the Canvas.
     invalidateStyleAndLayerComposition();
@@ -439,6 +441,8 @@
     if (m_context) {
         // Need to make sure a RenderLayer and compositing layer get created for the Canvas.
         invalidateStyleAndLayerComposition();
+
+        InspectorInstrumentation::didCreateCanvasRenderingContext(*this);
     }
 
     return downcast<WebGLRenderingContextBase>(m_context.get());
@@ -480,6 +484,8 @@
     if (m_context) {
         // Need to make sure a RenderLayer and compositing layer get created for the Canvas.
         invalidateStyleAndLayerComposition();
+
+        InspectorInstrumentation::didCreateCanvasRenderingContext(*this);
     }
 
     return static_cast<WebGPURenderingContext*>(m_context.get());
@@ -511,8 +517,10 @@
     ASSERT_UNUSED(type, HTMLCanvasElement::isBitmapRendererType(type));
     ASSERT(!m_context);
 
-    m_context = ImageBitmapRenderingContext::create(*this, WTFMove(settings));
+    m_context = std::make_unique<ImageBitmapRenderingContext>(*this, WTFMove(settings));
 
+    InspectorInstrumentation::didCreateCanvasRenderingContext(*this);
+
 #if USE(IOSURFACE_CANVAS_BACKING_STORE) || ENABLE(ACCELERATED_2D_CANVAS)
     // Need to make sure a RenderLayer and compositing layer get created for the Canvas.
     invalidateStyleAndLayerComposition();
@@ -626,7 +634,7 @@
 void HTMLCanvasElement::paint(GraphicsContext& context, const LayoutRect& r)
 {
     if (UNLIKELY(m_context && m_context->callTracingActive()))
-        InspectorInstrumentation::didFinishRecordingCanvasFrame(*m_context);
+        InspectorInstrumentation::didFinishRecordingCanvasFrame(*this);
 
     // Clear the dirty rect
     m_dirtyRect = FloatRect();
@@ -981,8 +989,8 @@
     size_t currentMemoryCost = memoryCost();
     activePixelMemory += currentMemoryCost;
 
-    if (m_context && m_imageBuffer && previousMemoryCost != currentMemoryCost)
-        InspectorInstrumentation::didChangeCanvasMemory(*m_context);
+    if (m_imageBuffer && previousMemoryCost != currentMemoryCost)
+        InspectorInstrumentation::didChangeCanvasMemory(const_cast<HTMLCanvasElement&>(*this));
 }
 
 void HTMLCanvasElement::setImageBufferAndMarkDirty(std::unique_ptr<ImageBuffer>&& buffer)

Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext.cpp (225989 => 225990)


--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext.cpp	2017-12-15 23:14:33 UTC (rev 225989)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext.cpp	2017-12-16 00:00:09 UTC (rev 225990)
@@ -32,7 +32,6 @@
 #include "HTMLVideoElement.h"
 #include "Image.h"
 #include "ImageBitmap.h"
-#include "InspectorInstrumentation.h"
 #include "OffscreenCanvas.h"
 #include "URL.h"
 #include "SecurityOrigin.h"
@@ -44,11 +43,6 @@
 {
 }
 
-CanvasRenderingContext::~CanvasRenderingContext()
-{
-    InspectorInstrumentation::willDestroyCanvasRenderingContext(*this);
-}
-
 void CanvasRenderingContext::ref()
 {
     m_canvas.refCanvasBase();

Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext.h (225989 => 225990)


--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext.h	2017-12-15 23:14:33 UTC (rev 225989)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext.h	2017-12-16 00:00:09 UTC (rev 225990)
@@ -44,7 +44,7 @@
 class CanvasRenderingContext : public ScriptWrappable {
     WTF_MAKE_NONCOPYABLE(CanvasRenderingContext); WTF_MAKE_FAST_ALLOCATED;
 public:
-    virtual ~CanvasRenderingContext();
+    virtual ~CanvasRenderingContext() = default;
 
     void ref();
     void deref();

Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp (225989 => 225990)


--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp	2017-12-15 23:14:33 UTC (rev 225989)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp	2017-12-16 00:00:09 UTC (rev 225990)
@@ -42,7 +42,6 @@
 #include "ImageBitmap.h"
 #include "ImageBuffer.h"
 #include "ImageData.h"
-#include "InspectorInstrumentation.h"
 #include "Path2D.h"
 #include "RenderElement.h"
 #include "RenderImage.h"
@@ -68,15 +67,6 @@
 
 using namespace HTMLNames;
 
-std::unique_ptr<CanvasRenderingContext2D> CanvasRenderingContext2D::create(CanvasBase& canvas, bool usesCSSCompatibilityParseMode, bool usesDashboardCompatibilityMode)
-{
-    auto renderingContext = std::unique_ptr<CanvasRenderingContext2D>(new CanvasRenderingContext2D(canvas, usesCSSCompatibilityParseMode, usesDashboardCompatibilityMode));
-
-    InspectorInstrumentation::didCreateCanvasRenderingContext(*renderingContext);
-
-    return renderingContext;
-}
-
 CanvasRenderingContext2D::CanvasRenderingContext2D(CanvasBase& canvas, bool usesCSSCompatibilityParseMode, bool usesDashboardCompatibilityMode)
     : CanvasRenderingContext2DBase(canvas, usesCSSCompatibilityParseMode, usesDashboardCompatibilityMode)
 {

Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h (225989 => 225990)


--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h	2017-12-15 23:14:33 UTC (rev 225989)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h	2017-12-16 00:00:09 UTC (rev 225990)
@@ -30,7 +30,6 @@
 #include "CanvasTextBaseline.h"
 #include "FontCascade.h"
 #include "FontSelectorClient.h"
-#include <memory>
 
 namespace WebCore {
 
@@ -38,8 +37,7 @@
 
 class CanvasRenderingContext2D final : public CanvasRenderingContext2DBase {
 public:
-    static std::unique_ptr<CanvasRenderingContext2D> create(CanvasBase&, bool usesCSSCompatibilityParseMode, bool usesDashboardCompatibilityMode);
-
+    CanvasRenderingContext2D(CanvasBase&, bool usesCSSCompatibilityParseMode, bool usesDashboardCompatibilityMode);
     virtual ~CanvasRenderingContext2D();
 
     HTMLCanvasElement& canvas() const { return downcast<HTMLCanvasElement>(canvasBase()); }
@@ -68,8 +66,6 @@
     bool is2d() const override { return true; }
 
 private:
-    CanvasRenderingContext2D(CanvasBase&, bool usesCSSCompatibilityParseMode, bool usesDashboardCompatibilityMode);
-
     // The relationship between FontCascade and CanvasRenderingContext2D::FontProxy must hold certain invariants.
     // Therefore, all font operations must pass through the State.
     const FontProxy& fontProxy();

Modified: trunk/Source/WebCore/html/canvas/ImageBitmapRenderingContext.cpp (225989 => 225990)


--- trunk/Source/WebCore/html/canvas/ImageBitmapRenderingContext.cpp	2017-12-15 23:14:33 UTC (rev 225989)
+++ trunk/Source/WebCore/html/canvas/ImageBitmapRenderingContext.cpp	2017-12-16 00:00:09 UTC (rev 225990)
@@ -28,7 +28,6 @@
 
 #include "ImageBitmap.h"
 #include "ImageBuffer.h"
-#include "InspectorInstrumentation.h"
 
 namespace WebCore {
 
@@ -38,15 +37,6 @@
 static RenderingMode bufferRenderingMode = Unaccelerated;
 #endif
 
-std::unique_ptr<ImageBitmapRenderingContext> ImageBitmapRenderingContext::create(CanvasBase& canvas, ImageBitmapRenderingContextSettings&& settings)
-{
-    auto renderingContext = std::unique_ptr<ImageBitmapRenderingContext>(new ImageBitmapRenderingContext(canvas, WTFMove(settings)));
-
-    InspectorInstrumentation::didCreateCanvasRenderingContext(*renderingContext);
-
-    return renderingContext;
-}
-
 ImageBitmapRenderingContext::ImageBitmapRenderingContext(CanvasBase& canvas, ImageBitmapRenderingContextSettings&& settings)
     : CanvasRenderingContext(canvas)
     , m_settings(WTFMove(settings))

Modified: trunk/Source/WebCore/html/canvas/ImageBitmapRenderingContext.h (225989 => 225990)


--- trunk/Source/WebCore/html/canvas/ImageBitmapRenderingContext.h	2017-12-15 23:14:33 UTC (rev 225989)
+++ trunk/Source/WebCore/html/canvas/ImageBitmapRenderingContext.h	2017-12-16 00:00:09 UTC (rev 225990)
@@ -30,7 +30,6 @@
 #include "ExceptionOr.h"
 #include "ImageBitmapRenderingContextSettings.h"
 #include "ImageBufferData.h"
-#include <memory>
 #include <wtf/RefPtr.h>
 
 namespace WebCore {
@@ -40,7 +39,6 @@
 
 class ImageBitmapRenderingContext final : public CanvasRenderingContext {
 public:
-    static std::unique_ptr<ImageBitmapRenderingContext> create(CanvasBase&, ImageBitmapRenderingContextSettings&&);
 
     enum class BitmapMode {
         Valid,
@@ -47,6 +45,7 @@
         Blank
     };
 
+    ImageBitmapRenderingContext(CanvasBase&, ImageBitmapRenderingContextSettings&&);
     ~ImageBitmapRenderingContext();
 
     HTMLCanvasElement* canvas() const;
@@ -57,8 +56,6 @@
     bool hasAlpha() { return m_settings.alpha; }
 
 private:
-    ImageBitmapRenderingContext(CanvasBase&, ImageBitmapRenderingContextSettings&&);
-
     bool isBitmapRenderer() const final { return true; }
     bool isAccelerated() const override;
 

Modified: trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.cpp (225989 => 225990)


--- trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.cpp	2017-12-15 23:14:33 UTC (rev 225989)
+++ trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.cpp	2017-12-16 00:00:09 UTC (rev 225990)
@@ -60,24 +60,6 @@
 
 namespace WebCore {
 
-std::unique_ptr<WebGL2RenderingContext> WebGL2RenderingContext::create(CanvasBase& canvas, GraphicsContext3DAttributes attributes)
-{
-    auto renderingContext = std::unique_ptr<WebGL2RenderingContext>(new WebGL2RenderingContext(canvas, attributes));
-
-    InspectorInstrumentation::didCreateCanvasRenderingContext(*renderingContext);
-
-    return renderingContext;
-}
-
-std::unique_ptr<WebGL2RenderingContext> WebGL2RenderingContext::create(CanvasBase& canvas, Ref<GraphicsContext3D>&& context, GraphicsContext3DAttributes attributes)
-{
-    auto renderingContext = std::unique_ptr<WebGL2RenderingContext>(new WebGL2RenderingContext(canvas, WTFMove(context), attributes));
-
-    InspectorInstrumentation::didCreateCanvasRenderingContext(*renderingContext);
-
-    return renderingContext;
-}
-
 WebGL2RenderingContext::WebGL2RenderingContext(CanvasBase& canvas, GraphicsContext3DAttributes attributes)
     : WebGLRenderingContextBase(canvas, attributes)
 {

Modified: trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.h (225989 => 225990)


--- trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.h	2017-12-15 23:14:33 UTC (rev 225989)
+++ trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.h	2017-12-16 00:00:09 UTC (rev 225990)
@@ -28,7 +28,6 @@
 #if ENABLE(WEBGL2)
 
 #include "WebGLRenderingContextBase.h"
-#include <memory>
 
 namespace WebCore {
 
@@ -40,8 +39,8 @@
 
 class WebGL2RenderingContext final : public WebGLRenderingContextBase {
 public:
-    static std::unique_ptr<WebGL2RenderingContext> create(CanvasBase&, GraphicsContext3DAttributes);
-    static std::unique_ptr<WebGL2RenderingContext> create(CanvasBase&, Ref<GraphicsContext3D>&&, GraphicsContext3DAttributes);
+    WebGL2RenderingContext(CanvasBase&, WebGLContextAttributes);
+    WebGL2RenderingContext(CanvasBase&, Ref<GraphicsContext3D>&&, WebGLContextAttributes);
 
     // Buffer objects
     using WebGLRenderingContextBase::bufferData;
@@ -200,9 +199,6 @@
     void hint(GC3Denum target, GC3Denum mode) final;
 
 private:
-    WebGL2RenderingContext(CanvasBase&, GraphicsContext3DAttributes);
-    WebGL2RenderingContext(CanvasBase&, Ref<GraphicsContext3D>&&, GraphicsContext3DAttributes);
-
     bool isWebGL2() const final { return true; }
 
     void initializeVertexArrayObjects() final;

Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp (225989 => 225990)


--- trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp	2017-12-15 23:14:33 UTC (rev 225989)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp	2017-12-16 00:00:09 UTC (rev 225990)
@@ -66,24 +66,6 @@
 
 namespace WebCore {
 
-std::unique_ptr<WebGLRenderingContext> WebGLRenderingContext::create(CanvasBase& canvas, GraphicsContext3DAttributes attributes)
-{
-    auto renderingContext = std::unique_ptr<WebGLRenderingContext>(new WebGLRenderingContext(canvas, attributes));
-
-    InspectorInstrumentation::didCreateCanvasRenderingContext(*renderingContext);
-
-    return renderingContext;
-}
-
-std::unique_ptr<WebGLRenderingContext> WebGLRenderingContext::create(CanvasBase& canvas, Ref<GraphicsContext3D>&& context, GraphicsContext3DAttributes attributes)
-{
-    auto renderingContext = std::unique_ptr<WebGLRenderingContext>(new WebGLRenderingContext(canvas, WTFMove(context), attributes));
-
-    InspectorInstrumentation::didCreateCanvasRenderingContext(*renderingContext);
-
-    return renderingContext;
-}
-
 WebGLRenderingContext::WebGLRenderingContext(CanvasBase& canvas, GraphicsContext3DAttributes attributes)
     : WebGLRenderingContextBase(canvas, attributes)
 {

Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContext.h (225989 => 225990)


--- trunk/Source/WebCore/html/canvas/WebGLRenderingContext.h	2017-12-15 23:14:33 UTC (rev 225989)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContext.h	2017-12-16 00:00:09 UTC (rev 225990)
@@ -26,7 +26,6 @@
 #pragma once
 
 #include "WebGLRenderingContextBase.h"
-#include <memory>
 
 #if ENABLE(WEBGL)
 
@@ -34,8 +33,8 @@
 
 class WebGLRenderingContext final : public WebGLRenderingContextBase {
 public:
-    static std::unique_ptr<WebGLRenderingContext> create(CanvasBase&, GraphicsContext3DAttributes);
-    static std::unique_ptr<WebGLRenderingContext> create(CanvasBase&, Ref<GraphicsContext3D>&&, GraphicsContext3DAttributes);
+    WebGLRenderingContext(CanvasBase&, GraphicsContext3DAttributes);
+    WebGLRenderingContext(CanvasBase&, Ref<GraphicsContext3D>&&, GraphicsContext3DAttributes);
 
     bool isWebGL1() const final { return true; }
 
@@ -55,10 +54,6 @@
     bool validateIndexArrayConservative(GC3Denum type, unsigned& numElementsRequired) final;
     bool validateBlendEquation(const char* functionName, GC3Denum mode) final;
     bool validateCapability(const char* functionName, GC3Denum cap) final;
-
-private:
-    WebGLRenderingContext(CanvasBase&, GraphicsContext3DAttributes);
-    WebGLRenderingContext(CanvasBase&, Ref<GraphicsContext3D>&&, GraphicsContext3DAttributes);
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp (225989 => 225990)


--- trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp	2017-12-15 23:14:33 UTC (rev 225989)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp	2017-12-16 00:00:09 UTC (rev 225990)
@@ -438,10 +438,10 @@
         std::unique_ptr<WebGLRenderingContextBase> renderingContext = nullptr;
 #if ENABLE(WEBGL2)
         if (type == "webgl2")
-            renderingContext = WebGL2RenderingContext::create(canvas, attributes);
+            renderingContext = std::make_unique<WebGL2RenderingContext>(canvas, attributes);
         else
 #endif
-            renderingContext = WebGLRenderingContext::create(canvas, attributes);
+            renderingContext = std::make_unique<WebGLRenderingContext>(canvas, attributes);
         renderingContext->suspendIfNeeded();
         return renderingContext;
     }
@@ -467,10 +467,10 @@
     std::unique_ptr<WebGLRenderingContextBase> renderingContext;
 #if ENABLE(WEBGL2)
     if (type == "webgl2")
-        renderingContext = WebGL2RenderingContext::create(canvas, context.releaseNonNull(), attributes);
+        renderingContext = std::make_unique<WebGL2RenderingContext>(canvas, context.releaseNonNull(), attributes);
     else
 #endif
-        renderingContext = WebGLRenderingContext::create(canvas, context.releaseNonNull(), attributes);
+        renderingContext = std::make_unique<WebGLRenderingContext>(canvas, context.releaseNonNull(), attributes);
     renderingContext->suspendIfNeeded();
 
     return renderingContext;

Modified: trunk/Source/WebCore/html/canvas/WebGPURenderingContext.cpp (225989 => 225990)


--- trunk/Source/WebCore/html/canvas/WebGPURenderingContext.cpp	2017-12-15 23:14:33 UTC (rev 225989)
+++ trunk/Source/WebCore/html/canvas/WebGPURenderingContext.cpp	2017-12-16 00:00:09 UTC (rev 225990)
@@ -32,7 +32,6 @@
 #include "Document.h"
 #include "FrameView.h"
 #include "GPUDevice.h"
-#include "InspectorInstrumentation.h"
 #include "WebGPUBuffer.h"
 #include "WebGPUCommandQueue.h"
 #include "WebGPUComputePipelineState.h"
@@ -81,11 +80,10 @@
         return nullptr;
     }
 
-    auto renderingContext = std::unique_ptr<WebGPURenderingContext>(new WebGPURenderingContext(canvas, device.releaseNonNull()));
+    std::unique_ptr<WebGPURenderingContext> renderingContext = nullptr;
+    renderingContext = std::unique_ptr<WebGPURenderingContext>(new WebGPURenderingContext(canvas, device.releaseNonNull()));
     renderingContext->suspendIfNeeded();
 
-    InspectorInstrumentation::didCreateCanvasRenderingContext(*renderingContext);
-
     return renderingContext;
 }
 

Modified: trunk/Source/WebCore/inspector/InspectorCanvas.cpp (225989 => 225990)


--- trunk/Source/WebCore/inspector/InspectorCanvas.cpp	2017-12-15 23:14:33 UTC (rev 225989)
+++ trunk/Source/WebCore/inspector/InspectorCanvas.cpp	2017-12-16 00:00:09 UTC (rev 225990)
@@ -30,10 +30,10 @@
 #include "CachedImage.h"
 #include "CanvasGradient.h"
 #include "CanvasPattern.h"
-#include "CanvasRenderingContext.h"
 #include "CanvasRenderingContext2D.h"
 #include "Document.h"
 #include "FloatPoint.h"
+#include "Frame.h"
 #include "Gradient.h"
 #include "HTMLCanvasElement.h"
 #include "HTMLImageElement.h"
@@ -44,6 +44,7 @@
 #include "ImageBuffer.h"
 #include "ImageData.h"
 #include "InspectorDOMAgent.h"
+#include "InspectorPageAgent.h"
 #include "InstrumentingAgents.h"
 #include "JSCanvasDirection.h"
 #include "JSCanvasFillRule.h"
@@ -77,14 +78,15 @@
 
 using namespace Inspector;
 
-Ref<InspectorCanvas> InspectorCanvas::create(CanvasRenderingContext& context)
+Ref<InspectorCanvas> InspectorCanvas::create(HTMLCanvasElement& canvas, const String& cssCanvasName)
 {
-    return adoptRef(*new InspectorCanvas(context));
+    return adoptRef(*new InspectorCanvas(canvas, cssCanvasName));
 }
 
-InspectorCanvas::InspectorCanvas(CanvasRenderingContext& context)
+InspectorCanvas::InspectorCanvas(HTMLCanvasElement& canvas, const String& cssCanvasName)
     : m_identifier("canvas:" + IdentifiersFactory::createIdentifier())
-    , m_context(context)
+    , m_canvas(canvas)
+    , m_cssCanvasName(cssCanvasName)
 {
 }
 
@@ -93,13 +95,6 @@
     resetRecordingData();
 }
 
-HTMLCanvasElement* InspectorCanvas::canvasElement()
-{
-    if (is<HTMLCanvasElement>(m_context.canvasBase()))
-        return downcast<HTMLCanvasElement>(&m_context.canvasBase());
-    return nullptr;
-}
-
 void InspectorCanvas::resetRecordingData()
 {
     m_initialState = nullptr;
@@ -113,7 +108,7 @@
     m_bufferUsed = 0;
     m_singleFrame = true;
 
-    m_context.setCallTracingActive(false);
+    m_canvas.renderingContext()->setCallTracingActive(false);
 }
 
 bool InspectorCanvas::hasRecordingData() const
@@ -162,7 +157,7 @@
     m_currentActions->addItem(action);
 
 #if ENABLE(WEBGL)
-    if (is<WebGLRenderingContext>(m_context) && shouldSnapshotWebGLAction(name))
+    if (is<WebGLRenderingContext>(m_canvas.renderingContext()) && shouldSnapshotWebGLAction(name))
         m_actionNeedingSnapshot = action;
 #endif
 }
@@ -217,21 +212,25 @@
 
 Ref<Inspector::Protocol::Canvas::Canvas> InspectorCanvas::buildObjectForCanvas(InstrumentingAgents& instrumentingAgents, bool captureBacktrace)
 {
+    Document& document = m_canvas.document();
+    Frame* frame = document.frame();
+    CanvasRenderingContext* context = m_canvas.renderingContext();
+
     Inspector::Protocol::Canvas::ContextType contextType;
-    if (is<CanvasRenderingContext2D>(m_context))
+    if (is<CanvasRenderingContext2D>(context))
         contextType = Inspector::Protocol::Canvas::ContextType::Canvas2D;
-    else if (is<ImageBitmapRenderingContext>(m_context))
+    else if (is<ImageBitmapRenderingContext>(context))
         contextType = Inspector::Protocol::Canvas::ContextType::BitmapRenderer;
 #if ENABLE(WEBGL)
-    else if (is<WebGLRenderingContext>(m_context))
+    else if (is<WebGLRenderingContext>(context))
         contextType = Inspector::Protocol::Canvas::ContextType::WebGL;
 #endif
 #if ENABLE(WEBGL2)
-    else if (is<WebGL2RenderingContext>(m_context))
+    else if (is<WebGL2RenderingContext>(context))
         contextType = Inspector::Protocol::Canvas::ContextType::WebGL2;
 #endif
 #if ENABLE(WEBGPU)
-    else if (is<WebGPURenderingContext>(m_context))
+    else if (is<WebGPURenderingContext>(context))
         contextType = Inspector::Protocol::Canvas::ContextType::WebGPU;
 #endif
     else {
@@ -241,37 +240,35 @@
 
     auto canvas = Inspector::Protocol::Canvas::Canvas::create()
         .setCanvasId(m_identifier)
+        .setFrameId(instrumentingAgents.inspectorPageAgent()->frameId(frame))
         .setContextType(contextType)
         .release();
 
-    if (auto* node = canvasElement()) {
-        String cssCanvasName = node->document().nameForCSSCanvasElement(*node);
-        if (!cssCanvasName.isEmpty())
-            canvas->setCssCanvasName(cssCanvasName);
-        else {
-            InspectorDOMAgent* domAgent = instrumentingAgents.inspectorDOMAgent();
-            int nodeId = domAgent->boundNodeId(node);
-            if (!nodeId) {
-                if (int documentNodeId = domAgent->boundNodeId(&node->document())) {
-                    ErrorString ignored;
-                    nodeId = domAgent->pushNodeToFrontend(ignored, documentNodeId, node);
-                }
+    if (!m_cssCanvasName.isEmpty())
+        canvas->setCssCanvasName(m_cssCanvasName);
+    else {
+        InspectorDOMAgent* domAgent = instrumentingAgents.inspectorDOMAgent();
+        int nodeId = domAgent->boundNodeId(&m_canvas);
+        if (!nodeId) {
+            if (int documentNodeId = domAgent->boundNodeId(&m_canvas.document())) {
+                ErrorString ignored;
+                nodeId = domAgent->pushNodeToFrontend(ignored, documentNodeId, &m_canvas);
             }
+        }
 
-            if (nodeId)
-                canvas->setNodeId(nodeId);
-        }
+        if (nodeId)
+            canvas->setNodeId(nodeId);
     }
 
-    if (is<ImageBitmapRenderingContext>(m_context)) {
+    if (is<ImageBitmapRenderingContext>(context)) {
         auto contextAttributes = Inspector::Protocol::Canvas::ContextAttributes::create()
             .release();
-        contextAttributes->setAlpha(downcast<ImageBitmapRenderingContext>(m_context).hasAlpha());
+        contextAttributes->setAlpha(downcast<ImageBitmapRenderingContext>(context)->hasAlpha());
         canvas->setContextAttributes(WTFMove(contextAttributes));
     }
 #if ENABLE(WEBGL)
-    else if (is<WebGLRenderingContextBase>(m_context)) {
-        if (std::optional<WebGLContextAttributes> attributes = downcast<WebGLRenderingContextBase>(m_context).getContextAttributes()) {
+    else if (is<WebGLRenderingContextBase>(context)) {
+        if (std::optional<WebGLContextAttributes> attributes = downcast<WebGLRenderingContextBase>(context)->getContextAttributes()) {
             auto contextAttributes = Inspector::Protocol::Canvas::ContextAttributes::create()
                 .release();
             contextAttributes->setAlpha(attributes->alpha);
@@ -286,13 +283,9 @@
     }
 #endif
 
-    // FIXME: <https://webkit.org/b/180833> Web Inspector: support OffscreenCanvas for Canvas related operations
+    if (size_t memoryCost = m_canvas.memoryCost())
+        canvas->setMemoryCost(memoryCost);
 
-    if (auto* node = canvasElement()) {
-        if (size_t memoryCost = node->memoryCost())
-            canvas->setMemoryCost(memoryCost);
-    }
-
     if (captureBacktrace) {
         auto stackTrace = Inspector::createScriptCallStack(JSMainThreadExecState::currentState(), Inspector::ScriptCallStack::maxCallStackSizeToCapture);
         canvas->setBacktrace(stackTrace->buildInspectorArray());
@@ -312,22 +305,17 @@
 
 String InspectorCanvas::getCanvasContentAsDataURL()
 {
-    // FIXME: <https://webkit.org/b/180833> Web Inspector: support OffscreenCanvas for Canvas related operations
-
-    auto* node = canvasElement();
-    if (!node)
-        return String();
-
 #if ENABLE(WEBGL)
-    if (is<WebGLRenderingContextBase>(m_context))
-        downcast<WebGLRenderingContextBase>(m_context).setPreventBufferClearForInspector(true);
+    CanvasRenderingContext* canvasRenderingContext = m_canvas.renderingContext();
+    if (is<WebGLRenderingContextBase>(canvasRenderingContext))
+        downcast<WebGLRenderingContextBase>(canvasRenderingContext)->setPreventBufferClearForInspector(true);
 #endif
 
-    ExceptionOr<UncachedString> result = node->toDataURL(ASCIILiteral("image/png"));
+    ExceptionOr<UncachedString> result = m_canvas.toDataURL(ASCIILiteral("image/png"));
 
 #if ENABLE(WEBGL)
-    if (is<WebGLRenderingContextBase>(m_context))
-        downcast<WebGLRenderingContextBase>(m_context).setPreventBufferClearForInspector(false);
+    if (is<WebGLRenderingContextBase>(canvasRenderingContext))
+        downcast<WebGLRenderingContextBase>(canvasRenderingContext)->setPreventBufferClearForInspector(false);
 #endif
 
     if (result.hasException())
@@ -443,26 +431,27 @@
         .release();
 
     auto attributes = JSON::Object::create();
-    attributes->setInteger(ASCIILiteral("width"), m_context.canvasBase().width());
-    attributes->setInteger(ASCIILiteral("height"), m_context.canvasBase().height());
+    attributes->setInteger(ASCIILiteral("width"), canvas().width());
+    attributes->setInteger(ASCIILiteral("height"), canvas().height());
 
     auto parameters = JSON::ArrayOf<JSON::Value>::create();
 
-    if (is<CanvasRenderingContext2D>(m_context)) {
-        const CanvasRenderingContext2D& context2d = downcast<CanvasRenderingContext2D>(m_context);
-        const CanvasRenderingContext2D::State& state = context2d.state();
+    CanvasRenderingContext* canvasRenderingContext = canvas().renderingContext();
+    if (is<CanvasRenderingContext2D>(canvasRenderingContext)) {
+        const CanvasRenderingContext2D* context2d = downcast<CanvasRenderingContext2D>(canvasRenderingContext);
+        const CanvasRenderingContext2D::State& state = context2d->state();
 
         attributes->setArray(ASCIILiteral("setTransform"), buildArrayForAffineTransform(state.transform));
-        attributes->setDouble(ASCIILiteral("globalAlpha"), context2d.globalAlpha());
-        attributes->setInteger(ASCIILiteral("globalCompositeOperation"), indexForData(context2d.globalCompositeOperation()));
-        attributes->setDouble(ASCIILiteral("lineWidth"), context2d.lineWidth());
-        attributes->setInteger(ASCIILiteral("lineCap"), indexForData(convertEnumerationToString(context2d.lineCap())));
-        attributes->setInteger(ASCIILiteral("lineJoin"), indexForData(convertEnumerationToString(context2d.lineJoin())));
-        attributes->setDouble(ASCIILiteral("miterLimit"), context2d.miterLimit());
-        attributes->setDouble(ASCIILiteral("shadowOffsetX"), context2d.shadowOffsetX());
-        attributes->setDouble(ASCIILiteral("shadowOffsetY"), context2d.shadowOffsetY());
-        attributes->setDouble(ASCIILiteral("shadowBlur"), context2d.shadowBlur());
-        attributes->setInteger(ASCIILiteral("shadowColor"), indexForData(context2d.shadowColor()));
+        attributes->setDouble(ASCIILiteral("globalAlpha"), context2d->globalAlpha());
+        attributes->setInteger(ASCIILiteral("globalCompositeOperation"), indexForData(context2d->globalCompositeOperation()));
+        attributes->setDouble(ASCIILiteral("lineWidth"), context2d->lineWidth());
+        attributes->setInteger(ASCIILiteral("lineCap"), indexForData(convertEnumerationToString(context2d->lineCap())));
+        attributes->setInteger(ASCIILiteral("lineJoin"), indexForData(convertEnumerationToString(context2d->lineJoin())));
+        attributes->setDouble(ASCIILiteral("miterLimit"), context2d->miterLimit());
+        attributes->setDouble(ASCIILiteral("shadowOffsetX"), context2d->shadowOffsetX());
+        attributes->setDouble(ASCIILiteral("shadowOffsetY"), context2d->shadowOffsetY());
+        attributes->setDouble(ASCIILiteral("shadowBlur"), context2d->shadowBlur());
+        attributes->setInteger(ASCIILiteral("shadowColor"), indexForData(context2d->shadowColor()));
 
         // The parameter to `setLineDash` is itself an array, so we need to wrap the parameters
         // list in an array to allow spreading.
@@ -470,11 +459,11 @@
         setLineDash->addItem(buildArrayForVector(state.lineDash));
         attributes->setArray(ASCIILiteral("setLineDash"), WTFMove(setLineDash));
 
-        attributes->setDouble(ASCIILiteral("lineDashOffset"), context2d.lineDashOffset());
-        attributes->setInteger(ASCIILiteral("font"), indexForData(context2d.font()));
-        attributes->setInteger(ASCIILiteral("textAlign"), indexForData(convertEnumerationToString(context2d.textAlign())));
-        attributes->setInteger(ASCIILiteral("textBaseline"), indexForData(convertEnumerationToString(context2d.textBaseline())));
-        attributes->setInteger(ASCIILiteral("direction"), indexForData(convertEnumerationToString(context2d.direction())));
+        attributes->setDouble(ASCIILiteral("lineDashOffset"), context2d->lineDashOffset());
+        attributes->setInteger(ASCIILiteral("font"), indexForData(context2d->font()));
+        attributes->setInteger(ASCIILiteral("textAlign"), indexForData(convertEnumerationToString(context2d->textAlign())));
+        attributes->setInteger(ASCIILiteral("textBaseline"), indexForData(convertEnumerationToString(context2d->textBaseline())));
+        attributes->setInteger(ASCIILiteral("direction"), indexForData(convertEnumerationToString(context2d->direction())));
 
         int strokeStyleIndex;
         if (auto canvasGradient = state.strokeStyle.canvasGradient())
@@ -494,17 +483,17 @@
             fillStyleIndex = indexForData(state.fillStyle.color());
         attributes->setInteger(ASCIILiteral("fillStyle"), fillStyleIndex);
 
-        attributes->setBoolean(ASCIILiteral("imageSmoothingEnabled"), context2d.imageSmoothingEnabled());
-        attributes->setInteger(ASCIILiteral("imageSmoothingQuality"), indexForData(convertEnumerationToString(context2d.imageSmoothingQuality())));
+        attributes->setBoolean(ASCIILiteral("imageSmoothingEnabled"), context2d->imageSmoothingEnabled());
+        attributes->setInteger(ASCIILiteral("imageSmoothingQuality"), indexForData(convertEnumerationToString(context2d->imageSmoothingQuality())));
 
         auto setPath = JSON::ArrayOf<JSON::Value>::create();
-        setPath->addItem(indexForData(buildStringFromPath(context2d.getPath()->path())));
+        setPath->addItem(indexForData(buildStringFromPath(context2d->getPath()->path())));
         attributes->setArray(ASCIILiteral("setPath"), WTFMove(setPath));
     }
 #if ENABLE(WEBGL)
-    else if (is<WebGLRenderingContextBase>(m_context)) {
-        WebGLRenderingContextBase& contextWebGLBase = downcast<WebGLRenderingContextBase>(m_context);
-        if (std::optional<WebGLContextAttributes> attributes = contextWebGLBase.getContextAttributes()) {
+    else if (is<WebGLRenderingContextBase>(canvasRenderingContext)) {
+        WebGLRenderingContextBase* contextWebGLBase = downcast<WebGLRenderingContextBase>(canvasRenderingContext);
+        if (std::optional<WebGLContextAttributes> attributes = contextWebGLBase->getContextAttributes()) {
             RefPtr<JSON::Object> contextAttributes = JSON::Object::create();
             contextAttributes->setBoolean(ASCIILiteral("alpha"), attributes->alpha);
             contextAttributes->setBoolean(ASCIILiteral("depth"), attributes->depth);

Modified: trunk/Source/WebCore/inspector/InspectorCanvas.h (225989 => 225990)


--- trunk/Source/WebCore/inspector/InspectorCanvas.h	2017-12-15 23:14:33 UTC (rev 225989)
+++ trunk/Source/WebCore/inspector/InspectorCanvas.h	2017-12-16 00:00:09 UTC (rev 225990)
@@ -39,7 +39,6 @@
 
 class CanvasGradient;
 class CanvasPattern;
-class CanvasRenderingContext;
 class HTMLCanvasElement;
 class HTMLImageElement;
 class HTMLVideoElement;
@@ -51,13 +50,12 @@
 
 class InspectorCanvas final : public RefCounted<InspectorCanvas> {
 public:
-    static Ref<InspectorCanvas> create(CanvasRenderingContext&);
+    static Ref<InspectorCanvas> create(HTMLCanvasElement&, const String& cssCanvasName);
 
     const String& identifier() { return m_identifier; }
-    CanvasRenderingContext& context() { return m_context; }
+    HTMLCanvasElement& canvas() { return m_canvas; }
+    const String& cssCanvasName() { return m_cssCanvasName; }
 
-    HTMLCanvasElement* canvasElement();
-
     void resetRecordingData();
     bool hasRecordingData() const;
     bool currentFrameHasData() const;
@@ -85,7 +83,7 @@
     ~InspectorCanvas();
 
 private:
-    InspectorCanvas(CanvasRenderingContext&);
+    InspectorCanvas(HTMLCanvasElement&, const String& cssCanvasName);
     void appendActionSnapshotIfNeeded();
     String getCanvasContentAsDataURL();
 
@@ -111,7 +109,8 @@
     RefPtr<JSON::ArrayOf<JSON::Value>> buildArrayForImageData(const ImageData&);
 
     String m_identifier;
-    CanvasRenderingContext& m_context;
+    HTMLCanvasElement& m_canvas;
+    String m_cssCanvasName;
 
     RefPtr<Inspector::Protocol::Recording::InitialState> m_initialState;
     RefPtr<JSON::ArrayOf<Inspector::Protocol::Recording::Frame>> m_frames;

Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp (225989 => 225990)


--- trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp	2017-12-15 23:14:33 UTC (rev 225989)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp	2017-12-16 00:00:09 UTC (rev 225990)
@@ -874,10 +874,10 @@
         timelineAgent->stopFromConsole(exec, title);
 }
 
-void InspectorInstrumentation::consoleStartRecordingCanvasImpl(InstrumentingAgents& instrumentingAgents, CanvasRenderingContext& context, JSC::ExecState& exec, JSC::JSObject* options)
+void InspectorInstrumentation::consoleStartRecordingCanvasImpl(InstrumentingAgents& instrumentingAgents, HTMLCanvasElement& canvasElement, JSC::ExecState& exec, JSC::JSObject* options)
 {
     if (InspectorCanvasAgent* canvasAgent = instrumentingAgents.inspectorCanvasAgent())
-        canvasAgent->consoleStartRecordingCanvas(context, exec, options);
+        canvasAgent->consoleStartRecordingCanvas(canvasElement, exec, options);
 }
 
 void InspectorInstrumentation::didOpenDatabaseImpl(InstrumentingAgents& instrumentingAgents, RefPtr<Database>&& database, const String& domain, const String& name, const String& version)
@@ -958,28 +958,28 @@
         networkAgent->didSendWebSocketFrame(identifier, frame);
 }
 
-void InspectorInstrumentation::didChangeCSSCanvasClientNodesImpl(InstrumentingAgents& instrumentingAgents, HTMLCanvasElement& canvasElement)
+void InspectorInstrumentation::didCreateCSSCanvasImpl(InstrumentingAgents& instrumentingAgents, HTMLCanvasElement& canvasElement, const String& name)
 {
     if (InspectorCanvasAgent* canvasAgent = instrumentingAgents.inspectorCanvasAgent())
-        canvasAgent->didChangeCSSCanvasClientNodes(canvasElement);
+        canvasAgent->didCreateCSSCanvas(canvasElement, name);
 }
 
-void InspectorInstrumentation::didCreateCanvasRenderingContextImpl(InstrumentingAgents& instrumentingAgents, CanvasRenderingContext& context)
+void InspectorInstrumentation::didChangeCSSCanvasClientNodesImpl(InstrumentingAgents& instrumentingAgents, HTMLCanvasElement& canvasElement)
 {
     if (InspectorCanvasAgent* canvasAgent = instrumentingAgents.inspectorCanvasAgent())
-        canvasAgent->didCreateCanvasRenderingContext(context);
+        canvasAgent->didChangeCSSCanvasClientNodes(canvasElement);
 }
 
-void InspectorInstrumentation::willDestroyCanvasRenderingContextImpl(InstrumentingAgents& instrumentingAgents, CanvasRenderingContext& context)
+void InspectorInstrumentation::didCreateCanvasRenderingContextImpl(InstrumentingAgents& instrumentingAgents, HTMLCanvasElement& canvasElement)
 {
     if (InspectorCanvasAgent* canvasAgent = instrumentingAgents.inspectorCanvasAgent())
-        canvasAgent->willDestroyCanvasRenderingContext(context);
+        canvasAgent->didCreateCanvasRenderingContext(canvasElement);
 }
 
-void InspectorInstrumentation::didChangeCanvasMemoryImpl(InstrumentingAgents& instrumentingAgents, CanvasRenderingContext& context)
+void InspectorInstrumentation::didChangeCanvasMemoryImpl(InstrumentingAgents& instrumentingAgents, HTMLCanvasElement& canvasElement)
 {
     if (InspectorCanvasAgent* canvasAgent = instrumentingAgents.inspectorCanvasAgent())
-        canvasAgent->didChangeCanvasMemory(context);
+        canvasAgent->didChangeCanvasMemory(canvasElement);
 }
 
 void InspectorInstrumentation::recordCanvasActionImpl(InstrumentingAgents& instrumentingAgents, CanvasRenderingContext& canvasRenderingContext, const String& name, Vector<RecordCanvasActionVariant>&& parameters)
@@ -988,23 +988,23 @@
         canvasAgent->recordCanvasAction(canvasRenderingContext, name, WTFMove(parameters));
 }
 
-void InspectorInstrumentation::didFinishRecordingCanvasFrameImpl(InstrumentingAgents& instrumentingAgents, CanvasRenderingContext& context, bool forceDispatch)
+void InspectorInstrumentation::didFinishRecordingCanvasFrameImpl(InstrumentingAgents& instrumentingAgents, HTMLCanvasElement& canvasElement, bool forceDispatch)
 {
     if (InspectorCanvasAgent* canvasAgent = instrumentingAgents.inspectorCanvasAgent())
-        canvasAgent->didFinishRecordingCanvasFrame(context, forceDispatch);
+        canvasAgent->didFinishRecordingCanvasFrame(canvasElement, forceDispatch);
 }
 
 #if ENABLE(WEBGL)
-void InspectorInstrumentation::didEnableExtensionImpl(InstrumentingAgents& instrumentingAgents, WebGLRenderingContextBase& contextWebGLBase, const String& extension)
+void InspectorInstrumentation::didEnableExtensionImpl(InstrumentingAgents& instrumentingAgents, WebGLRenderingContextBase& context, const String& extension)
 {
     if (InspectorCanvasAgent* canvasAgent = instrumentingAgents.inspectorCanvasAgent())
-        canvasAgent->didEnableExtension(contextWebGLBase, extension);
+        canvasAgent->didEnableExtension(context, extension);
 }
 
-void InspectorInstrumentation::didCreateProgramImpl(InstrumentingAgents& instrumentingAgents, WebGLRenderingContextBase& contextWebGLBase, WebGLProgram& program)
+void InspectorInstrumentation::didCreateProgramImpl(InstrumentingAgents& instrumentingAgents, WebGLRenderingContextBase& context, WebGLProgram& program)
 {
     if (InspectorCanvasAgent* canvasAgent = instrumentingAgents.inspectorCanvasAgent())
-        canvasAgent->didCreateProgram(contextWebGLBase, program);
+        canvasAgent->didCreateProgram(context, program);
 }
 
 void InspectorInstrumentation::willDeleteProgramImpl(InstrumentingAgents& instrumentingAgents, WebGLProgram& program)

Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.h (225989 => 225990)


--- trunk/Source/WebCore/inspector/InspectorInstrumentation.h	2017-12-15 23:14:33 UTC (rev 225989)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.h	2017-12-16 00:00:09 UTC (rev 225990)
@@ -225,7 +225,7 @@
     static void consoleTimeStamp(Frame&, Ref<Inspector::ScriptArguments>&&);
     static void startProfiling(Page&, JSC::ExecState*, const String& title);
     static void stopProfiling(Page&, JSC::ExecState*, const String& title);
-    static void consoleStartRecordingCanvas(CanvasRenderingContext&, JSC::ExecState&, JSC::JSObject* options);
+    static void consoleStartRecordingCanvas(HTMLCanvasElement&, JSC::ExecState&, JSC::JSObject* options);
 
     static void didRequestAnimationFrame(Document&, int callbackId);
     static void didCancelAnimationFrame(Document&, int callbackId);
@@ -252,12 +252,12 @@
     static void didHandleMemoryPressure(Page&, Critical);
 #endif
 
+    static void didCreateCSSCanvas(HTMLCanvasElement&, const String&);
     static void didChangeCSSCanvasClientNodes(HTMLCanvasElement&);
-    static void didCreateCanvasRenderingContext(CanvasRenderingContext&);
-    static void willDestroyCanvasRenderingContext(CanvasRenderingContext&);
-    static void didChangeCanvasMemory(CanvasRenderingContext&);
+    static void didCreateCanvasRenderingContext(HTMLCanvasElement&);
+    static void didChangeCanvasMemory(HTMLCanvasElement&);
     static void recordCanvasAction(CanvasRenderingContext&, const String&, Vector<RecordCanvasActionVariant>&& = { });
-    static void didFinishRecordingCanvasFrame(CanvasRenderingContext&, bool forceDispatch = false);
+    static void didFinishRecordingCanvasFrame(HTMLCanvasElement&, bool forceDispatch = false);
 #if ENABLE(WEBGL)
     static void didEnableExtension(WebGLRenderingContextBase&, const String&);
     static void didCreateProgram(WebGLRenderingContextBase&, WebGLProgram&);
@@ -393,7 +393,7 @@
     static void consoleTimeStampImpl(InstrumentingAgents&, Frame&, Ref<Inspector::ScriptArguments>&&);
     static void startProfilingImpl(InstrumentingAgents&, JSC::ExecState*, const String& title);
     static void stopProfilingImpl(InstrumentingAgents&, JSC::ExecState*, const String& title);
-    static void consoleStartRecordingCanvasImpl(InstrumentingAgents&, CanvasRenderingContext&, JSC::ExecState&, JSC::JSObject* options);
+    static void consoleStartRecordingCanvasImpl(InstrumentingAgents&, HTMLCanvasElement&, JSC::ExecState&, JSC::JSObject* options);
 
     static void didRequestAnimationFrameImpl(InstrumentingAgents&, int callbackId, Document&);
     static void didCancelAnimationFrameImpl(InstrumentingAgents&, int callbackId, Document&);
@@ -423,12 +423,12 @@
     static void networkStateChangedImpl(InstrumentingAgents&);
     static void updateApplicationCacheStatusImpl(InstrumentingAgents&, Frame&);
 
+    static void didCreateCSSCanvasImpl(InstrumentingAgents&, HTMLCanvasElement&, const String&);
     static void didChangeCSSCanvasClientNodesImpl(InstrumentingAgents&, HTMLCanvasElement&);
-    static void didCreateCanvasRenderingContextImpl(InstrumentingAgents&, CanvasRenderingContext&);
-    static void willDestroyCanvasRenderingContextImpl(InstrumentingAgents&, CanvasRenderingContext&);
-    static void didChangeCanvasMemoryImpl(InstrumentingAgents&, CanvasRenderingContext&);
+    static void didCreateCanvasRenderingContextImpl(InstrumentingAgents&, HTMLCanvasElement&);
+    static void didChangeCanvasMemoryImpl(InstrumentingAgents&, HTMLCanvasElement&);
     static void recordCanvasActionImpl(InstrumentingAgents&, CanvasRenderingContext&, const String&, Vector<RecordCanvasActionVariant>&& = { });
-    static void didFinishRecordingCanvasFrameImpl(InstrumentingAgents&, CanvasRenderingContext&, bool forceDispatch = false);
+    static void didFinishRecordingCanvasFrameImpl(InstrumentingAgents&, HTMLCanvasElement&, bool forceDispatch = false);
 #if ENABLE(WEBGL)
     static void didEnableExtensionImpl(InstrumentingAgents&, WebGLRenderingContextBase&, const String&);
     static void didCreateProgramImpl(InstrumentingAgents&, WebGLRenderingContextBase&, WebGLProgram&);
@@ -1201,6 +1201,12 @@
 }
 #endif
 
+inline void InspectorInstrumentation::didCreateCSSCanvas(HTMLCanvasElement& canvasElement, const String& name)
+{
+    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(&canvasElement.document()))
+        didCreateCSSCanvasImpl(*instrumentingAgents, canvasElement, name);
+}
+
 inline void InspectorInstrumentation::didChangeCSSCanvasClientNodes(HTMLCanvasElement& canvasElement)
 {
     FAST_RETURN_IF_NO_FRONTENDS(void());
@@ -1208,65 +1214,92 @@
         didChangeCSSCanvasClientNodesImpl(*instrumentingAgents, canvasElement);
 }
 
-inline void InspectorInstrumentation::didCreateCanvasRenderingContext(CanvasRenderingContext& context)
+inline void InspectorInstrumentation::didCreateCanvasRenderingContext(HTMLCanvasElement& canvasElement)
 {
-    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context.canvasBase().scriptExecutionContext()))
-        didCreateCanvasRenderingContextImpl(*instrumentingAgents, context);
+    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(&canvasElement.document()))
+        didCreateCanvasRenderingContextImpl(*instrumentingAgents, canvasElement);
 }
 
-inline void InspectorInstrumentation::willDestroyCanvasRenderingContext(CanvasRenderingContext& context)
+inline void InspectorInstrumentation::didChangeCanvasMemory(HTMLCanvasElement& canvasElement)
 {
-    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context.canvasBase().scriptExecutionContext()))
-        willDestroyCanvasRenderingContextImpl(*instrumentingAgents, context);
-}
-
-inline void InspectorInstrumentation::didChangeCanvasMemory(CanvasRenderingContext& context)
-{
     FAST_RETURN_IF_NO_FRONTENDS(void());
-    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context.canvasBase().scriptExecutionContext()))
-        didChangeCanvasMemoryImpl(*instrumentingAgents, context);
+    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(&canvasElement.document()))
+        didChangeCanvasMemoryImpl(*instrumentingAgents, canvasElement);
 }
 
-inline void InspectorInstrumentation::recordCanvasAction(CanvasRenderingContext& context, const String& name, Vector<RecordCanvasActionVariant>&& parameters)
+inline void InspectorInstrumentation::recordCanvasAction(CanvasRenderingContext& canvasRenderingContext, const String& name, Vector<RecordCanvasActionVariant>&& parameters)
 {
     FAST_RETURN_IF_NO_FRONTENDS(void());
-    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context.canvasBase().scriptExecutionContext()))
-        recordCanvasActionImpl(*instrumentingAgents, context, name, WTFMove(parameters));
+    auto& canvasBase = canvasRenderingContext.canvasBase();
+    auto* canvasElement = is<HTMLCanvasElement>(canvasBase) ? &downcast<HTMLCanvasElement>(canvasBase) : nullptr;
+    if (canvasElement) {
+        if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(&canvasElement->document()))
+            recordCanvasActionImpl(*instrumentingAgents, canvasRenderingContext, name, WTFMove(parameters));
+    }
 }
 
-inline void InspectorInstrumentation::didFinishRecordingCanvasFrame(CanvasRenderingContext& context, bool forceDispatch)
+inline void InspectorInstrumentation::didFinishRecordingCanvasFrame(HTMLCanvasElement& canvasElement, bool forceDispatch)
 {
     FAST_RETURN_IF_NO_FRONTENDS(void());
-    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context.canvasBase().scriptExecutionContext()))
-        didFinishRecordingCanvasFrameImpl(*instrumentingAgents, context, forceDispatch);
+    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(&canvasElement.document()))
+        didFinishRecordingCanvasFrameImpl(*instrumentingAgents, canvasElement, forceDispatch);
 }
 
 #if ENABLE(WEBGL)
-inline void InspectorInstrumentation::didEnableExtension(WebGLRenderingContextBase& contextWebGLBase, const String& extension)
+inline void InspectorInstrumentation::didEnableExtension(WebGLRenderingContextBase& context, const String& extension)
 {
     FAST_RETURN_IF_NO_FRONTENDS(void());
-    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(contextWebGLBase.canvasBase().scriptExecutionContext()))
-        didEnableExtensionImpl(*instrumentingAgents, contextWebGLBase, extension);
+    auto canvas = context.canvas();
+    WTF::switchOn(canvas,
+        [&] (const RefPtr<HTMLCanvasElement>& htmlCanvasElement) {
+            if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(htmlCanvasElement->document()))
+                didEnableExtensionImpl(*instrumentingAgents, context, extension);
+        },
+        [&] (const RefPtr<OffscreenCanvas>&) {
+        }
+    );
 }
 
-inline void InspectorInstrumentation::didCreateProgram(WebGLRenderingContextBase& contextWebGLBase, WebGLProgram& program)
+inline void InspectorInstrumentation::didCreateProgram(WebGLRenderingContextBase& context, WebGLProgram& program)
 {
-    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(contextWebGLBase.canvasBase().scriptExecutionContext()))
-        didCreateProgramImpl(*instrumentingAgents, contextWebGLBase, program);
+    auto canvas = context.canvas();
+    WTF::switchOn(canvas,
+        [&] (const RefPtr<HTMLCanvasElement>& htmlCanvasElement) {
+            if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(htmlCanvasElement->document()))
+                didCreateProgramImpl(*instrumentingAgents, context, program);
+        },
+        [&] (const RefPtr<OffscreenCanvas>&) {
+        }
+    );
 }
 
-inline void InspectorInstrumentation::willDeleteProgram(WebGLRenderingContextBase& contextWebGLBase, WebGLProgram& program)
+inline void InspectorInstrumentation::willDeleteProgram(WebGLRenderingContextBase& context, WebGLProgram& program)
 {
-    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(contextWebGLBase.canvasBase().scriptExecutionContext()))
-        willDeleteProgramImpl(*instrumentingAgents, program);
+    auto canvas = context.canvas();
+    WTF::switchOn(canvas,
+        [&] (const RefPtr<HTMLCanvasElement>& htmlCanvasElement) {
+            if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(htmlCanvasElement->document()))
+                willDeleteProgramImpl(*instrumentingAgents, program);
+        },
+        [&] (const RefPtr<OffscreenCanvas>&) {
+        }
+    );
 }
 
-inline bool InspectorInstrumentation::isShaderProgramDisabled(WebGLRenderingContextBase& contextWebGLBase, WebGLProgram& program)
+inline bool InspectorInstrumentation::isShaderProgramDisabled(WebGLRenderingContextBase& context, WebGLProgram& program)
 {
     FAST_RETURN_IF_NO_FRONTENDS(false);
-    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(contextWebGLBase.canvasBase().scriptExecutionContext()))
-        return isShaderProgramDisabledImpl(*instrumentingAgents, program);
-    return false;
+    auto canvas = context.canvas();
+    return WTF::switchOn(canvas,
+        [&] (const RefPtr<HTMLCanvasElement>& htmlCanvasElement) {
+            if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(htmlCanvasElement->document()))
+                return isShaderProgramDisabledImpl(*instrumentingAgents, program);
+            return false;
+        },
+        [&] (const RefPtr<OffscreenCanvas>&) {
+            return false;
+        }
+    );
 }
 #endif
 
@@ -1349,11 +1382,11 @@
     stopProfilingImpl(instrumentingAgentsForPage(page), exec, title);
 }
 
-inline void InspectorInstrumentation::consoleStartRecordingCanvas(CanvasRenderingContext& context, JSC::ExecState& exec, JSC::JSObject* options)
+inline void InspectorInstrumentation::consoleStartRecordingCanvas(HTMLCanvasElement& canvasElement, JSC::ExecState& exec, JSC::JSObject* options)
 {
     FAST_RETURN_IF_NO_FRONTENDS(void());
-    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context.canvasBase().scriptExecutionContext()))
-        consoleStartRecordingCanvasImpl(*instrumentingAgents, context, exec, options);
+    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(&canvasElement.document()))
+        consoleStartRecordingCanvasImpl(*instrumentingAgents, canvasElement, exec, options);
 }
 
 inline void InspectorInstrumentation::didRequestAnimationFrame(Document& document, int callbackId)

Modified: trunk/Source/WebCore/inspector/InspectorShaderProgram.cpp (225989 => 225990)


--- trunk/Source/WebCore/inspector/InspectorShaderProgram.cpp	2017-12-15 23:14:33 UTC (rev 225989)
+++ trunk/Source/WebCore/inspector/InspectorShaderProgram.cpp	2017-12-16 00:00:09 UTC (rev 225990)
@@ -52,10 +52,11 @@
 {
 }
 
-WebGLRenderingContextBase& InspectorShaderProgram::context() const
+WebGLRenderingContextBase* InspectorShaderProgram::context() const
 {
-    ASSERT(is<WebGLRenderingContextBase>(m_canvas.context()));
-    return downcast<WebGLRenderingContextBase>(m_canvas.context());
+    auto* context = m_canvas.canvas().renderingContext();
+    ASSERT(context && is<WebGLRenderingContextBase>(context));
+    return downcast<WebGLRenderingContextBase>(context);
 }
 
 WebGLShader* InspectorShaderProgram::shaderForType(const String& protocolType)

Modified: trunk/Source/WebCore/inspector/InspectorShaderProgram.h (225989 => 225990)


--- trunk/Source/WebCore/inspector/InspectorShaderProgram.h	2017-12-15 23:14:33 UTC (rev 225989)
+++ trunk/Source/WebCore/inspector/InspectorShaderProgram.h	2017-12-16 00:00:09 UTC (rev 225990)
@@ -42,7 +42,7 @@
 
     const String& identifier() const { return m_identifier; }
     InspectorCanvas& canvas() const { return m_canvas; }
-    WebGLRenderingContextBase& context() const;
+    WebGLRenderingContextBase* context() const;
     WebGLProgram& program() const { return m_program; }
     WebGLShader* shaderForType(const String&);
 

Modified: trunk/Source/WebCore/inspector/agents/InspectorCanvasAgent.cpp (225989 => 225990)


--- trunk/Source/WebCore/inspector/agents/InspectorCanvasAgent.cpp	2017-12-15 23:14:33 UTC (rev 225989)
+++ trunk/Source/WebCore/inspector/agents/InspectorCanvasAgent.cpp	2017-12-16 00:00:09 UTC (rev 225990)
@@ -103,11 +103,12 @@
         m_frontendDispatcher->canvasAdded(inspectorCanvas->buildObjectForCanvas(m_instrumentingAgents, captureBacktrace));
 
 #if ENABLE(WEBGL)
-        if (is<WebGLRenderingContextBase>(inspectorCanvas->context())) {
-            WebGLRenderingContextBase& contextWebGL = downcast<WebGLRenderingContextBase>(inspectorCanvas->context());
-            if (std::optional<Vector<String>> extensions = contextWebGL.getSupportedExtensions()) {
+        CanvasRenderingContext* context = inspectorCanvas->canvas().renderingContext();
+        if (is<WebGLRenderingContextBase>(context)) {
+            WebGLRenderingContextBase* contextWebGL = downcast<WebGLRenderingContextBase>(context);
+            if (std::optional<Vector<String>> extensions = contextWebGL->getSupportedExtensions()) {
                 for (const String& extension : *extensions) {
-                    if (contextWebGL.extensionIsEnabled(extension))
+                    if (contextWebGL->extensionIsEnabled(extension))
                         m_frontendDispatcher->extensionEnabled(inspectorCanvas->identifier(), extension);
                 }
             }
@@ -148,19 +149,13 @@
     if (!inspectorCanvas)
         return;
 
-    auto* node = inspectorCanvas->canvasElement();
-    if (!node) {
-        errorString = ASCIILiteral("No node for canvas");
-        return;
-    }
-
-    int documentNodeId = m_instrumentingAgents.inspectorDOMAgent()->boundNodeId(&node->document());
+    int documentNodeId = m_instrumentingAgents.inspectorDOMAgent()->boundNodeId(&inspectorCanvas->canvas().document());
     if (!documentNodeId) {
         errorString = ASCIILiteral("Document has not been requested");
         return;
     }
 
-    *nodeId = m_instrumentingAgents.inspectorDOMAgent()->pushNodeToFrontend(errorString, documentNodeId, node);
+    *nodeId = m_instrumentingAgents.inspectorDOMAgent()->pushNodeToFrontend(errorString, documentNodeId, &inspectorCanvas->canvas());
 }
 
 void InspectorCanvasAgent::requestContent(ErrorString& errorString, const String& canvasId, String* content)
@@ -169,39 +164,33 @@
     if (!inspectorCanvas)
         return;
 
-    // FIXME: <https://webkit.org/b/180833> Web Inspector: support OffscreenCanvas for Canvas related operations
-
-    if (auto* node = inspectorCanvas->canvasElement()) {
-        if (is<CanvasRenderingContext2D>(inspectorCanvas->context()) || is<ImageBitmapRenderingContext>(inspectorCanvas->context())) {
-            auto result = node->toDataURL(ASCIILiteral("image/png"));
-            if (result.hasException()) {
-                errorString = result.releaseException().releaseMessage();
-                return;
-            }
-            *content = result.releaseReturnValue().string;
+    CanvasRenderingContext* context = inspectorCanvas->canvas().renderingContext();
+    if (is<CanvasRenderingContext2D>(context) || is<ImageBitmapRenderingContext>(context)) {
+        auto result = inspectorCanvas->canvas().toDataURL(ASCIILiteral("image/png"));
+        if (result.hasException()) {
+            errorString = result.releaseException().releaseMessage();
             return;
         }
-
+        *content = result.releaseReturnValue().string;
+    }
 #if ENABLE(WEBGL)
-        if (is<WebGLRenderingContextBase>(inspectorCanvas->context())) {
-            WebGLRenderingContextBase& contextWebGLBase = downcast<WebGLRenderingContextBase>(inspectorCanvas->context());
+    else if (is<WebGLRenderingContextBase>(context)) {
+        WebGLRenderingContextBase* gl = downcast<WebGLRenderingContextBase>(context);
 
-            contextWebGLBase.setPreventBufferClearForInspector(true);
-            auto result = node->toDataURL(ASCIILiteral("image/png"));
-            contextWebGLBase.setPreventBufferClearForInspector(false);
+        gl->setPreventBufferClearForInspector(true);
+        auto result = inspectorCanvas->canvas().toDataURL(ASCIILiteral("image/png"));
+        gl->setPreventBufferClearForInspector(false);
 
-            if (result.hasException()) {
-                errorString = result.releaseException().releaseMessage();
-                return;
-            }
-            *content = result.releaseReturnValue().string;
+        if (result.hasException()) {
+            errorString = result.releaseException().releaseMessage();
             return;
         }
+        *content = result.releaseReturnValue().string;
+    }
 #endif
-    }
-
-    // FIXME: <https://webkit.org/b/173621> Web Inspector: Support getting the content of WebGPU context;
-    errorString = ASCIILiteral("Unsupported canvas context type");
+    // FIXME: <https://webkit.org/b/173621> Web Inspector: Support getting the content of WebGPU contexts
+    else
+        errorString = ASCIILiteral("Unsupported canvas context type");
 }
 
 void InspectorCanvasAgent::requestCSSCanvasClientNodes(ErrorString& errorString, const String& canvasId, RefPtr<JSON::ArrayOf<int>>& result)
@@ -210,20 +199,14 @@
     if (!inspectorCanvas)
         return;
 
-    auto* node = inspectorCanvas->canvasElement();
-    if (!node) {
-        errorString = ASCIILiteral("CSS canvas does not support OffscreenCanvas");
-        return;
-    }
-
     result = JSON::ArrayOf<int>::create();
-    for (auto* client : node->cssCanvasClients()) {
-        if (int documentNodeId = m_instrumentingAgents.inspectorDOMAgent()->boundNodeId(&client->document()))
-            result->addItem(m_instrumentingAgents.inspectorDOMAgent()->pushNodeToFrontend(errorString, documentNodeId, client));
+    for (Element* element : inspectorCanvas->canvas().cssCanvasClients()) {
+        if (int documentNodeId = m_instrumentingAgents.inspectorDOMAgent()->boundNodeId(&element->document()))
+            result->addItem(m_instrumentingAgents.inspectorDOMAgent()->pushNodeToFrontend(errorString, documentNodeId, element));
     }
 }
 
-static JSC::JSValue contextAsScriptValue(JSC::ExecState& state, CanvasRenderingContext& context)
+static JSC::JSValue contextAsScriptValue(JSC::ExecState& state, CanvasRenderingContext* context)
 {
     JSC::JSLockHolder lock(&state);
 
@@ -253,11 +236,18 @@
     if (!inspectorCanvas)
         return;
 
-    auto& state = *inspectorCanvas->context().canvasBase().scriptExecutionContext()->execState();
+    Frame* frame = inspectorCanvas->canvas().document().frame();
+    if (!frame) {
+        errorString = ASCIILiteral("Canvas belongs to a document without a frame");
+        return;
+    }
+
+    auto& state = *mainWorldExecState(frame);
     auto injectedScript = m_injectedScriptManager.injectedScriptFor(&state);
     ASSERT(!injectedScript.hasNoValue());
 
-    JSC::JSValue value = contextAsScriptValue(state, inspectorCanvas->context());
+    CanvasRenderingContext* context = inspectorCanvas->canvas().renderingContext();
+    JSC::JSValue value = contextAsScriptValue(state, context);
     if (!value) {
         ASSERT_NOT_REACHED();
         errorString = ASCIILiteral("Unknown context type");
@@ -274,7 +264,7 @@
     if (!inspectorCanvas)
         return;
 
-    if (inspectorCanvas->context().callTracingActive()) {
+    if (inspectorCanvas->canvas().renderingContext()->callTracingActive()) {
         errorString = ASCIILiteral("Already recording canvas");
         return;
     }
@@ -285,7 +275,7 @@
     if (memoryLimit)
         inspectorCanvas->setBufferLimit(*memoryLimit);
 
-    inspectorCanvas->context().setCallTracingActive(true);
+    inspectorCanvas->canvas().renderingContext()->setCallTracingActive(true);
 }
 
 void InspectorCanvasAgent::stopRecording(ErrorString& errorString, const String& canvasId)
@@ -294,12 +284,12 @@
     if (!inspectorCanvas)
         return;
 
-    if (!inspectorCanvas->context().callTracingActive()) {
+    if (!inspectorCanvas->canvas().renderingContext()->callTracingActive()) {
         errorString = ASCIILiteral("No active recording for canvas");
         return;
     }
 
-    didFinishRecordingCanvasFrame(inspectorCanvas->context(), true);
+    didFinishRecordingCanvasFrame(inspectorCanvas->canvas(), true);
 }
 
 void InspectorCanvasAgent::requestShaderSource(ErrorString& errorString, const String& programId, const String& shaderType, String* content)
@@ -337,9 +327,9 @@
         return;
     }
 
-    WebGLRenderingContextBase& contextWebGL = inspectorProgram->context();
-    contextWebGL.shaderSource(shader, source);
-    contextWebGL.compileShader(shader);
+    WebGLRenderingContextBase* contextWebGL = inspectorProgram->context();
+    contextWebGL->shaderSource(shader, source);
+    contextWebGL->compileShader(shader);
 
     if (!shader->isValid()) {
         errorString = ASCIILiteral("Shader compilation failed.");
@@ -346,7 +336,7 @@
         return;
     }
 
-    contextWebGL.linkProgramWithoutInvalidatingAttribLocations(&inspectorProgram->program());
+    contextWebGL->linkProgramWithoutInvalidatingAttribLocations(&inspectorProgram->program());
 #else
     UNUSED_PARAM(programId);
     UNUSED_PARAM(shaderType);
@@ -372,19 +362,38 @@
 
 void InspectorCanvasAgent::frameNavigated(Frame& frame)
 {
-    if (frame.isMainFrame())
+    if (frame.isMainFrame()) {
         clearCanvasData();
+        return;
+    }
+
+    Vector<InspectorCanvas*> inspectorCanvases;
+    for (auto& inspectorCanvas : m_identifierToInspectorCanvas.values()) {
+        if (inspectorCanvas->canvas().document().frame() == &frame)
+            inspectorCanvases.append(inspectorCanvas.get());
+    }
+
+    for (auto* inspectorCanvas : inspectorCanvases) {
+        String identifier = unbindCanvas(*inspectorCanvas);
+        if (m_enabled)
+            m_frontendDispatcher->canvasRemoved(identifier);
+    }
 }
 
-void InspectorCanvasAgent::didChangeCSSCanvasClientNodes(HTMLCanvasElement& canvasElement)
+void InspectorCanvasAgent::didCreateCSSCanvas(HTMLCanvasElement& canvasElement, const String& name)
 {
-    auto* context = canvasElement.renderingContext();
-    if (!context) {
+    if (findInspectorCanvas(canvasElement)) {
         ASSERT_NOT_REACHED();
         return;
     }
 
-    auto* inspectorCanvas = findInspectorCanvas(*context);
+    ASSERT(!m_canvasToCSSCanvasName.contains(&canvasElement));
+    m_canvasToCSSCanvasName.set(&canvasElement, name);
+}
+
+void InspectorCanvasAgent::didChangeCSSCanvasClientNodes(HTMLCanvasElement& canvasElement)
+{
+    auto* inspectorCanvas = findInspectorCanvas(canvasElement);
     if (!inspectorCanvas)
         return;
 
@@ -391,15 +400,18 @@
     m_frontendDispatcher->cssCanvasClientNodesChanged(inspectorCanvas->identifier());
 }
 
-void InspectorCanvasAgent::didCreateCanvasRenderingContext(CanvasRenderingContext& context)
+void InspectorCanvasAgent::didCreateCanvasRenderingContext(HTMLCanvasElement& canvasElement)
 {
-    if (findInspectorCanvas(context)) {
+    if (findInspectorCanvas(canvasElement)) {
         ASSERT_NOT_REACHED();
         return;
     }
 
-    auto inspectorCanvas = InspectorCanvas::create(context);
+    canvasElement.addObserver(*this);
 
+    String cssCanvasName = m_canvasToCSSCanvasName.take(&canvasElement);
+    auto inspectorCanvas = InspectorCanvas::create(canvasElement, cssCanvasName);
+
     if (m_enabled) {
         const bool captureBacktrace = true;
         m_frontendDispatcher->canvasAdded(inspectorCanvas->buildObjectForCanvas(m_instrumentingAgents, captureBacktrace));
@@ -408,40 +420,23 @@
     m_identifierToInspectorCanvas.set(inspectorCanvas->identifier(), WTFMove(inspectorCanvas));
 }
 
-void InspectorCanvasAgent::willDestroyCanvasRenderingContext(CanvasRenderingContext& context)
+void InspectorCanvasAgent::didChangeCanvasMemory(HTMLCanvasElement& canvasElement)
 {
-    auto* inspectorCanvas = findInspectorCanvas(context);
+    auto* inspectorCanvas = findInspectorCanvas(canvasElement);
     if (!inspectorCanvas)
         return;
 
-    String identifier = unbindCanvas(*inspectorCanvas);
-    if (!m_enabled)
-        return;
-
-    // willDestroyCanvasRenderingContext is called in response to the GC destroying the CanvasRenderingContext.
-    // Due to the single-process model used in WebKit1, the event must be dispatched from a timer to prevent
-    // the frontend from making JS allocations while the GC is still active.
-    m_removedCanvasIdentifiers.append(identifier);
-
-    if (!m_canvasDestroyedTimer.isActive())
-        m_canvasDestroyedTimer.startOneShot(0_s);
+    m_frontendDispatcher->canvasMemoryChanged(inspectorCanvas->identifier(), canvasElement.memoryCost());
 }
 
-void InspectorCanvasAgent::didChangeCanvasMemory(CanvasRenderingContext& context)
+void InspectorCanvasAgent::recordCanvasAction(CanvasRenderingContext& canvasRenderingContext, const String& name, Vector<RecordCanvasActionVariant>&& parameters)
 {
-    auto* inspectorCanvas = findInspectorCanvas(context);
-    if (!inspectorCanvas)
+    auto& canvasBase = canvasRenderingContext.canvasBase();
+    auto* canvasElement = is<HTMLCanvasElement>(canvasBase) ? &downcast<HTMLCanvasElement>(canvasBase) : nullptr;
+    if (!canvasElement)
         return;
 
-    // FIXME: <https://webkit.org/b/180833> Web Inspector: support OffscreenCanvas for Canvas related operations
-
-    if (auto* node = inspectorCanvas->canvasElement())
-        m_frontendDispatcher->canvasMemoryChanged(inspectorCanvas->identifier(), node->memoryCost());
-}
-
-void InspectorCanvasAgent::recordCanvasAction(CanvasRenderingContext& canvasRenderingContext, const String& name, Vector<RecordCanvasActionVariant>&& parameters)
-{
-    auto* inspectorCanvas = findInspectorCanvas(canvasRenderingContext);
+    auto* inspectorCanvas = findInspectorCanvas(*canvasElement);
     ASSERT(inspectorCanvas);
     if (!inspectorCanvas)
         return;
@@ -456,20 +451,41 @@
         m_canvasRecordingTimer.startOneShot(0_s);
 
     if (!inspectorCanvas->hasBufferSpace())
-        didFinishRecordingCanvasFrame(inspectorCanvas->context(), true);
+        didFinishRecordingCanvasFrame(*canvasElement, true);
 }
 
-void InspectorCanvasAgent::didFinishRecordingCanvasFrame(CanvasRenderingContext& context, bool forceDispatch)
+void InspectorCanvasAgent::canvasDestroyed(HTMLCanvasElement& canvasElement)
 {
-    auto* inspectorCanvas = findInspectorCanvas(context);
+    auto* inspectorCanvas = findInspectorCanvas(canvasElement);
     ASSERT(inspectorCanvas);
     if (!inspectorCanvas)
         return;
 
-    ASSERT(inspectorCanvas->context().callTracingActive());
-    if (!inspectorCanvas->context().callTracingActive())
+    String identifier = unbindCanvas(*inspectorCanvas);
+    if (!m_enabled)
         return;
 
+    // WebCore::CanvasObserver::canvasDestroyed is called in response to the GC destroying the HTMLCanvasElement.
+    // Due to the single-process model used in WebKit1, the event must be dispatched from a timer to prevent
+    // the frontend from making JS allocations while the GC is still active.
+    m_removedCanvasIdentifiers.append(identifier);
+
+    if (!m_canvasDestroyedTimer.isActive())
+        m_canvasDestroyedTimer.startOneShot(0_s);
+}
+
+void InspectorCanvasAgent::didFinishRecordingCanvasFrame(HTMLCanvasElement& canvasElement, bool forceDispatch)
+{
+    auto* inspectorCanvas = findInspectorCanvas(canvasElement);
+    ASSERT(inspectorCanvas);
+    if (!inspectorCanvas)
+        return;
+
+    CanvasRenderingContext* canvasRenderingContext = inspectorCanvas->canvas().renderingContext();
+    ASSERT(canvasRenderingContext->callTracingActive());
+    if (!canvasRenderingContext->callTracingActive())
+        return;
+
     if (!inspectorCanvas->hasRecordingData()) {
         if (forceDispatch) {
             m_frontendDispatcher->recordingFinished(inspectorCanvas->identifier(), nullptr);
@@ -492,10 +508,10 @@
     // FIXME: <https://webkit.org/b/176008> Web Inspector: Record actions performed on WebGL2RenderingContext
 
     Inspector::Protocol::Recording::Type type;
-    if (is<CanvasRenderingContext2D>(inspectorCanvas->context()))
+    if (is<CanvasRenderingContext2D>(canvasRenderingContext))
         type = Inspector::Protocol::Recording::Type::Canvas2D;
 #if ENABLE(WEBGL)
-    else if (is<WebGLRenderingContext>(inspectorCanvas->context()))
+    else if (is<WebGLRenderingContext>(canvasRenderingContext))
         type = Inspector::Protocol::Recording::Type::CanvasWebGL;
 #endif
     else {
@@ -519,13 +535,13 @@
     inspectorCanvas->resetRecordingData();
 }
 
-void InspectorCanvasAgent::consoleStartRecordingCanvas(CanvasRenderingContext& context, JSC::ExecState& exec, JSC::JSObject* options)
+void InspectorCanvasAgent::consoleStartRecordingCanvas(HTMLCanvasElement& canvasElement, JSC::ExecState& exec, JSC::JSObject* options)
 {
-    auto* inspectorCanvas = findInspectorCanvas(context);
+    auto* inspectorCanvas = findInspectorCanvas(canvasElement);
     if (!inspectorCanvas)
         return;
 
-    if (inspectorCanvas->context().callTracingActive())
+    if (inspectorCanvas->canvas().renderingContext()->callTracingActive())
         return;
 
     inspectorCanvas->resetRecordingData();
@@ -539,32 +555,38 @@
             inspectorCanvas->setBufferLimit(optionMemoryLimit.toNumber(&exec));
     }
 
-    inspectorCanvas->context().setCallTracingActive(true);
+    inspectorCanvas->canvas().renderingContext()->setCallTracingActive(true);
 }
 
 #if ENABLE(WEBGL)
 void InspectorCanvasAgent::didEnableExtension(WebGLRenderingContextBase& context, const String& extension)
 {
-    auto* inspectorCanvas = findInspectorCanvas(context);
-    if (!inspectorCanvas)
-        return;
+    auto canvas = context.canvas();
+    if (WTF::holds_alternative<RefPtr<HTMLCanvasElement>>(canvas)) {
+        auto* inspectorCanvas = findInspectorCanvas(*WTF::get<RefPtr<HTMLCanvasElement>>(canvas));
+        if (!inspectorCanvas)
+            return;
 
-    m_frontendDispatcher->extensionEnabled(inspectorCanvas->identifier(), extension);
+        m_frontendDispatcher->extensionEnabled(inspectorCanvas->identifier(), extension);
+    }
 }
 
 void InspectorCanvasAgent::didCreateProgram(WebGLRenderingContextBase& context, WebGLProgram& program)
 {
-    auto* inspectorCanvas = findInspectorCanvas(context);
-    ASSERT(inspectorCanvas);
-    if (!inspectorCanvas)
-        return;
+    auto canvas = context.canvas();
+    if (WTF::holds_alternative<RefPtr<HTMLCanvasElement>>(canvas)) {
+        auto* inspectorCanvas = findInspectorCanvas(*WTF::get<RefPtr<HTMLCanvasElement>>(canvas));
+        ASSERT(inspectorCanvas);
+        if (!inspectorCanvas)
+            return;
 
-    auto inspectorProgram = InspectorShaderProgram::create(program, *inspectorCanvas);
-    String programIdentifier = inspectorProgram->identifier();
-    m_identifierToInspectorProgram.set(programIdentifier, WTFMove(inspectorProgram));
+        auto inspectorProgram = InspectorShaderProgram::create(program, *inspectorCanvas);
+        String programIdentifier = inspectorProgram->identifier();
+        m_identifierToInspectorProgram.set(programIdentifier, WTFMove(inspectorProgram));
 
-    if (m_enabled)
-        m_frontendDispatcher->programCreated(inspectorCanvas->identifier(), programIdentifier);
+        if (m_enabled)
+            m_frontendDispatcher->programCreated(inspectorCanvas->identifier(), programIdentifier);
+    }
 }
 
 void InspectorCanvasAgent::willDeleteProgram(WebGLProgram& program)
@@ -604,16 +626,20 @@
 void InspectorCanvasAgent::canvasRecordingTimerFired()
 {
     for (auto& inspectorCanvas : m_identifierToInspectorCanvas.values()) {
-        if (!inspectorCanvas->context().callTracingActive())
+        if (!inspectorCanvas->canvas().renderingContext()->callTracingActive())
             continue;
 
-        didFinishRecordingCanvasFrame(inspectorCanvas->context());
+        didFinishRecordingCanvasFrame(inspectorCanvas->canvas());
     }
 }
 
 void InspectorCanvasAgent::clearCanvasData()
 {
+    for (auto& inspectorCanvas : m_identifierToInspectorCanvas.values())
+        inspectorCanvas->canvas().removeObserver(*this);
+
     m_identifierToInspectorCanvas.clear();
+    m_canvasToCSSCanvasName.clear();
     m_removedCanvasIdentifiers.clear();
 #if ENABLE(WEBGL)
     m_identifierToInspectorProgram.clear();
@@ -628,6 +654,8 @@
 
 String InspectorCanvasAgent::unbindCanvas(InspectorCanvas& inspectorCanvas)
 {
+    ASSERT(!m_canvasToCSSCanvasName.contains(&inspectorCanvas.canvas()));
+
 #if ENABLE(WEBGL)
     Vector<InspectorShaderProgram*> programsToRemove;
     for (auto& inspectorProgram : m_identifierToInspectorProgram.values()) {
@@ -656,10 +684,10 @@
     return inspectorCanvas.get();
 }
 
-InspectorCanvas* InspectorCanvasAgent::findInspectorCanvas(CanvasRenderingContext& context)
+InspectorCanvas* InspectorCanvasAgent::findInspectorCanvas(HTMLCanvasElement& canvasElement)
 {
     for (auto& inspectorCanvas : m_identifierToInspectorCanvas.values()) {
-        if (&inspectorCanvas->context() == &context)
+        if (&inspectorCanvas->canvas() == &canvasElement)
             return inspectorCanvas.get();
     }
 
@@ -669,6 +697,8 @@
 #if ENABLE(WEBGL)
 String InspectorCanvasAgent::unbindProgram(InspectorShaderProgram& inspectorProgram)
 {
+    ASSERT(inspectorProgram.context());
+
     String identifier = inspectorProgram.identifier();
     m_identifierToInspectorProgram.remove(identifier);
 

Modified: trunk/Source/WebCore/inspector/agents/InspectorCanvasAgent.h (225989 => 225990)


--- trunk/Source/WebCore/inspector/agents/InspectorCanvasAgent.h	2017-12-15 23:14:33 UTC (rev 225989)
+++ trunk/Source/WebCore/inspector/agents/InspectorCanvasAgent.h	2017-12-16 00:00:09 UTC (rev 225990)
@@ -55,7 +55,7 @@
 
 typedef String ErrorString;
 
-class InspectorCanvasAgent final : public InspectorAgentBase, public Inspector::CanvasBackendDispatcherHandler {
+class InspectorCanvasAgent final : public InspectorAgentBase, public CanvasObserver, public Inspector::CanvasBackendDispatcherHandler {
     WTF_MAKE_NONCOPYABLE(InspectorCanvasAgent);
     WTF_MAKE_FAST_ALLOCATED;
 public:
@@ -81,13 +81,13 @@
 
     // InspectorInstrumentation
     void frameNavigated(Frame&);
+    void didCreateCSSCanvas(HTMLCanvasElement&, const String&);
     void didChangeCSSCanvasClientNodes(HTMLCanvasElement&);
-    void didCreateCanvasRenderingContext(CanvasRenderingContext&);
-    void willDestroyCanvasRenderingContext(CanvasRenderingContext&);
-    void didChangeCanvasMemory(CanvasRenderingContext&);
+    void didCreateCanvasRenderingContext(HTMLCanvasElement&);
+    void didChangeCanvasMemory(HTMLCanvasElement&);
     void recordCanvasAction(CanvasRenderingContext&, const String&, Vector<RecordCanvasActionVariant>&& = { });
-    void didFinishRecordingCanvasFrame(CanvasRenderingContext&, bool forceDispatch = false);
-    void consoleStartRecordingCanvas(CanvasRenderingContext&, JSC::ExecState&, JSC::JSObject* options);
+    void didFinishRecordingCanvasFrame(HTMLCanvasElement&, bool forceDispatch = false);
+    void consoleStartRecordingCanvas(HTMLCanvasElement&, JSC::ExecState&, JSC::JSObject* options);
 #if ENABLE(WEBGL)
     void didEnableExtension(WebGLRenderingContextBase&, const String&);
     void didCreateProgram(WebGLRenderingContextBase&, WebGLProgram&);
@@ -95,6 +95,11 @@
     bool isShaderProgramDisabled(WebGLProgram&);
 #endif
 
+    // CanvasObserver
+    void canvasChanged(HTMLCanvasElement&, const FloatRect&) override { }
+    void canvasResized(HTMLCanvasElement&) override { }
+    void canvasDestroyed(HTMLCanvasElement&) override;
+
 private:
     void canvasDestroyedTimerFired();
     void canvasRecordingTimerFired();
@@ -101,7 +106,7 @@
     void clearCanvasData();
     String unbindCanvas(InspectorCanvas&);
     InspectorCanvas* assertInspectorCanvas(ErrorString&, const String& identifier);
-    InspectorCanvas* findInspectorCanvas(CanvasRenderingContext&);
+    InspectorCanvas* findInspectorCanvas(HTMLCanvasElement&);
 #if ENABLE(WEBGL)
     String unbindProgram(InspectorShaderProgram&);
     InspectorShaderProgram* assertInspectorProgram(ErrorString&, const String& identifier);
@@ -114,6 +119,7 @@
     RefPtr<Inspector::CanvasBackendDispatcher> m_backendDispatcher;
     Inspector::InjectedScriptManager& m_injectedScriptManager;
     HashMap<String, RefPtr<InspectorCanvas>> m_identifierToInspectorCanvas;
+    HashMap<HTMLCanvasElement*, String> m_canvasToCSSCanvasName;
     Vector<String> m_removedCanvasIdentifiers;
     Timer m_canvasDestroyedTimer;
     Timer m_canvasRecordingTimer;

Modified: trunk/Source/WebCore/page/PageConsoleClient.cpp (225989 => 225990)


--- trunk/Source/WebCore/page/PageConsoleClient.cpp	2017-12-15 23:14:33 UTC (rev 225989)
+++ trunk/Source/WebCore/page/PageConsoleClient.cpp	2017-12-16 00:00:09 UTC (rev 225990)
@@ -231,14 +231,16 @@
     if (arguments->argumentCount() >= 2)
         options = arguments->argumentAt(1).jsValue().getObject();
 
-    if (HTMLCanvasElement* canvasElement = JSHTMLCanvasElement::toWrapped(*target->vm(), target)) {
-        if (CanvasRenderingContext* context = canvasElement->renderingContext())
-            InspectorInstrumentation::consoleStartRecordingCanvas(*context, *exec, options);
-    } else if (CanvasRenderingContext2D* context2d = JSCanvasRenderingContext2D::toWrapped(*target->vm(), target))
-        InspectorInstrumentation::consoleStartRecordingCanvas(*context2d, *exec, options);
+    if (HTMLCanvasElement* canvasElement = JSHTMLCanvasElement::toWrapped(*target->vm(), target))
+        InspectorInstrumentation::consoleStartRecordingCanvas(*canvasElement, *exec, options);
+    else if (CanvasRenderingContext2D* context2d = JSCanvasRenderingContext2D::toWrapped(*target->vm(), target))
+        InspectorInstrumentation::consoleStartRecordingCanvas(context2d->canvas(), *exec, options);
 #if ENABLE(WEBGL)
-    else if (WebGLRenderingContext* contextWebGL = JSWebGLRenderingContext::toWrapped(*target->vm(), target))
-        InspectorInstrumentation::consoleStartRecordingCanvas(*contextWebGL, *exec, options);
+    else if (WebGLRenderingContext* contextWebGL = JSWebGLRenderingContext::toWrapped(*target->vm(), target)) {
+        auto canvas = contextWebGL->canvas();
+        if (WTF::holds_alternative<RefPtr<HTMLCanvasElement>>(canvas))
+            InspectorInstrumentation::consoleStartRecordingCanvas(*WTF::get<RefPtr<HTMLCanvasElement>>(canvas), *exec, options);
+    }
 #endif
 }
 
@@ -251,14 +253,16 @@
     if (!target)
         return;
 
-    if (HTMLCanvasElement* canvasElement = JSHTMLCanvasElement::toWrapped(*target->vm(), target)) {
-        if (CanvasRenderingContext* context = canvasElement->renderingContext())
-            InspectorInstrumentation::didFinishRecordingCanvasFrame(*context, true);
-    } else if (CanvasRenderingContext2D* context2d = JSCanvasRenderingContext2D::toWrapped(*target->vm(), target))
-        InspectorInstrumentation::didFinishRecordingCanvasFrame(*context2d, true);
+    if (HTMLCanvasElement* canvasElement = JSHTMLCanvasElement::toWrapped(*target->vm(), target))
+        InspectorInstrumentation::didFinishRecordingCanvasFrame(*canvasElement, true);
+    else if (CanvasRenderingContext2D* context2d = JSCanvasRenderingContext2D::toWrapped(*target->vm(), target))
+        InspectorInstrumentation::didFinishRecordingCanvasFrame(context2d->canvas(), true);
 #if ENABLE(WEBGL)
-    else if (WebGLRenderingContext* contextWebGL = JSWebGLRenderingContext::toWrapped(*target->vm(), target))
-        InspectorInstrumentation::didFinishRecordingCanvasFrame(*contextWebGL, true);
+    else if (WebGLRenderingContext* contextWebGL = JSWebGLRenderingContext::toWrapped(*target->vm(), target)) {
+        auto canvas = contextWebGL->canvas();
+        if (WTF::holds_alternative<RefPtr<HTMLCanvasElement>>(canvas))
+            InspectorInstrumentation::didFinishRecordingCanvasFrame(*WTF::get<RefPtr<HTMLCanvasElement>>(canvas), true);
+    }
 #endif
 }
 

Modified: trunk/Source/WebInspectorUI/ChangeLog (225989 => 225990)


--- trunk/Source/WebInspectorUI/ChangeLog	2017-12-15 23:14:33 UTC (rev 225989)
+++ trunk/Source/WebInspectorUI/ChangeLog	2017-12-16 00:00:09 UTC (rev 225990)
@@ -1,3 +1,17 @@
+2017-12-15  Ryan Haddad  <[email protected]>
+
+        Unreviewed, rolling out r225941.
+
+        This change introduced LayoutTest crashes and assertion
+        failures.
+
+        Reverted changeset:
+
+        "Web Inspector: replace HTMLCanvasElement with
+        CanvasRenderingContext for instrumentation logic"
+        https://bugs.webkit.org/show_bug.cgi?id=180770
+        https://trac.webkit.org/changeset/225941
+
 2017-12-15  Devin Rousso  <[email protected]>
 
         Web Inspector: Canvas Tab should be turned on by default

Modified: trunk/Source/WebInspectorUI/UserInterface/Models/Canvas.js (225989 => 225990)


--- trunk/Source/WebInspectorUI/UserInterface/Models/Canvas.js	2017-12-15 23:14:33 UTC (rev 225989)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/Canvas.js	2017-12-16 00:00:09 UTC (rev 225990)
@@ -25,15 +25,17 @@
 
 WI.Canvas = class Canvas extends WI.Object
 {
-    constructor(identifier, contextType, {domNode, cssCanvasName, contextAttributes, memoryCost, backtrace} = {})
+    constructor(identifier, contextType, frame, {domNode, cssCanvasName, contextAttributes, memoryCost, backtrace} = {})
     {
         super();
 
         console.assert(identifier);
         console.assert(contextType);
+        console.assert(frame instanceof WI.Frame);
 
         this._identifier = identifier;
         this._contextType = contextType;
+        this._frame = frame;
         this._domNode = domNode || null;
         this._cssCanvasName = cssCanvasName || "";
         this._contextAttributes = contextAttributes || {};
@@ -75,7 +77,8 @@
             console.error("Invalid canvas context type", payload.contextType);
         }
 
-        return new WI.Canvas(payload.canvasId, contextType, {
+        let frame = WI.frameResourceManager.frameForIdentifier(payload.frameId);
+        return new WI.Canvas(payload.canvasId, contextType, frame, {
             domNode: payload.nodeId ? WI.domTreeManager.nodeForId(payload.nodeId) : null,
             cssCanvasName: payload.cssCanvasName,
             contextAttributes: payload.contextAttributes,
@@ -111,6 +114,7 @@
 
     get identifier() { return this._identifier; }
     get contextType() { return this._contextType; }
+    get frame() { return this._frame; }
     get cssCanvasName() { return this._cssCanvasName; }
     get contextAttributes() { return this._contextAttributes; }
     get extensions() { return this._extensions; }
@@ -259,6 +263,8 @@
 
     saveIdentityToCookie(cookie)
     {
+        cookie[WI.Canvas.FrameURLCookieKey] = this._frame.url.hash;
+
         if (this._cssCanvasName)
             cookie[WI.Canvas.CSSCanvasNameCookieKey] = this._cssCanvasName;
         else if (this._domNode)

Modified: trunk/Tools/ChangeLog (225989 => 225990)


--- trunk/Tools/ChangeLog	2017-12-15 23:14:33 UTC (rev 225989)
+++ trunk/Tools/ChangeLog	2017-12-16 00:00:09 UTC (rev 225990)
@@ -1,3 +1,17 @@
+2017-12-15  Ryan Haddad  <[email protected]>
+
+        Unreviewed, rolling out r225941.
+
+        This change introduced LayoutTest crashes and assertion
+        failures.
+
+        Reverted changeset:
+
+        "Web Inspector: replace HTMLCanvasElement with
+        CanvasRenderingContext for instrumentation logic"
+        https://bugs.webkit.org/show_bug.cgi?id=180770
+        https://trac.webkit.org/changeset/225941
+
 2017-12-15  Alex Christensen  <[email protected]>
 
         Introduce SPI _WKWebsitePolicies.websiteDataStore

Modified: trunk/Tools/Scripts/webkitpy/common/config/watchlist (225989 => 225990)


--- trunk/Tools/Scripts/webkitpy/common/config/watchlist	2017-12-15 23:14:33 UTC (rev 225989)
+++ trunk/Tools/Scripts/webkitpy/common/config/watchlist	2017-12-16 00:00:09 UTC (rev 225990)
@@ -190,7 +190,9 @@
                         r"|Source/WebInspectorUI/UserInterface/\w*/Recording.*\.js"
                         # Canvas
                         r"|Source/WebCore/inspector/InspectorCanvas.*"
-                        r"|Source/WebCore/html/canvas/Canvas.*",
+                        r"|Source/WebCore/html/canvas/Canvas.*\.idl"
+                        r"|Source/WebCore/html/canvas/WebGLRenderingContext\.idl"
+                        r"|Source/WebCore/html/canvas/WebGLRenderingContextBase\.idl",
         },
         "WebInspectorUIImages": {
             "filename": r"Source/WebInspectorUI/UserInterface/Images",
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to