diff --git a/.travis.yml b/.travis.yml index 278c18bd260..dec7987e178 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,8 +27,6 @@ matrix: - ./mach build -d --verbose - ./mach test-unit - ./mach clean - - ./mach build-geckolib - - ./mach test-stylo - bash etc/ci/lockfile_changed.sh cache: directories: diff --git a/components/gfx/font.rs b/components/gfx/font.rs index 09578168ea7..2cf92e6a328 100644 --- a/components/gfx/font.rs +++ b/components/gfx/font.rs @@ -19,7 +19,7 @@ use std::rc::Rc; use std::str; use std::sync::Arc; use std::sync::atomic::{ATOMIC_USIZE_INIT, AtomicUsize, Ordering}; -use style::computed_values::{font_stretch, font_variant_caps, font_weight}; +use style::computed_values::{font_stretch, font_style, font_variant_caps, font_weight}; use style::properties::style_structs::Font as FontStyleStruct; use style::values::computed::font::SingleFontFamily; use text::Shaper; @@ -47,18 +47,24 @@ static TEXT_SHAPING_PERFORMANCE_COUNTER: AtomicUsize = ATOMIC_USIZE_INIT; // resources needed by the graphics layer to draw glyphs. pub trait FontHandleMethods: Sized { - fn new_from_template(fctx: &FontContextHandle, template: Arc, pt_size: Option) - -> Result; + fn new_from_template( + fctx: &FontContextHandle, + template: Arc, + pt_size: Option, + ) -> Result; + fn template(&self) -> Arc; fn family_name(&self) -> String; fn face_name(&self) -> Option; - fn is_italic(&self) -> bool; + + fn style(&self) -> font_style::T; fn boldness(&self) -> font_weight::T; fn stretchiness(&self) -> font_stretch::T; fn glyph_index(&self, codepoint: char) -> Option; fn glyph_h_advance(&self, GlyphId) -> Option; fn glyph_h_kerning(&self, glyph0: GlyphId, glyph1: GlyphId) -> FractionalPixel; + /// Can this font do basic horizontal LTR shaping without Harfbuzz? fn can_do_fast_shaping(&self) -> bool; fn metrics(&self) -> FontMetrics; diff --git a/components/gfx/font_cache_thread.rs b/components/gfx/font_cache_thread.rs index fdb48e519fe..39375191ae1 100644 --- a/components/gfx/font_cache_thread.rs +++ b/components/gfx/font_cache_thread.rs @@ -18,14 +18,11 @@ use platform::font_list::system_default_family; use platform::font_template::FontTemplateData; use servo_atoms::Atom; use servo_url::ServoUrl; +use std::{fmt, f32, mem, thread}; use std::borrow::ToOwned; use std::collections::HashMap; -use std::fmt; -use std::mem; use std::ops::Deref; use std::sync::{Arc, Mutex}; -use std::thread; -use std::u32; use style::font_face::{EffectiveSources, Source}; use style::values::computed::font::{SingleFontFamily, FamilyName}; use webrender_api; @@ -63,7 +60,7 @@ impl FontTemplates { // We didn't find an exact match. Do more expensive fuzzy matching. // TODO(#190): Do a better job. - let (mut best_template_data, mut best_distance) = (None, u32::MAX); + let (mut best_template_data, mut best_distance) = (None, f32::MAX); for template in &mut self.templates { if let Some((template_data, distance)) = template.data_for_approximate_descriptor(fctx, desc) { diff --git a/components/gfx/font_template.rs b/components/gfx/font_template.rs index 239bfcdd8c9..13c531f4d43 100644 --- a/components/gfx/font_template.rs +++ b/components/gfx/font_template.rs @@ -10,7 +10,6 @@ use servo_atoms::Atom; use std::fmt::{Debug, Error, Formatter}; use std::io::Error as IoError; use std::sync::{Arc, Weak}; -use std::u32; use style::computed_values::font_stretch::T as FontStretch; use style::computed_values::font_style::T as FontStyle; use style::properties::style_structs::Font as FontStyleStruct; @@ -20,21 +19,35 @@ use style::values::computed::font::FontWeight; /// to be expanded or refactored when we support more of the font styling parameters. /// /// NB: If you change this, you will need to update `style::properties::compute_font_hash()`. -#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Serialize)] +#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)] pub struct FontTemplateDescriptor { pub weight: FontWeight, pub stretch: FontStretch, - pub italic: bool, + pub style: FontStyle, } +fn style_to_number(s: &FontStyle) -> f32 { + use style::values::generics::font::FontStyle as GenericFontStyle; + + match *s { + GenericFontStyle::Normal => 0., + GenericFontStyle::Italic => FontStyle::default_angle().0.degrees(), + GenericFontStyle::Oblique(ref angle) => angle.0.degrees(), + } +} + + impl FontTemplateDescriptor { #[inline] - pub fn new(weight: FontWeight, stretch: FontStretch, italic: bool) - -> FontTemplateDescriptor { - FontTemplateDescriptor { - weight: weight, - stretch: stretch, - italic: italic, + pub fn new( + weight: FontWeight, + stretch: FontStretch, + style: FontStyle, + ) -> Self { + Self { + weight, + stretch, + style, } } @@ -46,30 +59,15 @@ impl FontTemplateDescriptor { /// /// The policy is to care most about differences in italicness, then weight, then stretch #[inline] - fn distance_from(&self, other: &FontTemplateDescriptor) -> u32 { - let italic_part = if self.italic == other.italic { 0 } else { 1000 }; + fn distance_from(&self, other: &FontTemplateDescriptor) -> f32 { + // 0 <= style_part <= 180, since font-style obliqueness should be + // between -90 and +90deg. + let style_part = (style_to_number(&self.style) - style_to_number(&other.style)).abs(); // 0 <= weightPart <= 800 - let weight_part = ((self.weight.0 as i16) - (other.weight.0 as i16)).abs() as u32; + let weight_part = (self.weight.0 - other.weight.0).abs(); // 0 <= stretchPart <= 8 - let stretch_part = (self.stretch_number() - other.stretch_number()).abs() as u32; - italic_part + weight_part + stretch_part - } - - /// Returns a number between 1 and 9 for the stretch property. - /// 1 is ultra_condensed, 5 is normal, and 9 is ultra_expanded - #[inline] - fn stretch_number(&self) -> i32 { - match self.stretch { - FontStretch::UltraCondensed => 1, - FontStretch::ExtraCondensed => 2, - FontStretch::Condensed => 3, - FontStretch::SemiCondensed => 4, - FontStretch::Normal => 5, - FontStretch::SemiExpanded => 6, - FontStretch::Expanded => 7, - FontStretch::ExtraExpanded => 8, - FontStretch::UltraExpanded => 9, - } + let stretch_part = ((self.stretch.0).0 - (other.stretch.0).0).abs(); + style_part + weight_part + stretch_part } } @@ -78,17 +76,11 @@ impl<'a> From<&'a FontStyleStruct> for FontTemplateDescriptor { FontTemplateDescriptor { weight: style.font_weight, stretch: style.font_stretch, - italic: style.font_style == FontStyle::Italic || style.font_style == FontStyle::Oblique, + style: style.font_style, } } } -impl PartialEq for FontTemplateDescriptor { - fn eq(&self, other: &FontTemplateDescriptor) -> bool { - self.weight == other.weight && self.stretch == other.stretch && self.italic == other.italic - } -} - /// This describes all the information needed to create /// font instance handles. It contains a unique /// FontTemplateData structure that is platform specific. @@ -173,10 +165,11 @@ impl FontTemplate { /// Returns the font data along with the distance between this font's descriptor and the given /// descriptor, if the font can be loaded. - pub fn data_for_approximate_descriptor(&mut self, - font_context: &FontContextHandle, - requested_descriptor: &FontTemplateDescriptor) - -> Option<(Arc, u32)> { + pub fn data_for_approximate_descriptor( + &mut self, + font_context: &FontContextHandle, + requested_descriptor: &FontTemplateDescriptor, + ) -> Option<(Arc, f32)> { self.descriptor(&font_context).and_then(|descriptor| { self.data().ok().map(|data| { (data, descriptor.distance_from(requested_descriptor)) @@ -195,9 +188,11 @@ impl FontTemplate { None); self.is_valid = handle.is_ok(); let handle = handle?; - self.descriptor = Some(FontTemplateDescriptor::new(handle.boldness(), - handle.stretchiness(), - handle.is_italic())); + self.descriptor = Some(FontTemplateDescriptor::new( + handle.boldness(), + handle.stretchiness(), + handle.style(), + )); Ok(()) } diff --git a/components/gfx/platform/freetype/font.rs b/components/gfx/platform/freetype/font.rs index 940563d7d29..506d6be2117 100644 --- a/components/gfx/platform/freetype/font.rs +++ b/components/gfx/platform/freetype/font.rs @@ -24,6 +24,7 @@ use std::os::raw::{c_char, c_long}; use std::sync::Arc; use style::computed_values::font_stretch::T as FontStretch; use style::computed_values::font_weight::T as FontWeight; +use style::values::computed::font::FontStyle; use super::c_str_to_string; use text::glyph::GlyphId; use text::util::fixed_to_float; @@ -149,43 +150,44 @@ impl FontHandleMethods for FontHandle { } } - fn is_italic(&self) -> bool { - unsafe { (*self.face).style_flags & FT_STYLE_FLAG_ITALIC as c_long != 0 } + fn style(&self) -> FontStyle { + use style::values::generics::font::FontStyle::*; + if unsafe { (*self.face).style_flags & FT_STYLE_FLAG_ITALIC as c_long != 0 } { + Italic + } else { + Normal + } } fn boldness(&self) -> FontWeight { - if let Some(os2) = self.os2_table() { - let weight = os2.us_weight_class as i32; - - if weight < 10 { - FontWeight::from_int(weight * 100).unwrap() - } else if weight >= 100 && weight < 1000 { - FontWeight::from_int(weight / 100 * 100).unwrap() - } else { - FontWeight::normal() - } - } else { - FontWeight::normal() - } + let os2 = match self.os2_table() { + None => return FontWeight::normal(), + Some(os2) => os2, + }; + let weight = os2.us_weight_class as f32; + FontWeight(weight.max(1.).min(1000.)) } fn stretchiness(&self) -> FontStretch { - if let Some(os2) = self.os2_table() { + use style::values::generics::NonNegative; + use style::values::specified::font::FontStretchKeyword; + let percentage = if let Some(os2) = self.os2_table() { match os2.us_width_class { - 1 => FontStretch::UltraCondensed, - 2 => FontStretch::ExtraCondensed, - 3 => FontStretch::Condensed, - 4 => FontStretch::SemiCondensed, - 5 => FontStretch::Normal, - 6 => FontStretch::SemiExpanded, - 7 => FontStretch::Expanded, - 8 => FontStretch::ExtraExpanded, - 9 => FontStretch::UltraExpanded, - _ => FontStretch::Normal + 1 => FontStretchKeyword::UltraCondensed, + 2 => FontStretchKeyword::ExtraCondensed, + 3 => FontStretchKeyword::Condensed, + 4 => FontStretchKeyword::SemiCondensed, + 5 => FontStretchKeyword::Normal, + 6 => FontStretchKeyword::SemiExpanded, + 7 => FontStretchKeyword::Expanded, + 8 => FontStretchKeyword::ExtraExpanded, + 9 => FontStretchKeyword::UltraExpanded, + _ => FontStretchKeyword::Normal } } else { - FontStretch::Normal - } + FontStretchKeyword::Normal + }.compute(); + NonNegative(percentage) } fn glyph_index(&self, codepoint: char) -> Option { diff --git a/components/gfx/platform/macos/font.rs b/components/gfx/platform/macos/font.rs index ca719ddf5b7..5eacf92ffd6 100644 --- a/components/gfx/platform/macos/font.rs +++ b/components/gfx/platform/macos/font.rs @@ -22,8 +22,7 @@ use servo_atoms::Atom; use std::{fmt, ptr}; use std::ops::Range; use std::sync::Arc; -use style::computed_values::font_stretch::T as FontStretch; -use style::computed_values::font_weight::T as FontWeight; +use style::values::computed::font::{FontStretch, FontStyle, FontWeight}; use text::glyph::GlyphId; const KERN_PAIR_LEN: usize = 6; @@ -204,34 +203,33 @@ impl FontHandleMethods for FontHandle { Some(self.ctfont.face_name()) } - fn is_italic(&self) -> bool { - self.ctfont.symbolic_traits().is_italic() + fn style(&self) -> FontStyle { + use style::values::generics::font::FontStyle::*; + if self.ctfont.symbolic_traits().is_italic() { + Italic + } else { + Normal + } } fn boldness(&self) -> FontWeight { let normalized = self.ctfont.all_traits().normalized_weight(); // [-1.0, 1.0] + // TODO(emilio): It may make sense to make this range [.01, 10.0], to + // align with css-fonts-4's range of [1, 1000]. let normalized = if normalized <= 0.0 { 4.0 + normalized * 3.0 // [1.0, 4.0] } else { 4.0 + normalized * 5.0 // [4.0, 9.0] }; // [1.0, 9.0], centered on 4.0 - FontWeight::from_int(normalized.round() as i32 * 100).unwrap() + FontWeight(normalized as f32 * 100.) } fn stretchiness(&self) -> FontStretch { + use style::values::computed::Percentage; + use style::values::generics::NonNegative; + let normalized = self.ctfont.all_traits().normalized_width(); // [-1.0, 1.0] - let normalized = (normalized + 1.0) / 2.0 * 9.0; // [0.0, 9.0] - match normalized { - v if v < 1.0 => FontStretch::UltraCondensed, - v if v < 2.0 => FontStretch::ExtraCondensed, - v if v < 3.0 => FontStretch::Condensed, - v if v < 4.0 => FontStretch::SemiCondensed, - v if v < 5.0 => FontStretch::Normal, - v if v < 6.0 => FontStretch::SemiExpanded, - v if v < 7.0 => FontStretch::Expanded, - v if v < 8.0 => FontStretch::ExtraExpanded, - _ => FontStretch::UltraExpanded, - } + NonNegative(Percentage(normalized as f32 + 1.0)) } fn glyph_index(&self, codepoint: char) -> Option { diff --git a/components/gfx/platform/windows/font.rs b/components/gfx/platform/windows/font.rs index 12df6d547d2..ed94d0fc5a2 100644 --- a/components/gfx/platform/windows/font.rs +++ b/components/gfx/platform/windows/font.rs @@ -19,6 +19,10 @@ use servo_atoms::Atom; use std::sync::Arc; use style::computed_values::font_stretch::T as StyleFontStretch; use style::computed_values::font_weight::T as StyleFontWeight; +use style::values::computed::font::FontStyle as StyleFontStyle; +use style::values::generics::NonNegative; +use style::values::generics::font::FontStyle as GenericFontStyle; +use style::values::specified::font::FontStretchKeyword; use text::glyph::GlyphId; use truetype; @@ -98,7 +102,7 @@ struct FontInfo { face_name: String, weight: StyleFontWeight, stretch: StyleFontStretch, - style: FontStyle, + style: StyleFontStyle, } impl FontInfo { @@ -157,75 +161,76 @@ impl FontInfo { }, }; - let weight = - StyleFontWeight::from_int( - min(9, max(1, weight_val as i32 / 100)) * 100 - ).unwrap(); + let weight = StyleFontWeight(weight_val as f32); - let stretch = match min(9, max(1, width_val)) { - 1 => StyleFontStretch::UltraCondensed, - 2 => StyleFontStretch::ExtraCondensed, - 3 => StyleFontStretch::Condensed, - 4 => StyleFontStretch::SemiCondensed, - 5 => StyleFontStretch::Normal, - 6 => StyleFontStretch::SemiExpanded, - 7 => StyleFontStretch::Expanded, - 8 => StyleFontStretch::ExtraExpanded, - 9 => StyleFontStretch::UltraExpanded, + let stretch = NonNegative(match min(9, max(1, width_val)) { + 1 => FontStretchKeyword::UltraCondensed, + 2 => FontStretchKeyword::ExtraCondensed, + 3 => FontStretchKeyword::Condensed, + 4 => FontStretchKeyword::SemiCondensed, + 5 => FontStretchKeyword::Normal, + 6 => FontStretchKeyword::SemiExpanded, + 7 => FontStretchKeyword::Expanded, + 8 => FontStretchKeyword::ExtraExpanded, + 9 => FontStretchKeyword::UltraExpanded, _ => return Err(()), - }; + }.compute()); let style = if italic_bool { - FontStyle::Italic + GenericFontStyle::Italic } else { - FontStyle::Normal + GenericFontStyle::Normal }; Ok(FontInfo { family_name: family, face_name: face, - weight: weight, - stretch: stretch, - style: style, + weight, + stretch, + style, }) } fn new_from_font(font: &Font) -> Result { - let style = font.style(); - let weight = StyleFontWeight(match font.weight() { - FontWeight::Thin => 100, - FontWeight::ExtraLight => 200, - FontWeight::Light => 300, - // slightly grayer gray - FontWeight::SemiLight => 300, - FontWeight::Regular => 400, - FontWeight::Medium => 500, - FontWeight::SemiBold => 600, - FontWeight::Bold => 700, - FontWeight::ExtraBold => 800, - FontWeight::Black => 900, - // slightly blacker black - FontWeight::ExtraBlack => 900, - }); - let stretch = match font.stretch() { - FontStretch::Undefined => StyleFontStretch::Normal, - FontStretch::UltraCondensed => StyleFontStretch::UltraCondensed, - FontStretch::ExtraCondensed => StyleFontStretch::ExtraCondensed, - FontStretch::Condensed => StyleFontStretch::Condensed, - FontStretch::SemiCondensed => StyleFontStretch::SemiCondensed, - FontStretch::Normal => StyleFontStretch::Normal, - FontStretch::SemiExpanded => StyleFontStretch::SemiExpanded, - FontStretch::Expanded => StyleFontStretch::Expanded, - FontStretch::ExtraExpanded => StyleFontStretch::ExtraExpanded, - FontStretch::UltraExpanded => StyleFontStretch::UltraExpanded, + let style = match font.style() { + FontStyle::Normal => GenericFontStyle::Normal, + FontStyle::Oblique => GenericFontStyle::Oblique(StyleFontStyle::default_angle()), + FontStyle::Italic => GenericFontStyle::Italic, }; + let weight = StyleFontWeight(match font.weight() { + FontWeight::Thin => 100., + FontWeight::ExtraLight => 200., + FontWeight::Light => 300., + // slightly grayer gray + FontWeight::SemiLight => 300., + FontWeight::Regular => 400., + FontWeight::Medium => 500., + FontWeight::SemiBold => 600., + FontWeight::Bold => 700., + FontWeight::ExtraBold => 800., + FontWeight::Black => 900., + // slightly blacker black + FontWeight::ExtraBlack => 1000., + }); + let stretch = NonNegative(match font.stretch() { + FontStretch::Undefined => FontStretchKeyword::Normal, + FontStretch::UltraCondensed => FontStretchKeyword::UltraCondensed, + FontStretch::ExtraCondensed => FontStretchKeyword::ExtraCondensed, + FontStretch::Condensed => FontStretchKeyword::Condensed, + FontStretch::SemiCondensed => FontStretchKeyword::SemiCondensed, + FontStretch::Normal => FontStretchKeyword::Normal, + FontStretch::SemiExpanded => FontStretchKeyword::SemiExpanded, + FontStretch::Expanded => FontStretchKeyword::Expanded, + FontStretch::ExtraExpanded => FontStretchKeyword::ExtraExpanded, + FontStretch::UltraExpanded => FontStretchKeyword::UltraExpanded, + }.compute()); Ok(FontInfo { family_name: font.family_name(), face_name: font.face_name(), - style: style, - weight: weight, - stretch: stretch, + style, + weight, + stretch, }) } } @@ -297,11 +302,8 @@ impl FontHandleMethods for FontHandle { Some(self.info.face_name.clone()) } - fn is_italic(&self) -> bool { - match self.info.style { - FontStyle::Normal => false, - FontStyle::Oblique | FontStyle::Italic => true, - } + fn style(&self) -> StyleFontStyle { + self.info.style } fn boldness(&self) -> StyleFontWeight { diff --git a/components/gfx/tests/font_context.rs b/components/gfx/tests/font_context.rs index f7fef58a5c2..c918ef86e90 100644 --- a/components/gfx/tests/font_context.rs +++ b/components/gfx/tests/font_context.rs @@ -22,12 +22,13 @@ use std::fs::File; use std::io::prelude::*; use std::path::PathBuf; use std::rc::Rc; -use style::properties::longhands::font_stretch::computed_value::T as FontStretch; -use style::properties::longhands::font_style::computed_value::T as FontStyle; use style::properties::longhands::font_variant_caps::computed_value::T as FontVariantCaps; use style::properties::style_structs::Font as FontStyleStruct; +use style::values::computed::Percentage; use style::values::computed::font::{FamilyName, FamilyNameSyntax, FontFamily, FontFamilyList, FontSize}; use style::values::computed::font::{FontWeight, SingleFontFamily}; +use style::values::generics::NonNegative; +use style::values::generics::font::FontStyle; struct TestFontSource { handle: FontContextHandle, @@ -108,7 +109,7 @@ fn style() -> FontStyleStruct { font_variant_caps: FontVariantCaps::Normal, font_weight: FontWeight::normal(), font_size: FontSize::medium(), - font_stretch: FontStretch::Normal, + font_stretch: NonNegative(Percentage(1.)), hash: 0, }; style.compute_font_hash(); diff --git a/components/gfx/tests/font_template.rs b/components/gfx/tests/font_template.rs index 4b513d9f0c4..af31d8f229d 100644 --- a/components/gfx/tests/font_template.rs +++ b/components/gfx/tests/font_template.rs @@ -16,8 +16,10 @@ fn test_font_template_descriptor() { use std::fs::File; use std::io::prelude::*; use std::path::PathBuf; - use style::computed_values::font_stretch::T as FontStretch; + use style::values::computed::Percentage; use style::values::computed::font::FontWeight; + use style::values::generics::NonNegative; + use style::values::generics::font::FontStyle; fn descriptor(filename: &str) -> FontTemplateDescriptor { let mut path: PathBuf = [ @@ -43,25 +45,25 @@ fn test_font_template_descriptor() { assert_eq!(descriptor("DejaVuSans"), FontTemplateDescriptor { weight: FontWeight::normal(), - stretch: FontStretch::Normal, - italic: false, + stretch: NonNegative(Percentage(1.)), + style: FontStyle::Normal, }); assert_eq!(descriptor("DejaVuSans-Bold"), FontTemplateDescriptor { weight: FontWeight::bold(), - stretch: FontStretch::Normal, - italic: false, + stretch: NonNegative(Percentage(1.)), + style: FontStyle::Normal, }); assert_eq!(descriptor("DejaVuSans-Oblique"), FontTemplateDescriptor { weight: FontWeight::normal(), - stretch: FontStretch::Normal, - italic: true, + stretch: NonNegative(Percentage(1.)), + style: FontStyle::Italic, }); assert_eq!(descriptor("DejaVuSansCondensed-BoldOblique"), FontTemplateDescriptor { weight: FontWeight::bold(), - stretch: FontStretch::SemiCondensed, - italic: true, + stretch: NonNegative(Percentage(0.875)), + style: FontStyle::Italic, }); } diff --git a/components/layout/multicol.rs b/components/layout/multicol.rs index 3659d50e219..487a878c08b 100644 --- a/components/layout/multicol.rs +++ b/components/layout/multicol.rs @@ -104,13 +104,13 @@ impl Flow for MulticolFlow { self.block_flow.fragment.border_box.size.inline - padding_and_borders; let column_width; { - let column_style = self.block_flow.fragment.style.get_column(); - - let column_gap = match column_style.column_gap { + let style = &self.block_flow.fragment.style; + let column_gap = match style.get_position().column_gap { Either::First(len) => len.0.to_pixel_length(content_inline_size).into(), Either::Second(_normal) => self.block_flow.fragment.style.get_font().font_size.size(), }; + let column_style = style.get_column(); let mut column_count; if let Either::First(column_width) = column_style.column_width { let column_width = Au::from(column_width); diff --git a/components/style/applicable_declarations.rs b/components/style/applicable_declarations.rs index ab7c47307d7..d4674fa1bc7 100644 --- a/components/style/applicable_declarations.rs +++ b/components/style/applicable_declarations.rs @@ -5,12 +5,11 @@ //! Applicable declarations management. use properties::PropertyDeclarationBlock; -use rule_tree::{CascadeLevel, StyleSource}; +use rule_tree::{CascadeLevel, ShadowCascadeOrder, StyleSource}; use servo_arc::Arc; use shared_lock::Locked; use smallvec::SmallVec; use std::fmt::{self, Debug}; -use std::mem; /// List of applicable declarations. This is a transient structure that shuttles /// declarations between selector matching and inserting into the rule tree, and @@ -25,45 +24,67 @@ pub type ApplicableDeclarationList = SmallVec<[ApplicableDeclarationBlock; 16]>; /// That's a limit that could be reached in realistic webpages, so we use /// 24 bits and enforce defined behavior in the overflow case. /// -/// Note that the value of 24 is also hard-coded into the level() accessor, -/// which does a byte-aligned load of the 4th byte. If you change this value -/// you'll need to change that as well. -/// /// [1] https://cs.chromium.org/chromium/src/third_party/WebKit/Source/core/css/ /// RuleSet.h?l=128&rcl=90140ab80b84d0f889abc253410f44ed54ae04f3 +const SOURCE_ORDER_SHIFT: usize = 0; const SOURCE_ORDER_BITS: usize = 24; -const SOURCE_ORDER_MASK: u32 = (1 << SOURCE_ORDER_BITS) - 1; -const SOURCE_ORDER_MAX: u32 = SOURCE_ORDER_MASK; +const SOURCE_ORDER_MAX: u32 = (1 << SOURCE_ORDER_BITS) - 1; +const SOURCE_ORDER_MASK: u32 = SOURCE_ORDER_MAX << SOURCE_ORDER_SHIFT; -/// Stores the source order of a block and the cascade level it belongs to. +/// We store up-to-15 shadow order levels. +/// +/// You'd need an element slotted across 16 components with ::slotted rules to +/// trigger this as of this writing, which looks... Unlikely. +const SHADOW_CASCADE_ORDER_SHIFT: usize = SOURCE_ORDER_BITS; +const SHADOW_CASCADE_ORDER_BITS: usize = 4; +const SHADOW_CASCADE_ORDER_MAX: u8 = (1 << SHADOW_CASCADE_ORDER_BITS) - 1; +const SHADOW_CASCADE_ORDER_MASK: u32 = (SHADOW_CASCADE_ORDER_MAX as u32) << SHADOW_CASCADE_ORDER_SHIFT; + +const CASCADE_LEVEL_SHIFT: usize = SOURCE_ORDER_BITS + SHADOW_CASCADE_ORDER_BITS; +const CASCADE_LEVEL_BITS: usize = 4; +const CASCADE_LEVEL_MAX: u8 = (1 << CASCADE_LEVEL_BITS) - 1; +const CASCADE_LEVEL_MASK: u32 = (CASCADE_LEVEL_MAX as u32) << CASCADE_LEVEL_SHIFT; + +/// Stores the source order of a block, the cascade level it belongs to, and the +/// counter needed to handle Shadow DOM cascade order properly. #[derive(Clone, Copy, Eq, MallocSizeOf, PartialEq)] -struct SourceOrderAndCascadeLevel(u32); +struct ApplicableDeclarationBits(u32); -impl SourceOrderAndCascadeLevel { - fn new(source_order: u32, cascade_level: CascadeLevel) -> SourceOrderAndCascadeLevel { +impl ApplicableDeclarationBits { + fn new( + source_order: u32, + cascade_level: CascadeLevel, + shadow_cascade_order: ShadowCascadeOrder, + ) -> Self { + debug_assert!( + cascade_level as u8 <= CASCADE_LEVEL_MAX, + "Gotta find more bits!" + ); let mut bits = ::std::cmp::min(source_order, SOURCE_ORDER_MAX); - bits |= (cascade_level as u8 as u32) << SOURCE_ORDER_BITS; - SourceOrderAndCascadeLevel(bits) + bits |= ((shadow_cascade_order & SHADOW_CASCADE_ORDER_MAX) as u32) << SHADOW_CASCADE_ORDER_SHIFT; + bits |= (cascade_level as u8 as u32) << CASCADE_LEVEL_SHIFT; + ApplicableDeclarationBits(bits) } - fn order(&self) -> u32 { - self.0 & SOURCE_ORDER_MASK + fn source_order(&self) -> u32 { + (self.0 & SOURCE_ORDER_MASK) >> SOURCE_ORDER_SHIFT + } + + fn shadow_cascade_order(&self) -> ShadowCascadeOrder { + ((self.0 & SHADOW_CASCADE_ORDER_MASK) >> SHADOW_CASCADE_ORDER_SHIFT) as ShadowCascadeOrder } fn level(&self) -> CascadeLevel { - unsafe { - // Transmute rather than shifting so that we're sure the compiler - // emits a simple byte-aligned load. - let as_bytes: [u8; 4] = mem::transmute(self.0); - CascadeLevel::from_byte(as_bytes[3]) - } + let byte = ((self.0 & CASCADE_LEVEL_MASK) >> CASCADE_LEVEL_SHIFT) as u8; + unsafe { CascadeLevel::from_byte(byte) } } } -impl Debug for SourceOrderAndCascadeLevel { +impl Debug for ApplicableDeclarationBits { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("SourceOrderAndCascadeLevel") - .field("order", &self.order()) + f.debug_struct("ApplicableDeclarationBits") + .field("source_order", &self.source_order()) + .field("shadow_cascade_order", &self.shadow_cascade_order()) .field("level", &self.level()) .finish() } @@ -79,8 +100,9 @@ pub struct ApplicableDeclarationBlock { /// The style source, either a style rule, or a property declaration block. #[ignore_malloc_size_of = "Arc"] pub source: StyleSource, - /// The source order of the block, and the cascade level it belongs to. - order_and_level: SourceOrderAndCascadeLevel, + /// The bits containing the source order, cascade level, and shadow cascade + /// order. + bits: ApplicableDeclarationBits, /// The specificity of the selector this block is represented by. pub specificity: u32, } @@ -95,38 +117,45 @@ impl ApplicableDeclarationBlock { ) -> Self { ApplicableDeclarationBlock { source: StyleSource::Declarations(declarations), - order_and_level: SourceOrderAndCascadeLevel::new(0, level), + bits: ApplicableDeclarationBits::new(0, level, 0), specificity: 0, } } /// Constructs an applicable declaration block from the given components #[inline] - pub fn new(source: StyleSource, order: u32, level: CascadeLevel, specificity: u32) -> Self { + pub fn new( + source: StyleSource, + order: u32, + level: CascadeLevel, + specificity: u32, + shadow_cascade_order: ShadowCascadeOrder, + ) -> Self { ApplicableDeclarationBlock { - source: source, - order_and_level: SourceOrderAndCascadeLevel::new(order, level), - specificity: specificity, + source, + bits: ApplicableDeclarationBits::new(order, level, shadow_cascade_order), + specificity, } } /// Returns the source order of the block. #[inline] pub fn source_order(&self) -> u32 { - self.order_and_level.order() + self.bits.source_order() } /// Returns the cascade level of the block. #[inline] pub fn level(&self) -> CascadeLevel { - self.order_and_level.level() + self.bits.level() } - /// Convenience method to consume self and return the source alongside the - /// level. + /// Convenience method to consume self and return the right thing for the + /// rule tree to iterate over. #[inline] - pub fn order_and_level(self) -> (StyleSource, CascadeLevel) { + pub fn for_rule_tree(self) -> (StyleSource, CascadeLevel, ShadowCascadeOrder) { let level = self.level(); - (self.source, level) + let cascade_order = self.bits.shadow_cascade_order(); + (self.source, level, cascade_order) } } diff --git a/components/style/build_gecko.rs b/components/style/build_gecko.rs index 2d1db9e7037..95bb1622942 100644 --- a/components/style/build_gecko.rs +++ b/components/style/build_gecko.rs @@ -3,38 +3,19 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ mod common { - use std::{env, fs, io}; - use std::path::{Path, PathBuf}; + use std::env; + use std::path::PathBuf; lazy_static! { pub static ref OUTDIR_PATH: PathBuf = PathBuf::from(env::var_os("OUT_DIR").unwrap()).join("gecko"); } - - /// Copy contents of one directory into another. - /// It currently only does a shallow copy. - pub fn copy_dir(from: P, to: Q, callback: F) -> io::Result<()> - where - P: AsRef, - Q: AsRef, - F: Fn(&Path), - { - let to = to.as_ref(); - for entry in from.as_ref().read_dir()? { - let entry = entry?; - let path = entry.path(); - callback(&path); - fs::copy(&path, to.join(entry.file_name()))?; - } - Ok(()) - } } #[cfg(feature = "bindgen")] mod bindings { use bindgen::{Builder, CodegenConfig}; - use bindgen::callbacks::{EnumVariantCustomBehavior, EnumVariantValue, ParseCallbacks}; - use regex::{Regex, RegexSet}; + use regex::Regex; use std::cmp; use std::collections::{HashMap, HashSet}; use std::env; @@ -416,27 +397,6 @@ mod bindings { } fn generate_structs() { - #[derive(Debug)] - struct Callbacks(HashMap); - impl ParseCallbacks for Callbacks { - fn enum_variant_behavior( - &self, - enum_name: Option<&str>, - variant_name: &str, - _variant_value: EnumVariantValue, - ) -> Option { - enum_name - .and_then(|enum_name| self.0.get(enum_name)) - .and_then(|regex| { - if regex.is_match(variant_name) { - Some(EnumVariantCustomBehavior::Constify) - } else { - None - } - }) - } - } - let builder = Builder::get_initial_builder() .enable_cxx_namespaces() .with_codegen_config(CodegenConfig { @@ -452,21 +412,6 @@ mod bindings { .handle_str_items("whitelist-vars", |b, item| b.whitelist_var(item)) .handle_str_items("whitelist-types", |b, item| b.whitelist_type(item)) .handle_str_items("opaque-types", |b, item| b.opaque_type(item)) - .handle_list("constified-enum-variants", |builder, iter| { - let mut map = HashMap::new(); - for item in iter { - let item = item.as_table().unwrap(); - let name = item["enum"].as_str().unwrap(); - let variants = item["variants"] - .as_array() - .unwrap() - .as_slice() - .iter() - .map(|item| item.as_str().unwrap()); - map.insert(name.into(), RegexSet::new(variants).unwrap()); - } - builder.parse_callbacks(Box::new(Callbacks(map))) - }) .handle_table_items("mapped-generic-types", |builder, item| { let generic = item["generic"].as_bool().unwrap(); let gecko = item["gecko"].as_str().unwrap(); @@ -650,23 +595,33 @@ mod bindings { generate_bindings(), generate_atoms(), } - - // Copy all generated files to dist for the binding package - let path = DISTDIR_PATH.join("rust_bindings/style"); - if path.exists() { - fs::remove_dir_all(&path).expect("Fail to remove binding dir in dist"); - } - fs::create_dir_all(&path).expect("Fail to create bindings dir in dist"); - copy_dir(&*OUTDIR_PATH, &path, |_| {}).expect("Fail to copy generated files to dist dir"); } } #[cfg(not(feature = "bindgen"))] mod bindings { - use std::env; - use std::path::PathBuf; + use std::{env, fs, io}; + use std::path::{Path, PathBuf}; use super::common::*; + /// Copy contents of one directory into another. + /// It currently only does a shallow copy. + fn copy_dir(from: P, to: Q, callback: F) -> io::Result<()> + where + P: AsRef, + Q: AsRef, + F: Fn(&Path), + { + let to = to.as_ref(); + for entry in from.as_ref().read_dir()? { + let entry = entry?; + let path = entry.path(); + callback(&path); + fs::copy(&path, to.join(entry.file_name()))?; + } + Ok(()) + } + pub fn generate() { let dir = PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").unwrap()).join("gecko/generated"); println!("cargo:rerun-if-changed={}", dir.display()); diff --git a/components/style/font_face.rs b/components/style/font_face.rs index a890822d02f..5a111925ae7 100644 --- a/components/style/font_face.rs +++ b/components/style/font_face.rs @@ -6,10 +6,6 @@ //! //! [ff]: https://drafts.csswg.org/css-fonts/#at-font-face-rule -#![deny(missing_docs)] - -#[cfg(feature = "gecko")] -use computed_values::{font_stretch, font_style, font_weight}; use cssparser::{AtRuleParser, DeclarationListParser, DeclarationParser, Parser}; use cssparser::{CowRcStr, SourceLocation}; #[cfg(feature = "gecko")] @@ -26,8 +22,12 @@ use style_traits::{Comma, CssWriter, OneOrMoreSeparated, ParseError}; use style_traits::{StyleParseErrorKind, ToCss}; use style_traits::values::SequenceWriter; use values::computed::font::FamilyName; +use values::generics::font::FontStyle as GenericFontStyle; +use values::specified::Angle; +use values::specified::font::{AbsoluteFontWeight, FontStretch as SpecifiedFontStretch}; #[cfg(feature = "gecko")] use values::specified::font::{SpecifiedFontFeatureSettings, SpecifiedFontVariationSettings}; +use values::specified::font::SpecifiedFontStyle; use values::specified::url::SpecifiedUrl; /// A source for a font-face rule. @@ -92,41 +92,97 @@ pub enum FontDisplay { Optional, } -/// A font-weight value for a @font-face rule. -/// The font-weight CSS property specifies the weight or boldness of the font. -#[cfg(feature = "gecko")] -#[derive(Clone, Debug, Eq, PartialEq, ToCss)] -pub enum FontWeight { - /// Numeric font weights for fonts that provide more than just normal and bold. - Weight(font_weight::T), - /// Normal font weight. Same as 400. - Normal, - /// Bold font weight. Same as 700. - Bold, -} +/// The font-weight descriptor: +/// +/// https://drafts.csswg.org/css-fonts-4/#descdef-font-face-font-weight +#[derive(Clone, Debug, PartialEq, ToCss)] +pub struct FontWeight(pub AbsoluteFontWeight, pub Option); -#[cfg(feature = "gecko")] impl Parse for FontWeight { fn parse<'i, 't>( - _: &ParserContext, + context: &ParserContext, input: &mut Parser<'i, 't>, - ) -> Result> { - let result = input.try(|input| { - let ident = input.expect_ident().map_err(|_| ())?; - match_ignore_ascii_case! { &ident, - "normal" => Ok(FontWeight::Normal), - "bold" => Ok(FontWeight::Bold), - _ => Err(()) + ) -> Result> { + let first = AbsoluteFontWeight::parse(context, input)?; + let second = + input.try(|input| AbsoluteFontWeight::parse(context, input)).ok(); + Ok(FontWeight(first, second)) + } +} + +/// The font-stretch descriptor: +/// +/// https://drafts.csswg.org/css-fonts-4/#descdef-font-face-font-stretch +#[derive(Clone, Debug, PartialEq, ToCss)] +pub struct FontStretch(pub SpecifiedFontStretch, pub Option); + +impl Parse for FontStretch { + fn parse<'i, 't>( + context: &ParserContext, + input: &mut Parser<'i, 't>, + ) -> Result> { + let first = SpecifiedFontStretch::parse(context, input)?; + let second = + input.try(|input| SpecifiedFontStretch::parse(context, input)).ok(); + Ok(FontStretch(first, second)) + } +} + +/// The font-style descriptor: +/// +/// https://drafts.csswg.org/css-fonts-4/#descdef-font-face-font-style +#[derive(Clone, Debug, PartialEq)] +#[allow(missing_docs)] +pub enum FontStyle { + Normal, + Italic, + Oblique(Angle, Angle), +} + +impl Parse for FontStyle { + fn parse<'i, 't>( + context: &ParserContext, + input: &mut Parser<'i, 't>, + ) -> Result> { + let style = SpecifiedFontStyle::parse(context, input)?; + Ok(match style { + GenericFontStyle::Normal => FontStyle::Normal, + GenericFontStyle::Italic => FontStyle::Italic, + GenericFontStyle::Oblique(angle) => { + let second_angle = input.try(|input| { + SpecifiedFontStyle::parse_angle(context, input) + }).unwrap_or_else(|_| angle.clone()); + + FontStyle::Oblique(angle, second_angle) } - }); - result.or_else(|_| { - font_weight::T::from_int(input.expect_integer()?) - .map(FontWeight::Weight) - .map_err(|()| input.new_custom_error(StyleParseErrorKind::UnspecifiedError)) }) } } +impl ToCss for FontStyle { + fn to_css(&self, dest: &mut CssWriter) -> fmt::Result + where + W: fmt::Write, + { + match *self { + FontStyle::Normal => dest.write_str("normal"), + FontStyle::Italic => dest.write_str("italic"), + FontStyle::Oblique(ref first, ref second) => { + dest.write_str("oblique")?; + if *first != SpecifiedFontStyle::default_angle() || first != second { + dest.write_char(' ')?; + first.to_css(dest)?; + } + if first != second { + dest.write_char(' ')?; + second.to_css(dest)?; + } + Ok(()) + } + } + } +} + /// Parse the block inside a `@font-face` rule. /// /// Note that the prelude parsing code lives in the `stylesheets` module. @@ -403,16 +459,16 @@ font_face_descriptors! { "src" sources / mSrc: Vec, ] optional descriptors = [ - /// The style of this font face - "font-style" style / mStyle: font_style::T, + /// The style of this font face. + "font-style" style / mStyle: FontStyle, - /// The weight of this font face + /// The weight of this font face. "font-weight" weight / mWeight: FontWeight, - /// The stretch of this font face - "font-stretch" stretch / mStretch: font_stretch::T, + /// The stretch of this font face. + "font-stretch" stretch / mStretch: FontStretch, - /// The display of this font face + /// The display of this font face. "font-display" display / mDisplay: FontDisplay, /// The ranges of code points outside of which this font face should not be used. diff --git a/components/style/gecko/generated/bindings.rs b/components/style/gecko/generated/bindings.rs index 508f9ce4345..d5c7443b5a3 100644 --- a/components/style/gecko/generated/bindings.rs +++ b/components/style/gecko/generated/bindings.rs @@ -232,6 +232,7 @@ use gecko_bindings::structs::nsresult; use gecko_bindings::structs::Loader; use gecko_bindings::structs::LoaderReusableStyleSheets; use gecko_bindings::structs::SheetLoadData; +use gecko_bindings::structs::SheetLoadDataHolder; use gecko_bindings::structs::ServoStyleSheet; use gecko_bindings::structs::ServoComputedData; use gecko_bindings::structs::ComputedStyleStrong; @@ -627,18 +628,36 @@ extern "C" { it: RawGeckoStyleChildrenIteratorBorrowedMut, ) -> RawGeckoNodeBorrowedOrNull; } +extern "C" { + pub fn Gecko_AddRefSheetLoadDataHolderArbitraryThread(aPtr: *mut SheetLoadDataHolder); +} +extern "C" { + pub fn Gecko_ReleaseSheetLoadDataHolderArbitraryThread(aPtr: *mut SheetLoadDataHolder); +} +extern "C" { + pub fn Gecko_StyleSheet_FinishAsyncParse( + data: *mut SheetLoadDataHolder, + sheet_contents: RawServoStyleSheetContentsStrong, + ); +} extern "C" { pub fn Gecko_LoadStyleSheet( loader: *mut Loader, parent: *mut ServoStyleSheet, parent_load_data: *mut SheetLoadData, reusable_sheets: *mut LoaderReusableStyleSheets, - base_url_data: *mut RawGeckoURLExtraData, - url_bytes: *const u8, - url_length: u32, + url: ServoBundledURI, media_list: RawServoMediaListStrong, ) -> *mut ServoStyleSheet; } +extern "C" { + pub fn Gecko_LoadStyleSheetAsync( + parent_data: *mut SheetLoadDataHolder, + url: ServoBundledURI, + media_list: RawServoMediaListStrong, + import_rule: RawServoImportRuleStrong, + ); +} extern "C" { pub fn Gecko_ElementState(element: RawGeckoElementBorrowed) -> u64; } @@ -1996,8 +2015,7 @@ extern "C" { loader: *mut Loader, gecko_stylesheet: *mut ServoStyleSheet, load_data: *mut SheetLoadData, - data: *const u8, - data_len: usize, + bytes: *const nsACString, parsing_mode: SheetParsingMode, extra_data: *mut RawGeckoURLExtraData, line_number_offset: u32, @@ -2005,6 +2023,16 @@ extern "C" { reusable_sheets: *mut LoaderReusableStyleSheets, ) -> RawServoStyleSheetContentsStrong; } +extern "C" { + pub fn Servo_StyleSheet_FromUTF8BytesAsync( + load_data: *mut SheetLoadDataHolder, + extra_data: *mut RawGeckoURLExtraData, + bytes: *const nsACString, + parsing_mode: SheetParsingMode, + line_number_offset: u32, + quirks_mode: nsCompatibility, + ); +} extern "C" { pub fn Servo_StyleSheet_Empty( parsing_mode: SheetParsingMode, @@ -2512,12 +2540,22 @@ extern "C" { pseudo_type: CSSPseudoElementType, ) -> bool; } +extern "C" { + pub fn Servo_StyleRule_SetSelectorText( + sheet: RawServoStyleSheetContentsBorrowed, + rule: RawServoStyleRuleBorrowed, + text: *const nsAString, + ) -> bool; +} extern "C" { pub fn Servo_ImportRule_GetHref(rule: RawServoImportRuleBorrowed, result: *mut nsAString); } extern "C" { pub fn Servo_ImportRule_GetSheet(rule: RawServoImportRuleBorrowed) -> *const ServoStyleSheet; } +extern "C" { + pub fn Servo_ImportRule_SetSheet(rule: RawServoImportRuleBorrowed, sheet: *mut ServoStyleSheet); +} extern "C" { pub fn Servo_Keyframe_GetKeyText(keyframe: RawServoKeyframeBorrowed, result: *mut nsAString); } diff --git a/components/style/gecko/generated/structs.rs b/components/style/gecko/generated/structs.rs index ebe6b79afbc..f88b116b646 100644 --- a/components/style/gecko/generated/structs.rs +++ b/components/style/gecko/generated/structs.rs @@ -149,15 +149,15 @@ pub mod root { pub const NS_FONT_WEIGHT_NORMAL: u32 = 400; pub const NS_FONT_WEIGHT_BOLD: u32 = 700; pub const NS_FONT_WEIGHT_THIN: u32 = 100; - pub const NS_FONT_STRETCH_ULTRA_CONDENSED: i32 = -4; - pub const NS_FONT_STRETCH_EXTRA_CONDENSED: i32 = -3; - pub const NS_FONT_STRETCH_CONDENSED: i32 = -2; - pub const NS_FONT_STRETCH_SEMI_CONDENSED: i32 = -1; - pub const NS_FONT_STRETCH_NORMAL: u32 = 0; - pub const NS_FONT_STRETCH_SEMI_EXPANDED: u32 = 1; - pub const NS_FONT_STRETCH_EXPANDED: u32 = 2; - pub const NS_FONT_STRETCH_EXTRA_EXPANDED: u32 = 3; - pub const NS_FONT_STRETCH_ULTRA_EXPANDED: u32 = 4; + pub const NS_FONT_STRETCH_ULTRA_CONDENSED: u32 = 50; + pub const NS_FONT_STRETCH_EXTRA_CONDENSED: u32 = 62; + pub const NS_FONT_STRETCH_CONDENSED: u32 = 75; + pub const NS_FONT_STRETCH_SEMI_CONDENSED: u32 = 87; + pub const NS_FONT_STRETCH_NORMAL: u32 = 100; + pub const NS_FONT_STRETCH_SEMI_EXPANDED: u32 = 112; + pub const NS_FONT_STRETCH_EXPANDED: u32 = 125; + pub const NS_FONT_STRETCH_EXTRA_EXPANDED: u32 = 150; + pub const NS_FONT_STRETCH_ULTRA_EXPANDED: u32 = 200; pub const NS_FONT_SMOOTHING_AUTO: u32 = 0; pub const NS_FONT_SMOOTHING_GRAYSCALE: u32 = 1; pub const NS_FONT_KERNING_AUTO: u32 = 0; @@ -429,15 +429,15 @@ pub mod root { pub const NS_STYLE_FONT_SIZE_LARGER: u32 = 8; pub const NS_STYLE_FONT_SIZE_SMALLER: u32 = 9; pub const NS_STYLE_FONT_SIZE_NO_KEYWORD: u32 = 10; - pub const NS_STYLE_FONT_STRETCH_ULTRA_CONDENSED: i32 = -4; - pub const NS_STYLE_FONT_STRETCH_EXTRA_CONDENSED: i32 = -3; - pub const NS_STYLE_FONT_STRETCH_CONDENSED: i32 = -2; - pub const NS_STYLE_FONT_STRETCH_SEMI_CONDENSED: i32 = -1; - pub const NS_STYLE_FONT_STRETCH_NORMAL: u32 = 0; - pub const NS_STYLE_FONT_STRETCH_SEMI_EXPANDED: u32 = 1; - pub const NS_STYLE_FONT_STRETCH_EXPANDED: u32 = 2; - pub const NS_STYLE_FONT_STRETCH_EXTRA_EXPANDED: u32 = 3; - pub const NS_STYLE_FONT_STRETCH_ULTRA_EXPANDED: u32 = 4; + pub const NS_STYLE_FONT_STRETCH_ULTRA_CONDENSED: u32 = 50; + pub const NS_STYLE_FONT_STRETCH_EXTRA_CONDENSED: u32 = 62; + pub const NS_STYLE_FONT_STRETCH_CONDENSED: u32 = 75; + pub const NS_STYLE_FONT_STRETCH_SEMI_CONDENSED: u32 = 87; + pub const NS_STYLE_FONT_STRETCH_NORMAL: u32 = 100; + pub const NS_STYLE_FONT_STRETCH_SEMI_EXPANDED: u32 = 112; + pub const NS_STYLE_FONT_STRETCH_EXPANDED: u32 = 125; + pub const NS_STYLE_FONT_STRETCH_EXTRA_EXPANDED: u32 = 150; + pub const NS_STYLE_FONT_STRETCH_ULTRA_EXPANDED: u32 = 200; pub const NS_STYLE_FONT_CAPTION: u32 = 1; pub const NS_STYLE_FONT_ICON: u32 = 2; pub const NS_STYLE_FONT_MENU: u32 = 3; @@ -6471,6 +6471,8 @@ pub mod root { __bindgen_bitfield_unit } } + pub type SheetLoadDataHolder = + root::nsMainThreadPtrHolder; #[repr(C)] #[derive(Debug, Copy)] pub struct ImageLoader { @@ -17422,6 +17424,16 @@ pub mod root { ); } #[repr(C)] + #[derive(Debug)] + pub struct nsMainThreadPtrHolder { + pub mRefCnt: root::mozilla::ThreadSafeAutoRefCnt, + pub mRawPtr: *mut T, + pub mStrict: bool, + pub mMainThreadEventTarget: root::nsCOMPtr, + pub mName: *const ::std::os::raw::c_char, + pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, + } + #[repr(C)] #[derive(Debug, Copy)] pub struct nsISerializable { pub _base: root::nsISupports, @@ -18354,18 +18366,6 @@ pub mod root { pub type nsRefPtrHashKey_KeyTypePointer = *mut T; pub const nsRefPtrHashKey_ALLOW_MEMMOVE: root::nsRefPtrHashKey__bindgen_ty_1 = 0; pub type nsRefPtrHashKey__bindgen_ty_1 = i32; - pub const nsCSSPropertyID_eCSSProperty_COUNT_no_shorthands: root::nsCSSPropertyID = - nsCSSPropertyID::eCSSProperty_all; - pub const nsCSSPropertyID_eCSSProperty_COUNT_DUMMY: root::nsCSSPropertyID = - nsCSSPropertyID::eCSSProperty_z_index; - pub const nsCSSPropertyID_eCSSProperty_COUNT: root::nsCSSPropertyID = - nsCSSPropertyID::eCSSPropertyAlias_WordWrap; - pub const nsCSSPropertyID_eCSSProperty_COUNT_DUMMY2: root::nsCSSPropertyID = - nsCSSPropertyID::eCSSProperty_transition; - pub const nsCSSPropertyID_eCSSProperty_COUNT_with_aliases: root::nsCSSPropertyID = - nsCSSPropertyID::eCSSPropertyExtra_no_properties; - pub const nsCSSPropertyID_eCSSProperty_COUNT_DUMMY3: root::nsCSSPropertyID = - nsCSSPropertyID::eCSSPropertyAlias_WebkitMaskSize; #[repr(i32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum nsCSSPropertyID { @@ -18516,11 +18516,11 @@ pub mod root { eCSSProperty_grid_template_rows = 143, eCSSProperty_height = 144, eCSSProperty_hyphens = 145, - eCSSProperty_initial_letter = 146, - eCSSProperty_image_orientation = 147, - eCSSProperty__moz_image_region = 148, - eCSSProperty_image_rendering = 149, - eCSSProperty_ime_mode = 150, + eCSSProperty_image_orientation = 146, + eCSSProperty__moz_image_region = 147, + eCSSProperty_image_rendering = 148, + eCSSProperty_ime_mode = 149, + eCSSProperty_initial_letter = 150, eCSSProperty_inline_size = 151, eCSSProperty_isolation = 152, eCSSProperty_justify_content = 153, @@ -18587,113 +18587,113 @@ pub mod root { eCSSProperty_outline_width = 214, eCSSProperty_overflow_clip_box_block = 215, eCSSProperty_overflow_clip_box_inline = 216, - eCSSProperty_overflow_x = 217, - eCSSProperty_overflow_y = 218, - eCSSProperty_padding_block_end = 219, - eCSSProperty_padding_block_start = 220, - eCSSProperty_padding_bottom = 221, - eCSSProperty_padding_inline_end = 222, - eCSSProperty_padding_inline_start = 223, - eCSSProperty_padding_left = 224, - eCSSProperty_padding_right = 225, - eCSSProperty_padding_top = 226, - eCSSProperty_page_break_after = 227, - eCSSProperty_page_break_before = 228, - eCSSProperty_page_break_inside = 229, - eCSSProperty_paint_order = 230, - eCSSProperty_perspective = 231, - eCSSProperty_perspective_origin = 232, - eCSSProperty_pointer_events = 233, - eCSSProperty_position = 234, - eCSSProperty_quotes = 235, - eCSSProperty_resize = 236, - eCSSProperty_right = 237, - eCSSProperty_rotate = 238, - eCSSProperty_ruby_align = 239, - eCSSProperty_ruby_position = 240, - eCSSProperty__moz_script_level = 241, - eCSSProperty__moz_script_min_size = 242, - eCSSProperty__moz_script_size_multiplier = 243, - eCSSProperty_scroll_behavior = 244, - eCSSProperty_overscroll_behavior_x = 245, - eCSSProperty_overscroll_behavior_y = 246, - eCSSProperty_scroll_snap_coordinate = 247, - eCSSProperty_scroll_snap_destination = 248, - eCSSProperty_scroll_snap_points_x = 249, - eCSSProperty_scroll_snap_points_y = 250, - eCSSProperty_scroll_snap_type_x = 251, - eCSSProperty_scroll_snap_type_y = 252, - eCSSProperty_shape_image_threshold = 253, - eCSSProperty_shape_outside = 254, - eCSSProperty_shape_rendering = 255, - eCSSProperty__x_span = 256, - eCSSProperty__moz_stack_sizing = 257, - eCSSProperty_stop_color = 258, - eCSSProperty_stop_opacity = 259, - eCSSProperty_stroke = 260, - eCSSProperty_stroke_dasharray = 261, - eCSSProperty_stroke_dashoffset = 262, - eCSSProperty_stroke_linecap = 263, - eCSSProperty_stroke_linejoin = 264, - eCSSProperty_stroke_miterlimit = 265, - eCSSProperty_stroke_opacity = 266, - eCSSProperty_stroke_width = 267, - eCSSProperty__moz_tab_size = 268, - eCSSProperty_table_layout = 269, - eCSSProperty_text_align = 270, - eCSSProperty_text_align_last = 271, - eCSSProperty_text_anchor = 272, - eCSSProperty_text_combine_upright = 273, - eCSSProperty_text_decoration_color = 274, - eCSSProperty_text_decoration_line = 275, - eCSSProperty_text_decoration_style = 276, - eCSSProperty_text_emphasis_color = 277, - eCSSProperty_text_emphasis_position = 278, - eCSSProperty_text_emphasis_style = 279, - eCSSProperty__webkit_text_fill_color = 280, - eCSSProperty_text_indent = 281, - eCSSProperty_text_justify = 282, - eCSSProperty_text_orientation = 283, - eCSSProperty_text_overflow = 284, - eCSSProperty_text_rendering = 285, - eCSSProperty_text_shadow = 286, - eCSSProperty__moz_text_size_adjust = 287, - eCSSProperty__webkit_text_stroke_color = 288, - eCSSProperty__webkit_text_stroke_width = 289, - eCSSProperty_scale = 290, - eCSSProperty_text_transform = 291, - eCSSProperty__x_text_zoom = 292, - eCSSProperty_top = 293, - eCSSProperty__moz_top_layer = 294, - eCSSProperty_touch_action = 295, - eCSSProperty_transform = 296, - eCSSProperty_transform_box = 297, - eCSSProperty_transform_origin = 298, - eCSSProperty_transform_style = 299, - eCSSProperty_transition_delay = 300, - eCSSProperty_transition_duration = 301, - eCSSProperty_transition_property = 302, - eCSSProperty_transition_timing_function = 303, - eCSSProperty_translate = 304, - eCSSProperty_unicode_bidi = 305, - eCSSProperty__moz_user_focus = 306, - eCSSProperty__moz_user_input = 307, - eCSSProperty__moz_user_modify = 308, - eCSSProperty__moz_user_select = 309, - eCSSProperty_vector_effect = 310, - eCSSProperty_vertical_align = 311, - eCSSProperty_visibility = 312, - eCSSProperty_white_space = 313, - eCSSProperty_width = 314, - eCSSProperty_will_change = 315, - eCSSProperty__moz_window_dragging = 316, - eCSSProperty__moz_window_shadow = 317, + eCSSProperty_overflow_wrap = 217, + eCSSProperty_overflow_x = 218, + eCSSProperty_overflow_y = 219, + eCSSProperty_overscroll_behavior_x = 220, + eCSSProperty_overscroll_behavior_y = 221, + eCSSProperty_padding_block_end = 222, + eCSSProperty_padding_block_start = 223, + eCSSProperty_padding_bottom = 224, + eCSSProperty_padding_inline_end = 225, + eCSSProperty_padding_inline_start = 226, + eCSSProperty_padding_left = 227, + eCSSProperty_padding_right = 228, + eCSSProperty_padding_top = 229, + eCSSProperty_page_break_after = 230, + eCSSProperty_page_break_before = 231, + eCSSProperty_page_break_inside = 232, + eCSSProperty_paint_order = 233, + eCSSProperty_perspective = 234, + eCSSProperty_perspective_origin = 235, + eCSSProperty_pointer_events = 236, + eCSSProperty_position = 237, + eCSSProperty_quotes = 238, + eCSSProperty_resize = 239, + eCSSProperty_right = 240, + eCSSProperty_rotate = 241, + eCSSProperty_ruby_align = 242, + eCSSProperty_ruby_position = 243, + eCSSProperty_scale = 244, + eCSSProperty__moz_script_level = 245, + eCSSProperty__moz_script_min_size = 246, + eCSSProperty__moz_script_size_multiplier = 247, + eCSSProperty_scroll_behavior = 248, + eCSSProperty_scroll_snap_coordinate = 249, + eCSSProperty_scroll_snap_destination = 250, + eCSSProperty_scroll_snap_points_x = 251, + eCSSProperty_scroll_snap_points_y = 252, + eCSSProperty_scroll_snap_type_x = 253, + eCSSProperty_scroll_snap_type_y = 254, + eCSSProperty_shape_image_threshold = 255, + eCSSProperty_shape_outside = 256, + eCSSProperty_shape_rendering = 257, + eCSSProperty__x_span = 258, + eCSSProperty__moz_stack_sizing = 259, + eCSSProperty_stop_color = 260, + eCSSProperty_stop_opacity = 261, + eCSSProperty_stroke = 262, + eCSSProperty_stroke_dasharray = 263, + eCSSProperty_stroke_dashoffset = 264, + eCSSProperty_stroke_linecap = 265, + eCSSProperty_stroke_linejoin = 266, + eCSSProperty_stroke_miterlimit = 267, + eCSSProperty_stroke_opacity = 268, + eCSSProperty_stroke_width = 269, + eCSSProperty__moz_tab_size = 270, + eCSSProperty_table_layout = 271, + eCSSProperty_text_align = 272, + eCSSProperty_text_align_last = 273, + eCSSProperty_text_anchor = 274, + eCSSProperty_text_combine_upright = 275, + eCSSProperty_text_decoration_color = 276, + eCSSProperty_text_decoration_line = 277, + eCSSProperty_text_decoration_style = 278, + eCSSProperty_text_emphasis_color = 279, + eCSSProperty_text_emphasis_position = 280, + eCSSProperty_text_emphasis_style = 281, + eCSSProperty__webkit_text_fill_color = 282, + eCSSProperty_text_indent = 283, + eCSSProperty_text_justify = 284, + eCSSProperty_text_orientation = 285, + eCSSProperty_text_overflow = 286, + eCSSProperty_text_rendering = 287, + eCSSProperty_text_shadow = 288, + eCSSProperty__moz_text_size_adjust = 289, + eCSSProperty__webkit_text_stroke_color = 290, + eCSSProperty__webkit_text_stroke_width = 291, + eCSSProperty_text_transform = 292, + eCSSProperty__x_text_zoom = 293, + eCSSProperty_top = 294, + eCSSProperty__moz_top_layer = 295, + eCSSProperty_touch_action = 296, + eCSSProperty_transform = 297, + eCSSProperty_transform_box = 298, + eCSSProperty_transform_origin = 299, + eCSSProperty_transform_style = 300, + eCSSProperty_transition_delay = 301, + eCSSProperty_transition_duration = 302, + eCSSProperty_transition_property = 303, + eCSSProperty_transition_timing_function = 304, + eCSSProperty_translate = 305, + eCSSProperty_unicode_bidi = 306, + eCSSProperty__moz_user_focus = 307, + eCSSProperty__moz_user_input = 308, + eCSSProperty__moz_user_modify = 309, + eCSSProperty__moz_user_select = 310, + eCSSProperty_vector_effect = 311, + eCSSProperty_vertical_align = 312, + eCSSProperty_visibility = 313, + eCSSProperty_white_space = 314, + eCSSProperty_width = 315, + eCSSProperty_will_change = 316, + eCSSProperty__moz_window_dragging = 317, eCSSProperty__moz_window_opacity = 318, - eCSSProperty__moz_window_transform = 319, - eCSSProperty__moz_window_transform_origin = 320, - eCSSProperty_word_break = 321, - eCSSProperty_word_spacing = 322, - eCSSProperty_overflow_wrap = 323, + eCSSProperty__moz_window_shadow = 319, + eCSSProperty__moz_window_transform = 320, + eCSSProperty__moz_window_transform_origin = 321, + eCSSProperty_word_break = 322, + eCSSProperty_word_spacing = 323, eCSSProperty_writing_mode = 324, eCSSProperty_z_index = 325, eCSSProperty_all = 326, @@ -18735,132 +18735,129 @@ pub mod root { eCSSProperty__moz_outline_radius = 362, eCSSProperty_overflow = 363, eCSSProperty_overflow_clip_box = 364, - eCSSProperty_padding = 365, - eCSSProperty_place_content = 366, - eCSSProperty_place_items = 367, - eCSSProperty_place_self = 368, - eCSSProperty_overscroll_behavior = 369, + eCSSProperty_overscroll_behavior = 365, + eCSSProperty_padding = 366, + eCSSProperty_place_content = 367, + eCSSProperty_place_items = 368, + eCSSProperty_place_self = 369, eCSSProperty_scroll_snap_type = 370, eCSSProperty_text_decoration = 371, eCSSProperty_text_emphasis = 372, eCSSProperty__webkit_text_stroke = 373, eCSSProperty_transition = 374, - eCSSPropertyAlias_WordWrap = 375, - eCSSPropertyAlias_MozTransform = 376, - eCSSPropertyAlias_MozTransformOrigin = 377, - eCSSPropertyAlias_MozPerspectiveOrigin = 378, - eCSSPropertyAlias_MozPerspective = 379, - eCSSPropertyAlias_MozTransformStyle = 380, - eCSSPropertyAlias_MozBackfaceVisibility = 381, - eCSSPropertyAlias_MozBorderImage = 382, - eCSSPropertyAlias_MozTransition = 383, - eCSSPropertyAlias_MozTransitionDelay = 384, - eCSSPropertyAlias_MozTransitionDuration = 385, - eCSSPropertyAlias_MozTransitionProperty = 386, - eCSSPropertyAlias_MozTransitionTimingFunction = 387, - eCSSPropertyAlias_MozAnimation = 388, - eCSSPropertyAlias_MozAnimationDelay = 389, - eCSSPropertyAlias_MozAnimationDirection = 390, - eCSSPropertyAlias_MozAnimationDuration = 391, - eCSSPropertyAlias_MozAnimationFillMode = 392, - eCSSPropertyAlias_MozAnimationIterationCount = 393, - eCSSPropertyAlias_MozAnimationName = 394, - eCSSPropertyAlias_MozAnimationPlayState = 395, - eCSSPropertyAlias_MozAnimationTimingFunction = 396, - eCSSPropertyAlias_MozBoxSizing = 397, - eCSSPropertyAlias_MozFontFeatureSettings = 398, - eCSSPropertyAlias_MozFontLanguageOverride = 399, - eCSSPropertyAlias_MozPaddingEnd = 400, - eCSSPropertyAlias_MozPaddingStart = 401, - eCSSPropertyAlias_MozMarginEnd = 402, - eCSSPropertyAlias_MozMarginStart = 403, - eCSSPropertyAlias_MozBorderEnd = 404, - eCSSPropertyAlias_MozBorderEndColor = 405, - eCSSPropertyAlias_MozBorderEndStyle = 406, - eCSSPropertyAlias_MozBorderEndWidth = 407, - eCSSPropertyAlias_MozBorderStart = 408, - eCSSPropertyAlias_MozBorderStartColor = 409, - eCSSPropertyAlias_MozBorderStartStyle = 410, - eCSSPropertyAlias_MozBorderStartWidth = 411, - eCSSPropertyAlias_MozHyphens = 412, - eCSSPropertyAlias_MozColumnCount = 413, - eCSSPropertyAlias_MozColumnFill = 414, - eCSSPropertyAlias_MozColumnGap = 415, - eCSSPropertyAlias_MozColumnRule = 416, - eCSSPropertyAlias_MozColumnRuleColor = 417, - eCSSPropertyAlias_MozColumnRuleStyle = 418, - eCSSPropertyAlias_MozColumnRuleWidth = 419, - eCSSPropertyAlias_MozColumnSpan = 420, - eCSSPropertyAlias_MozColumnWidth = 421, - eCSSPropertyAlias_MozColumns = 422, - eCSSPropertyAlias_WebkitAnimation = 423, - eCSSPropertyAlias_WebkitAnimationDelay = 424, - eCSSPropertyAlias_WebkitAnimationDirection = 425, - eCSSPropertyAlias_WebkitAnimationDuration = 426, - eCSSPropertyAlias_WebkitAnimationFillMode = 427, - eCSSPropertyAlias_WebkitAnimationIterationCount = 428, - eCSSPropertyAlias_WebkitAnimationName = 429, - eCSSPropertyAlias_WebkitAnimationPlayState = 430, - eCSSPropertyAlias_WebkitAnimationTimingFunction = 431, - eCSSPropertyAlias_WebkitFilter = 432, - eCSSPropertyAlias_WebkitTextSizeAdjust = 433, - eCSSPropertyAlias_WebkitTransform = 434, - eCSSPropertyAlias_WebkitTransformOrigin = 435, - eCSSPropertyAlias_WebkitTransformStyle = 436, - eCSSPropertyAlias_WebkitBackfaceVisibility = 437, - eCSSPropertyAlias_WebkitPerspective = 438, - eCSSPropertyAlias_WebkitPerspectiveOrigin = 439, - eCSSPropertyAlias_WebkitTransition = 440, - eCSSPropertyAlias_WebkitTransitionDelay = 441, - eCSSPropertyAlias_WebkitTransitionDuration = 442, - eCSSPropertyAlias_WebkitTransitionProperty = 443, - eCSSPropertyAlias_WebkitTransitionTimingFunction = 444, - eCSSPropertyAlias_WebkitBorderRadius = 445, - eCSSPropertyAlias_WebkitBorderTopLeftRadius = 446, - eCSSPropertyAlias_WebkitBorderTopRightRadius = 447, - eCSSPropertyAlias_WebkitBorderBottomLeftRadius = 448, - eCSSPropertyAlias_WebkitBorderBottomRightRadius = 449, - eCSSPropertyAlias_WebkitBackgroundClip = 450, - eCSSPropertyAlias_WebkitBackgroundOrigin = 451, - eCSSPropertyAlias_WebkitBackgroundSize = 452, - eCSSPropertyAlias_WebkitBorderImage = 453, - eCSSPropertyAlias_WebkitBoxShadow = 454, - eCSSPropertyAlias_WebkitBoxSizing = 455, - eCSSPropertyAlias_WebkitBoxFlex = 456, - eCSSPropertyAlias_WebkitBoxOrdinalGroup = 457, - eCSSPropertyAlias_WebkitBoxOrient = 458, - eCSSPropertyAlias_WebkitBoxDirection = 459, - eCSSPropertyAlias_WebkitBoxAlign = 460, - eCSSPropertyAlias_WebkitBoxPack = 461, - eCSSPropertyAlias_WebkitFlexDirection = 462, - eCSSPropertyAlias_WebkitFlexWrap = 463, - eCSSPropertyAlias_WebkitFlexFlow = 464, - eCSSPropertyAlias_WebkitOrder = 465, - eCSSPropertyAlias_WebkitFlex = 466, - eCSSPropertyAlias_WebkitFlexGrow = 467, - eCSSPropertyAlias_WebkitFlexShrink = 468, - eCSSPropertyAlias_WebkitFlexBasis = 469, - eCSSPropertyAlias_WebkitJustifyContent = 470, - eCSSPropertyAlias_WebkitAlignItems = 471, - eCSSPropertyAlias_WebkitAlignSelf = 472, - eCSSPropertyAlias_WebkitAlignContent = 473, - eCSSPropertyAlias_WebkitUserSelect = 474, - eCSSPropertyAlias_WebkitMask = 475, - eCSSPropertyAlias_WebkitMaskClip = 476, - eCSSPropertyAlias_WebkitMaskComposite = 477, - eCSSPropertyAlias_WebkitMaskImage = 478, - eCSSPropertyAlias_WebkitMaskOrigin = 479, - eCSSPropertyAlias_WebkitMaskPosition = 480, - eCSSPropertyAlias_WebkitMaskPositionX = 481, - eCSSPropertyAlias_WebkitMaskPositionY = 482, - eCSSPropertyAlias_WebkitMaskRepeat = 483, - eCSSPropertyAlias_WebkitMaskSize = 484, + eCSSPropertyAlias__moz_animation = 375, + eCSSPropertyAlias__moz_animation_delay = 376, + eCSSPropertyAlias__moz_animation_direction = 377, + eCSSPropertyAlias__moz_animation_duration = 378, + eCSSPropertyAlias__moz_animation_fill_mode = 379, + eCSSPropertyAlias__moz_animation_iteration_count = 380, + eCSSPropertyAlias__moz_animation_name = 381, + eCSSPropertyAlias__moz_animation_play_state = 382, + eCSSPropertyAlias__moz_animation_timing_function = 383, + eCSSPropertyAlias__moz_backface_visibility = 384, + eCSSPropertyAlias__moz_border_end = 385, + eCSSPropertyAlias__moz_border_end_color = 386, + eCSSPropertyAlias__moz_border_end_style = 387, + eCSSPropertyAlias__moz_border_end_width = 388, + eCSSPropertyAlias__moz_border_image = 389, + eCSSPropertyAlias__moz_border_start = 390, + eCSSPropertyAlias__moz_border_start_color = 391, + eCSSPropertyAlias__moz_border_start_style = 392, + eCSSPropertyAlias__moz_border_start_width = 393, + eCSSPropertyAlias__moz_box_sizing = 394, + eCSSPropertyAlias__moz_column_count = 395, + eCSSPropertyAlias__moz_column_fill = 396, + eCSSPropertyAlias__moz_column_gap = 397, + eCSSPropertyAlias__moz_column_rule = 398, + eCSSPropertyAlias__moz_column_rule_color = 399, + eCSSPropertyAlias__moz_column_rule_style = 400, + eCSSPropertyAlias__moz_column_rule_width = 401, + eCSSPropertyAlias__moz_column_span = 402, + eCSSPropertyAlias__moz_column_width = 403, + eCSSPropertyAlias__moz_columns = 404, + eCSSPropertyAlias__moz_font_feature_settings = 405, + eCSSPropertyAlias__moz_font_language_override = 406, + eCSSPropertyAlias__moz_hyphens = 407, + eCSSPropertyAlias__moz_margin_end = 408, + eCSSPropertyAlias__moz_margin_start = 409, + eCSSPropertyAlias__moz_padding_end = 410, + eCSSPropertyAlias__moz_padding_start = 411, + eCSSPropertyAlias__moz_perspective = 412, + eCSSPropertyAlias__moz_perspective_origin = 413, + eCSSPropertyAlias__moz_transform = 414, + eCSSPropertyAlias__moz_transform_origin = 415, + eCSSPropertyAlias__moz_transform_style = 416, + eCSSPropertyAlias__moz_transition = 417, + eCSSPropertyAlias__moz_transition_delay = 418, + eCSSPropertyAlias__moz_transition_duration = 419, + eCSSPropertyAlias__moz_transition_property = 420, + eCSSPropertyAlias__moz_transition_timing_function = 421, + eCSSPropertyAlias__webkit_align_content = 422, + eCSSPropertyAlias__webkit_align_items = 423, + eCSSPropertyAlias__webkit_align_self = 424, + eCSSPropertyAlias__webkit_animation = 425, + eCSSPropertyAlias__webkit_animation_delay = 426, + eCSSPropertyAlias__webkit_animation_direction = 427, + eCSSPropertyAlias__webkit_animation_duration = 428, + eCSSPropertyAlias__webkit_animation_fill_mode = 429, + eCSSPropertyAlias__webkit_animation_iteration_count = 430, + eCSSPropertyAlias__webkit_animation_name = 431, + eCSSPropertyAlias__webkit_animation_play_state = 432, + eCSSPropertyAlias__webkit_animation_timing_function = 433, + eCSSPropertyAlias__webkit_backface_visibility = 434, + eCSSPropertyAlias__webkit_background_clip = 435, + eCSSPropertyAlias__webkit_background_origin = 436, + eCSSPropertyAlias__webkit_background_size = 437, + eCSSPropertyAlias__webkit_border_bottom_left_radius = 438, + eCSSPropertyAlias__webkit_border_bottom_right_radius = 439, + eCSSPropertyAlias__webkit_border_image = 440, + eCSSPropertyAlias__webkit_border_radius = 441, + eCSSPropertyAlias__webkit_border_top_left_radius = 442, + eCSSPropertyAlias__webkit_border_top_right_radius = 443, + eCSSPropertyAlias__webkit_box_align = 444, + eCSSPropertyAlias__webkit_box_direction = 445, + eCSSPropertyAlias__webkit_box_flex = 446, + eCSSPropertyAlias__webkit_box_ordinal_group = 447, + eCSSPropertyAlias__webkit_box_orient = 448, + eCSSPropertyAlias__webkit_box_pack = 449, + eCSSPropertyAlias__webkit_box_shadow = 450, + eCSSPropertyAlias__webkit_box_sizing = 451, + eCSSPropertyAlias__webkit_filter = 452, + eCSSPropertyAlias__webkit_flex = 453, + eCSSPropertyAlias__webkit_flex_basis = 454, + eCSSPropertyAlias__webkit_flex_direction = 455, + eCSSPropertyAlias__webkit_flex_flow = 456, + eCSSPropertyAlias__webkit_flex_grow = 457, + eCSSPropertyAlias__webkit_flex_shrink = 458, + eCSSPropertyAlias__webkit_flex_wrap = 459, + eCSSPropertyAlias__webkit_justify_content = 460, + eCSSPropertyAlias__webkit_mask = 461, + eCSSPropertyAlias__webkit_mask_clip = 462, + eCSSPropertyAlias__webkit_mask_composite = 463, + eCSSPropertyAlias__webkit_mask_image = 464, + eCSSPropertyAlias__webkit_mask_origin = 465, + eCSSPropertyAlias__webkit_mask_position = 466, + eCSSPropertyAlias__webkit_mask_position_x = 467, + eCSSPropertyAlias__webkit_mask_position_y = 468, + eCSSPropertyAlias__webkit_mask_repeat = 469, + eCSSPropertyAlias__webkit_mask_size = 470, + eCSSPropertyAlias__webkit_order = 471, + eCSSPropertyAlias__webkit_perspective = 472, + eCSSPropertyAlias__webkit_perspective_origin = 473, + eCSSPropertyAlias__webkit_text_size_adjust = 474, + eCSSPropertyAlias__webkit_transform = 475, + eCSSPropertyAlias__webkit_transform_origin = 476, + eCSSPropertyAlias__webkit_transform_style = 477, + eCSSPropertyAlias__webkit_transition = 478, + eCSSPropertyAlias__webkit_transition_delay = 479, + eCSSPropertyAlias__webkit_transition_duration = 480, + eCSSPropertyAlias__webkit_transition_property = 481, + eCSSPropertyAlias__webkit_transition_timing_function = 482, + eCSSPropertyAlias__webkit_user_select = 483, + eCSSPropertyAlias_word_wrap = 484, eCSSPropertyExtra_no_properties = 485, eCSSPropertyExtra_all_properties = 486, - eCSSPropertyExtra_x_none_value = 487, - eCSSPropertyExtra_x_auto_value = 488, - eCSSPropertyExtra_variable = 489, - eCSSProperty_DOM = 490, + eCSSPropertyExtra_variable = 487, } #[repr(i32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] diff --git a/components/style/gecko/rules.rs b/components/style/gecko/rules.rs index 2f144279656..a57314a418c 100644 --- a/components/style/gecko/rules.rs +++ b/components/style/gecko/rules.rs @@ -5,17 +5,18 @@ //! Bindings for CSS Rule objects use byteorder::{BigEndian, WriteBytesExt}; -use computed_values::{font_stretch, font_style, font_weight}; use counter_style::{self, CounterBound}; use cssparser::UnicodeRange; -use font_face::{FontDisplay, FontWeight, Source}; +use font_face::{FontDisplay, FontWeight, FontStretch, FontStyle, Source}; use gecko_bindings::structs::{self, nsCSSValue}; use gecko_bindings::sugar::ns_css_value::ToNsCssValue; use properties::longhands::font_language_override; use std::str; use values::computed::font::FamilyName; use values::generics::font::FontTag; +use values::specified::font::{AbsoluteFontWeight, FontStretch as SpecifiedFontStretch}; use values::specified::font::{SpecifiedFontFeatureSettings, SpecifiedFontVariationSettings}; +use values::specified::font::SpecifiedFontStyle; impl<'a> ToNsCssValue for &'a FamilyName { fn convert(self, nscssvalue: &mut nsCSSValue) { @@ -23,19 +24,20 @@ impl<'a> ToNsCssValue for &'a FamilyName { } } -impl ToNsCssValue for font_weight::T { +impl<'a> ToNsCssValue for &'a SpecifiedFontStretch { fn convert(self, nscssvalue: &mut nsCSSValue) { - nscssvalue.set_font_weight(self.0) + let number = match *self { + SpecifiedFontStretch::Stretch(ref p) => p.get(), + SpecifiedFontStretch::Keyword(ref kw) => kw.compute().0, + SpecifiedFontStretch::System(..) => unreachable!(), + }; + nscssvalue.set_font_stretch(number); } } -impl<'a> ToNsCssValue for &'a FontWeight { +impl<'a> ToNsCssValue for &'a AbsoluteFontWeight { fn convert(self, nscssvalue: &mut nsCSSValue) { - match *self { - FontWeight::Normal => nscssvalue.set_enum(structs::NS_FONT_WEIGHT_NORMAL as i32), - FontWeight::Bold => nscssvalue.set_enum(structs::NS_FONT_WEIGHT_BOLD as i32), - FontWeight::Weight(weight) => nscssvalue.set_font_weight(weight.0), - } + nscssvalue.set_font_weight(self.compute().0) } } @@ -77,6 +79,52 @@ impl<'a> ToNsCssValue for &'a SpecifiedFontVariationSettings { } } +macro_rules! descriptor_range_conversion { + ($name:ident) => { + impl<'a> ToNsCssValue for &'a $name { + fn convert(self, nscssvalue: &mut nsCSSValue) { + let $name(ref first, ref second) = *self; + let second = match *second { + None => { + nscssvalue.set_from(first); + return; + } + Some(ref second) => second, + }; + + let mut a = nsCSSValue::null(); + let mut b = nsCSSValue::null(); + + a.set_from(first); + b.set_from(second); + + nscssvalue.set_pair(&a, &b); + } + } + } +} + +descriptor_range_conversion!(FontWeight); +descriptor_range_conversion!(FontStretch); + +impl<'a> ToNsCssValue for &'a FontStyle { + fn convert(self, nscssvalue: &mut nsCSSValue) { + match *self { + FontStyle::Normal => nscssvalue.set_normal(), + FontStyle::Italic => nscssvalue.set_enum(structs::NS_FONT_STYLE_ITALIC as i32), + FontStyle::Oblique(ref first, ref second) => { + let mut a = nsCSSValue::null(); + let mut b = nsCSSValue::null(); + + a.set_font_style(SpecifiedFontStyle::compute_angle(first).degrees()); + b.set_font_style(SpecifiedFontStyle::compute_angle(second).degrees()); + + nscssvalue.set_pair(&a, &b); + } + } + } +} + impl<'a> ToNsCssValue for &'a font_language_override::SpecifiedValue { fn convert(self, nscssvalue: &mut nsCSSValue) { match *self { @@ -90,46 +138,6 @@ impl<'a> ToNsCssValue for &'a font_language_override::SpecifiedValue { } } -macro_rules! map_enum { - ( - $( - $prop:ident { - $($servo:ident => $gecko:ident,)+ - } - )+ - ) => { - $( - impl<'a> ToNsCssValue for &'a $prop::T { - fn convert(self, nscssvalue: &mut nsCSSValue) { - nscssvalue.set_enum(match *self { - $( $prop::T::$servo => structs::$gecko as i32, )+ - }) - } - } - )+ - } -} - -map_enum! { - font_style { - Normal => NS_FONT_STYLE_NORMAL, - Italic => NS_FONT_STYLE_ITALIC, - Oblique => NS_FONT_STYLE_OBLIQUE, - } - - font_stretch { - Normal => NS_FONT_STRETCH_NORMAL, - UltraCondensed => NS_FONT_STRETCH_ULTRA_CONDENSED, - ExtraCondensed => NS_FONT_STRETCH_EXTRA_CONDENSED, - Condensed => NS_FONT_STRETCH_CONDENSED, - SemiCondensed => NS_FONT_STRETCH_SEMI_CONDENSED, - SemiExpanded => NS_FONT_STRETCH_SEMI_EXPANDED, - Expanded => NS_FONT_STRETCH_EXPANDED, - ExtraExpanded => NS_FONT_STRETCH_EXTRA_EXPANDED, - UltraExpanded => NS_FONT_STRETCH_ULTRA_EXPANDED, - } -} - impl<'a> ToNsCssValue for &'a Vec { fn convert(self, nscssvalue: &mut nsCSSValue) { let src_len = self.iter().fold(0, |acc, src| { diff --git a/components/style/gecko_bindings/sugar/ns_css_value.rs b/components/style/gecko_bindings/sugar/ns_css_value.rs index 45693561510..644166e3797 100644 --- a/components/style/gecko_bindings/sugar/ns_css_value.rs +++ b/components/style/gecko_bindings/sugar/ns_css_value.rs @@ -167,19 +167,29 @@ impl nsCSSValue { unsafe { bindings::Gecko_CSSValue_SetAtomIdent(self, s.into_addrefed()) } } - /// Set to a font format + /// Set to a font format. pub fn set_font_format(&mut self, s: &str) { self.set_string_internal(s, nsCSSUnit::eCSSUnit_Font_Format); } - /// Set to a local font value + /// Set to a local font value. pub fn set_local_font(&mut self, s: &Atom) { self.set_string_from_atom_internal(s, nsCSSUnit::eCSSUnit_Local_Font); } + /// Set to a font stretch. + pub fn set_font_stretch(&mut self, s: f32) { + unsafe { bindings::Gecko_CSSValue_SetFontStretch(self, s) } + } + + /// Set to a font style + pub fn set_font_style(&mut self, s: f32) { + unsafe { bindings::Gecko_CSSValue_SetFontSlantStyle(self, s) } + } + /// Set to a font weight - pub fn set_font_weight(&mut self, w: u16) { - unsafe { bindings::Gecko_CSSValue_SetFontWeight(self, w as f32) } + pub fn set_font_weight(&mut self, w: f32) { + unsafe { bindings::Gecko_CSSValue_SetFontWeight(self, w) } } fn set_int_internal(&mut self, value: i32, unit: nsCSSUnit) { diff --git a/components/style/gecko_bindings/sugar/refptr.rs b/components/style/gecko_bindings/sugar/refptr.rs index 0d8fb817a85..76a7021ef5b 100644 --- a/components/style/gecko_bindings/sugar/refptr.rs +++ b/components/style/gecko_bindings/sugar/refptr.rs @@ -312,3 +312,9 @@ impl_threadsafe_refcount!( Gecko_AddRefSharedFontListArbitraryThread, Gecko_ReleaseSharedFontListArbitraryThread ); + +impl_threadsafe_refcount!( + ::gecko_bindings::structs::SheetLoadDataHolder, + Gecko_AddRefSheetLoadDataHolderArbitraryThread, + Gecko_ReleaseSheetLoadDataHolderArbitraryThread +); diff --git a/components/style/properties/build.py b/components/style/properties/build.py index 326859ea6d8..04418723ee4 100644 --- a/components/style/properties/build.py +++ b/components/style/properties/build.py @@ -21,7 +21,7 @@ RE_PYTHON_ADDR = re.compile(r'<.+? object at 0x[0-9a-fA-F]+>') def main(): - usage = "Usage: %s [ servo | gecko ] [ style-crate | html ]" % sys.argv[0] + usage = "Usage: %s [ servo | gecko ] [ style-crate | geckolib