Add stubs for box-splitting.

This commit is contained in:
Brian J. Burg 2012-10-15 15:09:57 -07:00
parent 40f26cf63e
commit 8b80e15fd0
2 changed files with 30 additions and 1 deletions

View file

@ -91,6 +91,13 @@ pub enum RenderBox {
UnscannedTextBox(RenderBoxData, ~str)
}
enum SplitBoxResult {
CannotSplit(@RenderBox),
SplitUnnecessary(@RenderBox),
SplitDidFit(@RenderBox, @RenderBox),
SplitDidNotFit(@RenderBox, @RenderBox)
}
enum InlineSpacerSide {
LogicalBefore,
LogicalAfter,
@ -107,6 +114,7 @@ trait RenderBoxMethods {
pure fn content_box() -> Rect<au>;
pure fn border_box() -> Rect<au>;
fn split_to_width(@self, &LayoutContext, au) -> SplitBoxResult;
fn get_min_width(&LayoutContext) -> au;
fn get_pref_width(&LayoutContext) -> au;
fn get_used_width() -> (au, au);
@ -167,6 +175,18 @@ impl RenderBox : RenderBoxMethods {
}
}
fn split_to_width(@self, _ctx: &LayoutContext, _max_width: au) -> SplitBoxResult {
// TODO: finish
CannotSplit(self)
/* match self {
@GenericBox(*) => CannotSplit(self),
@ImageBox(*) => CannotSplit(self),
@TextBox(*) => {
}
}
*/
}
/** In general, these functions are transitively impure because they
* may cause glyphs to be allocated. For now, it's impure because of
* holder.get_image()

View file

@ -5,7 +5,7 @@ use au::au;
use geom::size::Size2D;
use servo_text::text_run::TextRun;
use servo_text::font_cache::FontCache;
use layout::box::{TextBox, RenderBox, UnscannedTextBox};
use layout::box::{TextBox, RenderBox, RenderBoxData, UnscannedTextBox};
use layout::context::LayoutContext;
pub struct TextBoxData {
@ -22,6 +22,15 @@ pub fn TextBoxData(run: @TextRun, offset: uint, length: uint) -> TextBoxData {
}
}
pub fn adapt_textbox_with_range(box_data: &RenderBoxData, run: @TextRun,
offset: uint, length: uint) -> @RenderBox {
let new_box_data = copy *box_data;
let new_text_data = TextBoxData(run, offset, length);
@TextBox(move new_box_data, move new_text_data)
// TODO: set position based on run metrics
//new_box_data.position.size = { width: run.font
}
trait UnscannedMethods {
pure fn raw_text() -> ~str;
}