mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
DevTools: Inspect node styles (#33025)
* feat: retrieve applied styles Signed-off-by: eri <eri@inventati.org> * feat: preliminary style showing Signed-off-by: eri <eri@inventati.org> * chore: some style tests Signed-off-by: eri <eri@inventati.org> * feat: edit style rules Signed-off-by: eri <eri@inventati.org> * feat: css database Signed-off-by: eri <eri@inventati.org> * feat: computed styles Signed-off-by: eri <eri@inventati.org> * feat: inherited styles Signed-off-by: eri <eri@inventati.org> * feat: get stylesheet styles Signed-off-by: eri <eri@inventati.org> * feat: all styles in inspector Signed-off-by: eri <eri@inventati.org> * feat: multiple stylesheets Signed-off-by: eri <eri@inventati.org> * refactor: clean up Signed-off-by: eri <eri@inventati.org> * Some minor cleanup Signed-off-by: Martin Robinson <mrobinson@igalia.com> --------- Signed-off-by: eri <eri@inventati.org> Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
67e2bb0ee6
commit
6357998ede
12 changed files with 810 additions and 200 deletions
|
@ -8,6 +8,7 @@
|
|||
use std::collections::HashMap;
|
||||
use std::net::TcpStream;
|
||||
|
||||
use devtools_traits::CssDatabaseProperty;
|
||||
use serde::Serialize;
|
||||
use serde_json::{Map, Value};
|
||||
|
||||
|
@ -17,21 +18,13 @@ use crate::StreamId;
|
|||
|
||||
pub struct CssPropertiesActor {
|
||||
name: String,
|
||||
properties: HashMap<String, CssDatabaseProperty>,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct CssDatabaseProperty {
|
||||
is_inherited: bool,
|
||||
values: Vec<&'static str>,
|
||||
supports: Vec<&'static str>,
|
||||
subproperties: Vec<&'static str>,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct GetCssDatabaseReply {
|
||||
properties: HashMap<&'static str, CssDatabaseProperty>,
|
||||
struct GetCssDatabaseReply<'a> {
|
||||
from: String,
|
||||
properties: &'a HashMap<String, CssDatabaseProperty>,
|
||||
}
|
||||
|
||||
impl Actor for CssPropertiesActor {
|
||||
|
@ -55,16 +48,7 @@ impl Actor for CssPropertiesActor {
|
|||
"getCSSDatabase" => {
|
||||
let _ = stream.write_json_packet(&GetCssDatabaseReply {
|
||||
from: self.name(),
|
||||
// TODO: Fill this programatically with other properties
|
||||
properties: HashMap::from([(
|
||||
"color",
|
||||
CssDatabaseProperty {
|
||||
is_inherited: true,
|
||||
values: vec!["color"],
|
||||
supports: vec!["color"],
|
||||
subproperties: vec!["color"],
|
||||
},
|
||||
)]),
|
||||
properties: &self.properties,
|
||||
});
|
||||
|
||||
ActorMessageStatus::Processed
|
||||
|
@ -75,7 +59,7 @@ impl Actor for CssPropertiesActor {
|
|||
}
|
||||
|
||||
impl CssPropertiesActor {
|
||||
pub fn new(name: String) -> Self {
|
||||
Self { name }
|
||||
pub fn new(name: String, properties: HashMap<String, CssDatabaseProperty>) -> Self {
|
||||
Self { name, properties }
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue