Commit 2645e53e authored by dino@apple.com's avatar dino@apple.com

<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.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154033 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent f15eb3dc
2013-08-13 Dean Jackson <dino@apple.com>
<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.
2013-08-13 Brent Fulgham <bfulgham@apple.com>
[Windows] Windows is incorrectly using a LayerTypeTiledBackingLayer
......@@ -73,8 +73,6 @@ public:
static bool causesRecompilation() { return true; }
static bool isSampling() { return false; }
static bool hasHeapProfiler() { return false; }
// FIXME: Implement this counter for JSC. See bug 73936 for more details.
static void visitNodeWrappers(WrappedNodeVisitor*) { }
// FIXME: Support these methods for JSC. See bug 90358.
static void visitExternalStrings(ExternalStringVisitor*) { }
static void visitExternalArrays(ExternalArrayVisitor*) { }
......
......@@ -188,6 +188,20 @@ private:
mutable RefPtr<Image> m_copiedImage; // FIXME: This is temporary for platforms that have to copy the image buffer to render (and for CSSCanvasValue).
};
inline bool isHTMLCanvasElement(const Node* node)
{
return node->hasTagName(HTMLNames::canvasTag);
}
inline const HTMLCanvasElement* toHTMLCanvasElement(const Node* node)
{
ASSERT_WITH_SECURITY_IMPLICATION(!node || isHTMLCanvasElement(node));
return static_cast<const HTMLCanvasElement*>(node);
}
// This will catch anyone doing an unnecessary cast.
void toHTMLCanvasElement(const HTMLCanvasElement*);
} //namespace
#endif
......@@ -46,6 +46,7 @@
#include "InspectorPageAgent.h"
#include "InspectorState.h"
#include "InstrumentingAgents.h"
#include "NodeList.h"
#include "Page.h"
#include "ScriptObject.h"
#include "ScriptProfiler.h"
......@@ -263,35 +264,23 @@ InjectedScriptCanvasModule InspectorCanvasAgent::injectedScriptCanvasModule(Erro
void InspectorCanvasAgent::findFramesWithUninstrumentedCanvases()
{
class NodeVisitor : public WrappedNodeVisitor {
public:
NodeVisitor(Page* page, FramesWithUninstrumentedCanvases& result)
: m_page(page)
, m_framesWithUninstrumentedCanvases(result)
{
}
m_framesWithUninstrumentedCanvases.clear();
virtual void visitNode(Node* node) OVERRIDE
{
if (!node->hasTagName(HTMLNames::canvasTag) || !node->document() || !node->document()->frame())
return;
Frame* frame = node->document()->frame();
if (frame->page() != m_page)
return;
HTMLCanvasElement* canvas = static_cast<HTMLCanvasElement*>(node);
if (canvas->renderingContext())
m_framesWithUninstrumentedCanvases.set(frame, true);
for (Frame* frame = m_pageAgent->page()->mainFrame(); frame; frame = frame->tree()->traverseNext()) {
if (!frame->document())
continue;
RefPtr<NodeList> canvases = frame->document()->getElementsByTagName(HTMLNames::canvasTag.localName());
if (canvases) {
for (unsigned i = 0, length = canvases->length(); i < length; i++) {
const HTMLCanvasElement* canvas = toHTMLCanvasElement(canvases->item(i));
if (canvas->renderingContext()) {
m_framesWithUninstrumentedCanvases.set(frame, true);
break;
}
}
}
private:
Page* m_page;
FramesWithUninstrumentedCanvases& m_framesWithUninstrumentedCanvases;
} nodeVisitor(m_pageAgent->page(), m_framesWithUninstrumentedCanvases);
m_framesWithUninstrumentedCanvases.clear();
ScriptProfiler::visitNodeWrappers(&nodeVisitor);
}
for (FramesWithUninstrumentedCanvases::iterator it = m_framesWithUninstrumentedCanvases.begin(); it != m_framesWithUninstrumentedCanvases.end(); ++it) {
String frameId = m_pageAgent->frameId(it->key);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment