Skip to content

Commit

Permalink
add case of merge inline info & modify ref test
Browse files Browse the repository at this point in the history
  • Loading branch information
ksh8281 committed Feb 7, 2014
1 parent 14ee921 commit 86777d6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 19 deletions.
34 changes: 15 additions & 19 deletions src/components/main/layout/text.rs
Expand Up @@ -18,16 +18,12 @@ use style::computed_values::white_space;
/// A stack-allocated object for scanning an inline flow into `TextRun`-containing `TextBox`es.
pub struct TextRunScanner {
clump: Range,
/// when flush_clump, some boxes not makes result.
/// if the lost box has border,margin,padding of inline, we should restore that stuff.
last_lost_box_index: Option<uint>
}

impl TextRunScanner {
pub fn new() -> TextRunScanner {
TextRunScanner {
clump: Range::empty(),
last_lost_box_index: None,
}
}

Expand Down Expand Up @@ -107,7 +103,7 @@ impl TextRunScanner {
// FIXME(pcwalton): Stop cloning boxes, as above.
debug!("TextRunScanner: pushing single non-text box in range: {}", self.clump);
let new_box = in_boxes[self.clump.begin()].clone();
self.push_to_outboxes(new_box,in_boxes,out_boxes);
out_boxes.push(new_box)
},
(true, true) => {
let old_box = &in_boxes[self.clump.begin()];
Expand Down Expand Up @@ -150,9 +146,15 @@ impl TextRunScanner {
let mut new_box = old_box.transform(new_metrics.bounding_box.size,
ScannedTextBox(new_text_box_info));
new_box.new_line_pos = new_line_pos;
self.push_to_outboxes(new_box,in_boxes,out_boxes);
out_boxes.push(new_box)

} else {
self.last_lost_box_index = Some(self.clump.begin());
if self.clump.begin() + 1 < in_boxes.len() {
// if the this box has border,margin,padding of inline,
// we should copy that stuff to next box.
in_boxes[self.clump.begin() + 1]
.merge_noncontent_inline_left(&in_boxes[self.clump.begin()]);
}
}
},
(false, true) => {
Expand Down Expand Up @@ -236,6 +238,11 @@ impl TextRunScanner {
debug!("Elided an `UnscannedTextbox` because it was zero-length after \
compression; {:s}",
in_boxes[i].debug_str());
// in this case, in_boxes[i] is elided
// so, we should merge inline info with next index of in_boxes
if i + 1 < in_boxes.len() {
in_boxes[i + 1].merge_noncontent_inline_left(&in_boxes[i]);
}
continue
}

Expand All @@ -244,7 +251,7 @@ impl TextRunScanner {
let mut new_box = in_boxes[i].transform(new_metrics.bounding_box.size,
ScannedTextBox(new_text_box_info));
new_box.new_line_pos = new_line_positions[logical_offset].new_line_pos.clone();
self.push_to_outboxes(new_box,in_boxes,out_boxes);
out_boxes.push(new_box)
}
}
} // End of match.
Expand Down Expand Up @@ -272,15 +279,4 @@ impl TextRunScanner {

new_whitespace
} // End of `flush_clump_to_list`.

fn push_to_outboxes(&mut self, new_box: Box, in_boxes: &~[Box], out_boxes: &mut ~[Box]) {
match self.last_lost_box_index {
Some(index) => {
new_box.merge_noncontent_inline_left(&in_boxes[index]);
},
None => {}
}
self.last_lost_box_index = None;
out_boxes.push(new_box)
}
}
5 changes: 5 additions & 0 deletions src/test/ref/inline_border_a.html
Expand Up @@ -17,6 +17,11 @@
</head>
<body>
<span style="border: 10px black solid"><img width="100" style="border:10px red solid" src="test.jpeg"></span>
<span style="background:red;font-size:35px;border: black 15px solid">
<span style="font-size:15px;background:yellow">
<img src="test.jpeg"/>
</span>
</span>
</body>
</html>

Binary file modified src/test/ref/inline_border_ref.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

5 comments on commit 86777d6

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from larsbergstrom
at ksh8281@86777d6

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging ksh8281/servo/inline_add2 = 86777d6 into auto

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ksh8281/servo/inline_add2 = 86777d6 merged ok, testing candidate = a1e98ad

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = a1e98ad

Please sign in to comment.