Skip to content
This repository was archived by the owner on Jul 10, 2023. It is now read-only.

Commit bd870b6

Browse files
committed
Include style attributes in selector matching.
1 parent b2a6568 commit bd870b6

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

select.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,23 @@ impl SelectCtx {
5454
a wide range of client-specific details like node relationships, names, and UA
5555
defaults.
5656
*/
57-
pub fn select_style<N: VoidPtrLike, H: SelectHandler<N>>(&self, node: &N, handler: &H) -> SelectResults {
57+
pub fn select_style<N: VoidPtrLike, H: SelectHandler<N>>(&self,
58+
node: &N,
59+
inline_style: Option<&Stylesheet>,
60+
handler: &H) -> SelectResults {
5861
let inner_handler = SelectHandlerWrapper {
5962
inner: handler
6063
};
64+
let inner_inline_style = match inline_style {
65+
None => None,
66+
Some(ref sheet) => Some(&sheet.inner),
67+
};
6168
SelectResults {
62-
inner: self.inner.select_style::<N, SelectHandlerWrapper<N, H>>(node, n::ll::t::CSS_MEDIA_SCREEN, None, &inner_handler)
69+
inner: self.inner.select_style::<N, SelectHandlerWrapper<N, H>>(
70+
node,
71+
n::ll::t::CSS_MEDIA_SCREEN,
72+
inner_inline_style,
73+
&inner_handler)
6374
}
6475
}
6576
}

stylesheet.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ CSS stylesheets, owned types, immutable after creation
99
use extra::net::url::Url;
1010
use util::DataStream;
1111
use netsurfcss::stylesheet::CssStylesheet;
12-
use parser::parse_stylesheet;
12+
use parser::{parse_stylesheet, parse_style_attribute};
1313

1414
pub struct Stylesheet {
1515
inner: CssStylesheet
@@ -21,4 +21,10 @@ impl Stylesheet {
2121
inner: parse_stylesheet(url, input)
2222
}
2323
}
24+
25+
pub fn from_attribute(url: Url, data: &str) -> Stylesheet {
26+
Stylesheet {
27+
inner: parse_style_attribute(url, data)
28+
}
29+
}
2430
}

0 commit comments

Comments
 (0)