mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
Auto merge of #18244 - kahsieh:master, r=Manishearth
stylo: Update CSS fallback font when lang changes r=manishearth in BugZilla. --- - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix [Bug 1367860](https://bugzilla.mozilla.org/show_bug.cgi?id=1367860). <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18244) <!-- Reviewable:end -->
This commit is contained in:
commit
2136dd2bb7
3 changed files with 28 additions and 17 deletions
|
@ -2169,9 +2169,10 @@ fn static_assert() {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn fixup_system(&mut self) {
|
||||
pub fn fixup_system(&mut self, default_font_type: structs::FontFamilyType) {
|
||||
self.gecko.mFont.systemFont = true;
|
||||
self.gecko.mGenericID = structs::kGenericFont_NONE;
|
||||
self.gecko.mFont.fontlist.mDefaultFontType = default_font_type;
|
||||
}
|
||||
|
||||
pub fn set_font_family(&mut self, v: longhands::font_family::computed_value::T) {
|
||||
|
@ -2223,7 +2224,16 @@ fn static_assert() {
|
|||
use gecko_bindings::structs::FontFamilyType;
|
||||
use gecko_string_cache::Atom;
|
||||
|
||||
::properties::longhands::font_family::computed_value::T(
|
||||
if self.gecko.mFont.fontlist.mFontlist.is_empty() {
|
||||
let default = match self.gecko.mFont.fontlist.mDefaultFontType {
|
||||
FontFamilyType::eFamily_serif => FontFamily::Generic(atom!("serif")),
|
||||
FontFamilyType::eFamily_sans_serif => FontFamily::Generic(atom!("sans-serif")),
|
||||
_ => panic!("Default generic must be serif or sans-serif"),
|
||||
};
|
||||
return longhands::font_family::computed_value::T(vec![default]);
|
||||
}
|
||||
|
||||
longhands::font_family::computed_value::T(
|
||||
self.gecko.mFont.fontlist.mFontlist.iter().map(|gecko_font_family_name| {
|
||||
match gecko_font_family_name.mType {
|
||||
FontFamilyType::eFamily_serif => FontFamily::Generic(atom!("serif")),
|
||||
|
|
|
@ -2491,11 +2491,13 @@ ${helpers.single_keyword("-moz-math-variant",
|
|||
|
||||
use app_units::Au;
|
||||
use cssparser::{Parser, ToCss};
|
||||
use gecko_bindings::structs::FontFamilyType;
|
||||
use properties::longhands;
|
||||
use std::fmt;
|
||||
use std::hash::{Hash, Hasher};
|
||||
use style_traits::ParseError;
|
||||
use values::computed::{ToComputedValue, Context};
|
||||
|
||||
<%
|
||||
system_fonts = """caption icon menu message-box small-caption status-bar
|
||||
-moz-window -moz-document -moz-workspace -moz-desktop
|
||||
|
@ -2584,6 +2586,7 @@ ${helpers.single_keyword("-moz-math-variant",
|
|||
font_feature_settings: longhands::font_feature_settings::get_initial_value(),
|
||||
font_variant_alternates: longhands::font_variant_alternates::get_initial_value(),
|
||||
system_font: *self,
|
||||
default_font_type: system.fontlist.mDefaultFontType,
|
||||
};
|
||||
unsafe { bindings::Gecko_nsFont_Destroy(&mut system); }
|
||||
ret
|
||||
|
@ -2615,6 +2618,7 @@ ${helpers.single_keyword("-moz-math-variant",
|
|||
pub ${name}: longhands::${name}::computed_value::T,
|
||||
% endfor
|
||||
pub system_font: SystemFont,
|
||||
pub default_font_type: FontFamilyType,
|
||||
}
|
||||
|
||||
impl SystemFont {
|
||||
|
|
|
@ -3331,20 +3331,15 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
// In case of just the language changing, the parent could have had no generic,
|
||||
// which Gecko just does regular cascading with. Do the same.
|
||||
// This can only happen in the case where the language changed but the family did not
|
||||
if generic != structs::kGenericFont_NONE {
|
||||
let pres_context = context.builder.device.pres_context();
|
||||
let gecko_font = context.builder.mutate_font().gecko_mut();
|
||||
gecko_font.mGenericID = generic;
|
||||
unsafe {
|
||||
bindings::Gecko_nsStyleFont_PrefillDefaultForGeneric(
|
||||
gecko_font,
|
||||
pres_context,
|
||||
generic,
|
||||
);
|
||||
}
|
||||
let pres_context = context.builder.device.pres_context();
|
||||
let gecko_font = context.builder.mutate_font().gecko_mut();
|
||||
gecko_font.mGenericID = generic;
|
||||
unsafe {
|
||||
bindings::Gecko_nsStyleFont_PrefillDefaultForGeneric(
|
||||
gecko_font,
|
||||
pres_context,
|
||||
generic,
|
||||
);
|
||||
}
|
||||
}
|
||||
% endif
|
||||
|
@ -3371,7 +3366,9 @@ where
|
|||
let device = context.builder.device;
|
||||
if let PropertyDeclaration::FontFamily(ref val) = **declaration {
|
||||
if val.get_system().is_some() {
|
||||
context.builder.mutate_font().fixup_system();
|
||||
let default = context.cached_system_font
|
||||
.as_ref().unwrap().default_font_type;
|
||||
context.builder.mutate_font().fixup_system(default);
|
||||
} else {
|
||||
context.builder.mutate_font().fixup_none_generic(device);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue