Bug 113398 - Web Inspector: add event for node inspection request while in inspection mode
Summary: Web Inspector: add event for node inspection request while in inspection mode
Status: RESOLVED WONTFIX
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (Deprecated) (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Dmitry Gozman
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-03-27 05:48 PDT by Dmitry Gozman
Modified: 2013-04-11 06:19 PDT (History)
12 users (show)

See Also:


Attachments
Patch (9.64 KB, patch)
2013-03-27 05:59 PDT, Dmitry Gozman
no flags Details | Formatted Diff | Diff
Patch (4.71 KB, patch)
2013-04-01 07:58 PDT, Dmitry Gozman
no flags Details | Formatted Diff | Diff
Patch (5.33 KB, patch)
2013-04-02 02:52 PDT, Dmitry Gozman
no flags Details | Formatted Diff | Diff
Patch (9.12 KB, patch)
2013-04-02 08:19 PDT, Dmitry Gozman
no flags Details | Formatted Diff | Diff
Patch (9.24 KB, patch)
2013-04-03 04:21 PDT, Dmitry Gozman
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dmitry Gozman 2013-03-27 05:48:58 PDT
Web Inspector: dispatch inspectNode to frontend without injected script. This will allow to inspect nodes while debugging.
Comment 1 Dmitry Gozman 2013-03-27 05:59:46 PDT
Created attachment 195293 [details]
Patch
Comment 2 Pavel Feldman 2013-03-27 06:57:59 PDT
Comment on attachment 195293 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=195293&action=review

> Source/WebCore/inspector/Inspector.json:1992
> +                "name": "shouldInspectNode",

You don't want them on DOM domain, you also want them to be hidden.

> Source/WebCore/inspector/InspectorDOMAgent.cpp:1031
> +    int nodeId = pushNodePathToFrontend(m_nodeToFocus.get());

It might be too early to push the node - document might not be requested yet.
Comment 3 Timothy Hatcher 2013-03-27 07:02:49 PDT
This seems overly complex — 2 methods and 1 event.

What problem does this solve? Why is this needed? "Why" should always be answered in the bug and/or change log.
Comment 4 Dmitry Gozman 2013-03-27 07:14:46 PDT
(In reply to comment #3)
> This seems overly complex — 2 methods and 1 event.
> 
> What problem does this solve? Why is this needed? "Why" should always be answered in the bug and/or change log.

As written in the bug description, this will allow to inspect nodes while debugging. Otherwise, security checks disallow to evaluate anything in injected script, if debugger stopped in another context (i.e. in iframe).

As for 2 additional methods, ChangeLog contains the explanation.
Comment 5 Dmitry Gozman 2013-03-27 07:15:20 PDT
Comment on attachment 195293 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=195293&action=review

>> Source/WebCore/inspector/Inspector.json:1992
>> +                "name": "shouldInspectNode",
> 
> You don't want them on DOM domain, you also want them to be hidden.

Which domain then? Inspector? Is it OK to use them from InspectorDOMAgent class then (I mean, it will introduce dependence InspectorDOMAgent <-- InspectorFrontend::Inspector) ?

>> Source/WebCore/inspector/InspectorDOMAgent.cpp:1031
>> +    int nodeId = pushNodePathToFrontend(m_nodeToFocus.get());
> 
> It might be too early to push the node - document might not be requested yet.

If so, this method will not do anything, and frontend will request nodeToFocus via getInspectedNode instead (which will happen after pushing document). See explanation in ChangeLog.
Comment 6 Timothy Hatcher 2013-03-27 07:24:28 PDT
Sorry I missed the bug description. Reading through it all again it makes sense, though still more complex than I would like.
Comment 7 Dmitry Gozman 2013-04-01 07:58:43 PDT
Created attachment 195969 [details]
Patch
Comment 8 Dmitry Gozman 2013-04-02 02:52:28 PDT
Created attachment 196109 [details]
Patch
Comment 9 Dmitry Gozman 2013-04-02 02:55:14 PDT
Separate event in DOM domain is the right thing here.
This also solves the problem with inspecting in debug mode, since we don't go into injected script.
Comment 10 Pavel Feldman 2013-04-02 07:06:46 PDT
Comment on attachment 196109 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=196109&action=review

> Source/WebCore/inspector/Inspector.json:2074
> +                "name": "nodeShouldBeInspected",

inspectNodeRequested

> Source/WebCore/inspector/InspectorDOMAgent.cpp:1033
> +    if (m_searchingForNode) {

Lets remove this "focusNode" method - it is misleading.

> Source/WebCore/inspector/front-end/DOMAgent.js:1050
> +        WebInspector.updateFocusedNode(nodeId);

DOMAgent is SDK, WebInspector is UI, no dependency is allowed.
Comment 11 Dmitry Gozman 2013-04-02 08:19:52 PDT
Created attachment 196145 [details]
Patch
Comment 12 Dmitry Gozman 2013-04-02 08:20:31 PDT
Comment on attachment 196109 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=196109&action=review

>> Source/WebCore/inspector/Inspector.json:2074
>> +                "name": "nodeShouldBeInspected",
> 
> inspectNodeRequested

Done.

>> Source/WebCore/inspector/InspectorDOMAgent.cpp:1033
>> +    if (m_searchingForNode) {
> 
> Lets remove this "focusNode" method - it is misleading.

Done. Code separated between InspectorController::inspect and InspectorDOMAgent::inspect.

>> Source/WebCore/inspector/front-end/DOMAgent.js:1050
>> +        WebInspector.updateFocusedNode(nodeId);
> 
> DOMAgent is SDK, WebInspector is UI, no dependency is allowed.

Fixed.
Comment 13 Pavel Feldman 2013-04-02 11:10:51 PDT
Comment on attachment 196145 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=196145&action=review

> Source/WebCore/inspector/InspectorController.cpp:346
> +    InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(mainWorldScriptState(frame));

if (node->nodeType() != Node::ELEMENT_NODE && node->nodeType() != Node::DOCUMENT_NODE) is now missing here.
Comment 14 Dmitry Gozman 2013-04-03 04:19:15 PDT
Comment on attachment 196145 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=196145&action=review

>> Source/WebCore/inspector/InspectorController.cpp:346
>> +    InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(mainWorldScriptState(frame));
> 
> if (node->nodeType() != Node::ELEMENT_NODE && node->nodeType() != Node::DOCUMENT_NODE) is now missing here.

Nice catch! Thanks. Fixed.
Comment 15 Dmitry Gozman 2013-04-03 04:21:25 PDT
Created attachment 196325 [details]
Patch