Skip to content

Commit

Permalink
backport modern css js (#110)
Browse files Browse the repository at this point in the history
This patch ports brendangregg/FlameGraph#189 to inferno. The original author
has consented to us porting their work to this project:
#26 (comment).

Fixes #50.
  • Loading branch information
Andrii Radyk authored and jonhoo committed Mar 24, 2019
1 parent 8f09515 commit 84bd1bd
Show file tree
Hide file tree
Showing 42 changed files with 49,437 additions and 49,174 deletions.
33 changes: 5 additions & 28 deletions src/flamegraph/attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,8 @@ impl FuncFrameAttrsMap {
}
match name {
"title" => funcattrs.title = Some(value.to_string()),
"id" => funcattrs.g.id = Some(value.to_string()),
"class" => funcattrs.g.class = Some(value.to_string()),
"style" => funcattrs.g.style = Some(value.to_string()),
"onmouseover" => funcattrs.g.onmouseover = Some(value.to_string()),
"onmouseout" => funcattrs.g.onmouseout = Some(value.to_string()),
"onclick" => funcattrs.g.onclick = Some(value.to_string()),
"href" => funcattrs.a.href = Some(value.to_string()),
"target" => funcattrs.a.target = Some(value.to_string()),
"g_extra" => parse_extra_attrs(&mut funcattrs.g.extra, value),
Expand Down Expand Up @@ -99,20 +96,11 @@ pub(super) struct FrameAttrs {
/// Any of them set to `None` will get the default value.
#[derive(PartialEq, Eq, Debug, Default)]
pub(super) struct GElementAttrs {
/// Defaults to "func_g"
/// Will not be included if None
pub(super) class: Option<String>,

/// Will not be included if None
pub(super) style: Option<String>,

/// Defaults to "s(this)"
pub(super) onmouseover: Option<String>,

/// Defaults to "c()"
pub(super) onmouseout: Option<String>,

/// Defaults to "zoom(this)"
pub(super) onclick: Option<String>,
pub(super) id: Option<String>,

/// Extra attributes to include
pub(super) extra: Vec<(String, String)>,
Expand Down Expand Up @@ -194,10 +182,6 @@ mod test {
"title=foo title",
// With quotes
r#"class="foo class""#,
r#"style="foo style""#,
"onmouseover=foo_onmouseover()",
"onmouseout=foo_onmouseout()",
"onclick=foo_onclick()",
// gextra1 without quotes, gextra2 with quotes
r#"g_extra=gextra1=gextra1 gextra2="foo gextra2""#,
"href=foo href",
Expand All @@ -210,7 +194,6 @@ mod test {
let bar = vec![
"bar",
"class=bar class",
"onmouseover=bar_onmouseover()",
"href=bar href",
// With an invalid attribute that has no value
// This gets skipped and logged.
Expand All @@ -236,11 +219,8 @@ mod test {
FrameAttrs {
title: Some("foo title".to_owned()),
g: GElementAttrs {
id: None,
class: Some("foo class".to_owned()),
style: Some("foo style".to_owned()),
onmouseover: Some("foo_onmouseover()".to_owned()),
onmouseout: Some("foo_onmouseout()".to_owned()),
onclick: Some("foo_onclick()".to_owned()),
extra: foo_g_extra,
},
a: AElementAttrs {
Expand All @@ -261,11 +241,8 @@ mod test {
FrameAttrs {
title: None,
g: GElementAttrs {
id: None,
class: Some("bar class".to_owned()),
style: None,
onmouseover: Some("bar_onmouseover()".to_owned()),
onmouseout: None,
onclick: None,
extra: Vec::default(),
},
a: AElementAttrs {
Expand Down
7 changes: 7 additions & 0 deletions src/flamegraph/flamegraph.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#search { opacity:0.1; cursor:pointer; }
#search:hover, #search.show { opacity:1; }
#subtitle { text-anchor:middle; font-color:rgb(160,160,160); }
#unzoom { cursor:pointer; }
#frames > *:hover { stroke:black; stroke-width:0.5; cursor:pointer; }
.hide { display:none; }
.parent { opacity:0.5; }
Loading

0 comments on commit 84bd1bd

Please sign in to comment.