Changeset 158976 in webkit


Ignore:
Timestamp:
Nov 8, 2013 4:39:31 PM (10 years ago)
Author:
Alexandru Chiculita
Message:

Web Inspector: It should be possible to debug the Inspector code
https://bugs.webkit.org/show_bug.cgi?id=124065

Reviewed by Timothy Hatcher.

Source/WebKit2:

When the script is paused, the debugger will pause all the pages in the same PageGroup.
All the Inspector windows were created in the same PageGroup, so pausing one debugger
would stop the other too.

Added WebInspectorPageGroups to manage the PageGroups created for the Inspectors.
The WebInspectors will now use the inspection "level" to figure out which PageGroup to use.
The inspector that debugs the main page will use "WebInspectorPageGroupLevel1",
the second inspector (that debugs the first inspector) will use "WebInspectorPageGroupLevel2" ...

  • UIProcess/WebInspectorProxy.cpp:

(WebKit::WebInspectorPageGroups::shared):
(WebKit::WebInspectorPageGroups::inspectorLevel):
(WebKit::WebInspectorPageGroups::isInspectorPageGroup):
(WebKit::WebInspectorPageGroups::inspectorPageGroupLevel):
(WebKit::WebInspectorPageGroups::inspectorPageGroupForLevel):
(WebKit::WebInspectorPageGroups::createInspectorPageGroup):
(WebKit::WebInspectorProxy::WebInspectorProxy):
(WebKit::WebInspectorProxy::inspectorPageGroup):
(WebKit::WebInspectorProxy::isInspectorPage):
(WebKit::WebInspectorProxy::canAttach):

  • UIProcess/WebInspectorProxy.h:

LayoutTests:

Added test to check that a second inspector window can be used to debug the first one.

  • inspector-protocol/debugger/nested-inspectors-expected.txt: Added.
  • inspector-protocol/debugger/nested-inspectors.html: Added.
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r158967 r158976  
     12013-11-08  Alexandru Chiculita  <achicu@adobe.com>
     2
     3        Web Inspector: It should be possible to debug the Inspector code
     4        https://bugs.webkit.org/show_bug.cgi?id=124065
     5
     6        Reviewed by Timothy Hatcher.
     7
     8        Added test to check that a second inspector window can be used to debug the first one.
     9
     10        * inspector-protocol/debugger/nested-inspectors-expected.txt: Added.
     11        * inspector-protocol/debugger/nested-inspectors.html: Added.
     12
    1132013-11-08  Hans Muller  <hmuller@adobe.com>
    214
  • trunk/Source/WebKit2/ChangeLog

    r158971 r158976  
     12013-11-08  Alexandru Chiculita  <achicu@adobe.com>
     2
     3        Web Inspector: It should be possible to debug the Inspector code
     4        https://bugs.webkit.org/show_bug.cgi?id=124065
     5
     6        Reviewed by Timothy Hatcher.
     7
     8        When the script is paused, the debugger will pause all the pages in the same PageGroup.
     9        All the Inspector windows were created in the same PageGroup, so pausing one debugger
     10        would stop the other too.
     11
     12        Added WebInspectorPageGroups to manage the PageGroups created for the Inspectors.
     13        The WebInspectors will now use the inspection "level" to figure out which PageGroup to use.
     14        The inspector that debugs the main page will use "__WebInspectorPageGroupLevel1__",
     15        the second inspector (that debugs the first inspector) will use "__WebInspectorPageGroupLevel2__" ...
     16
     17        * UIProcess/WebInspectorProxy.cpp:
     18        (WebKit::WebInspectorPageGroups::shared):
     19        (WebKit::WebInspectorPageGroups::inspectorLevel):
     20        (WebKit::WebInspectorPageGroups::isInspectorPageGroup):
     21        (WebKit::WebInspectorPageGroups::inspectorPageGroupLevel):
     22        (WebKit::WebInspectorPageGroups::inspectorPageGroupForLevel):
     23        (WebKit::WebInspectorPageGroups::createInspectorPageGroup):
     24        (WebKit::WebInspectorProxy::WebInspectorProxy):
     25        (WebKit::WebInspectorProxy::inspectorPageGroup):
     26        (WebKit::WebInspectorProxy::isInspectorPage):
     27        (WebKit::WebInspectorProxy::canAttach):
     28        * UIProcess/WebInspectorProxy.h:
     29
    1302013-11-08  Anders Carlsson  <andersca@apple.com>
    231
  • trunk/Source/WebKit2/UIProcess/WebInspectorProxy.cpp

    r156550 r158976  
    5959const unsigned WebInspectorProxy::minimumAttachedHeight = 250;
    6060
    61 static PassRefPtr<WebPageGroup> createInspectorPageGroup()
    62 {
    63     RefPtr<WebPageGroup> pageGroup = WebPageGroup::create("__WebInspectorPageGroup__", false, false);
     61class WebInspectorPageGroups {
     62public:
     63    static WebInspectorPageGroups& shared()
     64    {
     65        DEFINE_STATIC_LOCAL(WebInspectorPageGroups, instance, ());
     66        return instance;
     67    }
     68
     69    unsigned inspectorLevel(WebPageGroup* inspectedPageGroup)
     70    {
     71        return isInspectorPageGroup(inspectedPageGroup) ? inspectorPageGroupLevel(inspectedPageGroup) + 1 : 1;
     72    }
     73
     74    bool isInspectorPageGroup(WebPageGroup* group)
     75    {
     76        return m_pageGroupLevel.contains(group);
     77    }
     78
     79    unsigned inspectorPageGroupLevel(WebPageGroup* group)
     80    {
     81        ASSERT(isInspectorPageGroup(group));
     82        return m_pageGroupLevel.get(group);
     83    }
     84
     85    WebPageGroup* inspectorPageGroupForLevel(unsigned level)
     86    {
     87        // The level is the key of the HashMap, so it cannot be 0.
     88        ASSERT(level);
     89
     90        auto iterator = m_pageGroupByLevel.find(level);
     91        if (iterator != m_pageGroupByLevel.end())
     92            return iterator->value.get();
     93
     94        RefPtr<WebPageGroup> group = createInspectorPageGroup(level);
     95        m_pageGroupByLevel.set(level, group.get());
     96        m_pageGroupLevel.set(group.get(), level);
     97        return group.get();
     98    }
     99
     100private:
     101    static PassRefPtr<WebPageGroup> createInspectorPageGroup(unsigned level)
     102    {
     103        RefPtr<WebPageGroup> pageGroup = WebPageGroup::create(String::format("__WebInspectorPageGroupLevel%u__", level), false, false);
    64104
    65105#ifndef NDEBUG
    66     // Allow developers to inspect the Web Inspector in debug builds.
    67     pageGroup->preferences()->setDeveloperExtrasEnabled(true);
    68     pageGroup->preferences()->setLogsPageMessagesToSystemConsoleEnabled(true);
    69 #endif
    70 
    71     pageGroup->preferences()->setApplicationChromeModeEnabled(true);
    72 
    73     return pageGroup.release();
    74 }
    75 
    76 WebPageGroup* WebInspectorProxy::inspectorPageGroup()
    77 {
    78     static WebPageGroup* pageGroup = createInspectorPageGroup().leakRef();
    79     return pageGroup;
    80 }
     106        // Allow developers to inspect the Web Inspector in debug builds.
     107        pageGroup->preferences()->setDeveloperExtrasEnabled(true);
     108        pageGroup->preferences()->setLogsPageMessagesToSystemConsoleEnabled(true);
     109#endif
     110
     111        pageGroup->preferences()->setApplicationChromeModeEnabled(true);
     112
     113        return pageGroup.release();
     114    }
     115
     116    typedef HashMap<unsigned, RefPtr<WebPageGroup> > PageGroupByLevelMap;
     117    typedef HashMap<WebPageGroup*, unsigned> PageGroupLevelMap;
     118
     119    PageGroupByLevelMap m_pageGroupByLevel;
     120    PageGroupLevelMap m_pageGroupLevel;
     121};
    81122
    82123WebInspectorProxy::WebInspectorProxy(WebPageProxy* page)
     
    99140#endif
    100141{
     142    m_level = WebInspectorPageGroups::shared().inspectorLevel(m_page->pageGroup());
    101143    m_page->process()->addMessageReceiver(Messages::WebInspectorProxy::messageReceiverName(), m_page->pageID(), this);
    102144}
     
    104146WebInspectorProxy::~WebInspectorProxy()
    105147{
     148}
     149
     150WebPageGroup* WebInspectorProxy::inspectorPageGroup() const
     151{
     152    return WebInspectorPageGroups::shared().inspectorPageGroupForLevel(m_level);
    106153}
    107154
     
    312359bool WebInspectorProxy::isInspectorPage(WebPageProxy* page)
    313360{
    314     return page->pageGroup() == inspectorPageGroup();
     361    return WebInspectorPageGroups::shared().isInspectorPageGroup(page->pageGroup());
    315362}
    316363
     
    503550
    504551    // Don't allow attaching to another inspector -- two inspectors in one window is too much!
    505     bool isInspectorPage = m_page->pageGroup() == inspectorPageGroup();
    506     if (isInspectorPage)
     552    if (m_level > 0)
    507553        return false;
    508554
  • trunk/Source/WebKit2/UIProcess/WebInspectorProxy.h

    r156354 r158976  
    191191    void open();
    192192
    193     static WebPageGroup* inspectorPageGroup();
     193    WebPageGroup* inspectorPageGroup() const;
    194194
    195195#if PLATFORM(GTK) || PLATFORM(EFL)
     
    217217    bool m_createdInspectorPage;
    218218    bool m_ignoreFirstBringToFront;
     219
     220    // The debugger stops all the pages in the same PageGroup. Having
     221    // all the inspectors in the same group will make it impossible to debug
     222    // the inspector code, so we use the level to make different page groups.
     223    unsigned m_level;
    219224
    220225    AttachmentSide m_attachmentSide;
Note: See TracChangeset for help on using the changeset viewer.