Changeset 218376 in webkit


Ignore:
Timestamp:
Jun 15, 2017 7:55:37 PM (7 years ago)
Author:
Matt Baker
Message:

Web Inspector: Instrument 2D/WebGL canvas contexts in the backend
https://bugs.webkit.org/show_bug.cgi?id=172623
<rdar://problem/32415986>

Reviewed by Devin Rousso.

Source/JavaScriptCore:

This patch adds a basic Canvas protocol. It includes Canvas and related
types and events for monitoring the lifetime of canvases in the page.

  • CMakeLists.txt:
  • DerivedSources.make:
  • inspector/protocol/Canvas.json: Added.
  • inspector/scripts/codegen/generator.py:

(Generator.stylized_name_for_enum_value):
Add special handling for Canvas.ContextType protocol enumeration,
so that "canvas-2d" and "webgl" map to Canvas2D and WebGL.

Source/WebCore:

Test: inspector/canvas/create-canvas-contexts.html

  • CMakeLists.txt:
  • WebCore.xcodeproj/project.pbxproj:
  • dom/Document.cpp:

(WebCore::Document::getCSSCanvasElement):
Instrument creation of CSS canvases. This merely registers the canvas
element with InspectorCanvasAgent and stores the name (identifier passed
to getCSSCanvasContext) for later use. It isn't until the context is
actually created that the frontend receives a notification.

  • html/HTMLCanvasElement.cpp:

(WebCore::HTMLCanvasElement::getContext2d):
(WebCore::HTMLCanvasElement::getContextWebGL):
Instrument creation of 2D and WebGL canvas contexts.

  • inspector/InspectorAllInOne.cpp:
  • inspector/InspectorCanvasAgent.cpp: Added.

New backend agent for canvas inspection. Canvas creation and destruction
are continuously monitored by the agent, regardless of the presence of
a frontend. This is necessary since there is no way to retrieve the
rendering contexts for with a given frame once they've been created.

(WebCore::InspectorCanvasAgent::InspectorCanvasAgent):
(WebCore::InspectorCanvasAgent::didCreateFrontendAndBackend):
(WebCore::InspectorCanvasAgent::willDestroyFrontendAndBackend):
(WebCore::InspectorCanvasAgent::discardAgent):
Unregister canvas observers to prevent dangling agent pointer.
(WebCore::InspectorCanvasAgent::enable):
Dispatch events for existing canvases, now that the frontend exists.
(WebCore::InspectorCanvasAgent::disable):
(WebCore::InspectorCanvasAgent::frameNavigated):
(WebCore::InspectorCanvasAgent::didCreateCSSCanvas):
Register the name/identifier associated with the CSS canvas, so that it
can be retrieved and associated with the rendering context later.

(WebCore::InspectorCanvasAgent::didCreateCanvasRenderingContext):
(WebCore::InspectorCanvasAgent::canvasDestroyed):
Removes the canvas from the agent, and queues it for notifying the
frontend during the next event loop.

(WebCore::InspectorCanvasAgent::canvasDestroyedTimerFired):
(WebCore::InspectorCanvasAgent::clearCanvasData):
(WebCore::InspectorCanvasAgent::getCanvasEntry):
(WebCore::InspectorCanvasAgent::buildObjectForCanvas):

  • inspector/InspectorCanvasAgent.h: Added.
  • inspector/InspectorController.cpp:

(WebCore::InspectorController::InspectorController):

  • inspector/InspectorInstrumentation.cpp:

(WebCore::InspectorInstrumentation::didCommitLoadImpl):
(WebCore::InspectorInstrumentation::didCreateCSSCanvasImpl):
(WebCore::InspectorInstrumentation::didCreateCanvasRenderingContextImpl):

  • inspector/InspectorInstrumentation.h:

(WebCore::InspectorInstrumentation::didCreateCSSCanvas):
(WebCore::InspectorInstrumentation::didCreateCanvasRenderingContext):
These instrumentation points should not fast return when no frontend
is attached.

  • inspector/InstrumentingAgents.cpp:

(WebCore::InstrumentingAgents::reset):

  • inspector/InstrumentingAgents.h:

(WebCore::InstrumentingAgents::inspectorCanvasAgent):
(WebCore::InstrumentingAgents::setInspectorCanvasAgent):
Plumbing for the new agent.

Source/WebInspectorUI:

  • UserInterface/Base/Main.js:

(WebInspector.loaded):

  • UserInterface/Controllers/CanvasManager.js: Added.

New frontend manager for the Canvas domain.
(WebInspector.CanvasManager):
(WebInspector.CanvasManager.prototype.get canvases):
(WebInspector.CanvasManager.prototype.canvasAdded):
(WebInspector.CanvasManager.prototype.canvasRemoved):
(WebInspector.CanvasManager.prototype._mainResourceDidChange):

  • UserInterface/Main.html:

New files.

  • UserInterface/Models/Canvas.js: Added.

(WebInspector.Canvas):
(WebInspector.Canvas.fromPayload):
(WebInspector.Canvas.displayNameForContextType):
Get displayable text "2D" or "WebGL" based on context type.
(WebInspector.Canvas.resetUniqueDisplayNameNumbers):
Called by CanvasManager when canvases are cleared.
(WebInspector.Canvas.prototype.get identifier):
(WebInspector.Canvas.prototype.get contextType):
(WebInspector.Canvas.prototype.get frame):
(WebInspector.Canvas.prototype.get cssCanvasName):
For CSS canvases, the identifier passed to getCSSCanvasContext.
(WebInspector.Canvas.prototype.get displayName):
Get displayable canvas name. The name depends on how the canvas was
created, and the information available:

  • getCSSCanvasContext: "CSS Canvas <identifier>"
  • getContext: "Canvas #<DOM id attribute value>"
  • Otherwise: "Canvas 1", "Canvas 2", ...

(WebInspector.Canvas.saveIdentityToCookie):

  • UserInterface/Protocol/CanvasObserver.js: Added.

(WebInspector.CanvasObserver.prototype.canvasAdded):
(WebInspector.CanvasObserver.prototype.canvasRemoved):
(WebInspector.CanvasObserver):

  • UserInterface/Test.html:
  • UserInterface/Test/Test.js:

(WebInspector.loaded):

LayoutTests:

Test that CanvasAgent dispatches events for canvas lifecycle events.

  • inspector/canvas/create-canvas-contexts-expected.txt: Added.
  • inspector/canvas/create-canvas-contexts.html: Added.
Location:
trunk
Files:
9 added
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r218371 r218376  
     12017-06-15  Matt Baker  <mattbaker@apple.com>
     2
     3        Web Inspector: Instrument 2D/WebGL canvas contexts in the backend
     4        https://bugs.webkit.org/show_bug.cgi?id=172623
     5        <rdar://problem/32415986>
     6
     7        Reviewed by Devin Rousso.
     8
     9        Test that CanvasAgent dispatches events for canvas lifecycle events.
     10
     11        * inspector/canvas/create-canvas-contexts-expected.txt: Added.
     12        * inspector/canvas/create-canvas-contexts.html: Added.
     13
    1142017-06-15  Myles C. Maxfield  <mmaxfield@apple.com>
    215
  • trunk/Source/JavaScriptCore/CMakeLists.txt

    r218272 r218376  
    13511351    ${JAVASCRIPTCORE_DIR}/inspector/protocol/ApplicationCache.json
    13521352    ${JAVASCRIPTCORE_DIR}/inspector/protocol/CSS.json
     1353    ${JAVASCRIPTCORE_DIR}/inspector/protocol/Canvas.json
    13531354    ${JAVASCRIPTCORE_DIR}/inspector/protocol/Console.json
    13541355    ${JAVASCRIPTCORE_DIR}/inspector/protocol/DOM.json
  • trunk/Source/JavaScriptCore/ChangeLog

    r218350 r218376  
     12017-06-15  Matt Baker  <mattbaker@apple.com>
     2
     3        Web Inspector: Instrument 2D/WebGL canvas contexts in the backend
     4        https://bugs.webkit.org/show_bug.cgi?id=172623
     5        <rdar://problem/32415986>
     6
     7        Reviewed by Devin Rousso.
     8
     9        This patch adds a basic Canvas protocol. It includes Canvas and related
     10        types and events for monitoring the lifetime of canvases in the page.
     11
     12        * CMakeLists.txt:
     13        * DerivedSources.make:
     14        * inspector/protocol/Canvas.json: Added.
     15
     16        * inspector/scripts/codegen/generator.py:
     17        (Generator.stylized_name_for_enum_value):
     18        Add special handling for Canvas.ContextType protocol enumeration,
     19        so that "canvas-2d" and "webgl" map to `Canvas2D` and `WebGL`.
     20
    1212017-06-15  Keith Miller  <keith_miller@apple.com>
    222
  • trunk/Source/JavaScriptCore/DerivedSources.make

    r210028 r218376  
    215215    $(JavaScriptCore)/inspector/protocol/ApplicationCache.json \
    216216    $(JavaScriptCore)/inspector/protocol/CSS.json \
     217    $(JavaScriptCore)/inspector/protocol/Canvas.json \
    217218    $(JavaScriptCore)/inspector/protocol/Console.json \
    218219    $(JavaScriptCore)/inspector/protocol/DOM.json \
  • trunk/Source/JavaScriptCore/inspector/scripts/codegen/generator.py

    r213621 r218376  
    3939    return str[:1].upper() + str[1:]
    4040
    41 _ALWAYS_SPECIALCASED_ENUM_VALUE_SUBSTRINGS = set(['API', 'CSS', 'DOM', 'HTML', 'JIT', 'XHR', 'XML', 'IOS', 'MacOS'])
     41_ALWAYS_SPECIALCASED_ENUM_VALUE_SUBSTRINGS = set(['2D', 'API', 'CSS', 'DOM', 'HTML', 'JIT', 'XHR', 'XML', 'IOS', 'MacOS'])
    4242_ALWAYS_SPECIALCASED_ENUM_VALUE_LOOKUP_TABLE = dict([(s.upper(), s) for s in _ALWAYS_SPECIALCASED_ENUM_VALUE_SUBSTRINGS])
     43
     44_ENUM_IDENTIFIER_RENAME_MAP = {
     45    'webgl': 'WebGL',  # Canvas.ContextType.webgl
     46}
    4347
    4448# These objects are built manually by creating and setting InspectorValues.
     
    252256
    253257        # Split on hyphen, introduce camelcase, and force uppercasing of acronyms.
    254         subwords = map(ucfirst, enum_value.split('-'))
     258        subwords = map(ucfirst, _ENUM_IDENTIFIER_RENAME_MAP.get(enum_value, enum_value).split('-'))
    255259        return re.sub(re.compile(regex, re.IGNORECASE), replaceCallback, "".join(subwords))
    256260
  • trunk/Source/WebCore/CMakeLists.txt

    r218179 r218376  
    18901890    inspector/InspectorApplicationCacheAgent.cpp
    18911891    inspector/InspectorCSSAgent.cpp
     1892    inspector/InspectorCanvasAgent.cpp
    18921893    inspector/InspectorClient.cpp
    18931894    inspector/InspectorController.cpp
  • trunk/Source/WebCore/ChangeLog

    r218375 r218376  
     12017-06-15  Matt Baker  <mattbaker@apple.com>
     2
     3        Web Inspector: Instrument 2D/WebGL canvas contexts in the backend
     4        https://bugs.webkit.org/show_bug.cgi?id=172623
     5        <rdar://problem/32415986>
     6
     7        Reviewed by Devin Rousso.
     8
     9        Test: inspector/canvas/create-canvas-contexts.html
     10
     11        * CMakeLists.txt:
     12        * WebCore.xcodeproj/project.pbxproj:
     13
     14        * dom/Document.cpp:
     15        (WebCore::Document::getCSSCanvasElement):
     16        Instrument creation of CSS canvases. This merely registers the canvas
     17        element with InspectorCanvasAgent and stores the name (identifier passed
     18        to getCSSCanvasContext) for later use. It isn't until the context is
     19        actually created that the frontend receives a notification.
     20
     21        * html/HTMLCanvasElement.cpp:
     22        (WebCore::HTMLCanvasElement::getContext2d):
     23        (WebCore::HTMLCanvasElement::getContextWebGL):
     24        Instrument creation of 2D and WebGL canvas contexts.
     25
     26        * inspector/InspectorAllInOne.cpp:
     27
     28        * inspector/InspectorCanvasAgent.cpp: Added.
     29        New backend agent for canvas inspection. Canvas creation and destruction
     30        are continuously monitored by the agent, regardless of the presence of
     31        a frontend. This is necessary since there is no way to retrieve the
     32        rendering contexts for with a given frame once they've been created.
     33
     34        (WebCore::InspectorCanvasAgent::InspectorCanvasAgent):
     35        (WebCore::InspectorCanvasAgent::didCreateFrontendAndBackend):
     36        (WebCore::InspectorCanvasAgent::willDestroyFrontendAndBackend):
     37        (WebCore::InspectorCanvasAgent::discardAgent):
     38        Unregister canvas observers to prevent dangling agent pointer.
     39        (WebCore::InspectorCanvasAgent::enable):
     40        Dispatch events for existing canvases, now that the frontend exists.
     41        (WebCore::InspectorCanvasAgent::disable):
     42        (WebCore::InspectorCanvasAgent::frameNavigated):
     43        (WebCore::InspectorCanvasAgent::didCreateCSSCanvas):
     44        Register the name/identifier associated with the CSS canvas, so that it
     45        can be retrieved and associated with the rendering context later.
     46
     47        (WebCore::InspectorCanvasAgent::didCreateCanvasRenderingContext):
     48        (WebCore::InspectorCanvasAgent::canvasDestroyed):
     49        Removes the canvas from the agent, and queues it for notifying the
     50        frontend during the next event loop.
     51
     52        (WebCore::InspectorCanvasAgent::canvasDestroyedTimerFired):
     53        (WebCore::InspectorCanvasAgent::clearCanvasData):
     54        (WebCore::InspectorCanvasAgent::getCanvasEntry):
     55        (WebCore::InspectorCanvasAgent::buildObjectForCanvas):
     56        * inspector/InspectorCanvasAgent.h: Added.
     57
     58        * inspector/InspectorController.cpp:
     59        (WebCore::InspectorController::InspectorController):
     60
     61        * inspector/InspectorInstrumentation.cpp:
     62        (WebCore::InspectorInstrumentation::didCommitLoadImpl):
     63        (WebCore::InspectorInstrumentation::didCreateCSSCanvasImpl):
     64        (WebCore::InspectorInstrumentation::didCreateCanvasRenderingContextImpl):
     65
     66        * inspector/InspectorInstrumentation.h:
     67        (WebCore::InspectorInstrumentation::didCreateCSSCanvas):
     68        (WebCore::InspectorInstrumentation::didCreateCanvasRenderingContext):
     69        These instrumentation points should not fast return when no frontend
     70        is attached.
     71
     72        * inspector/InstrumentingAgents.cpp:
     73        (WebCore::InstrumentingAgents::reset):
     74
     75        * inspector/InstrumentingAgents.h:
     76        (WebCore::InstrumentingAgents::inspectorCanvasAgent):
     77        (WebCore::InstrumentingAgents::setInspectorCanvasAgent):
     78        Plumbing for the new agent.
     79
    1802017-06-15  Jer Noble  <jer.noble@apple.com>
    281
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r218371 r218376  
    28792879                6C4C96DF1AD4483500365672 /* JSReadableStreamBYOBRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 6C4C96DB1AD4483500365672 /* JSReadableStreamBYOBRequest.h */; };
    28802880                6C4C96DF1AD4483500365A50 /* JSReadableStreamDefaultController.h in Headers */ = {isa = PBXBuildFile; fileRef = 6C4C96DB1AD4483500365A50 /* JSReadableStreamDefaultController.h */; };
     2881                6A32D7CE1A16D8C000412F0B /* InspectorCanvasAgent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6A4B6D6619D225D8006F11D3 /* InspectorCanvasAgent.cpp */; };
     2882                6A4B6D6519D22519006F11D3 /* InspectorCanvasAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = 6A4B6D6419D22519006F11D3 /* InspectorCanvasAgent.h */; };
    28812883                6C638895A96CCEE50C8C946C /* CachedResourceRequestInitiators.h in Headers */ = {isa = PBXBuildFile; fileRef = 6C638893A96CCEE50C8C946C /* CachedResourceRequestInitiators.h */; settings = {ATTRIBUTES = (Private, ); }; };
    28822884                6C638896A96CCEE50C8C946C /* CachedResourceRequestInitiators.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6C638894A96CCEE50C8C946C /* CachedResourceRequestInitiators.cpp */; };
     
    1071910721                6C4C96DB1AD4483500365672 /* JSReadableStreamBYOBRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSReadableStreamBYOBRequest.h; sourceTree = "<group>"; };
    1072010722                6C4C96DB1AD4483500365A50 /* JSReadableStreamDefaultController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSReadableStreamDefaultController.h; sourceTree = "<group>"; };
     10723                6A4B6D6419D22519006F11D3 /* InspectorCanvasAgent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorCanvasAgent.h; sourceTree = "<group>"; };
     10724                6A4B6D6619D225D8006F11D3 /* InspectorCanvasAgent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorCanvasAgent.cpp; sourceTree = "<group>"; };
    1072110725                6C638893A96CCEE50C8C946C /* CachedResourceRequestInitiators.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CachedResourceRequestInitiators.h; sourceTree = "<group>"; };
    1072210726                6C638894A96CCEE50C8C946C /* CachedResourceRequestInitiators.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CachedResourceRequestInitiators.cpp; sourceTree = "<group>"; };
     
    1722117225                                B885E8D211E06DD2009FFBF4 /* InspectorApplicationCacheAgent.cpp */,
    1722217226                                B885E8D311E06DD2009FFBF4 /* InspectorApplicationCacheAgent.h */,
     17227                                6A4B6D6619D225D8006F11D3 /* InspectorCanvasAgent.cpp */,
     17228                                6A4B6D6419D22519006F11D3 /* InspectorCanvasAgent.h */,
    1722317229                                7A1F2B51126C61B20006A7E6 /* InspectorClient.cpp */,
    1722417230                                1C81B9580E97330800266E07 /* InspectorClient.h */,
     
    2774627752                                82AB1744124B99EC00C5069D /* InspectorCSSAgent.h in Headers */,
    2774727753                                4A9CC82116BF9BB400EC645A /* InspectorCSSOMWrappers.h in Headers */,
     27754                                6A4B6D6519D22519006F11D3 /* InspectorCanvasAgent.h in Headers */,
    2774827755                                7AB0B1C11211A62200A76940 /* InspectorDatabaseAgent.h in Headers */,
    2774927756                                41F062140F5F192600A07EAC /* InspectorDatabaseResource.h in Headers */,
     
    3172431731                                93309DF1099E64920056E581 /* InsertTextCommand.cpp in Sources */,
    3172531732                                B885E8D411E06DD2009FFBF4 /* InspectorApplicationCacheAgent.cpp in Sources */,
     31733                                6A32D7CE1A16D8C000412F0B /* InspectorCanvasAgent.cpp in Sources */,
    3172631734                                7A1F2B52126C61B20006A7E6 /* InspectorClient.cpp in Sources */,
    3172731735                                1C81B95B0E97330800266E07 /* InspectorController.cpp in Sources */,
  • trunk/Source/WebCore/dom/Document.cpp

    r218229 r218376  
    54095409{
    54105410    RefPtr<HTMLCanvasElement>& element = m_cssCanvasElements.add(name, nullptr).iterator->value;
    5411     if (!element)
     5411    if (!element) {
    54125412        element = HTMLCanvasElement::create(*this);
     5413        InspectorInstrumentation::didCreateCSSCanvas(*element, name);
     5414    }
    54135415    return element.get();
    54145416}
  • trunk/Source/WebCore/html/HTMLCanvasElement.cpp

    r217651 r218376  
    4444#include "HTMLParserIdioms.h"
    4545#include "ImageData.h"
     46#include "InspectorInstrumentation.h"
    4647#include "MIMETypeRegistry.h"
    4748#include "RenderHTMLCanvas.h"
     
    248249        downcast<CanvasRenderingContext2D>(*m_context).setTracksDisplayListReplay(m_tracksDisplayListReplay);
    249250
     251        InspectorInstrumentation::didCreateCanvasRenderingContext(*this);
     252
    250253#if USE(IOSURFACE_CANVAS_BACKING_STORE) || ENABLE(ACCELERATED_2D_CANVAS)
    251254        // Need to make sure a RenderLayer and compositing layer get created for the Canvas
     
    303306            // Need to make sure a RenderLayer and compositing layer get created for the Canvas
    304307            invalidateStyleAndLayerComposition();
     308
     309            InspectorInstrumentation::didCreateCanvasRenderingContext(*this);
    305310        }
    306311    }
  • trunk/Source/WebCore/inspector/InspectorAllInOne.cpp

    r211771 r218376  
    3232#include "InspectorApplicationCacheAgent.cpp"
    3333#include "InspectorCSSAgent.cpp"
     34#include "InspectorCanvasAgent.cpp"
    3435#include "InspectorClient.cpp"
    3536#include "InspectorController.cpp"
  • trunk/Source/WebCore/inspector/InspectorController.cpp

    r217509 r218376  
    3939#include "InspectorApplicationCacheAgent.h"
    4040#include "InspectorCSSAgent.h"
     41#include "InspectorCanvasAgent.h"
    4142#include "InspectorClient.h"
    4243#include "InspectorDOMAgent.h"
     
    184185    m_agents.append(std::make_unique<InspectorWorkerAgent>(pageContext));
    185186
     187    auto canvasAgentPtr = std::make_unique<InspectorCanvasAgent>(pageContext, pageAgent);
     188    m_instrumentingAgents->setInspectorCanvasAgent(canvasAgentPtr.get());
     189    m_agents.append(WTFMove(canvasAgentPtr));
     190
    186191    ASSERT(m_injectedScriptManager->commandLineAPIHost());
    187192    if (CommandLineAPIHost* commandLineAPIHost = m_injectedScriptManager->commandLineAPIHost()) {
  • trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp

    r215173 r218376  
    4141#include "InspectorApplicationCacheAgent.h"
    4242#include "InspectorCSSAgent.h"
     43#include "InspectorCanvasAgent.h"
    4344#include "InspectorDOMAgent.h"
    4445#include "InspectorDOMDebuggerAgent.h"
     
    6263#include "ScriptController.h"
    6364#include "WebConsoleAgent.h"
     65#include "WebGLRenderingContextBase.h"
    6466#include "WebSocketFrame.h"
    6567#include <inspector/ConsoleMessage.h>
     
    749751    }
    750752
     753    if (InspectorCanvasAgent* canvasAgent = instrumentingAgents.inspectorCanvasAgent())
     754        canvasAgent->frameNavigated(loader);
     755
    751756    if (InspectorDOMAgent* domAgent = instrumentingAgents.inspectorDOMAgent())
    752757        domAgent->didCommitLoad(frame.document());
     
    988993}
    989994#endif
     995
     996void InspectorInstrumentation::didCreateCSSCanvasImpl(InstrumentingAgents* instrumentingAgents, HTMLCanvasElement& canvasElement, const String& name)
     997{
     998    if (InspectorCanvasAgent* canvasAgent = instrumentingAgents->inspectorCanvasAgent())
     999        canvasAgent->didCreateCSSCanvas(canvasElement, name);
     1000}
     1001
     1002void InspectorInstrumentation::didCreateCanvasRenderingContextImpl(InstrumentingAgents* instrumentingAgents, HTMLCanvasElement& canvasElement)
     1003{
     1004    if (InspectorCanvasAgent* canvasAgent = instrumentingAgents->inspectorCanvasAgent())
     1005        canvasAgent->didCreateCanvasRenderingContext(canvasElement);
     1006}
    9901007
    9911008#if ENABLE(WEB_REPLAY)
  • trunk/Source/WebCore/inspector/InspectorInstrumentation.h

    r215173 r218376  
    3737#include "FormData.h"
    3838#include "Frame.h"
     39#include "HTMLCanvasElement.h"
    3940#include "HitTestResult.h"
    4041#include "InspectorController.h"
     
    8283class ShadowRoot;
    8384class URL;
     85class WebGLRenderingContextBase;
    8486class WebKitNamedFlow;
    8587class WorkerInspectorProxy;
     
    243245    static void didHandleMemoryPressure(Page&, Critical);
    244246#endif
     247
     248    static void didCreateCSSCanvas(HTMLCanvasElement&, const String&);
     249    static void didCreateCanvasRenderingContext(HTMLCanvasElement&);
    245250
    246251    static void networkStateChanged(Page&);
     
    416421    static void updateApplicationCacheStatusImpl(InstrumentingAgents&, Frame&);
    417422
     423    static void didCreateCSSCanvasImpl(InstrumentingAgents*, HTMLCanvasElement&, const String&);
     424    static void didCreateCanvasRenderingContextImpl(InstrumentingAgents*, HTMLCanvasElement&);
     425
    418426    static void layerTreeDidChangeImpl(InstrumentingAgents&);
    419427    static void renderLayerDestroyedImpl(InstrumentingAgents&, const RenderLayer&);
     
    11741182#endif
    11751183
     1184inline void InspectorInstrumentation::didCreateCSSCanvas(HTMLCanvasElement& canvasElement, const String& name)
     1185{
     1186    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(&canvasElement.document()))
     1187        didCreateCSSCanvasImpl(instrumentingAgents, canvasElement, name);
     1188}
     1189   
     1190inline void InspectorInstrumentation::didCreateCanvasRenderingContext(HTMLCanvasElement& canvasElement)
     1191{
     1192    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(&canvasElement.document()))
     1193        didCreateCanvasRenderingContextImpl(instrumentingAgents, canvasElement);
     1194}
     1195
    11761196inline void InspectorInstrumentation::networkStateChanged(Page& page)
    11771197{
  • trunk/Source/WebCore/inspector/InstrumentingAgents.cpp

    r208008 r218376  
    6868    m_pageHeapAgent = nullptr;
    6969    m_inspectorDOMDebuggerAgent = nullptr;
     70    m_inspectorCanvasAgent = nullptr;
    7071}
    7172
  • trunk/Source/WebCore/inspector/InstrumentingAgents.h

    r208008 r218376  
    4545
    4646class InspectorApplicationCacheAgent;
     47class InspectorCanvasAgent;
    4748class InspectorCSSAgent;
    4849class InspectorDOMAgent;
     
    8384    InspectorPageAgent* inspectorPageAgent() const { return m_inspectorPageAgent; }
    8485    void setInspectorPageAgent(InspectorPageAgent* agent) { m_inspectorPageAgent = agent; }
     86
     87    InspectorCanvasAgent* inspectorCanvasAgent() const { return m_inspectorCanvasAgent; }
     88    void setInspectorCanvasAgent(InspectorCanvasAgent* agent) { m_inspectorCanvasAgent = agent; }
    8589
    8690    InspectorCSSAgent* inspectorCSSAgent() const { return m_inspectorCSSAgent; }
     
    171175    PageHeapAgent* m_pageHeapAgent { nullptr };
    172176    InspectorDOMDebuggerAgent* m_inspectorDOMDebuggerAgent { nullptr };
     177    InspectorCanvasAgent* m_inspectorCanvasAgent { nullptr };
    173178};
    174179
  • trunk/Source/WebInspectorUI/ChangeLog

    r218359 r218376  
     12017-06-15  Matt Baker  <mattbaker@apple.com>
     2
     3        Web Inspector: Instrument 2D/WebGL canvas contexts in the backend
     4        https://bugs.webkit.org/show_bug.cgi?id=172623
     5        <rdar://problem/32415986>
     6
     7        Reviewed by Devin Rousso.
     8
     9        * UserInterface/Base/Main.js:
     10        (WebInspector.loaded):
     11
     12        * UserInterface/Controllers/CanvasManager.js: Added.
     13        New frontend manager for the Canvas domain.
     14        (WebInspector.CanvasManager):
     15        (WebInspector.CanvasManager.prototype.get canvases):
     16        (WebInspector.CanvasManager.prototype.canvasAdded):
     17        (WebInspector.CanvasManager.prototype.canvasRemoved):
     18        (WebInspector.CanvasManager.prototype._mainResourceDidChange):
     19
     20        * UserInterface/Main.html:
     21        New files.
     22
     23        * UserInterface/Models/Canvas.js: Added.
     24        (WebInspector.Canvas):
     25        (WebInspector.Canvas.fromPayload):
     26        (WebInspector.Canvas.displayNameForContextType):
     27        Get displayable text "2D" or "WebGL" based on context type.
     28        (WebInspector.Canvas.resetUniqueDisplayNameNumbers):
     29        Called by CanvasManager when canvases are cleared.
     30        (WebInspector.Canvas.prototype.get identifier):
     31        (WebInspector.Canvas.prototype.get contextType):
     32        (WebInspector.Canvas.prototype.get frame):
     33        (WebInspector.Canvas.prototype.get cssCanvasName):
     34        For CSS canvases, the identifier passed to getCSSCanvasContext.
     35        (WebInspector.Canvas.prototype.get displayName):
     36        Get displayable canvas name. The name depends on how the canvas was
     37        created, and the information available:
     38          - getCSSCanvasContext: "CSS Canvas <identifier>"
     39          - getContext: "Canvas #<DOM id attribute value>"
     40          - Otherwise: "Canvas 1", "Canvas 2", ...
     41
     42        (WebInspector.Canvas.saveIdentityToCookie):
     43
     44        * UserInterface/Protocol/CanvasObserver.js: Added.
     45        (WebInspector.CanvasObserver.prototype.canvasAdded):
     46        (WebInspector.CanvasObserver.prototype.canvasRemoved):
     47        (WebInspector.CanvasObserver):
     48
     49        * UserInterface/Test.html:
     50        * UserInterface/Test/Test.js:
     51        (WebInspector.loaded):
     52
    1532017-06-15  Joseph Pecoraro  <pecoraro@apple.com>
    254
  • trunk/Source/WebInspectorUI/UserInterface/Base/Main.js

    r218042 r218376  
    9696    if (InspectorBackend.registerReplayDispatcher)
    9797        InspectorBackend.registerReplayDispatcher(new WebInspector.ReplayObserver);
     98    if (InspectorBackend.registerCanvasDispatcher)
     99        InspectorBackend.registerCanvasDispatcher(new WebInspector.CanvasObserver);
    98100
    99101    // Main backend target.
     
    137139    this.replayManager = new WebInspector.ReplayManager;
    138140    this.domDebuggerManager = new WebInspector.DOMDebuggerManager;
     141    this.canvasManager = new WebInspector.CanvasManager;
    139142
    140143    // Enable the Console Agent after creating the singleton managers.
  • trunk/Source/WebInspectorUI/UserInterface/Main.html

    r217924 r218376  
    275275    <script src="Protocol/ApplicationCacheObserver.js"></script>
    276276    <script src="Protocol/CSSObserver.js"></script>
     277    <script src="Protocol/CanvasObserver.js"></script>
    277278    <script src="Protocol/ConsoleObserver.js"></script>
    278279    <script src="Protocol/DOMObserver.js"></script>
     
    318319    <script src="Models/CSSStyleSheet.js"></script>
    319320    <script src="Models/CallFrame.js"></script>
     321    <script src="Models/Canvas.js"></script>
    320322    <script src="Models/Collection.js"></script>
    321323    <script src="Models/CollectionEntry.js"></script>
     
    735737    <script src="Controllers/BreakpointPopoverController.js"></script>
    736738    <script src="Controllers/CSSStyleManager.js"></script>
     739    <script src="Controllers/CanvasManager.js"></script>
    737740    <script src="Controllers/CodeMirrorColorEditingController.js"></script>
    738741    <script src="Controllers/CodeMirrorCompletionController.js"></script>
  • trunk/Source/WebInspectorUI/UserInterface/Test.html

    r217924 r218376  
    7272    <script src="Protocol/InspectorObserver.js"></script>
    7373    <script src="Protocol/CSSObserver.js"></script>
     74    <script src="Protocol/CanvasObserver.js"></script>
    7475    <script src="Protocol/ConsoleObserver.js"></script>
    7576    <script src="Protocol/DOMObserver.js"></script>
     
    106107    <script src="Models/CallingContextTree.js"></script>
    107108    <script src="Models/CallingContextTreeNode.js"></script>
     109    <script src="Models/Canvas.js"></script>
    108110    <script src="Models/Collection.js"></script>
    109111    <script src="Models/CollectionEntry.js"></script>
     
    186188    <script src="Controllers/BreakpointLogMessageLexer.js"></script>
    187189    <script src="Controllers/CSSStyleManager.js"></script>
     190    <script src="Controllers/CanvasManager.js"></script>
    188191    <script src="Controllers/DOMDebuggerManager.js"></script>
    189192    <script src="Controllers/DOMTreeManager.js"></script>
  • trunk/Source/WebInspectorUI/UserInterface/Test/Test.js

    r214841 r218376  
    5050    if (InspectorBackend.registerReplayDispatcher)
    5151        InspectorBackend.registerReplayDispatcher(new WebInspector.ReplayObserver);
     52    InspectorBackend.registerCanvasDispatcher(new WebInspector.CanvasObserver);
    5253
    5354    WebInspector.mainTarget = new WebInspector.MainTarget;
     
    7071    this.replayManager = new WebInspector.ReplayManager;
    7172    this.domDebuggerManager = new WebInspector.DOMDebuggerManager;
     73    this.canvasManager = new WebInspector.CanvasManager;
    7274
    7375    document.addEventListener("DOMContentLoaded", this.contentLoaded);
Note: See TracChangeset for help on using the changeset viewer.