Changeset 35842 in webkit


Ignore:
Timestamp:
Aug 19, 2008 11:33:27 AM (16 years ago)
Author:
timothy@apple.com
Message:

Added support for console.count in the inspector.

Reviewed by Geoff Garen.

  • page/Console.cpp: (WebCore::Console::count):
  • page/Console.h:
  • page/Console.idl: Added console.count.
  • page/InspectorController.cpp: (WebCore::InspectorController::didCommitLoad): Clears m_counts. (WebCore::InspectorController::count): Updates the count number sing "title@source:line" as the identifier, and adds a message to the console.
  • page/InspectorController.h: Added m_counts.
Location:
trunk/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r35841 r35842  
     12008-08-19  Keishi Hattori  <casey.hattori@gmail.com>
     2
     3        Added support for console.count in the inspector.
     4
     5        Reviewed by Geoff Garen.
     6
     7        * page/Console.cpp:
     8        (WebCore::Console::count):
     9        * page/Console.h:
     10        * page/Console.idl: Added console.count.
     11        * page/InspectorController.cpp:
     12        (WebCore::InspectorController::didCommitLoad): Clears m_counts.
     13        (WebCore::InspectorController::count): Updates the count number
     14        sing "title@source:line" as the identifier, and adds a
     15        message to the console.
     16        * page/InspectorController.h: Added m_counts.
     17
    1182008-08-19  Keishi Hattori  <casey.hattori@gmail.com>
    219
  • trunk/WebCore/page/Console.cpp

    r35833 r35842  
    262262}
    263263
     264void Console::count(const UString& title)
     265{
     266    if (!m_frame)
     267        return;
     268
     269    Page* page = m_frame->page();
     270    if (!page)
     271        return;
     272
     273    // FIXME: pass the file and line number to the InspectorController
     274    // when we have this information.
     275    page->inspectorController()->count(title, 0, String());
     276}
     277
    264278void Console::profile(ExecState* exec, const ArgList& args)
    265279{
  • trunk/WebCore/page/Console.h

    r35833 r35842  
    8181        void dir(KJS::ExecState*, const KJS::ArgList& arguments);
    8282        void assertCondition(bool condition, KJS::ExecState*, const KJS::ArgList& arguments);
     83        void count(const KJS::UString& title);
    8384        void profile(KJS::ExecState*, const KJS::ArgList& arguments);
    8485        void profileEnd(KJS::ExecState*, const KJS::ArgList& arguments);
  • trunk/WebCore/page/Console.idl

    r35787 r35842  
    3737        [Custom] void dir();
    3838        [Custom, ImplementationFunction=assertCondition] void assert(in boolean condition);
     39        void count(in [ConvertUndefinedOrNullToNullString] DOMString title);
    3940
    4041        [Custom] void profile(in DOMString title);
  • trunk/WebCore/page/InspectorController.cpp

    r35841 r35842  
    20872087
    20882088        m_times.clear();
     2089        m_counts.clear();
    20892090        m_profiles.clear();
    20902091
     
    25642565}
    25652566
     2567void InspectorController::count(const UString& title, unsigned lineNumber, const String& sourceID)
     2568{
     2569    String identifier = String(title) + String::format("@%s:%d", sourceID.utf8().data(), lineNumber);
     2570    HashMap<String, unsigned>::iterator it = m_counts.find(identifier);
     2571    int count;
     2572    if (it == m_counts.end())
     2573        count = 1;
     2574    else {
     2575        count = it->second + 1;
     2576        m_counts.remove(it);
     2577    }
     2578
     2579    m_counts.add(identifier, count);
     2580
     2581    String message = String::format("%s: %d", title.UTF8String().c_str(), count);
     2582    addMessageToConsole(JSMessageSource, LogMessageLevel, message, lineNumber, sourceID);
     2583}
     2584
    25662585void InspectorController::startTiming(const UString& title)
    25672586{
  • trunk/WebCore/page/InspectorController.h

    r35788 r35842  
    178178    void drawNodeHighlight(GraphicsContext&) const;
    179179   
     180    void count(const KJS::UString& title, unsigned lineNumber, const String& sourceID);
     181
    180182    void startTiming(const KJS::UString& title);
    181183    bool stopTiming(const KJS::UString& title, double& elapsed);
     
    234236    Vector<RefPtr<KJS::Profile> > m_profiles;
    235237    HashMap<String, double> m_times;
     238    HashMap<String, unsigned> m_counts;
    236239#if ENABLE(DATABASE)
    237240    DatabaseResourcesSet m_databaseResources;
Note: See TracChangeset for help on using the changeset viewer.