Title: [154033] trunk/Source/WebCore
Revision
154033
Author
[email protected]
Date
2013-08-13 17:58:06 -0700 (Tue, 13 Aug 2013)

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

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (154032 => 154033)


--- trunk/Source/WebCore/ChangeLog	2013-08-14 00:51:25 UTC (rev 154032)
+++ trunk/Source/WebCore/ChangeLog	2013-08-14 00:58:06 UTC (rev 154033)
@@ -1,3 +1,22 @@
+2013-08-13  Dean Jackson  <[email protected]>
+
+        <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  <[email protected]>
 
         [Windows] Windows is incorrectly using a LayerTypeTiledBackingLayer

Modified: trunk/Source/WebCore/bindings/js/ScriptProfiler.h (154032 => 154033)


--- trunk/Source/WebCore/bindings/js/ScriptProfiler.h	2013-08-14 00:51:25 UTC (rev 154032)
+++ trunk/Source/WebCore/bindings/js/ScriptProfiler.h	2013-08-14 00:58:06 UTC (rev 154033)
@@ -73,8 +73,6 @@
     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*) { }

Modified: trunk/Source/WebCore/html/HTMLCanvasElement.h (154032 => 154033)


--- trunk/Source/WebCore/html/HTMLCanvasElement.h	2013-08-14 00:51:25 UTC (rev 154032)
+++ trunk/Source/WebCore/html/HTMLCanvasElement.h	2013-08-14 00:58:06 UTC (rev 154033)
@@ -188,6 +188,20 @@
     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

Modified: trunk/Source/WebCore/inspector/InspectorCanvasAgent.cpp (154032 => 154033)


--- trunk/Source/WebCore/inspector/InspectorCanvasAgent.cpp	2013-08-14 00:51:25 UTC (rev 154032)
+++ trunk/Source/WebCore/inspector/InspectorCanvasAgent.cpp	2013-08-14 00:58:06 UTC (rev 154033)
@@ -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,36 +264,24 @@
 
 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;
+    for (Frame* frame = m_pageAgent->page()->mainFrame(); frame; frame = frame->tree()->traverseNext()) {
+        if (!frame->document())
+            continue;
 
-            HTMLCanvasElement* canvas = static_cast<HTMLCanvasElement*>(node);
-            if (canvas->renderingContext())
-                m_framesWithUninstrumentedCanvases.set(frame, true);
+        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);
         if (!frameId.isEmpty())
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to