properly incrementally set block size

This commit is contained in:
Clark Gaebel 2014-10-21 14:26:22 -07:00
parent 156ca98236
commit b31f9e0188
3 changed files with 13 additions and 15 deletions

View file

@ -380,19 +380,19 @@ pub struct ScannedTextFragmentInfo {
/// fragments, it will have to be restored. /// fragments, it will have to be restored.
pub original_new_line_pos: Option<Vec<CharIndex>>, pub original_new_line_pos: Option<Vec<CharIndex>>,
/// The inline-size of the text fragment. /// The intrinsic size of the text fragment.
pub content_inline_size: Au, pub content_size: LogicalSize<Au>,
} }
impl ScannedTextFragmentInfo { impl ScannedTextFragmentInfo {
/// Creates the information specific to a scanned text fragment from a range and a text run. /// Creates the information specific to a scanned text fragment from a range and a text run.
pub fn new(run: Arc<Box<TextRun>>, range: Range<CharIndex>, content_inline_size: Au) pub fn new(run: Arc<Box<TextRun>>, range: Range<CharIndex>, content_size: LogicalSize<Au>)
-> ScannedTextFragmentInfo { -> ScannedTextFragmentInfo {
ScannedTextFragmentInfo { ScannedTextFragmentInfo {
run: run, run: run,
range: range, range: range,
original_new_line_pos: None, original_new_line_pos: None,
content_inline_size: content_inline_size, content_size: content_size,
} }
} }
} }
@ -603,7 +603,7 @@ impl Fragment {
let new_border_box = let new_border_box =
LogicalRect::from_point_size(self.style.writing_mode, self.border_box.start, size); LogicalRect::from_point_size(self.style.writing_mode, self.border_box.start, size);
info.content_inline_size = size.inline; info.content_size = size.clone();
Fragment { Fragment {
node: self.node, node: self.node,
@ -821,7 +821,7 @@ impl Fragment {
} }
}; };
self.border_padding = border + padding self.border_padding = border + padding;
} }
// Return offset from original position because of `position: relative`. // Return offset from original position because of `position: relative`.
@ -1705,7 +1705,7 @@ impl Fragment {
ScannedTextFragment(ref info) => { ScannedTextFragment(ref info) => {
// Scanned text fragments will have already had their content inline-sizes assigned // Scanned text fragments will have already had their content inline-sizes assigned
// by this point. // by this point.
self.border_box.size.inline = info.content_inline_size + noncontent_inline_size self.border_box.size.inline = info.content_size.inline + noncontent_inline_size
} }
ImageFragment(ref mut image_fragment_info) => { ImageFragment(ref mut image_fragment_info) => {
// TODO(ksh8281): compute border,margin // TODO(ksh8281): compute border,margin
@ -1805,10 +1805,10 @@ impl Fragment {
image_fragment_info.computed_block_size = Some(block_size); image_fragment_info.computed_block_size = Some(block_size);
self.border_box.size.block = block_size + noncontent_block_size self.border_box.size.block = block_size + noncontent_block_size
} }
ScannedTextFragment(_) => { ScannedTextFragment(ref info) => {
// Scanned text fragments' content block-sizes are calculated by the text run // Scanned text fragments' content block-sizes are calculated by the text run
// scanner during flow construction. // scanner during flow construction.
self.border_box.size.block = self.border_box.size.block + noncontent_block_size self.border_box.size.block = info.content_size.block + noncontent_block_size
} }
InlineBlockFragment(ref mut info) => { InlineBlockFragment(ref mut info) => {
// Not the primary fragment, so we do not take the noncontent size into account. // Not the primary fragment, so we do not take the noncontent size into account.

View file

@ -408,7 +408,7 @@ impl LineBreaker {
ScannedTextFragmentInfo::new( ScannedTextFragmentInfo::new(
run.clone(), run.clone(),
split.range, split.range,
in_fragment.border_box.size.inline); in_fragment.border_box.size);
let size = LogicalSize::new( let size = LogicalSize::new(
writing_mode, split.inline_size, in_fragment.border_box.size.block); writing_mode, split.inline_size, in_fragment.border_box.size.block);
in_fragment.transform(size, info) in_fragment.transform(size, info)
@ -499,7 +499,7 @@ impl LineBreaker {
ScannedTextFragmentInfo::new( ScannedTextFragmentInfo::new(
run.clone(), run.clone(),
split.range, split.range,
in_fragment.border_box.size.inline); in_fragment.border_box.size);
let size = LogicalSize::new(self.floats.writing_mode, let size = LogicalSize::new(self.floats.writing_mode,
split.inline_size, split.inline_size,
in_fragment.border_box.size.block); in_fragment.border_box.size.block);

View file

@ -159,9 +159,9 @@ impl TextRunScanner {
continue continue
} }
let text_inline_size = old_fragment.border_box.size.inline; let text_size = old_fragment.border_box.size;
let new_text_fragment_info = let new_text_fragment_info =
ScannedTextFragmentInfo::new(run.clone(), range, text_inline_size); ScannedTextFragmentInfo::new(run.clone(), range, text_size);
let new_metrics = new_text_fragment_info.run.metrics_for_range(&range); let new_metrics = new_text_fragment_info.run.metrics_for_range(&range);
let bounding_box_size = bounding_box_for_run_metrics(&new_metrics, let bounding_box_size = bounding_box_for_run_metrics(&new_metrics,
old_fragment.style.writing_mode); old_fragment.style.writing_mode);
@ -223,5 +223,3 @@ pub fn line_height_from_style(style: &ComputedValues, metrics: &FontMetrics) ->
line_height::Length(l) => l line_height::Length(l) => l
} }
} }