mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
stylo: Support -moz-min-font-size-ratio
This commit is contained in:
parent
de269b6b36
commit
ccccfb988a
7 changed files with 88 additions and 48 deletions
|
@ -1487,7 +1487,8 @@ fn static_assert() {
|
|||
font-synthesis -x-lang font-variant-alternates
|
||||
font-variant-east-asian font-variant-ligatures
|
||||
font-variant-numeric font-language-override
|
||||
font-feature-settings font-variation-settings"""
|
||||
font-feature-settings font-variation-settings
|
||||
-moz-min-font-size-ratio"""
|
||||
%>
|
||||
<%self:impl_trait style_struct_name="Font"
|
||||
skip_longhands="${skip_font_longhands}"
|
||||
|
@ -1630,7 +1631,6 @@ fn static_assert() {
|
|||
// actual computed size, and the other of which (mFont.size) is the 'display
|
||||
// size' which takes font zooming into account. We don't handle font zooming yet.
|
||||
pub fn set_font_size(&mut self, v: longhands::font_size::computed_value::T) {
|
||||
self.gecko.mFont.size = v.0;
|
||||
self.gecko.mSize = v.0;
|
||||
self.gecko.mScriptUnconstrainedSize = v.0;
|
||||
}
|
||||
|
@ -1638,21 +1638,27 @@ fn static_assert() {
|
|||
/// Set font size, taking into account scriptminsize and scriptlevel
|
||||
/// Returns Some(size) if we have to recompute the script unconstrained size
|
||||
pub fn apply_font_size(&mut self, v: longhands::font_size::computed_value::T,
|
||||
parent: &Self) -> Option<Au> {
|
||||
parent: &Self,
|
||||
device: &Device) -> Option<Au> {
|
||||
let (adjusted_size, adjusted_unconstrained_size)
|
||||
= self.calculate_script_level_size(parent);
|
||||
// In this case, we have been unaffected by scriptminsize, ignore it
|
||||
if parent.gecko.mSize == parent.gecko.mScriptUnconstrainedSize &&
|
||||
adjusted_size == adjusted_unconstrained_size {
|
||||
self.set_font_size(v);
|
||||
self.fixup_font_min_size(device);
|
||||
None
|
||||
} else {
|
||||
self.gecko.mFont.size = v.0;
|
||||
self.gecko.mSize = v.0;
|
||||
self.fixup_font_min_size(device);
|
||||
Some(Au(parent.gecko.mScriptUnconstrainedSize))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn fixup_font_min_size(&mut self, device: &Device) {
|
||||
unsafe { bindings::Gecko_nsStyleFont_FixupMinFontSize(&mut self.gecko, &*device.pres_context) }
|
||||
}
|
||||
|
||||
pub fn apply_unconstrained_font_size(&mut self, v: Au) {
|
||||
self.gecko.mScriptUnconstrainedSize = v.0;
|
||||
}
|
||||
|
@ -1761,7 +1767,8 @@ fn static_assert() {
|
|||
///
|
||||
/// Returns true if the inherited keyword size was actually used
|
||||
pub fn inherit_font_size_from(&mut self, parent: &Self,
|
||||
kw_inherited_size: Option<Au>) -> bool {
|
||||
kw_inherited_size: Option<Au>,
|
||||
device: &Device) -> bool {
|
||||
let (adjusted_size, adjusted_unconstrained_size)
|
||||
= self.calculate_script_level_size(parent);
|
||||
if adjusted_size.0 != parent.gecko.mSize ||
|
||||
|
@ -1780,23 +1787,23 @@ fn static_assert() {
|
|||
|
||||
// In the case that MathML has given us an adjusted size, apply it.
|
||||
// Keep track of the unconstrained adjusted size.
|
||||
self.gecko.mFont.size = adjusted_size.0;
|
||||
self.gecko.mSize = adjusted_size.0;
|
||||
self.gecko.mScriptUnconstrainedSize = adjusted_unconstrained_size.0;
|
||||
self.fixup_font_min_size(device);
|
||||
false
|
||||
} else if let Some(size) = kw_inherited_size {
|
||||
// Parent element was a keyword-derived size.
|
||||
self.gecko.mFont.size = size.0;
|
||||
self.gecko.mSize = size.0;
|
||||
// MathML constraints didn't apply here, so we can ignore this.
|
||||
self.gecko.mScriptUnconstrainedSize = size.0;
|
||||
self.fixup_font_min_size(device);
|
||||
true
|
||||
} else {
|
||||
// MathML isn't affecting us, and our parent element does not
|
||||
// have a keyword-derived size. Set things normally.
|
||||
self.gecko.mFont.size = parent.gecko.mFont.size;
|
||||
self.gecko.mSize = parent.gecko.mSize;
|
||||
self.gecko.mScriptUnconstrainedSize = parent.gecko.mScriptUnconstrainedSize;
|
||||
self.fixup_font_min_size(device);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -1899,6 +1906,21 @@ fn static_assert() {
|
|||
}
|
||||
|
||||
${impl_simple_copy('font_variant_numeric', 'mFont.variantNumeric')}
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
pub fn set__moz_min_font_size_ratio(&mut self, v: longhands::_moz_min_font_size_ratio::computed_value::T) {
|
||||
let percentage = if v.0 > 255. {
|
||||
255.
|
||||
} else if v.0 < 0. {
|
||||
0.
|
||||
} else {
|
||||
v.0
|
||||
};
|
||||
|
||||
self.gecko.mMinFontSizeRatio = percentage as u8;
|
||||
}
|
||||
|
||||
${impl_simple_copy('_moz_min_font_size_ratio', 'mMinFontSizeRatio')}
|
||||
</%self:impl_trait>
|
||||
|
||||
<%def name="impl_copy_animation_or_transition_value(type, ident, gecko_ffi_name)">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue