Skip to content

Instantly share code, notes, and snippets.

@pcwalton
Last active February 14, 2019 20:56
Show Gist options
  • Save pcwalton/cb4bedde82ad682bda5a0481ded32a35 to your computer and use it in GitHub Desktop.
Save pcwalton/cb4bedde82ad682bda5a0481ded32a35 to your computer and use it in GitHub Desktop.
struct LayoutObjectRef<T>(Arc<RwLock<LayoutObject<T>>>);
struct LayoutObject<T> {
style: Arc<ComputedValues>,
// position? borders? padding? margins?
contents: T,
}
struct BlockFormattingContext(BlockOrInline);
enum BlockOrInline {
Block(List<BlockLevel>),
Inline(List<InlineLevel>),
}
enum BlockLevel {
Normal(LayoutObjectRef<BlockOrInline>),
NewContext(LayoutObjectRef<FormattingContext>),
}
enum InlineLevel {
Text(LayoutObjectRef<Text>),
Inline(LayoutObjectRef<Inline>),
Replaced(LayoutObjectRef<FormattingContext>),
}
struct Text {
content: DOMString,
}
struct Inline {
flags: InlineFlags,
}
bitflags! {
flags InlineFlags: u8 {
const FIRST_FRAGMENT = 0x01;
const LAST_FRAGMENT = 0x02;
}
}
enum FormattingContext {
Flow(BlockFormattingContext),
Replaced,
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment