diff options
author | bors-servo <release+servo@mozilla.com> | 2014-02-06 21:07:38 -0500 |
---|---|---|
committer | bors-servo <release+servo@mozilla.com> | 2014-02-06 21:07:38 -0500 |
commit | a1e98ada50eafa32c9eda2e6416ce3429612d4d0 (patch) | |
tree | 1fccb1568220b6a4f922f7a2abc29c22722504e0 /src | |
parent | 14ee9218e4ca502524c4671a02bc1d637382fbfc (diff) | |
parent | 86777d6460d603909987b3d7abb0963bba789e4b (diff) | |
download | servo-a1e98ada50eafa32c9eda2e6416ce3429612d4d0.tar.gz servo-a1e98ada50eafa32c9eda2e6416ce3429612d4d0.zip |
auto merge of #1577 : ksh8281/servo/inline_add2, r=larsbergstrom
there is a issue when TextRunScanning.
this is for
```
<span style="background:red;font-size:35px;border: black solid 15px">
<span style="background:purple; 20px solid">
<img src="test.jpeg" style="border:blue 30px solid;" />
</span>
</span>
```
this case. left border of "img" is missing
Diffstat (limited to 'src')
-rw-r--r-- | src/components/main/layout/text.rs | 34 | ||||
-rw-r--r-- | src/test/ref/inline_border_a.html | 5 | ||||
-rw-r--r-- | src/test/ref/inline_border_ref.png | bin | 20306 -> 285052 bytes |
3 files changed, 20 insertions, 19 deletions
diff --git a/src/components/main/layout/text.rs b/src/components/main/layout/text.rs index f8c5ad88009..e41ce00122c 100644 --- a/src/components/main/layout/text.rs +++ b/src/components/main/layout/text.rs @@ -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, } } @@ -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()]; @@ -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) => { @@ -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 } @@ -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. @@ -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) - } } diff --git a/src/test/ref/inline_border_a.html b/src/test/ref/inline_border_a.html index e29ca5030fa..0f823180225 100644 --- a/src/test/ref/inline_border_a.html +++ b/src/test/ref/inline_border_a.html @@ -17,6 +17,11 @@ body { </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> diff --git a/src/test/ref/inline_border_ref.png b/src/test/ref/inline_border_ref.png Binary files differindex 3d1690ed6c6..5a80ec636c8 100644 --- a/src/test/ref/inline_border_ref.png +++ b/src/test/ref/inline_border_ref.png |