mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
InlineFlow should always inherit text-width from base style
Fixes #222.
This commit is contained in:
parent
c168e04fe1
commit
555e04475e
4 changed files with 46 additions and 14 deletions
|
@ -579,22 +579,10 @@ impl InlineFlow {
|
|||
}
|
||||
|
||||
/// Sets box X positions based on alignment for one line.
|
||||
fn set_horizontal_box_positions(boxes: &[Box], line: &LineBox) {
|
||||
fn set_horizontal_box_positions(boxes: &[Box], line: &LineBox, linebox_align: text_align::T) {
|
||||
// Figure out how much width we have.
|
||||
let slack_width = Au::max(Au(0), line.green_zone.width - line.bounds.size.width);
|
||||
|
||||
// Get the text alignment.
|
||||
//
|
||||
// TODO(burg, issue #222): use 'text-align' property from `InlineFlow`'s block container,
|
||||
// not from the style of the first box child.
|
||||
let linebox_align = if line.range.begin() < boxes.len() {
|
||||
let first_box = &boxes[line.range.begin()];
|
||||
first_box.style().Text.text_align
|
||||
} else {
|
||||
// Nothing to lay out, so assume left alignment.
|
||||
text_align::left
|
||||
};
|
||||
|
||||
// Set the box x positions based on that alignment.
|
||||
let mut offset_x = line.bounds.origin.x;
|
||||
offset_x = offset_x + match linebox_align {
|
||||
|
@ -712,10 +700,13 @@ impl Flow for InlineFlow {
|
|||
|
||||
let mut line_height_offset = Au::new(0);
|
||||
|
||||
// All lines use text alignment from base (non-inline) node
|
||||
let text_align = self.base.node.style().get().Text.text_align;
|
||||
|
||||
// Now, go through each line and lay out the boxes inside.
|
||||
for line in self.lines.mut_iter() {
|
||||
// Lay out boxes horizontally.
|
||||
InlineFlow::set_horizontal_box_positions(self.boxes, line);
|
||||
InlineFlow::set_horizontal_box_positions(self.boxes, line, text_align);
|
||||
|
||||
// Set the top y position of the current linebox.
|
||||
// `line_height_offset` is updated at the end of the previous loop.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue