Skip to content

DevTools: Inspect node styles - #33025

Merged
mrobinson merged 12 commits into
servo:mainfrom
eerii:devtools-style
Aug 25, 2024
Merged

mrobinson merged 12 commits into
servo:mainfrom
eerii:devtools-style

Conversation

@eerii

@eerii eerii commented Aug 13, 2024 •

Copy link
Copy Markdown
Member

This pr restores the element style inspector and the computed styles list.

New features:

  • View the applied styles for a node (the ones defined explicitly). This includes the style attribute (for example <p style="color: blue">) and the styles defined in stylesheets (like p { color: blue; })
  • Modify the applied styles or add a new one. Preview the changes live.
  • View the computed styles for a node (all of the calculated css properties).
  • Show all of the supported CSS properties, mark the ones that are spelled wrongly and autocomplete names.

Future work:

  • Disable properties with the checkbox (start with getCompatibility for the inspector actor)
  • Handle pseudo elements (check AppliedEntry::pseudo_element in the page style actor)
  • Improve the way it works with big websites, and add some type of caching

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 mentioned this pull request Aug 13, 2024
22 of 26 tasks
@eerii
eerii marked this pull request as ready for review August 15, 2024 18:19
@eerii
eerii requested a review from gterzian as a code owner August 15, 2024 18:19
@eerii

eerii commented Aug 16, 2024

Copy link
Copy Markdown
Member Author

This should be ready for review now @mrobinson :)


let css_properties = CssPropertiesActor::new(actors.new_name("css-properties"));
let properties = (|| {
let (tx, rx) = ipc::channel().ok()?;

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
let (tx, rx) = ipc::channel().ok()?;
let (properties_sender, properties_receiver) = ipc::channel().ok()?;


// Get the css selectors that match this node present in the currently active stylesheets
let selectors = (|| {
let (tx, rx) = ipc::channel().ok()?;

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
let (tx, rx) = ipc::channel().ok()?;
let (selector_sender, selectors_receiver) = ipc::channel().ok()?;

///
/// - `isPositionEditable`: Informs whether you can change a style property in the inspector
/// - `isPositionEditable`: Informs whether you can change a style property in the inspector.
fn handle_message(

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.

This getting quite large. Would it be possible to split it into methods -- one per message?

let node = registry.find::<NodeActor>(&self.node);
let walker = registry.find::<WalkerActor>(&node.walker);

let (tx, rx) = ipc::channel().ok()?;

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
let (tx, rx) = ipc::channel().ok()?;
let (document_sender, document_receiver) = ipc::channel().ok()?;

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

Copy link
Copy Markdown
Member

Great work! I've pushed a new commit with some minor nits, but otherwise this looks good. I'll push to the MQ now.

@mrobinson
mrobinson enabled auto-merge August 25, 2024 09:02
@mrobinson
mrobinson added this pull request to the merge queue Aug 25, 2024
Merged via the queue into servo:main with commit 6357998 Aug 25, 2024
@eerii
eerii deleted the devtools-style branch October 21, 2025 17:41
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