mirror of
https://github.com/servo/servo.git
synced 2025-06-23 16:44:33 +01:00
Create a trait for RenderBox.
This commit is contained in:
parent
94b0ecd850
commit
2bc9e66257
1 changed files with 24 additions and 15 deletions
|
@ -97,15 +97,19 @@ pub enum RenderBox {
|
||||||
UnscannedTextBox(RenderBoxData, ~str)
|
UnscannedTextBox(RenderBoxData, ~str)
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RenderBox {
|
trait RenderBoxMethods {
|
||||||
pure fn d(&self) -> &self/RenderBoxData {
|
pure fn d(&self) -> &self/RenderBoxData;
|
||||||
match *self {
|
|
||||||
GenericBox(ref d) => d,
|
pure fn is_replaced() -> bool;
|
||||||
ImageBox(ref d, _) => d,
|
pure fn content_box() -> Rect<au>;
|
||||||
TextBox(ref d, _) => d,
|
pure fn border_box() -> Rect<au>;
|
||||||
UnscannedTextBox(ref d, _) => d,
|
|
||||||
}
|
fn get_min_width(&LayoutContext) -> au;
|
||||||
}
|
fn get_pref_width(&LayoutContext) -> au;
|
||||||
|
fn get_used_width() -> (au, au);
|
||||||
|
fn get_used_height() -> (au, au);
|
||||||
|
fn build_display_list(&dl::DisplayListBuilder, dirty: &Rect<au>,
|
||||||
|
offset: &Point2D<au>, &dl::DisplayList);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn RenderBoxData(node: Node, ctx: @FlowContext, id: int) -> RenderBoxData {
|
fn RenderBoxData(node: Node, ctx: @FlowContext, id: int) -> RenderBoxData {
|
||||||
|
@ -120,7 +124,16 @@ fn RenderBoxData(node: Node, ctx: @FlowContext, id: int) -> RenderBoxData {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RenderBox {
|
impl RenderBox : RenderBoxMethods {
|
||||||
|
pure fn d(&self) -> &self/RenderBoxData {
|
||||||
|
match *self {
|
||||||
|
GenericBox(ref d) => d,
|
||||||
|
ImageBox(ref d, _) => d,
|
||||||
|
TextBox(ref d, _) => d,
|
||||||
|
UnscannedTextBox(ref d, _) => d,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pure fn is_replaced() -> bool {
|
pure fn is_replaced() -> bool {
|
||||||
match self {
|
match self {
|
||||||
ImageBox(*) => true, // TODO: form elements, etc
|
ImageBox(*) => true, // TODO: form elements, etc
|
||||||
|
@ -238,7 +251,7 @@ impl RenderBox {
|
||||||
|
|
||||||
/* The box formed by the border edge, as defined in CSS 2.1 Section 8.1.
|
/* The box formed by the border edge, as defined in CSS 2.1 Section 8.1.
|
||||||
Coordinates are relative to the owning flow. */
|
Coordinates are relative to the owning flow. */
|
||||||
fn border_box() -> Rect<au> {
|
pure fn border_box() -> Rect<au> {
|
||||||
// TODO: actually compute content_box + padding + border
|
// TODO: actually compute content_box + padding + border
|
||||||
self.content_box()
|
self.content_box()
|
||||||
}
|
}
|
||||||
|
@ -296,10 +309,6 @@ impl RenderBox {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
trait ImageBoxMethods {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The tree holding render box relations. These are only defined for
|
* The tree holding render box relations. These are only defined for
|
||||||
* nested CSS boxes that are nested in an otherwise inline flow
|
* nested CSS boxes that are nested in an otherwise inline flow
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue