lewp_html/types/browsing_context.rs
1/// A browsing context is an environment in which Document objects are presented to the user.
2#[derive(Debug)]
3pub enum BrowsingContext {
4 /// Represents an empty browsing context.
5 Empty,
6 /// Represents a "_blank" browsing context.
7 Blank,
8 /// Represents a "_self" browsing context.
9 Self_,
10 /// Represents a "_parent" browsing context.
11 Parent,
12 /// Represents a "_top" browsing context.
13 Top,
14}
15
16impl std::fmt::Display for BrowsingContext {
17 fn fmt(
18 &self,
19 f: &mut std::fmt::Formatter<'_>,
20 ) -> Result<(), std::fmt::Error> {
21 let s = match self {
22 Self::Empty => String::from(""),
23 Self::Self_ => String::from("Self"),
24 _ => format!("{:?}", self),
25 };
26 write!(f, "_{}", s.to_lowercase())
27 }
28}