diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2016-06-08 19:50:58 -0500 |
---|---|---|
committer | bors-servo <lbergstrom+bors@mozilla.com> | 2016-06-08 19:50:58 -0500 |
commit | 04b682195d2a75ad5961ec05ec1f7a1503c3f3f3 (patch) | |
tree | d4efaf02502172091e0b9ac4ac504f4500c4a35b | |
parent | 28c0b869cab72020edbc54e5ccd761dc2dbb92b2 (diff) | |
parent | 670309ec1515c9a5f26761bf0d6bf141263b6b1d (diff) | |
download | servo-04b682195d2a75ad5961ec05ec1f7a1503c3f3f3.tar.gz servo-04b682195d2a75ad5961ec05ec1f7a1503c3f3f3.zip |
Auto merge of #11667 - mbrubeck:font-family-master, r=heycam
Support font-family in geckolib
r? @heycam
Depends on https://bugzilla.mozilla.org/show_bug.cgi?id=1278647
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11667)
<!-- Reviewable:end -->
-rw-r--r-- | ports/geckolib/gecko_bindings/bindings.rs | 9 | ||||
-rwxr-xr-x | ports/geckolib/gecko_bindings/tools/regen_bindings.sh | 3 | ||||
-rw-r--r-- | ports/geckolib/properties.mako.rs | 39 |
3 files changed, 48 insertions, 3 deletions
diff --git a/ports/geckolib/gecko_bindings/bindings.rs b/ports/geckolib/gecko_bindings/bindings.rs index 608d22fc63d..d9ce707dc81 100644 --- a/ports/geckolib/gecko_bindings/bindings.rs +++ b/ports/geckolib/gecko_bindings/bindings.rs @@ -32,6 +32,9 @@ use structs::SheetParsingMode; use structs::nsMainThreadPtrHandle; use structs::nsMainThreadPtrHolder; use structs::nscolor; +use structs::nsFont; +use structs::FontFamilyList; +use structs::FontFamilyType; use heapsize::HeapSizeOf; unsafe impl Send for nsStyleFont {} unsafe impl Sync for nsStyleFont {} @@ -185,6 +188,12 @@ extern "C" { aString: *const ::std::os::raw::c_char, aLength: u32) -> bool; + pub fn Gecko_FontFamilyList_Clear(aList: *mut FontFamilyList); + pub fn Gecko_FontFamilyList_AppendNamed(aList: *mut FontFamilyList, + aName: *mut nsIAtom); + pub fn Gecko_FontFamilyList_AppendGeneric(list: *mut FontFamilyList, + familyType: FontFamilyType); + pub fn Gecko_CopyFontFamilyFrom(dst: *mut nsFont, src: *const nsFont); pub fn Gecko_SetListStyleType(style_struct: *mut nsStyleList, type_: u32); pub fn Gecko_CopyListStyleTypeFrom(dst: *mut nsStyleList, src: *const nsStyleList); diff --git a/ports/geckolib/gecko_bindings/tools/regen_bindings.sh b/ports/geckolib/gecko_bindings/tools/regen_bindings.sh index 6af8acb7370..401ae785a3a 100755 --- a/ports/geckolib/gecko_bindings/tools/regen_bindings.sh +++ b/ports/geckolib/gecko_bindings/tools/regen_bindings.sh @@ -51,7 +51,8 @@ do done # Other mapped types. -for TYPE in SheetParsingMode nsMainThreadPtrHandle nsMainThreadPtrHolder nscolor +for TYPE in SheetParsingMode nsMainThreadPtrHandle nsMainThreadPtrHolder nscolor nsFont \ + FontFamilyList FontFamilyType do MAP_GECKO_TYPES=$MAP_GECKO_TYPES"-blacklist-type $TYPE " MAP_GECKO_TYPES=$MAP_GECKO_TYPES"-raw-line 'use structs::$TYPE;' " diff --git a/ports/geckolib/properties.mako.rs b/ports/geckolib/properties.mako.rs index 9f1fed583f0..1b1b65545eb 100644 --- a/ports/geckolib/properties.mako.rs +++ b/ports/geckolib/properties.mako.rs @@ -20,7 +20,9 @@ use gecko_bindings::bindings::{Gecko_CopyMozBindingFrom, Gecko_CopyListStyleType use gecko_bindings::bindings::{Gecko_SetMozBinding, Gecko_SetListStyleType}; use gecko_bindings::bindings::{Gecko_SetNullImageValue, Gecko_SetGradientImageValue}; use gecko_bindings::bindings::{Gecko_CreateGradient}; -use gecko_bindings::bindings::{Gecko_CopyImageValueFrom}; +use gecko_bindings::bindings::{Gecko_CopyImageValueFrom, Gecko_CopyFontFamilyFrom}; +use gecko_bindings::bindings::{Gecko_FontFamilyList_AppendGeneric, Gecko_FontFamilyList_AppendNamed}; +use gecko_bindings::bindings::{Gecko_FontFamilyList_Clear}; use gecko_bindings::structs; use glue::ArcHelpers; use std::fmt::{self, Debug}; @@ -604,7 +606,40 @@ fn static_assert() { } </%self:impl_trait> -<%self:impl_trait style_struct_name="Font" skip_longhands="font-style font-size font-weight" skip_additionals="*"> +<%self:impl_trait style_struct_name="Font" + skip_longhands="font-family font-style font-size font-weight" + skip_additionals="*"> + + fn set_font_family(&mut self, v: longhands::font_family::computed_value::T) { + use style::properties::longhands::font_family::computed_value::FontFamily; + use gecko_bindings::structs::FontFamilyType; + + let list = &mut self.gecko.mFont.fontlist; + unsafe { Gecko_FontFamilyList_Clear(list); } + + for family in &v.0 { + match *family { + FontFamily::FamilyName(ref name) => { + unsafe { Gecko_FontFamilyList_AppendNamed(list, name.as_ptr()); } + } + FontFamily::Generic(ref name) => { + let family_type = + if name == &atom!("serif") { FontFamilyType::eFamily_serif } + else if name == &atom!("sans-serif") { FontFamilyType::eFamily_sans_serif } + else if name == &atom!("cursive") { FontFamilyType::eFamily_cursive } + else if name == &atom!("fantasy") { FontFamilyType::eFamily_fantasy } + else if name == &atom!("monospace") { FontFamilyType::eFamily_monospace } + else { panic!("Unknown generic font family") }; + unsafe { Gecko_FontFamilyList_AppendGeneric(list, family_type); } + } + } + } + } + + fn copy_font_family_from(&mut self, other: &Self) { + unsafe { Gecko_CopyFontFamilyFrom(&mut self.gecko.mFont, &other.gecko.mFont); } + } + <%call expr="impl_keyword('font_style', 'mFont.style', data.longhands_by_name['font-style'].keyword, need_clone=False)"></%call> |