CamelCase box kinds

This commit is contained in:
Patrick Walton 2012-06-14 17:31:02 -07:00
parent 09ee4b18ef
commit 9ed8b20778
5 changed files with 25 additions and 23 deletions

View file

@ -17,11 +17,11 @@ import layout::text::*;
import util::tree; import util::tree;
import util::color::Color; import util::color::Color;
enum box_kind { enum BoxKind {
bk_block, BlockBox,
bk_inline, InlineBox,
bk_intrinsic(@Size2D<au>), IntrinsicBox(@Size2D<au>),
bk_text(@text_box) TextBox(@text_box)
} }
class appearance { class appearance {
@ -38,7 +38,7 @@ enum box = {
tree: tree::fields<@box>, tree: tree::fields<@box>,
node: Node, node: Node,
mut bounds: Rect<au>, mut bounds: Rect<au>,
kind: box_kind, kind: BoxKind,
appearance: appearance appearance: appearance
}; };
@ -99,10 +99,10 @@ impl layout_methods for @box {
#[doc="The main reflow routine."] #[doc="The main reflow routine."]
fn reflow(available_width: au) { fn reflow(available_width: au) {
alt self.kind { alt self.kind {
bk_block { self.reflow_block(available_width) } BlockBox { self.reflow_block(available_width) }
bk_inline { self.reflow_inline(available_width) } InlineBox { self.reflow_inline(available_width) }
bk_intrinsic(size) { self.reflow_intrinsic(*size) } IntrinsicBox(size) { self.reflow_intrinsic(*size) }
bk_text(subbox) { self.reflow_text(available_width, subbox) } TextBox(subbox) { self.reflow_text(available_width, subbox) }
} }
} }

View file

@ -10,7 +10,7 @@ import util::tree;
impl block_layout_methods for @box { impl block_layout_methods for @box {
#[doc="The main reflow routine for block layout."] #[doc="The main reflow routine for block layout."]
fn reflow_block(available_width: au) { fn reflow_block(available_width: au) {
assert self.kind == bk_block; assert self.kind == BlockBox;
#debug["starting reflow block"]; #debug["starting reflow block"];

View file

@ -4,8 +4,8 @@ import dom::base::{ElementData, HTMLDivElement, HTMLImageElement, Element, Text,
import dom::style::{display_type, di_block, di_inline, di_none}; import dom::style::{display_type, di_block, di_inline, di_none};
import dom::rcu::reader_methods; import dom::rcu::reader_methods;
import gfx::geometry; import gfx::geometry;
import layout::base::{NodeMethods, appearance, bk_block, bk_inline, bk_intrinsic, bk_text, box}; import layout::base::{BlockBox, BoxKind, InlineBox, IntrinsicBox, NodeMethods, TextBox};
import layout::base::{box_kind, btree, ntree, rd_tree_ops, wr_tree_ops}; import layout::base::{appearance, box, btree, ntree, rd_tree_ops, wr_tree_ops};
import layout::style::style::{style_methods}; import layout::style::style::{style_methods};
import layout::text::text_box; import layout::text::text_box;
import util::tree; import util::tree;
@ -28,7 +28,7 @@ enum ctxt = {
mut anon_box: option<@box> mut anon_box: option<@box>
}; };
fn new_box(n: Node, kind: box_kind) -> @box { fn new_box(n: Node, kind: BoxKind) -> @box {
@box({tree: tree::empty(), @box({tree: tree::empty(),
node: n, node: n,
mut bounds: geometry::zero_rect_au(), mut bounds: geometry::zero_rect_au(),
@ -78,7 +78,7 @@ impl methods for ctxt {
// TODO: check what css actually specifies // TODO: check what css actually specifies
// //
let b = new_box(self.parent_node, bk_inline); let b = new_box(self.parent_node, InlineBox);
self.anon_box = some(b); self.anon_box = some(b);
b b
} }
@ -160,14 +160,16 @@ impl box_builder_priv for Node {
Determines the kind of box that this node needs. Also, for images, computes the intrinsic Determines the kind of box that this node needs. Also, for images, computes the intrinsic
size. size.
"] "]
fn determine_box_kind() -> box_kind { fn determine_box_kind() -> BoxKind {
alt self.rd({ |n| copy n.kind }) { alt self.rd({ |n| copy n.kind }) {
~Text(string) { bk_text(@text_box(string)) } ~Text(string) {
TextBox(@text_box(string))
}
~Element(element) { ~Element(element) {
alt *element.kind { alt *element.kind {
HTMLDivElement { bk_block } HTMLDivElement { BlockBox }
HTMLImageElement({size}) { bk_intrinsic(@size) } HTMLImageElement({size}) { IntrinsicBox(@size) }
UnknownElement { bk_inline } UnknownElement { InlineBox }
} }
} }
} }
@ -180,7 +182,7 @@ impl box_builder_methods for Node {
let box_kind = self.determine_box_kind(); let box_kind = self.determine_box_kind();
let my_box = new_box(self, box_kind); let my_box = new_box(self, box_kind);
alt box_kind { alt box_kind {
bk_block | bk_inline { BlockBox | InlineBox {
let cx = create_context(self, my_box); let cx = create_context(self, my_box);
cx.construct_boxes_for_children(); cx.construct_boxes_for_children();
} }

View file

@ -12,7 +12,7 @@ import util::tree;
#[doc="The main reflow routine for inline layout."] #[doc="The main reflow routine for inline layout."]
impl inline_layout_methods for @box { impl inline_layout_methods for @box {
fn reflow_inline(available_width: au) { fn reflow_inline(available_width: au) {
assert self.kind == bk_inline; assert self.kind == InlineBox;
#debug["starting reflow inline"]; #debug["starting reflow inline"];

View file

@ -19,7 +19,7 @@ class text_box {
impl text_layout_methods for @box { impl text_layout_methods for @box {
fn reflow_text(_available_width: au, subbox: @text_box) { fn reflow_text(_available_width: au, subbox: @text_box) {
alt self.kind { alt self.kind {
bk_text(*) { /* ok */ } TextBox(*) { /* ok */ }
_ { fail "expected text box in reflow_text!" } _ { fail "expected text box in reflow_text!" }
}; };