mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
CamelCase box kinds
This commit is contained in:
parent
09ee4b18ef
commit
9ed8b20778
5 changed files with 25 additions and 23 deletions
|
@ -17,11 +17,11 @@ import layout::text::*;
|
|||
import util::tree;
|
||||
import util::color::Color;
|
||||
|
||||
enum box_kind {
|
||||
bk_block,
|
||||
bk_inline,
|
||||
bk_intrinsic(@Size2D<au>),
|
||||
bk_text(@text_box)
|
||||
enum BoxKind {
|
||||
BlockBox,
|
||||
InlineBox,
|
||||
IntrinsicBox(@Size2D<au>),
|
||||
TextBox(@text_box)
|
||||
}
|
||||
|
||||
class appearance {
|
||||
|
@ -38,7 +38,7 @@ enum box = {
|
|||
tree: tree::fields<@box>,
|
||||
node: Node,
|
||||
mut bounds: Rect<au>,
|
||||
kind: box_kind,
|
||||
kind: BoxKind,
|
||||
appearance: appearance
|
||||
};
|
||||
|
||||
|
@ -99,10 +99,10 @@ impl layout_methods for @box {
|
|||
#[doc="The main reflow routine."]
|
||||
fn reflow(available_width: au) {
|
||||
alt self.kind {
|
||||
bk_block { self.reflow_block(available_width) }
|
||||
bk_inline { self.reflow_inline(available_width) }
|
||||
bk_intrinsic(size) { self.reflow_intrinsic(*size) }
|
||||
bk_text(subbox) { self.reflow_text(available_width, subbox) }
|
||||
BlockBox { self.reflow_block(available_width) }
|
||||
InlineBox { self.reflow_inline(available_width) }
|
||||
IntrinsicBox(size) { self.reflow_intrinsic(*size) }
|
||||
TextBox(subbox) { self.reflow_text(available_width, subbox) }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import util::tree;
|
|||
impl block_layout_methods for @box {
|
||||
#[doc="The main reflow routine for block layout."]
|
||||
fn reflow_block(available_width: au) {
|
||||
assert self.kind == bk_block;
|
||||
assert self.kind == BlockBox;
|
||||
|
||||
#debug["starting reflow block"];
|
||||
|
||||
|
|
|
@ -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::rcu::reader_methods;
|
||||
import gfx::geometry;
|
||||
import layout::base::{NodeMethods, appearance, bk_block, bk_inline, bk_intrinsic, bk_text, box};
|
||||
import layout::base::{box_kind, btree, ntree, rd_tree_ops, wr_tree_ops};
|
||||
import layout::base::{BlockBox, BoxKind, InlineBox, IntrinsicBox, NodeMethods, TextBox};
|
||||
import layout::base::{appearance, box, btree, ntree, rd_tree_ops, wr_tree_ops};
|
||||
import layout::style::style::{style_methods};
|
||||
import layout::text::text_box;
|
||||
import util::tree;
|
||||
|
@ -28,7 +28,7 @@ enum ctxt = {
|
|||
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(),
|
||||
node: n,
|
||||
mut bounds: geometry::zero_rect_au(),
|
||||
|
@ -78,7 +78,7 @@ impl methods for ctxt {
|
|||
// 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);
|
||||
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
|
||||
size.
|
||||
"]
|
||||
fn determine_box_kind() -> box_kind {
|
||||
fn determine_box_kind() -> BoxKind {
|
||||
alt self.rd({ |n| copy n.kind }) {
|
||||
~Text(string) { bk_text(@text_box(string)) }
|
||||
~Text(string) {
|
||||
TextBox(@text_box(string))
|
||||
}
|
||||
~Element(element) {
|
||||
alt *element.kind {
|
||||
HTMLDivElement { bk_block }
|
||||
HTMLImageElement({size}) { bk_intrinsic(@size) }
|
||||
UnknownElement { bk_inline }
|
||||
HTMLDivElement { BlockBox }
|
||||
HTMLImageElement({size}) { IntrinsicBox(@size) }
|
||||
UnknownElement { InlineBox }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -180,7 +182,7 @@ impl box_builder_methods for Node {
|
|||
let box_kind = self.determine_box_kind();
|
||||
let my_box = new_box(self, box_kind);
|
||||
alt box_kind {
|
||||
bk_block | bk_inline {
|
||||
BlockBox | InlineBox {
|
||||
let cx = create_context(self, my_box);
|
||||
cx.construct_boxes_for_children();
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import util::tree;
|
|||
#[doc="The main reflow routine for inline layout."]
|
||||
impl inline_layout_methods for @box {
|
||||
fn reflow_inline(available_width: au) {
|
||||
assert self.kind == bk_inline;
|
||||
assert self.kind == InlineBox;
|
||||
|
||||
#debug["starting reflow inline"];
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ class text_box {
|
|||
impl text_layout_methods for @box {
|
||||
fn reflow_text(_available_width: au, subbox: @text_box) {
|
||||
alt self.kind {
|
||||
bk_text(*) { /* ok */ }
|
||||
TextBox(*) { /* ok */ }
|
||||
_ { fail "expected text box in reflow_text!" }
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue