diff --git a/src/servo/layout/box.rs b/src/servo/layout/box.rs index da280bd22fd..85ac4ed4333 100644 --- a/src/servo/layout/box.rs +++ b/src/servo/layout/box.rs @@ -111,7 +111,8 @@ trait RenderBoxMethods { pure fn is_replaced() -> bool; pure fn can_split() -> bool; pure fn is_whitespace_only() -> bool; - pure fn can_merge_with_box(@self, other: @RenderBox) -> bool; + // TODO(Issue #220): this should be a pure/const method + fn can_merge_with_box(@self, other: @RenderBox) -> bool; pure fn content_box() -> Rect; pure fn border_box() -> Rect; pure fn margin_box() -> Rect; @@ -170,11 +171,13 @@ impl RenderBox : RenderBoxMethods { } } - pure fn can_merge_with_box(@self, other: @RenderBox) -> bool { + fn can_merge_with_box(@self, other: @RenderBox) -> bool { assert !core::box::ptr_eq(self, other); match (self, other) { - (@UnscannedTextBox(*), @UnscannedTextBox(*)) => true, + (@UnscannedTextBox(*), @UnscannedTextBox(*)) => { + self.font_style() == other.font_style() + }, (@TextBox(_,d1), @TextBox(_,d2)) => { core::box::ptr_eq(d1.run, d2.run) } (_, _) => false } @@ -524,9 +527,6 @@ impl RenderBox : RenderBoxMethods { } // Converts this node's ComputedStyle to a font style used in the graphics code. - // - // FIXME: Do we really need two structures here? Perhaps we can just use the structures from - // rust-css in the graphics code. fn font_style(@self) -> FontStyle { do self.with_style_of_nearest_element |my_style| { let font_families = do my_style.font_family().map |family| { diff --git a/src/servo/layout/inline.rs b/src/servo/layout/inline.rs index 38c80bb8a18..a1f0b38c5f3 100644 --- a/src/servo/layout/inline.rs +++ b/src/servo/layout/inline.rs @@ -186,14 +186,13 @@ priv impl TextRunScanner { } // helper functions - pure fn can_coalesce_text_nodes(boxes: &[@RenderBox], left_i: uint, right_i: uint) -> bool { + fn can_coalesce_text_nodes(boxes: &[@RenderBox], left_i: uint, right_i: uint) -> bool { assert left_i < boxes.len(); assert right_i > 0 && right_i < boxes.len(); assert left_i != right_i; let (left, right) = (boxes[left_i], boxes[right_i]); match (left, right) { - // TODO(Issue #117): check whether text styles, fonts are the same. (@UnscannedTextBox(*), @UnscannedTextBox(*)) => left.can_merge_with_box(right), (_, _) => false } @@ -239,8 +238,6 @@ priv impl TextRunScanner { // TODO(Issue #115): use actual CSS 'white-space' property of relevant style. let compression = CompressWhitespaceNewline; let transformed_text = transform_text(text, compression); - // TODO(Issue #116): use actual font and style for corresponding - // DOM node to create text run. // TODO(Issue #177): text run creation must account for text-renderability by fontgroup fonts. // this is probably achieved by creating fontgroup above, and then letting FontGroup decide // which Font to stick into the TextRun. @@ -278,11 +275,9 @@ priv impl TextRunScanner { // create the run, then make new boxes with the run and adjusted text indices - // TODO(Issue #116): use actual font for corresponding DOM node to create text run. // TODO(Issue #177): text run creation must account for text-renderability by fontgroup fonts. // this is probably achieved by creating fontgroup above, and then letting FontGroup decide // which Font to stick into the TextRun. - // FIXME: Is this right? --pcwalton let font_style = in_boxes[self.clump.begin()].font_style(); let fontgroup = ctx.font_ctx.get_resolved_font_for_style(&font_style); let run = @TextRun::new(fontgroup.fonts[0], move run_str);