Skip to content

DevTools: Inline text and clean whitespace - #32884

Merged
mrobinson merged 5 commits into
servo:mainfrom
eerii:devtools-inline-v2
Jul 30, 2024
Merged

mrobinson merged 5 commits into
servo:mainfrom
eerii:devtools-inline-v2

Conversation

@eerii

@eerii eerii commented Jul 30, 2024 •

Copy link
Copy Markdown
Member

This PR addresses two issues left by #32655:

  • In some cases child text nodes are small enough to show them inline in the DOM tree view. When this happens, Servo needs to append an special inlineTextChild to the NodeActorMsg with the child's contents. The conditions for this are defined here:
    • The node only has one child
    • The child is a text node
    • The text is not very long (<50 characters, defined here)
    • The node is not a slot or a flex item
  • The spaces and line breaks in an HTML file are usually just separators that allow to format the code nicely. However, the browser treats this whitespace as an inline anonymous box. Usually this doesn't have any effect, but when they appear surrounded by inline elements they may have a non zero size, as seen in this example. Because of this, filtering the whitespace in the inspector tree is more tricky than it may seem, since we need to keep this inline whitespace because it can create gaps in the layout which should be inspectable. The rules for filtering are defined here.
Before After
image image

  • ./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 requested a review from gterzian as a code owner July 30, 2024 05:56
@eerii
eerii force-pushed the devtools-inline-v2 branch from e5a9c05 to 97841bd Compare July 30, 2024 05:57
@eerii eerii mentioned this pull request Jul 30, 2024
22 of 26 tasks

@mrobinson mrobinson left a comment

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.

Looks great. Just a few minor comments:

Comment thread components/script/devtools.rs Resolved
Comment thread components/script/devtools.rs Resolved
Signed-off-by: eri <[email protected]>
Signed-off-by: Martin Robinson <[email protected]>
Co-authored-by: Martin Robinson <[email protected]>
@mrobinson

Copy link
Copy Markdown
Member

Thanks!

@mrobinson
mrobinson enabled auto-merge July 30, 2024 09:55
@mrobinson
mrobinson added this pull request to the merge queue Jul 30, 2024
Merged via the queue into servo:main with commit c06a6a7 Jul 30, 2024
@eerii
eerii deleted the devtools-inline-v2 branch July 30, 2024 11:33
Gae24 pushed a commit to Gae24/servo that referenced this pull request Aug 7, 2024
* feat: inline text contents

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

* feat: filter whitespace only nodes

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

* chore: cleanup

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

* fix: url fix

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

* fix: review fixes

Signed-off-by: eri <[email protected]>
Signed-off-by: Martin Robinson <[email protected]>
Co-authored-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.

2 participants