mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Add stubs for box-splitting.
This commit is contained in:
parent
40f26cf63e
commit
8b80e15fd0
2 changed files with 30 additions and 1 deletions
|
@ -91,6 +91,13 @@ pub enum RenderBox {
|
||||||
UnscannedTextBox(RenderBoxData, ~str)
|
UnscannedTextBox(RenderBoxData, ~str)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum SplitBoxResult {
|
||||||
|
CannotSplit(@RenderBox),
|
||||||
|
SplitUnnecessary(@RenderBox),
|
||||||
|
SplitDidFit(@RenderBox, @RenderBox),
|
||||||
|
SplitDidNotFit(@RenderBox, @RenderBox)
|
||||||
|
}
|
||||||
|
|
||||||
enum InlineSpacerSide {
|
enum InlineSpacerSide {
|
||||||
LogicalBefore,
|
LogicalBefore,
|
||||||
LogicalAfter,
|
LogicalAfter,
|
||||||
|
@ -107,6 +114,7 @@ trait RenderBoxMethods {
|
||||||
pure fn content_box() -> Rect<au>;
|
pure fn content_box() -> Rect<au>;
|
||||||
pure fn border_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_min_width(&LayoutContext) -> au;
|
||||||
fn get_pref_width(&LayoutContext) -> au;
|
fn get_pref_width(&LayoutContext) -> au;
|
||||||
fn get_used_width() -> (au, 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
|
/** In general, these functions are transitively impure because they
|
||||||
* may cause glyphs to be allocated. For now, it's impure because of
|
* may cause glyphs to be allocated. For now, it's impure because of
|
||||||
* holder.get_image()
|
* holder.get_image()
|
||||||
|
|
|
@ -5,7 +5,7 @@ use au::au;
|
||||||
use geom::size::Size2D;
|
use geom::size::Size2D;
|
||||||
use servo_text::text_run::TextRun;
|
use servo_text::text_run::TextRun;
|
||||||
use servo_text::font_cache::FontCache;
|
use servo_text::font_cache::FontCache;
|
||||||
use layout::box::{TextBox, RenderBox, UnscannedTextBox};
|
use layout::box::{TextBox, RenderBox, RenderBoxData, UnscannedTextBox};
|
||||||
use layout::context::LayoutContext;
|
use layout::context::LayoutContext;
|
||||||
|
|
||||||
pub struct TextBoxData {
|
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 {
|
trait UnscannedMethods {
|
||||||
pure fn raw_text() -> ~str;
|
pure fn raw_text() -> ~str;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue