Skip to content

DevTools: Show HTML tree - #32655

Merged
mrobinson merged 15 commits into
servo:mainfrom
eerii:devtools-inspector
Jul 26, 2024
Merged

mrobinson merged 15 commits into
servo:mainfrom
eerii:devtools-inspector

Conversation

@eerii

@eerii eerii commented Jul 1, 2024 •

Copy link
Copy Markdown
Member

This PR partly restores the HTML inspector functionality for the DevTools implementation. The inspector is probably the part of the devtools that has more associated actors. There were quite a few API changes since the last working implementation, so making it work again requires both fixing existing actors and creating new ones.

Existing actors New actors
Inspector Accessibility
Walker Access. Walker
Highligter Simulator
Node CSS Properties
Page Style Reflow
Layout
Thread
Network Parent

Some of the new actors and messages are placeholders that don't contain correct information yet, but they are required for the flow of messages to continue, since Firefox waits until a reply is issued for some of them to emit others.

image

Right now the DOM tree outline is showing, with two caveats that will be addressed in future PRs (since this has already gotten quite big):

  • Node contents don't show up, for example, the text inside a paragraph. This is because this needs to be sent as a special inline content field in the node message which is not handled yet.
  • Styles and CSS are not there yet since they require quite a few more work.

A few actors and message fields also seem to be outdated, namely Emulation, Performance and Timeline. Since Emulation was only a placeholder I removed it, but I kept the other two since they had work done in them that might be useful.


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes are a part of Fix support for the DevTools protocol #32404
  • These changes do not require tests because there are no tests yet for DevTools

@eerii eerii mentioned this pull request Jul 1, 2024
22 of 26 tasks
@nicoburns

Copy link
Copy Markdown
Contributor

Amazing. As someone working on Servo's layout, I can't wait for this to land. At the moment if something isn't laying out correctly, it is not at all easy to work out why, and being able to interactively inspect the layout and the styles would be a complete game changer.

@mrobinson

Copy link
Copy Markdown
Member

Amazing. As someone working on Servo's layout, I can't wait for this to land. At the moment if something isn't laying out correctly, it is not at all easy to work out why, and being able to interactively inspect the layout and the styles would be a complete game changer.

In the meantime, you can also use -Z dump-flow-tree to when running Servo to see what the fragment tree looks like.

@nicoburns

Copy link
Copy Markdown
Contributor

In the meantime, you can also use -Z dump-flow-tree to when running Servo to see what the fragment tree looks like.

Oh, thanks. That looks really helpful. Although I'm still really looking forward to the interactive inspector, as I find that debug trees printed out in full are very verbose and hard to debug through (better than nothing though! And perhaps I can reduce my examples down to find the relevant parts of the tree)

@eerii
eerii force-pushed the devtools-inspector branch from bb852c9 to 11ec349 Compare July 4, 2024 18:50
@eerii eerii mentioned this pull request Jul 8, 2024
4 tasks done
@eerii
eerii force-pushed the devtools-inspector branch 2 times, most recently from 38e1d15 to 5936960 Compare July 10, 2024 17:06
@eerii
eerii force-pushed the devtools-inspector branch from 46d446f to 57f8ab4 Compare July 10, 2024 18:07
@eerii
eerii force-pushed the devtools-inspector branch from 820dcef to 43c1ddd Compare July 16, 2024 07:48
@eerii

eerii commented Jul 17, 2024

Copy link
Copy Markdown
Member Author

Quick update on this, there is still work to be done but we finally have a preview of the DOM tree. It still doesn't show the contents or the style, but the node walking is now working.

image

Before going further I am going to focus on cleaning this pr, since it got a bit messy with all of the changes.

@eerii
eerii force-pushed the devtools-inspector branch from 0399bbd to 34542da Compare July 17, 2024 17:09
@eerii eerii changed the title DevTools: Restore inspector DevTools: Show HTML tree Jul 18, 2024
@eerii
eerii marked this pull request as ready for review July 18, 2024 09:39
@eerii
eerii requested a review from gterzian as a code owner July 18, 2024 09:39
@eerii
eerii force-pushed the devtools-inspector branch from 31caf17 to a9cdb2d Compare July 18, 2024 09:44
@eerii
eerii force-pushed the devtools-inspector branch from 2133d52 to ca51072 Compare July 25, 2024 08:27
Comment thread components/devtools/actors/reflow.rs Resolved
Comment thread components/devtools/actors/reflow.rs Resolved
Ok(ActorMessageStatus::Ignored)
Ok(match msg_type {
"start" => {
// TODO: Create an observer on "reflows" events

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// TODO: Create an observer on "reflows" events
// TODO: Create an observer on "reflows" events.

Comment thread components/devtools/actors/timeline.rs Resolved
Comment thread components/devtools/actors/watcher.rs Resolved

/// The network parent actor can handle the following messages:
///
/// - `setSaveRequestAndResponseBodies`: Doesn't do anything yet

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// - `setSaveRequestAndResponseBodies`: Doesn't do anything yet
/// - `setSaveRequestAndResponseBodies`: Doesn't do anything yet

Fix a few nits in comments

Signed-off-by: Martin Robinson <[email protected]>
@mrobinson

Copy link
Copy Markdown
Member

I'm mainly rubber-stamping this one as there are many changes we need to make to the data structures and messages to become compatible with the newer version of the DevTools protocol. Nothing here seems out-of-line with that idea. Thanks!

@mrobinson
mrobinson enabled auto-merge July 26, 2024 15:01
@mrobinson
mrobinson added this pull request to the merge queue Jul 26, 2024
Merged via the queue into servo:main with commit 902bf57 Jul 26, 2024
@eerii
eerii deleted the devtools-inspector branch July 27, 2024 16:33
@eerii eerii mentioned this pull request Jul 30, 2024
4 tasks done
Gae24 pushed a commit to Gae24/servo that referenced this pull request Aug 7, 2024
* feat: watch root node

Signed-off-by: eri <[email protected]>

* reafactor: divide inspector in components

Signed-off-by: eri <[email protected]>

* feat: add css properties actor

Signed-off-by: eri <[email protected]>

* feat: accesibility actor

Signed-off-by: eri <[email protected]>

* feat: layout actor

Signed-off-by: eri <[email protected]>

* feat: network parent and refactor

Signed-off-by: eri <[email protected]>

* feat: progress on the inspector messages

Signed-off-by: eri <[email protected]>

* feat: more progress on inspector

Signed-off-by: eri <[email protected]>

* feat: try to fix nodes showing

Signed-off-by: eri <[email protected]>

* feat: initial dom tree

Signed-off-by: eri <[email protected]>

* feat: some more messages

Signed-off-by: eri <[email protected]>

* feat: clean and add documentation

Signed-off-by: eri <[email protected]>

* refactor: add more docs and clean

Signed-off-by: eri <[email protected]>

* fix: restore deleted node attributes field

Signed-off-by: eri <[email protected]>

* Apply suggestions from code review

Fix a few nits in comments

Signed-off-by: Martin Robinson <[email protected]>

---------

Signed-off-by: eri <[email protected]>
Signed-off-by: Martin Robinson <[email protected]>
Co-authored-by: Martin Robinson <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants