Skip to content

Commit

Permalink
properly incrementally set block size
Browse files Browse the repository at this point in the history
  • Loading branch information
Clark Gaebel committed Oct 21, 2014
1 parent 156ca98 commit b31f9e0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
18 changes: 9 additions & 9 deletions components/layout/fragment.rs
Expand Up @@ -380,19 +380,19 @@ pub struct ScannedTextFragmentInfo {
/// fragments, it will have to be restored.
pub original_new_line_pos: Option<Vec<CharIndex>>,

/// The inline-size of the text fragment.
pub content_inline_size: Au,
/// The intrinsic size of the text fragment.
pub content_size: LogicalSize<Au>,
}

impl ScannedTextFragmentInfo {
/// 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 {
run: run,
range: range,
original_new_line_pos: None,
content_inline_size: content_inline_size,
content_size: content_size,
}
}
}
Expand Down Expand Up @@ -603,7 +603,7 @@ impl Fragment {
let new_border_box =
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 {
node: self.node,
Expand Down Expand Up @@ -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`.
Expand Down Expand Up @@ -1705,7 +1705,7 @@ impl Fragment {
ScannedTextFragment(ref info) => {
// Scanned text fragments will have already had their content inline-sizes assigned
// 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) => {
// TODO(ksh8281): compute border,margin
Expand Down Expand Up @@ -1805,10 +1805,10 @@ impl Fragment {
image_fragment_info.computed_block_size = Some(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
// 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) => {
// Not the primary fragment, so we do not take the noncontent size into account.
Expand Down
4 changes: 2 additions & 2 deletions components/layout/inline.rs
Expand Up @@ -408,7 +408,7 @@ impl LineBreaker {
ScannedTextFragmentInfo::new(
run.clone(),
split.range,
in_fragment.border_box.size.inline);
in_fragment.border_box.size);
let size = LogicalSize::new(
writing_mode, split.inline_size, in_fragment.border_box.size.block);
in_fragment.transform(size, info)
Expand Down Expand Up @@ -499,7 +499,7 @@ impl LineBreaker {
ScannedTextFragmentInfo::new(
run.clone(),
split.range,
in_fragment.border_box.size.inline);
in_fragment.border_box.size);
let size = LogicalSize::new(self.floats.writing_mode,
split.inline_size,
in_fragment.border_box.size.block);
Expand Down
6 changes: 2 additions & 4 deletions components/layout/text.rs
Expand Up @@ -159,9 +159,9 @@ impl TextRunScanner {
continue
}

let text_inline_size = old_fragment.border_box.size.inline;
let text_size = old_fragment.border_box.size;
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 bounding_box_size = bounding_box_for_run_metrics(&new_metrics,
old_fragment.style.writing_mode);
Expand Down Expand Up @@ -223,5 +223,3 @@ pub fn line_height_from_style(style: &ComputedValues, metrics: &FontMetrics) ->
line_height::Length(l) => l
}
}


6 comments on commit b31f9e0

@pcwalton
Copy link
Contributor

Choose a reason for hiding this comment

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

r+

@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 pcwalton
at cgaebel@b31f9e0

@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 cgaebel/servo/issue-3753 = b31f9e0 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.

cgaebel/servo/issue-3753 = b31f9e0 merged ok, testing candidate = fe230ef

@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 = fe230ef

Please sign in to comment.