mirror of
https://github.com/servo/servo.git
synced 2025-08-07 14:35:33 +01:00
Don't coalesce UnscannedTextBoxes if their font styles differ.
This commit is contained in:
parent
d76195757a
commit
0b37bdb332
2 changed files with 7 additions and 12 deletions
|
@ -111,7 +111,8 @@ trait RenderBoxMethods {
|
||||||
pure fn is_replaced() -> bool;
|
pure fn is_replaced() -> bool;
|
||||||
pure fn can_split() -> bool;
|
pure fn can_split() -> bool;
|
||||||
pure fn is_whitespace_only() -> 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<Au>;
|
pure fn content_box() -> Rect<Au>;
|
||||||
pure fn border_box() -> Rect<Au>;
|
pure fn border_box() -> Rect<Au>;
|
||||||
pure fn margin_box() -> Rect<Au>;
|
pure fn margin_box() -> Rect<Au>;
|
||||||
|
@ -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);
|
assert !core::box::ptr_eq(self, other);
|
||||||
|
|
||||||
match (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) }
|
(@TextBox(_,d1), @TextBox(_,d2)) => { core::box::ptr_eq(d1.run, d2.run) }
|
||||||
(_, _) => false
|
(_, _) => false
|
||||||
}
|
}
|
||||||
|
@ -524,9 +527,6 @@ impl RenderBox : RenderBoxMethods {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Converts this node's ComputedStyle to a font style used in the graphics code.
|
// 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 {
|
fn font_style(@self) -> FontStyle {
|
||||||
do self.with_style_of_nearest_element |my_style| {
|
do self.with_style_of_nearest_element |my_style| {
|
||||||
let font_families = do my_style.font_family().map |family| {
|
let font_families = do my_style.font_family().map |family| {
|
||||||
|
|
|
@ -186,14 +186,13 @@ priv impl TextRunScanner {
|
||||||
}
|
}
|
||||||
|
|
||||||
// helper functions
|
// 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 left_i < boxes.len();
|
||||||
assert right_i > 0 && right_i < boxes.len();
|
assert right_i > 0 && right_i < boxes.len();
|
||||||
assert left_i != right_i;
|
assert left_i != right_i;
|
||||||
|
|
||||||
let (left, right) = (boxes[left_i], boxes[right_i]);
|
let (left, right) = (boxes[left_i], boxes[right_i]);
|
||||||
match (left, right) {
|
match (left, right) {
|
||||||
// TODO(Issue #117): check whether text styles, fonts are the same.
|
|
||||||
(@UnscannedTextBox(*), @UnscannedTextBox(*)) => left.can_merge_with_box(right),
|
(@UnscannedTextBox(*), @UnscannedTextBox(*)) => left.can_merge_with_box(right),
|
||||||
(_, _) => false
|
(_, _) => false
|
||||||
}
|
}
|
||||||
|
@ -239,8 +238,6 @@ priv impl TextRunScanner {
|
||||||
// TODO(Issue #115): use actual CSS 'white-space' property of relevant style.
|
// TODO(Issue #115): use actual CSS 'white-space' property of relevant style.
|
||||||
let compression = CompressWhitespaceNewline;
|
let compression = CompressWhitespaceNewline;
|
||||||
let transformed_text = transform_text(text, compression);
|
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.
|
// 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
|
// this is probably achieved by creating fontgroup above, and then letting FontGroup decide
|
||||||
// which Font to stick into the TextRun.
|
// 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
|
// 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.
|
// 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
|
// this is probably achieved by creating fontgroup above, and then letting FontGroup decide
|
||||||
// which Font to stick into the TextRun.
|
// which Font to stick into the TextRun.
|
||||||
// FIXME: Is this right? --pcwalton
|
|
||||||
let font_style = in_boxes[self.clump.begin()].font_style();
|
let font_style = in_boxes[self.clump.begin()].font_style();
|
||||||
let fontgroup = ctx.font_ctx.get_resolved_font_for_style(&font_style);
|
let fontgroup = ctx.font_ctx.get_resolved_font_for_style(&font_style);
|
||||||
let run = @TextRun::new(fontgroup.fonts[0], move run_str);
|
let run = @TextRun::new(fontgroup.fonts[0], move run_str);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue