blob: 1318b7ed8372314915ccf9b70ffed089720696ba (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
use crate::prelude::*;
/// Hide content without affecting layout.
#[func]
#[capable(Layout, Inline)]
#[derive(Debug, Hash)]
pub struct HideNode(pub Content);
#[node]
impl HideNode {
fn construct(_: &Vm, args: &mut Args) -> SourceResult<Content> {
Ok(Self(args.expect("body")?).pack())
}
}
impl Layout for HideNode {
fn layout(
&self,
vt: &mut Vt,
styles: StyleChain,
regions: Regions,
) -> SourceResult<Fragment> {
let mut fragment = self.0.layout(vt, styles, regions)?;
for frame in &mut fragment {
frame.clear();
}
Ok(fragment)
}
}
impl Inline for HideNode {}
|