aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout/fragment.rs
diff options
context:
space:
mode:
authorbors-servo <metajack+bors@gmail.com>2014-10-16 15:06:19 -0600
committerbors-servo <metajack+bors@gmail.com>2014-10-16 15:06:19 -0600
commit83196ddb26b5611bccfa2d709396daeff259bcd1 (patch)
tree73d0a42e4bd696456c72739d45666c1208bebf28 /components/layout/fragment.rs
parent8d3b107568ab965b518b8003b702a5db993fa7d0 (diff)
parenta6fcec468fd2334b2854cc3d53ceb7c299641971 (diff)
downloadservo-83196ddb26b5611bccfa2d709396daeff259bcd1.tar.gz
servo-83196ddb26b5611bccfa2d709396daeff259bcd1.zip
auto merge of #3697 : pcwalton/servo/get-layout-font-group, r=glennw
Seems to be a 38% layout win on a site I tested with a lot of text. Other browser engines typically do not duplicate the information in the font style struct. `FontStyle` actually predates @SimonSapin's CSS selector matching library. It's time to get rid of it! r? @glennw
Diffstat (limited to 'components/layout/fragment.rs')
-rw-r--r--components/layout/fragment.rs16
1 files changed, 5 insertions, 11 deletions
diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs
index 73afce62279..63992e37413 100644
--- a/components/layout/fragment.rs
+++ b/components/layout/fragment.rs
@@ -32,7 +32,6 @@ use gfx::display_list::{LineDisplayItemClass, OpaqueNode, PseudoDisplayItemClass
use gfx::display_list::{SidewaysLeft, SidewaysRight, SolidColorDisplayItem};
use gfx::display_list::{SolidColorDisplayItemClass, StackingLevel, TextDisplayItem};
use gfx::display_list::{TextDisplayItemClass, Upright};
-use gfx::font::FontStyle;
use gfx::text::glyph::CharIndex;
use gfx::text::text_run::TextRun;
use script_traits::UntrustedNodeAddress;
@@ -707,8 +706,8 @@ impl Fragment {
}
pub fn calculate_line_height(&self, layout_context: &LayoutContext) -> Au {
- let font_style = text::computed_style_to_font_style(&*self.style);
- let font_metrics = text::font_metrics_for_style(layout_context.font_context(), &font_style);
+ let font_style = self.style.get_font();
+ let font_metrics = text::font_metrics_for_style(layout_context.font_context(), font_style);
text::line_height_from_style(&*self.style, &font_metrics)
}
@@ -862,11 +861,6 @@ impl Fragment {
}
}
- /// Converts this fragment's computed style to a font style used for rendering.
- pub fn font_style(&self) -> FontStyle {
- text::computed_style_to_font_style(self.style())
- }
-
#[inline(always)]
pub fn style<'a>(&'a self) -> &'a ComputedValues {
&*self.style
@@ -1834,9 +1828,9 @@ 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 = text::computed_style_to_font_style(&*self.style);
+ let font_style = self.style.get_font();
let font_metrics = text::font_metrics_for_style(layout_context.font_context(),
- &font_style);
+ font_style);
InlineMetrics::from_block_height(&font_metrics,
block_flow.base.position.size.block +
block_flow.fragment.margin.block_start_end())
@@ -1872,7 +1866,7 @@ impl Fragment {
match (&self.specific, &other.specific) {
(&UnscannedTextFragment(_), &UnscannedTextFragment(_)) => {
// FIXME: Should probably use a whitelist of styles that can safely differ (#3165)
- self.font_style() == other.font_style() &&
+ self.style().get_font() == other.style().get_font() &&
self.text_decoration() == other.text_decoration() &&
self.white_space() == other.white_space()
}