Changeset 154033 in webkit


Ignore:
Timestamp:
Aug 13, 2013 5:58:06 PM (11 years ago)
Author:
dino@apple.com
Message:

<https://webkit.org/b/119776> Don't use ScriptProfiler to find canvases for instrumentation

Reviewed by Joseph Pecoraro.

InspectorCanvasAgent::findFramesWithUninstrumentedCanvases uses a ScriptProfiler to walk the tree
looking for canvas elements. This is currently not implemented in JSC, but we can do this directly
with DOM methods. We're only looking for Canvas elements that have a context, so there isn't a need
for this abstract walking object.

  • html/HTMLCanvasElement.h: Add new helpers to cast to <canvas>.

(WebCore::isHTMLCanvasElement):
(WebCore::toHTMLCanvasElement):

  • inspector/InspectorCanvasAgent.cpp:

(WebCore::InspectorCanvasAgent::findFramesWithUninstrumentedCanvases): Simply walk
the frame tree and use getElementsByTagName to find canvas elements.

  • bindings/js/bindings/js/ScriptProfiler.h: Removed unused method.
Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r154030 r154033  
     12013-08-13  Dean Jackson  <dino@apple.com>
     2
     3        <https://webkit.org/b/119776> Don't use ScriptProfiler to find canvases for instrumentation
     4
     5        Reviewed by Joseph Pecoraro.
     6
     7        InspectorCanvasAgent::findFramesWithUninstrumentedCanvases uses a ScriptProfiler to walk the tree
     8        looking for canvas elements. This is currently not implemented in JSC, but we can do this directly
     9        with DOM methods. We're only looking for Canvas elements that have a context, so there isn't a need
     10        for this abstract walking object.
     11
     12        * html/HTMLCanvasElement.h: Add new helpers to cast to <canvas>.
     13        (WebCore::isHTMLCanvasElement):
     14        (WebCore::toHTMLCanvasElement):
     15        * inspector/InspectorCanvasAgent.cpp:
     16        (WebCore::InspectorCanvasAgent::findFramesWithUninstrumentedCanvases): Simply walk
     17        the frame tree and use getElementsByTagName to find canvas elements.
     18        * bindings/js/bindings/js/ScriptProfiler.h: Removed unused method.
     19
    1202013-08-13  Brent Fulgham  <bfulgham@apple.com>
    221
  • trunk/Source/WebCore/bindings/js/ScriptProfiler.h

    r152080 r154033  
    7474    static bool isSampling() { return false; }
    7575    static bool hasHeapProfiler() { return false; }
    76     // FIXME: Implement this counter for JSC. See bug 73936 for more details.
    77     static void visitNodeWrappers(WrappedNodeVisitor*) { }
    7876    // FIXME: Support these methods for JSC. See bug 90358.
    7977    static void visitExternalStrings(ExternalStringVisitor*) { }
  • trunk/Source/WebCore/html/HTMLCanvasElement.h

    r151822 r154033  
    189189};
    190190
     191inline bool isHTMLCanvasElement(const Node* node)
     192{
     193    return node->hasTagName(HTMLNames::canvasTag);
     194}
     195
     196inline const HTMLCanvasElement* toHTMLCanvasElement(const Node* node)
     197{
     198    ASSERT_WITH_SECURITY_IMPLICATION(!node || isHTMLCanvasElement(node));
     199    return static_cast<const HTMLCanvasElement*>(node);
     200}
     201
     202// This will catch anyone doing an unnecessary cast.
     203void toHTMLCanvasElement(const HTMLCanvasElement*);
     204
    191205} //namespace
    192206
  • trunk/Source/WebCore/inspector/InspectorCanvasAgent.cpp

    r143328 r154033  
    4747#include "InspectorState.h"
    4848#include "InstrumentingAgents.h"
     49#include "NodeList.h"
    4950#include "Page.h"
    5051#include "ScriptObject.h"
     
    264265void InspectorCanvasAgent::findFramesWithUninstrumentedCanvases()
    265266{
    266     class NodeVisitor : public WrappedNodeVisitor {
    267     public:
    268         NodeVisitor(Page* page, FramesWithUninstrumentedCanvases& result)
    269             : m_page(page)
    270             , m_framesWithUninstrumentedCanvases(result)
    271         {
     267    m_framesWithUninstrumentedCanvases.clear();
     268
     269    for (Frame* frame = m_pageAgent->page()->mainFrame(); frame; frame = frame->tree()->traverseNext()) {
     270        if (!frame->document())
     271            continue;
     272
     273        RefPtr<NodeList> canvases = frame->document()->getElementsByTagName(HTMLNames::canvasTag.localName());
     274        if (canvases) {
     275            for (unsigned i = 0, length = canvases->length(); i < length; i++) {
     276                const HTMLCanvasElement* canvas = toHTMLCanvasElement(canvases->item(i));
     277                if (canvas->renderingContext()) {
     278                    m_framesWithUninstrumentedCanvases.set(frame, true);
     279                    break;
     280                }
     281            }
    272282        }
    273 
    274         virtual void visitNode(Node* node) OVERRIDE
    275         {
    276             if (!node->hasTagName(HTMLNames::canvasTag) || !node->document() || !node->document()->frame())
    277                 return;
    278            
    279             Frame* frame = node->document()->frame();
    280             if (frame->page() != m_page)
    281                 return;
    282 
    283             HTMLCanvasElement* canvas = static_cast<HTMLCanvasElement*>(node);
    284             if (canvas->renderingContext())
    285                 m_framesWithUninstrumentedCanvases.set(frame, true);
    286         }
    287 
    288     private:
    289         Page* m_page;
    290         FramesWithUninstrumentedCanvases& m_framesWithUninstrumentedCanvases;
    291     } nodeVisitor(m_pageAgent->page(), m_framesWithUninstrumentedCanvases);
    292 
    293     m_framesWithUninstrumentedCanvases.clear();
    294     ScriptProfiler::visitNodeWrappers(&nodeVisitor);
     283    }
    295284
    296285    for (FramesWithUninstrumentedCanvases::iterator it = m_framesWithUninstrumentedCanvases.begin(); it != m_framesWithUninstrumentedCanvases.end(); ++it) {
Note: See TracChangeset for help on using the changeset viewer.