mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Cache last fontgroup. Style recalc on wikipedia/rust 66ms -> 41ms.
This commit is contained in:
parent
012a80cc18
commit
b1c226778f
6 changed files with 36 additions and 13 deletions
|
@ -724,7 +724,7 @@ impl Fragment {
|
|||
}
|
||||
|
||||
pub fn calculate_line_height(&self, layout_context: &LayoutContext) -> Au {
|
||||
let font_style = self.style.get_font();
|
||||
let font_style = self.style.get_font_arc();
|
||||
let font_metrics = text::font_metrics_for_style(layout_context.font_context(), font_style);
|
||||
text::line_height_from_style(&*self.style, &font_metrics)
|
||||
}
|
||||
|
@ -1394,7 +1394,7 @@ impl Fragment {
|
|||
InlineBlockFragment(ref info) => {
|
||||
// See CSS 2.1 § 10.8.1.
|
||||
let block_flow = info.flow_ref.deref().as_immutable_block();
|
||||
let font_style = self.style.get_font();
|
||||
let font_style = self.style.get_font_arc();
|
||||
let font_metrics = text::font_metrics_for_style(layout_context.font_context(),
|
||||
font_style);
|
||||
InlineMetrics::from_block_height(&font_metrics,
|
||||
|
|
|
@ -859,7 +859,7 @@ impl InlineFlow {
|
|||
return (Au(0), Au(0))
|
||||
}
|
||||
|
||||
let font_style = style.get_font();
|
||||
let font_style = style.get_font_arc();
|
||||
let font_metrics = text::font_metrics_for_style(font_context, font_style);
|
||||
let line_height = text::line_height_from_style(style, &font_metrics);
|
||||
let inline_metrics = InlineMetrics::from_font_metrics(&font_metrics, line_height);
|
||||
|
@ -873,7 +873,7 @@ impl InlineFlow {
|
|||
match frag.inline_context {
|
||||
Some(ref inline_context) => {
|
||||
for style in inline_context.styles.iter() {
|
||||
let font_style = style.get_font();
|
||||
let font_style = style.get_font_arc();
|
||||
let font_metrics = text::font_metrics_for_style(font_context, font_style);
|
||||
let line_height = text::line_height_from_style(&**style, &font_metrics);
|
||||
let inline_metrics = InlineMetrics::from_font_metrics(&font_metrics,
|
||||
|
|
|
@ -106,7 +106,7 @@ impl TextRunScanner {
|
|||
let compression;
|
||||
{
|
||||
let in_fragment = self.clump.front().unwrap();
|
||||
let font_style = in_fragment.style().get_font();
|
||||
let font_style = in_fragment.style().get_font_arc();
|
||||
fontgroup = font_context.get_layout_font_group_for_style(font_style);
|
||||
compression = match in_fragment.white_space() {
|
||||
white_space::normal | white_space::nowrap => CompressWhitespaceNewline,
|
||||
|
@ -209,7 +209,7 @@ fn bounding_box_for_run_metrics(metrics: &RunMetrics, writing_mode: WritingMode)
|
|||
///
|
||||
/// `#[inline]` because often the caller only needs a few fields from the font metrics.
|
||||
#[inline]
|
||||
pub fn font_metrics_for_style(font_context: &mut FontContext, font_style: &FontStyle)
|
||||
pub fn font_metrics_for_style(font_context: &mut FontContext, font_style: Arc<FontStyle>)
|
||||
-> FontMetrics {
|
||||
let fontgroup = font_context.get_layout_font_group_for_style(font_style);
|
||||
fontgroup.fonts.get(0).borrow().metrics.clone()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue