Skip to content
Permalink
Browse files

stylo: Add keyword info to computed value of font-size

  • Loading branch information
Manishearth committed Sep 23, 2017
1 parent 5a6b90b commit c2fcc9ce1aec95f03490854e2a10200aaf4d7031
@@ -118,7 +118,7 @@ impl FontContext {

let layout_font_group_cache_key = LayoutFontGroupCacheKey {
pointer: style.clone(),
size: Au::from(style.font_size),
size: style.font_size.size(),
};
if let Some(ref cached_font_group) = self.layout_font_group_cache.get(
&layout_font_group_cache_key) {
@@ -148,7 +148,7 @@ impl FontContext {
Some(ref cached_font_ref) => {
let cached_font = (*cached_font_ref).borrow();
if cached_font.descriptor == desc &&
cached_font.requested_pt_size == Au::from(style.font_size) &&
cached_font.requested_pt_size == style.font_size.size() &&
cached_font.variant == style.font_variant_caps {
fonts.push((*cached_font_ref).clone());
cache_hit = true;
@@ -166,7 +166,7 @@ impl FontContext {
Some(template_info) => {
let layout_font = self.create_layout_font(template_info.font_template,
desc.clone(),
Au::from(style.font_size),
style.font_size.size(),
style.font_variant_caps,
template_info.font_key);
let font = match layout_font {
@@ -199,7 +199,7 @@ impl FontContext {
for cached_font_entry in &self.fallback_font_cache {
let cached_font = cached_font_entry.font.borrow();
if cached_font.descriptor == desc &&
cached_font.requested_pt_size == Au::from(style.font_size) &&
cached_font.requested_pt_size == style.font_size.size() &&
cached_font.variant == style.font_variant_caps {
fonts.push(cached_font_entry.font.clone());
cache_hit = true;
@@ -211,7 +211,7 @@ impl FontContext {
let template_info = self.font_cache_thread.last_resort_font_template(desc.clone());
let layout_font = self.create_layout_font(template_info.font_template,
desc.clone(),
Au::from(style.font_size),
style.font_size.size(),
style.font_variant_caps,
template_info.font_key);
match layout_font {
@@ -97,10 +97,10 @@ impl Flow for MulticolFlow {
{
let column_style = self.block_flow.fragment.style.get_column();

let column_gap = Au::from(match column_style.column_gap {
Either::First(len) => len,
Either::Second(_normal) => self.block_flow.fragment.style.get_font().font_size,
});
let column_gap = match column_style.column_gap {
Either::First(len) => len.into(),
Either::Second(_normal) => self.block_flow.fragment.style.get_font().font_size.size(),
};

let mut column_count;
if let Either::First(column_width) = column_style.column_width {
@@ -447,7 +447,7 @@ pub fn font_metrics_for_style(font_context: &mut FontContext, font_style: ::Serv

/// Returns the line block-size needed by the given computed style and font size.
pub fn line_height_from_style(style: &ComputedValues, metrics: &FontMetrics) -> Au {
let font_size = Au::from(style.get_font().font_size);
let font_size = style.get_font().font_size.size();
match style.get_inheritedtext().line_height {
LineHeight::Normal => Au::from(metrics.line_gap),
LineHeight::Number(l) => font_size.scale_by(l.0),
@@ -78,7 +78,7 @@ impl Device {
pres_context: pres_context,
default_values: ComputedValues::default_values(unsafe { &*pres_context }),
// FIXME(bz): Seems dubious?
root_font_size: AtomicIsize::new(font_size::get_initial_value().0.to_i32_au() as isize),
root_font_size: AtomicIsize::new(font_size::get_initial_value().size().0 as isize),
body_text_color: AtomicUsize::new(unsafe { &*pres_context }.mDefaultColor as usize),
used_root_font_size: AtomicBool::new(false),
used_viewport_size: AtomicBool::new(false),
@@ -511,7 +511,6 @@ pub trait MatchMethods : TElement {
mut new_styles: ResolvedElementStyles,
important_rules_changed: bool,
) -> ChildCascadeRequirement {
use app_units::Au;
use dom::TNode;
use std::cmp;

@@ -553,7 +552,7 @@ pub trait MatchMethods : TElement {

if old_styles.primary.as_ref().map_or(true, |s| s.get_font().clone_font_size() != new_font_size) {
debug_assert!(self.owner_doc_matches_for_testing(device));
device.set_root_font_size(Au::from(new_font_size));
device.set_root_font_size(new_font_size.size());
// If the root font-size changed since last time, and something
// in the document did use rem units, ensure we recascade the
// entire tree.
@@ -2167,8 +2167,8 @@ fn static_assert() {
}

pub fn set_font_size(&mut self, v: longhands::font_size::computed_value::T) {
self.gecko.mSize = v.0.to_i32_au();
self.gecko.mScriptUnconstrainedSize = v.0.to_i32_au();
self.gecko.mSize = v.size().0;
self.gecko.mScriptUnconstrainedSize = v.size().0;
}

/// Set font size, taking into account scriptminsize and scriptlevel
@@ -2185,7 +2185,7 @@ fn static_assert() {
self.fixup_font_min_size(device);
None
} else {
self.gecko.mSize = v.0.to_i32_au();
self.gecko.mSize = v.size().0;
self.fixup_font_min_size(device);
Some(Au(parent.gecko.mScriptUnconstrainedSize).into())
}
@@ -2348,7 +2348,10 @@ fn static_assert() {
}

pub fn clone_font_size(&self) -> longhands::font_size::computed_value::T {
Au(self.gecko.mSize).into()
longhands::font_size::computed_value::T {
size: Au(self.gecko.mSize).into(),
info: None, // XXXManishearth this is a placeholder
}
}

pub fn set_font_weight(&mut self, v: longhands::font_weight::computed_value::T) {

0 comments on commit c2fcc9c

Please sign in to comment.
You can’t perform that action at this time.