Changeset 88940 in webkit


Ignore:
Timestamp:
Jun 15, 2011 8:44:00 AM (13 years ago)
Author:
caseq@chromium.org
Message:

2011-06-15 Andrey Kosyakov <caseq@chromium.org>

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):
Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r88939 r88940  
     12011-06-15  Andrey Kosyakov  <caseq@chromium.org>
     2
     3        Reviewed by Pavel Feldman.
     4
     5        Web Inspector: provide unique identifiers for frames
     6        https://bugs.webkit.org/show_bug.cgi?id=62721
     7
     8        * inspector/InspectorInstrumentation.cpp:
     9        (WebCore::InspectorInstrumentation::frameDestroyedImpl):
     10        * inspector/InspectorInstrumentation.h:
     11        (WebCore::InspectorInstrumentation::frameDestroyed):
     12        * inspector/InspectorPageAgent.cpp:
     13        (WebCore::InspectorPageAgent::frameForId):
     14        (WebCore::InspectorPageAgent::frameId):
     15        (WebCore::InspectorPageAgent::frameDestroyed):
     16        * inspector/InspectorPageAgent.h:
     17        * page/Frame.cpp:
     18        (WebCore::Frame::~Frame):
     19
    1202011-06-15  Andrey Kosyakov  <caseq@chromium.org>
    221
  • trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp

    r88937 r88940  
    631631}
    632632
     633void InspectorInstrumentation::frameDestroyedImpl(InstrumentingAgents* instrumentingAgents, Frame* frame)
     634{
     635    if (InspectorPageAgent* inspectorPageAgent = instrumentingAgents->inspectorPageAgent())
     636        inspectorPageAgent->frameDestroyed(frame);
     637}
     638
    633639InspectorInstrumentationCookie InspectorInstrumentation::willWriteHTMLImpl(InstrumentingAgents* instrumentingAgents, unsigned int length, unsigned int startLine)
    634640{
  • trunk/Source/WebCore/inspector/InspectorInstrumentation.h

    r88937 r88940  
    137137    static void frameDetachedFromParent(Frame*);
    138138    static void didCommitLoad(Frame*, DocumentLoader*);
     139    static void frameDestroyed(Frame*);
    139140
    140141    static InspectorInstrumentationCookie willWriteHTML(Document*, unsigned int length, unsigned int startLine);
     
    264265    static void frameDetachedFromParentImpl(InstrumentingAgents*, Frame*);
    265266    static void didCommitLoadImpl(InstrumentingAgents*, Page*, DocumentLoader*);
     267    static void frameDestroyedImpl(InstrumentingAgents*, Frame*);
    266268
    267269    static InspectorInstrumentationCookie willWriteHTMLImpl(InstrumentingAgents*, unsigned int length, unsigned int startLine);
     
    854856}
    855857
     858inline void InspectorInstrumentation::frameDestroyed(Frame* frame)
     859{
     860#if ENABLE(INSPECTOR)
     861    Page* page = frame->page();
     862    if (!page)
     863        return;
     864    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
     865        frameDestroyedImpl(instrumentingAgents, frame);
     866#endif
     867}
     868
    856869inline InspectorInstrumentationCookie InspectorInstrumentation::willWriteHTML(Document* document, unsigned int length, unsigned int startLine)
    857870{
  • trunk/Source/WebCore/inspector/InspectorPageAgent.cpp

    r86760 r88940  
    7070// This should be kept the same as the one in front-end/utilities.js
    7171static const char regexSpecialCharacters[] = "[](){}+-*.,?\\^$|";
     72static unsigned int s_lastFrameIdentifier = 0;
    7273}
    7374
     
    563564Frame* InspectorPageAgent::frameForId(const String& frameId)
    564565{
    565     Frame* mainFrame = m_page->mainFrame();
    566     for (Frame* frame = mainFrame; frame; frame = frame->tree()->traverseNext(mainFrame)) {
    567         if (pointerAsId(frame) == frameId)
    568             return frame;
    569     }
    570     return 0;
     566    bool ok = false;
     567    unsigned int identifier = frameId.toUIntStrict(&ok);
     568    if (!ok || !identifier)
     569        return 0;
     570    return m_identifierToFrame.get(identifier);
    571571}
    572572
    573573String InspectorPageAgent::frameId(Frame* frame)
    574574{
    575     return pointerAsId(frame);
     575    if (!frame)
     576        return "";
     577    unsigned int identifier = m_frameToIdentifier.get(frame);
     578    if (!identifier) {
     579        identifier = ++s_lastFrameIdentifier;
     580        m_frameToIdentifier.set(frame, identifier);
     581        m_identifierToFrame.set(identifier, frame);
     582    }
     583    return String::number(identifier);
    576584}
    577585
     
    579587{
    580588    return pointerAsId(loader);
     589}
     590
     591void InspectorPageAgent::frameDestroyed(Frame* frame)
     592{
     593    HashMap<Frame*, unsigned int>::iterator iterator = m_frameToIdentifier.find(frame);
     594    if (iterator != m_frameToIdentifier.end()) {
     595        m_identifierToFrame.remove(iterator->second);
     596        m_frameToIdentifier.remove(iterator);
     597    }
    581598}
    582599
  • trunk/Source/WebCore/inspector/InspectorPageAgent.h

    r86562 r88940  
    3434#if ENABLE(INSPECTOR)
    3535
     36#include "Frame.h"
    3637#include "InspectorFrontend.h"
    3738#include "PlatformString.h"
     39#include <wtf/HashMap.h>
    3840#include <wtf/RefCounted.h>
    3941#include <wtf/Vector.h>
     
    99101    void frameNavigated(DocumentLoader*);
    100102    void frameDetached(Frame*);
     103    void frameDestroyed(Frame*);
    101104
    102105    // Inspector Controller API
     
    121124    InspectorFrontend::Page* m_frontend;
    122125    Vector<String> m_scriptsToEvaluateOnLoad;
     126    HashMap<Frame*, unsigned int> m_frameToIdentifier;
     127    HashMap<unsigned int, Frame*> m_identifierToFrame;
    123128};
    124129
  • trunk/Source/WebCore/page/Frame.cpp

    r88737 r88940  
    5858#include "HTMLTableCellElement.h"
    5959#include "HitTestResult.h"
     60#include "InspectorInstrumentation.h"
    6061#include "Logging.h"
    6162#include "MediaFeatureNames.h"
     
    238239    for (HashSet<FrameDestructionObserver*>::iterator it = m_destructionObservers.begin(); it != stop; ++it)
    239240        (*it)->frameDestroyed();
     241
     242    InspectorInstrumentation::frameDestroyed(this);
    240243
    241244    if (m_view) {
Note: See TracChangeset for help on using the changeset viewer.