Title: [88940] trunk/Source/WebCore
Revision
88940
Author
[email protected]
Date
2011-06-15 08:44:00 -0700 (Wed, 15 Jun 2011)

Log Message

2011-06-15  Andrey Kosyakov  <[email protected]>

        Reviewed by Pavel Feldman.

        Web Inspector: provide unique identifiers for frames
        https://bugs.webkit.org/show_bug.cgi?id=62721

        * inspector/InspectorInstrumentation.cpp:
        (WebCore::InspectorInstrumentation::frameDestroyedImpl):
        * inspector/InspectorInstrumentation.h:
        (WebCore::InspectorInstrumentation::frameDestroyed):
        * inspector/InspectorPageAgent.cpp:
        (WebCore::InspectorPageAgent::frameForId):
        (WebCore::InspectorPageAgent::frameId):
        (WebCore::InspectorPageAgent::frameDestroyed):
        * inspector/InspectorPageAgent.h:
        * page/Frame.cpp:
        (WebCore::Frame::~Frame):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (88939 => 88940)


--- trunk/Source/WebCore/ChangeLog	2011-06-15 15:42:06 UTC (rev 88939)
+++ trunk/Source/WebCore/ChangeLog	2011-06-15 15:44:00 UTC (rev 88940)
@@ -1,5 +1,24 @@
 2011-06-15  Andrey Kosyakov  <[email protected]>
 
+        Reviewed by Pavel Feldman.
+
+        Web Inspector: provide unique identifiers for frames
+        https://bugs.webkit.org/show_bug.cgi?id=62721
+
+        * inspector/InspectorInstrumentation.cpp:
+        (WebCore::InspectorInstrumentation::frameDestroyedImpl):
+        * inspector/InspectorInstrumentation.h:
+        (WebCore::InspectorInstrumentation::frameDestroyed):
+        * inspector/InspectorPageAgent.cpp:
+        (WebCore::InspectorPageAgent::frameForId):
+        (WebCore::InspectorPageAgent::frameId):
+        (WebCore::InspectorPageAgent::frameDestroyed):
+        * inspector/InspectorPageAgent.h:
+        * page/Frame.cpp:
+        (WebCore::Frame::~Frame):
+
+2011-06-15  Andrey Kosyakov  <[email protected]>
+
         Unreviewed build fix: comment unused parameter names.
 
         * loader/ThreadableLoaderClient.h:

Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp (88939 => 88940)


--- trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp	2011-06-15 15:42:06 UTC (rev 88939)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp	2011-06-15 15:44:00 UTC (rev 88940)
@@ -630,6 +630,12 @@
         pageAgent->frameNavigated(loader);
 }
 
+void InspectorInstrumentation::frameDestroyedImpl(InstrumentingAgents* instrumentingAgents, Frame* frame)
+{
+    if (InspectorPageAgent* inspectorPageAgent = instrumentingAgents->inspectorPageAgent())
+        inspectorPageAgent->frameDestroyed(frame);
+}
+
 InspectorInstrumentationCookie InspectorInstrumentation::willWriteHTMLImpl(InstrumentingAgents* instrumentingAgents, unsigned int length, unsigned int startLine)
 {
     int timelineAgentId = 0;

Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.h (88939 => 88940)


--- trunk/Source/WebCore/inspector/InspectorInstrumentation.h	2011-06-15 15:42:06 UTC (rev 88939)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.h	2011-06-15 15:44:00 UTC (rev 88940)
@@ -136,6 +136,7 @@
     static void loadEventFired(Frame*, const KURL&);
     static void frameDetachedFromParent(Frame*);
     static void didCommitLoad(Frame*, DocumentLoader*);
+    static void frameDestroyed(Frame*);
 
     static InspectorInstrumentationCookie willWriteHTML(Document*, unsigned int length, unsigned int startLine);
     static void didWriteHTML(const InspectorInstrumentationCookie&, unsigned int endLine);
@@ -263,6 +264,7 @@
     static void loadEventFiredImpl(InstrumentingAgents*, Frame*, const KURL&);
     static void frameDetachedFromParentImpl(InstrumentingAgents*, Frame*);
     static void didCommitLoadImpl(InstrumentingAgents*, Page*, DocumentLoader*);
+    static void frameDestroyedImpl(InstrumentingAgents*, Frame*);
 
     static InspectorInstrumentationCookie willWriteHTMLImpl(InstrumentingAgents*, unsigned int length, unsigned int startLine);
     static void didWriteHTMLImpl(const InspectorInstrumentationCookie&, unsigned int endLine);
@@ -853,6 +855,17 @@
 #endif
 }
 
+inline void InspectorInstrumentation::frameDestroyed(Frame* frame)
+{
+#if ENABLE(INSPECTOR)
+    Page* page = frame->page();
+    if (!page)
+        return;
+    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
+        frameDestroyedImpl(instrumentingAgents, frame);
+#endif
+}
+
 inline InspectorInstrumentationCookie InspectorInstrumentation::willWriteHTML(Document* document, unsigned int length, unsigned int startLine)
 {
 #if ENABLE(INSPECTOR)

Modified: trunk/Source/WebCore/inspector/InspectorPageAgent.cpp (88939 => 88940)


--- trunk/Source/WebCore/inspector/InspectorPageAgent.cpp	2011-06-15 15:42:06 UTC (rev 88939)
+++ trunk/Source/WebCore/inspector/InspectorPageAgent.cpp	2011-06-15 15:44:00 UTC (rev 88940)
@@ -69,6 +69,7 @@
 namespace {
 // This should be kept the same as the one in front-end/utilities.js
 static const char regexSpecialCharacters[] = "[](){}+-*.,?\\^$|";
+static unsigned int s_lastFrameIdentifier = 0;
 }
 
 static bool decodeSharedBuffer(PassRefPtr<SharedBuffer> buffer, const String& textEncodingName, String* result)
@@ -562,17 +563,24 @@
 
 Frame* InspectorPageAgent::frameForId(const String& frameId)
 {
-    Frame* mainFrame = m_page->mainFrame();
-    for (Frame* frame = mainFrame; frame; frame = frame->tree()->traverseNext(mainFrame)) {
-        if (pointerAsId(frame) == frameId)
-            return frame;
-    }
-    return 0;
+    bool ok = false;
+    unsigned int identifier = frameId.toUIntStrict(&ok);
+    if (!ok || !identifier)
+        return 0;
+    return m_identifierToFrame.get(identifier);
 }
 
 String InspectorPageAgent::frameId(Frame* frame)
 {
-    return pointerAsId(frame);
+    if (!frame)
+        return "";
+    unsigned int identifier = m_frameToIdentifier.get(frame);
+    if (!identifier) {
+        identifier = ++s_lastFrameIdentifier;
+        m_frameToIdentifier.set(frame, identifier);
+        m_identifierToFrame.set(identifier, frame);
+    }
+    return String::number(identifier);
 }
 
 String InspectorPageAgent::loaderId(DocumentLoader* loader)
@@ -580,6 +588,15 @@
     return pointerAsId(loader);
 }
 
+void InspectorPageAgent::frameDestroyed(Frame* frame)
+{
+    HashMap<Frame*, unsigned int>::iterator iterator = m_frameToIdentifier.find(frame);
+    if (iterator != m_frameToIdentifier.end()) {
+        m_identifierToFrame.remove(iterator->second);
+        m_frameToIdentifier.remove(iterator);
+    }
+}
+
 PassRefPtr<InspectorObject> InspectorPageAgent::buildObjectForFrame(Frame* frame)
 {
     RefPtr<InspectorObject> frameObject = InspectorObject::create();

Modified: trunk/Source/WebCore/inspector/InspectorPageAgent.h (88939 => 88940)


--- trunk/Source/WebCore/inspector/InspectorPageAgent.h	2011-06-15 15:42:06 UTC (rev 88939)
+++ trunk/Source/WebCore/inspector/InspectorPageAgent.h	2011-06-15 15:44:00 UTC (rev 88940)
@@ -33,8 +33,10 @@
 
 #if ENABLE(INSPECTOR)
 
+#include "Frame.h"
 #include "InspectorFrontend.h"
 #include "PlatformString.h"
+#include <wtf/HashMap.h>
 #include <wtf/RefCounted.h>
 #include <wtf/Vector.h>
 
@@ -98,6 +100,7 @@
     void loadEventFired();
     void frameNavigated(DocumentLoader*);
     void frameDetached(Frame*);
+    void frameDestroyed(Frame*);
 
     // Inspector Controller API
     void setFrontend(InspectorFrontend*);
@@ -120,6 +123,8 @@
     InjectedScriptManager* m_injectedScriptManager;
     InspectorFrontend::Page* m_frontend;
     Vector<String> m_scriptsToEvaluateOnLoad;
+    HashMap<Frame*, unsigned int> m_frameToIdentifier;
+    HashMap<unsigned int, Frame*> m_identifierToFrame;
 };
 
 

Modified: trunk/Source/WebCore/page/Frame.cpp (88939 => 88940)


--- trunk/Source/WebCore/page/Frame.cpp	2011-06-15 15:42:06 UTC (rev 88939)
+++ trunk/Source/WebCore/page/Frame.cpp	2011-06-15 15:44:00 UTC (rev 88940)
@@ -57,6 +57,7 @@
 #include "HTMLNames.h"
 #include "HTMLTableCellElement.h"
 #include "HitTestResult.h"
+#include "InspectorInstrumentation.h"
 #include "Logging.h"
 #include "MediaFeatureNames.h"
 #include "MediaStreamFrameController.h"
@@ -238,6 +239,8 @@
     for (HashSet<FrameDestructionObserver*>::iterator it = m_destructionObservers.begin(); it != stop; ++it)
         (*it)->frameDestroyed();
 
+    InspectorInstrumentation::frameDestroyed(this);
+
     if (m_view) {
         m_view->hide();
         m_view->clearFrame();
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to