Auto merge of #10938 - bholley:margin_padding_fontsize_hasclass, r=emilio

Geckolib: Implement Margin, Padding, font-size, and has_class

<!-- 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/10938)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-05-01 19:48:53 -07:00
commit ca05f03ea3
5 changed files with 172 additions and 81 deletions

View file

@ -891,7 +891,7 @@ pub const NS_ERROR_XPATH_INVALID_ARG: nsresult =
nsresult::NS_ERROR_ILLEGAL_VALUE; nsresult::NS_ERROR_ILLEGAL_VALUE;
pub const NS_SUCCESS_RESTART_APP: nsresult = nsresult::NS_SUCCESS_DONT_FIXUP; pub const NS_SUCCESS_RESTART_APP: nsresult = nsresult::NS_SUCCESS_DONT_FIXUP;
#[repr(i32)] #[repr(i32)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum nsresult { pub enum nsresult {
NS_OK = 0, NS_OK = 0,
NS_ERROR_BASE = -1041039360, NS_ERROR_BASE = -1041039360,
@ -1322,9 +1322,8 @@ pub enum nsresult {
NS_ERROR_DOM_BLUETOOTH_AUTH_REJECTED = -2140536821, NS_ERROR_DOM_BLUETOOTH_AUTH_REJECTED = -2140536821,
NS_ERROR_SIGNED_APP_MANIFEST_INVALID = -2140471295, NS_ERROR_SIGNED_APP_MANIFEST_INVALID = -2140471295,
NS_ERROR_DOM_ANIM_MISSING_PROPS_ERR = -2140405759, NS_ERROR_DOM_ANIM_MISSING_PROPS_ERR = -2140405759,
NS_ERROR_DOM_ANIM_NO_TARGET_ERR = -2140405758, NS_ERROR_DOM_ANIM_NO_TIMELINE_ERR = -2140405758,
NS_ERROR_DOM_ANIM_NO_TIMELINE_ERR = -2140405757, NS_ERROR_DOM_ANIM_NO_EFFECT_ERR = -2140405757,
NS_ERROR_DOM_ANIM_NO_EFFECT_ERR = -2140405756,
NS_ERROR_DOM_PUSH_INVALID_REGISTRATION_ERR = -2140340223, NS_ERROR_DOM_PUSH_INVALID_REGISTRATION_ERR = -2140340223,
NS_ERROR_DOM_PUSH_DENIED_ERR = -2140340222, NS_ERROR_DOM_PUSH_DENIED_ERR = -2140340222,
NS_ERROR_DOM_PUSH_ABORT_ERR = -2140340221, NS_ERROR_DOM_PUSH_ABORT_ERR = -2140340221,
@ -1394,7 +1393,7 @@ pub struct nsAString_internal {
pub mFlags: u32, pub mFlags: u32,
} }
#[repr(u32)] #[repr(u32)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum nsAString_internal_nsTSubstring_h_unnamed_1 { pub enum nsAString_internal_nsTSubstring_h_unnamed_1 {
F_NONE = 0, F_NONE = 0,
F_TERMINATED = 1, F_TERMINATED = 1,
@ -1432,7 +1431,7 @@ pub struct nsACString_internal {
pub mFlags: u32, pub mFlags: u32,
} }
#[repr(u32)] #[repr(u32)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum nsACString_internal_nsTSubstring_h_unnamed_2 { pub enum nsACString_internal_nsTSubstring_h_unnamed_2 {
F_NONE = 0, F_NONE = 0,
F_TERMINATED = 1, F_TERMINATED = 1,
@ -1538,7 +1537,7 @@ pub struct nsAutoString {
pub mStorage: [::std::os::raw::c_ushort; 64usize], pub mStorage: [::std::os::raw::c_ushort; 64usize],
} }
#[repr(u32)] #[repr(u32)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum nsAutoString_nsTString_h_unnamed_3 { kDefaultStorageSize = 64, } pub enum nsAutoString_nsTString_h_unnamed_3 { kDefaultStorageSize = 64, }
#[test] #[test]
fn bindgen_test_layout_nsAutoString() { fn bindgen_test_layout_nsAutoString() {
@ -1624,7 +1623,7 @@ pub struct nsAutoCString {
pub mStorage: [::std::os::raw::c_char; 64usize], pub mStorage: [::std::os::raw::c_char; 64usize],
} }
#[repr(u32)] #[repr(u32)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum nsAutoCString_nsTString_h_unnamed_4 { kDefaultStorageSize = 64, } pub enum nsAutoCString_nsTString_h_unnamed_4 { kDefaultStorageSize = 64, }
#[test] #[test]
fn bindgen_test_layout_nsAutoCString() { fn bindgen_test_layout_nsAutoCString() {
@ -1709,7 +1708,7 @@ fn bindgen_test_layout_NS_ConvertUTF8toUTF16() {
pub type nsVoidableString = nsAutoString; pub type nsVoidableString = nsAutoString;
pub enum ErrorReporter { } pub enum ErrorReporter { }
#[repr(u32)] #[repr(u32)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum nsCSSTokenType { pub enum nsCSSTokenType {
eCSSToken_Whitespace = 0, eCSSToken_Whitespace = 0,
eCSSToken_Comment = 1, eCSSToken_Comment = 1,
@ -1735,7 +1734,7 @@ pub enum nsCSSTokenType {
eCSSToken_HTMLComment = 21, eCSSToken_HTMLComment = 21,
} }
#[repr(u32)] #[repr(u32)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum nsCSSTokenSerializationType { pub enum nsCSSTokenSerializationType {
eCSSTokenSerialization_Nothing = 0, eCSSTokenSerialization_Nothing = 0,
eCSSTokenSerialization_Whitespace = 1, eCSSTokenSerialization_Whitespace = 1,
@ -1799,7 +1798,7 @@ fn bindgen_test_layout_nsCSSScannerPosition() {
assert_eq!(::std::mem::align_of::<nsCSSScannerPosition>() , 4usize); assert_eq!(::std::mem::align_of::<nsCSSScannerPosition>() , 4usize);
} }
#[repr(u32)] #[repr(u32)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum nsCSSScannerExclude { pub enum nsCSSScannerExclude {
eCSSScannerExclude_None = 0, eCSSScannerExclude_None = 0,
eCSSScannerExclude_Comments = 1, eCSSScannerExclude_Comments = 1,
@ -1825,7 +1824,7 @@ pub struct nsCSSScanner {
pub mSeenVariableReference: bool, pub mSeenVariableReference: bool,
} }
#[repr(u32)] #[repr(u32)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum nsCSSScanner_EOFCharacters { pub enum nsCSSScanner_EOFCharacters {
eEOFCharacters_None = 0, eEOFCharacters_None = 0,
eEOFCharacters_DropBackslash = 1, eEOFCharacters_DropBackslash = 1,
@ -2260,7 +2259,7 @@ fn bindgen_test_layout_PLDHashTable_Iterator() {
assert_eq!(::std::mem::align_of::<PLDHashTable_Iterator>() , 8usize); assert_eq!(::std::mem::align_of::<PLDHashTable_Iterator>() , 8usize);
} }
#[repr(u32)] #[repr(u32)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum PLDHashTable_SearchReason { ForSearchOrRemove = 0, ForAdd = 1, } pub enum PLDHashTable_SearchReason { ForSearchOrRemove = 0, ForAdd = 1, }
#[test] #[test]
fn bindgen_test_layout_PLDHashTable() { fn bindgen_test_layout_PLDHashTable() {
@ -2407,7 +2406,7 @@ fn bindgen_test_layout_CSSVariableValues() {
assert_eq!(::std::mem::align_of::<CSSVariableValues>() , 8usize); assert_eq!(::std::mem::align_of::<CSSVariableValues>() , 8usize);
} }
#[repr(i8)] #[repr(i8)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum SheetType { pub enum SheetType {
Agent = 0, Agent = 0,
User = 1, User = 1,
@ -2454,14 +2453,14 @@ pub type gfxFloat = f64;
* @see nsLineLayout::NotifyOptionalBreakPosition * @see nsLineLayout::NotifyOptionalBreakPosition
*/ */
#[repr(i32)] #[repr(i32)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum gfxBreakPriority { pub enum gfxBreakPriority {
eNoBreak = 0, eNoBreak = 0,
eWordWrapBreak = 1, eWordWrapBreak = 1,
eNormalBreak = 2, eNormalBreak = 2,
} }
#[repr(i32)] #[repr(i32)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum gfxSurfaceType { pub enum gfxSurfaceType {
Image = 0, Image = 0,
PDF = 1, PDF = 1,
@ -2490,7 +2489,7 @@ pub enum gfxSurfaceType {
Max = 24, Max = 24,
} }
#[repr(i32)] #[repr(i32)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum gfxContentType { pub enum gfxContentType {
COLOR = 4096, COLOR = 4096,
ALPHA = 8192, ALPHA = 8192,
@ -2499,7 +2498,7 @@ pub enum gfxContentType {
} }
pub type Float = f32; pub type Float = f32;
#[repr(i8)] #[repr(i8)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum SurfaceType { pub enum SurfaceType {
DATA = 0, DATA = 0,
D2D1_BITMAP = 1, D2D1_BITMAP = 1,
@ -2517,7 +2516,7 @@ pub enum SurfaceType {
pub const A8R8G8B8_UINT32: SurfaceFormat = SurfaceFormat::B8G8R8A8; pub const A8R8G8B8_UINT32: SurfaceFormat = SurfaceFormat::B8G8R8A8;
pub const X8R8G8B8_UINT32: SurfaceFormat = SurfaceFormat::B8G8R8X8; pub const X8R8G8B8_UINT32: SurfaceFormat = SurfaceFormat::B8G8R8X8;
#[repr(i8)] #[repr(i8)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum SurfaceFormat { pub enum SurfaceFormat {
B8G8R8A8 = 0, B8G8R8A8 = 0,
B8G8R8X8 = 1, B8G8R8X8 = 1,
@ -2533,7 +2532,7 @@ pub enum SurfaceFormat {
UNKNOWN = 11, UNKNOWN = 11,
} }
#[repr(i8)] #[repr(i8)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum FilterType { pub enum FilterType {
BLEND = 0, BLEND = 0,
TRANSFORM = 1, TRANSFORM = 1,
@ -2563,14 +2562,14 @@ pub enum FilterType {
UNPREMULTIPLY = 25, UNPREMULTIPLY = 25,
} }
#[repr(i8)] #[repr(i8)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum DrawTargetType { pub enum DrawTargetType {
SOFTWARE_RASTER = 0, SOFTWARE_RASTER = 0,
HARDWARE_RASTER = 1, HARDWARE_RASTER = 1,
VECTOR = 2, VECTOR = 2,
} }
#[repr(i8)] #[repr(i8)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum BackendType { pub enum BackendType {
NONE = 0, NONE = 0,
DIRECT2D = 1, DIRECT2D = 1,
@ -2582,7 +2581,7 @@ pub enum BackendType {
DIRECT2D1_1 = 7, DIRECT2D1_1 = 7,
} }
#[repr(i8)] #[repr(i8)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum FontType { pub enum FontType {
DWRITE = 0, DWRITE = 0,
GDI = 1, GDI = 1,
@ -2592,7 +2591,7 @@ pub enum FontType {
COREGRAPHICS = 5, COREGRAPHICS = 5,
} }
#[repr(i8)] #[repr(i8)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum NativeSurfaceType { pub enum NativeSurfaceType {
D3D10_TEXTURE = 0, D3D10_TEXTURE = 0,
CAIRO_CONTEXT = 1, CAIRO_CONTEXT = 1,
@ -2601,7 +2600,7 @@ pub enum NativeSurfaceType {
OPENGL_TEXTURE = 4, OPENGL_TEXTURE = 4,
} }
#[repr(i8)] #[repr(i8)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum NativeFontType { pub enum NativeFontType {
DWRITE_FONT_FACE = 0, DWRITE_FONT_FACE = 0,
GDI_FONT_FACE = 1, GDI_FONT_FACE = 1,
@ -2610,13 +2609,13 @@ pub enum NativeFontType {
CAIRO_FONT_FACE = 4, CAIRO_FONT_FACE = 4,
} }
#[repr(i8)] #[repr(i8)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum FontStyle { NORMAL = 0, ITALIC = 1, BOLD = 2, BOLD_ITALIC = 3, } pub enum FontStyle { NORMAL = 0, ITALIC = 1, BOLD = 2, BOLD_ITALIC = 3, }
#[repr(i8)] #[repr(i8)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum FontHinting { NONE = 0, LIGHT = 1, NORMAL = 2, FULL = 3, } pub enum FontHinting { NONE = 0, LIGHT = 1, NORMAL = 2, FULL = 3, }
#[repr(i8)] #[repr(i8)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum CompositionOp { pub enum CompositionOp {
OP_OVER = 0, OP_OVER = 0,
OP_ADD = 1, OP_ADD = 1,
@ -2647,10 +2646,10 @@ pub enum CompositionOp {
OP_COUNT = 26, OP_COUNT = 26,
} }
#[repr(i8)] #[repr(i8)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum Axis { X_AXIS = 0, Y_AXIS = 1, BOTH = 2, } pub enum Axis { X_AXIS = 0, Y_AXIS = 1, BOTH = 2, }
#[repr(i8)] #[repr(i8)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum ExtendMode { pub enum ExtendMode {
CLAMP = 0, CLAMP = 0,
REPEAT = 1, REPEAT = 1,
@ -2659,16 +2658,16 @@ pub enum ExtendMode {
REFLECT = 4, REFLECT = 4,
} }
#[repr(i8)] #[repr(i8)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum FillRule { FILL_WINDING = 0, FILL_EVEN_ODD = 1, } pub enum FillRule { FILL_WINDING = 0, FILL_EVEN_ODD = 1, }
#[repr(i8)] #[repr(i8)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum AntialiasMode { NONE = 0, GRAY = 1, SUBPIXEL = 2, DEFAULT = 3, } pub enum AntialiasMode { NONE = 0, GRAY = 1, SUBPIXEL = 2, DEFAULT = 3, }
#[repr(i8)] #[repr(i8)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum Filter { GOOD = 0, LINEAR = 1, POINT = 2, SENTINEL = 3, } pub enum Filter { GOOD = 0, LINEAR = 1, POINT = 2, SENTINEL = 3, }
#[repr(i8)] #[repr(i8)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum PatternType { pub enum PatternType {
COLOR = 0, COLOR = 0,
SURFACE = 1, SURFACE = 1,
@ -2676,13 +2675,13 @@ pub enum PatternType {
RADIAL_GRADIENT = 3, RADIAL_GRADIENT = 3,
} }
#[repr(i8)] #[repr(i8)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum JoinStyle { BEVEL = 0, ROUND = 1, MITER = 2, MITER_OR_BEVEL = 3, } pub enum JoinStyle { BEVEL = 0, ROUND = 1, MITER = 2, MITER_OR_BEVEL = 3, }
#[repr(i8)] #[repr(i8)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum CapStyle { BUTT = 0, ROUND = 1, SQUARE = 2, } pub enum CapStyle { BUTT = 0, ROUND = 1, SQUARE = 2, }
#[repr(i8)] #[repr(i8)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum SamplingBounds { UNBOUNDED = 0, BOUNDED = 1, } pub enum SamplingBounds { UNBOUNDED = 0, BOUNDED = 1, }
#[repr(C)] #[repr(C)]
#[derive(Debug, Copy)] #[derive(Debug, Copy)]
@ -2715,14 +2714,14 @@ fn bindgen_test_layout_GradientStop() {
assert_eq!(::std::mem::align_of::<GradientStop>() , 4usize); assert_eq!(::std::mem::align_of::<GradientStop>() , 4usize);
} }
#[repr(i32)] #[repr(i32)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum JobStatus { Complete = 0, Wait = 1, Yield = 2, Error = 3, } pub enum JobStatus { Complete = 0, Wait = 1, Yield = 2, Error = 3, }
pub type gfxImageFormat = SurfaceFormat; pub type gfxImageFormat = SurfaceFormat;
#[repr(C)] #[repr(C)]
#[derive(Debug, Copy)] #[derive(Debug, Copy)]
pub struct RectCorner; pub struct RectCorner;
#[repr(u32)] #[repr(u32)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum RectCorner_Types_h_unnamed_5 { pub enum RectCorner_Types_h_unnamed_5 {
TopLeft = 0, TopLeft = 0,
TopRight = 1, TopRight = 1,
@ -2734,7 +2733,7 @@ impl ::std::clone::Clone for RectCorner {
fn clone(&self) -> Self { *self } fn clone(&self) -> Self { *self }
} }
#[repr(u32)] #[repr(u32)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum Side { pub enum Side {
eSideTop = 0, eSideTop = 0,
eSideRight = 1, eSideRight = 1,
@ -2742,7 +2741,7 @@ pub enum Side {
eSideLeft = 3, eSideLeft = 3,
} }
#[repr(u32)] #[repr(u32)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum SideBits { pub enum SideBits {
eSideBitsNone = 0, eSideBitsNone = 0,
eSideBitsTop = 1, eSideBitsTop = 1,
@ -2854,7 +2853,7 @@ pub const eFamily_generic_count: FontFamilyType =
* between unquoted and quoted names for serializaiton * between unquoted and quoted names for serializaiton
*/ */
#[repr(u32)] #[repr(u32)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum FontFamilyType { pub enum FontFamilyType {
eFamily_none = 0, eFamily_none = 0,
eFamily_named = 1, eFamily_named = 1,
@ -2868,7 +2867,7 @@ pub enum FontFamilyType {
eFamily_moz_fixed = 9, eFamily_moz_fixed = 9,
} }
#[repr(u32)] #[repr(u32)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum QuotedName { eQuotedName = 0, eUnquotedName = 1, } pub enum QuotedName { eQuotedName = 0, eUnquotedName = 1, }
/** /**
* font family name, a string for the name if not a generic and * font family name, a string for the name if not a generic and
@ -2971,13 +2970,13 @@ fn bindgen_test_layout_nsFont() {
assert_eq!(::std::mem::align_of::<nsFont>() , 8usize); assert_eq!(::std::mem::align_of::<nsFont>() , 8usize);
} }
#[repr(i8)] #[repr(i8)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum StyleBoxSizing { Content = 0, Padding = 1, Border = 2, } pub enum StyleBoxSizing { Content = 0, Padding = 1, Border = 2, }
#[repr(i32)] #[repr(i32)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum PlaybackDirection { _BindgenOpaqueEnum = 0, } pub enum PlaybackDirection { _BindgenOpaqueEnum = 0, }
#[repr(i32)] #[repr(i32)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum FillMode { _BindgenOpaqueEnum = 0, } pub enum FillMode { _BindgenOpaqueEnum = 0, }
pub enum nsIContentSecurityPolicy { } pub enum nsIContentSecurityPolicy { }
pub enum nsIDOMDocument { } pub enum nsIDOMDocument { }
@ -3027,7 +3026,7 @@ pub const eCSSProperty_COUNT_DUMMY3: nsCSSProperty =
pub const eCSSPropertyExtra_no_properties: nsCSSProperty = pub const eCSSPropertyExtra_no_properties: nsCSSProperty =
nsCSSProperty::eCSSProperty_COUNT_with_aliases; nsCSSProperty::eCSSProperty_COUNT_with_aliases;
#[repr(i32)] #[repr(i32)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum nsCSSProperty { pub enum nsCSSProperty {
eCSSProperty_UNKNOWN = -1, eCSSProperty_UNKNOWN = -1,
eCSSProperty_align_content = 0, eCSSProperty_align_content = 0,
@ -3459,7 +3458,7 @@ pub enum nsCSSProperty {
eCSSPropertyExtra_variable = 426, eCSSPropertyExtra_variable = 426,
} }
#[repr(i32)] #[repr(i32)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum nsCSSFontDesc { pub enum nsCSSFontDesc {
eCSSFontDesc_UNKNOWN = -1, eCSSFontDesc_UNKNOWN = -1,
eCSSFontDesc_Family = 0, eCSSFontDesc_Family = 0,
@ -3474,7 +3473,7 @@ pub enum nsCSSFontDesc {
eCSSFontDesc_COUNT = 9, eCSSFontDesc_COUNT = 9,
} }
#[repr(i32)] #[repr(i32)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum nsCSSCounterDesc { pub enum nsCSSCounterDesc {
eCSSCounterDesc_UNKNOWN = -1, eCSSCounterDesc_UNKNOWN = -1,
eCSSCounterDesc_System = 0, eCSSCounterDesc_System = 0,
@ -3490,7 +3489,7 @@ pub enum nsCSSCounterDesc {
eCSSCounterDesc_COUNT = 10, eCSSCounterDesc_COUNT = 10,
} }
#[repr(i32)] #[repr(i32)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum nsCSSPropertyLogicalGroup { pub enum nsCSSPropertyLogicalGroup {
eCSSPropertyLogicalGroup_UNKNOWN = -1, eCSSPropertyLogicalGroup_UNKNOWN = -1,
eCSSPropertyLogicalGroup_BorderColor = 0, eCSSPropertyLogicalGroup_BorderColor = 0,
@ -3583,7 +3582,7 @@ fn bindgen_test_layout_FontFamilyListRefCnt() {
assert_eq!(::std::mem::align_of::<FontFamilyListRefCnt>() , 8usize); assert_eq!(::std::mem::align_of::<FontFamilyListRefCnt>() , 8usize);
} }
#[repr(u32)] #[repr(u32)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum nsCSSUnit { pub enum nsCSSUnit {
eCSSUnit_Null = 0, eCSSUnit_Null = 0,
eCSSUnit_Auto = 1, eCSSUnit_Auto = 1,
@ -3674,7 +3673,7 @@ pub struct nsCSSValue {
pub mValue: nsCSSValue_nsCSSValue_h_unnamed_8, pub mValue: nsCSSValue_nsCSSValue_h_unnamed_8,
} }
#[repr(u32)] #[repr(u32)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum nsCSSValue_Serialization { eNormalized = 0, eAuthorSpecified = 1, } pub enum nsCSSValue_Serialization { eNormalized = 0, eAuthorSpecified = 1, }
#[repr(C)] #[repr(C)]
#[derive(Debug, Copy)] #[derive(Debug, Copy)]
@ -4008,7 +4007,7 @@ fn bindgen_test_layout_CounterStyleManager() {
* invariants. * invariants.
*/ */
#[repr(u32)] #[repr(u32)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum SheetParsingMode { pub enum SheetParsingMode {
eAuthorSheetFeatures = 0, eAuthorSheetFeatures = 0,
eUserSheetFeatures = 1, eUserSheetFeatures = 1,
@ -4025,7 +4024,7 @@ pub struct _vftable_nsIRequest {
pub _base: _vftable_nsISupports, pub _base: _vftable_nsISupports,
} }
#[repr(u32)] #[repr(u32)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum nsIRequest_nsIRequest_h_unnamed_9 { pub enum nsIRequest_nsIRequest_h_unnamed_9 {
LOAD_REQUESTMASK = 65535, LOAD_REQUESTMASK = 65535,
LOAD_NORMAL = 0, LOAD_NORMAL = 0,
@ -4138,13 +4137,13 @@ pub struct ArenaRefPtr<T> {
pub _phantom0: ::std::marker::PhantomData<T>, pub _phantom0: ::std::marker::PhantomData<T>,
} }
#[repr(u32)] #[repr(u32)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum LogicalAxis { eLogicalAxisBlock = 0, eLogicalAxisInline = 1, } pub enum LogicalAxis { eLogicalAxisBlock = 0, eLogicalAxisInline = 1, }
#[repr(u32)] #[repr(u32)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum LogicalEdge { eLogicalEdgeStart = 0, eLogicalEdgeEnd = 1, } pub enum LogicalEdge { eLogicalEdgeStart = 0, eLogicalEdgeEnd = 1, }
#[repr(u32)] #[repr(u32)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum LogicalSide { pub enum LogicalSide {
eLogicalSideBStart = 0, eLogicalSideBStart = 0,
eLogicalSideBEnd = 1, eLogicalSideBEnd = 1,
@ -4153,7 +4152,7 @@ pub enum LogicalSide {
} }
pub const eStyleUnit_MAX: nsStyleUnit = nsStyleUnit::eStyleUnit_Calc; pub const eStyleUnit_MAX: nsStyleUnit = nsStyleUnit::eStyleUnit_Calc;
#[repr(i8)] #[repr(i8)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum nsStyleUnit { pub enum nsStyleUnit {
eStyleUnit_Null = 0, eStyleUnit_Null = 0,
eStyleUnit_Normal = 1, eStyleUnit_Normal = 1,
@ -4231,7 +4230,7 @@ fn bindgen_test_layout_nsStyleCoord_Calc() {
assert_eq!(::std::mem::align_of::<nsStyleCoord_Calc>() , 8usize); assert_eq!(::std::mem::align_of::<nsStyleCoord_Calc>() , 8usize);
} }
#[repr(u32)] #[repr(u32)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum nsStyleCoord_CoordConstructorType { CoordConstructor = 0, } pub enum nsStyleCoord_CoordConstructorType { CoordConstructor = 0, }
#[test] #[test]
fn bindgen_test_layout_nsStyleCoord() { fn bindgen_test_layout_nsStyleCoord() {
@ -4361,7 +4360,7 @@ fn bindgen_test_layout_nsStyleGradient() {
assert_eq!(::std::mem::align_of::<nsStyleGradient>() , 8usize); assert_eq!(::std::mem::align_of::<nsStyleGradient>() , 8usize);
} }
#[repr(u32)] #[repr(u32)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum nsStyleImageType { pub enum nsStyleImageType {
eStyleImageType_Null = 0, eStyleImageType_Null = 0,
eStyleImageType_Image = 1, eStyleImageType_Image = 1,
@ -4437,7 +4436,7 @@ pub struct nsStyleImageLayers {
pub mLayers: [u64; 15usize], pub mLayers: [u64; 15usize],
} }
#[repr(u32)] #[repr(u32)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum nsStyleImageLayers_nsStyleStruct_h_unnamed_14 { pub enum nsStyleImageLayers_nsStyleStruct_h_unnamed_14 {
shorthand = 0, shorthand = 0,
color = 1, color = 1,
@ -4491,7 +4490,7 @@ fn bindgen_test_layout_nsStyleImageLayers_Size_Dimension() {
4usize); 4usize);
} }
#[repr(u32)] #[repr(u32)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum nsStyleImageLayers_Size_DimensionType { pub enum nsStyleImageLayers_Size_DimensionType {
eContain = 0, eContain = 0,
eCover = 1, eCover = 1,
@ -4840,14 +4839,14 @@ pub struct nsStyleImageOrientation {
pub mOrientation: u8, pub mOrientation: u8,
} }
#[repr(u32)] #[repr(u32)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum nsStyleImageOrientation_Bits { pub enum nsStyleImageOrientation_Bits {
ORIENTATION_MASK = 3, ORIENTATION_MASK = 3,
FLIP_MASK = 4, FLIP_MASK = 4,
FROM_IMAGE_MASK = 8, FROM_IMAGE_MASK = 8,
} }
#[repr(u32)] #[repr(u32)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum nsStyleImageOrientation_Angles { pub enum nsStyleImageOrientation_Angles {
ANGLE_0 = 0, ANGLE_0 = 0,
ANGLE_90 = 1, ANGLE_90 = 1,
@ -4885,7 +4884,7 @@ pub struct nsTimingFunction {
pub nsTimingFunction_nsStyleStruct_h_unnamed_15: nsTimingFunction_nsStyleStruct_h_unnamed_15, pub nsTimingFunction_nsStyleStruct_h_unnamed_15: nsTimingFunction_nsStyleStruct_h_unnamed_15,
} }
#[repr(i32)] #[repr(i32)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum nsTimingFunction_Type { pub enum nsTimingFunction_Type {
Ease = 0, Ease = 0,
Linear = 1, Linear = 1,
@ -4897,7 +4896,7 @@ pub enum nsTimingFunction_Type {
CubicBezier = 7, CubicBezier = 7,
} }
#[repr(i32)] #[repr(i32)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum nsTimingFunction_StepSyntax { pub enum nsTimingFunction_StepSyntax {
Keyword = 0, Keyword = 0,
FunctionalWithoutKeyword = 1, FunctionalWithoutKeyword = 1,
@ -4905,7 +4904,7 @@ pub enum nsTimingFunction_StepSyntax {
FunctionalWithEndKeyword = 3, FunctionalWithEndKeyword = 3,
} }
#[repr(i32)] #[repr(i32)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum nsTimingFunction_Keyword { Implicit = 0, Explicit = 1, } pub enum nsTimingFunction_Keyword { Implicit = 0, Explicit = 1, }
#[repr(C)] #[repr(C)]
#[derive(Debug, Copy)] #[derive(Debug, Copy)]
@ -5085,7 +5084,7 @@ fn bindgen_test_layout_nsStyleTableBorder() {
assert_eq!(::std::mem::align_of::<nsStyleTableBorder>() , 4usize); assert_eq!(::std::mem::align_of::<nsStyleTableBorder>() , 4usize);
} }
#[repr(u32)] #[repr(u32)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum nsStyleContentType { pub enum nsStyleContentType {
eStyleContentType_String = 1, eStyleContentType_String = 1,
eStyleContentType_Image = 10, eStyleContentType_Image = 10,
@ -5234,7 +5233,7 @@ fn bindgen_test_layout_nsStyleColumn() {
assert_eq!(::std::mem::align_of::<nsStyleColumn>() , 8usize); assert_eq!(::std::mem::align_of::<nsStyleColumn>() , 8usize);
} }
#[repr(u32)] #[repr(u32)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum nsStyleSVGPaintType { pub enum nsStyleSVGPaintType {
eStyleSVGPaintType_None = 1, eStyleSVGPaintType_None = 1,
eStyleSVGPaintType_Color = 2, eStyleSVGPaintType_Color = 2,
@ -5243,7 +5242,7 @@ pub enum nsStyleSVGPaintType {
eStyleSVGPaintType_ContextStroke = 5, eStyleSVGPaintType_ContextStroke = 5,
} }
#[repr(u32)] #[repr(u32)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum nsStyleSVGOpacitySource { pub enum nsStyleSVGOpacitySource {
eStyleSVGOpacitySource_Normal = 0, eStyleSVGOpacitySource_Normal = 0,
eStyleSVGOpacitySource_ContextFillOpacity = 1, eStyleSVGOpacitySource_ContextFillOpacity = 1,
@ -5321,7 +5320,7 @@ pub struct nsStyleBasicShape {
pub mRadius: nsStyleCorners, pub mRadius: nsStyleCorners,
} }
#[repr(u32)] #[repr(u32)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum nsStyleBasicShape_Type { pub enum nsStyleBasicShape_Type {
eInset = 0, eInset = 0,
eCircle = 1, eCircle = 1,

View file

@ -40,6 +40,7 @@ mod gecko_style_structs;
pub mod glue; pub mod glue;
mod selector_impl; mod selector_impl;
mod traversal; mod traversal;
mod values;
mod wrapper; mod wrapper;
// Generated from the properties.mako.rs template by build.rs // Generated from the properties.mako.rs template by build.rs

View file

@ -28,6 +28,8 @@ use style::properties::{CascadePropertyFn, ServoComputedValues, ComputedValues};
use style::properties::longhands; use style::properties::longhands;
use style::properties::make_cascade_vec; use style::properties::make_cascade_vec;
use style::properties::style_struct_traits::*; use style::properties::style_struct_traits::*;
use gecko_style_structs::{nsStyleUnion, nsStyleUnit};
use values::ToGeckoStyleCoord;
#[derive(Clone)] #[derive(Clone)]
pub struct GeckoComputedValues { pub struct GeckoComputedValues {
@ -196,6 +198,20 @@ def set_gecko_property(ffi_name, expr):
% endif % endif
</%def> </%def>
<%def name="impl_style_coord(ident, unit_ffi_name, union_ffi_name)">
fn set_${ident}(&mut self, v: longhands::${ident}::computed_value::T) {
v.to_gecko_style_coord(&mut self.gecko.${unit_ffi_name},
&mut self.gecko.${union_ffi_name});
}
fn copy_${ident}_from(&mut self, other: &Self) {
use gecko_style_structs::nsStyleUnit::eStyleUnit_Calc;
assert!(self.gecko.${unit_ffi_name} != eStyleUnit_Calc,
"stylo: Can't yet handle refcounted Calc");
self.gecko.${unit_ffi_name} = other.gecko.${unit_ffi_name};
self.gecko.${union_ffi_name} = other.gecko.${union_ffi_name};
}
</%def>
<%def name="impl_style_struct(style_struct)"> <%def name="impl_style_struct(style_struct)">
impl ${style_struct.gecko_struct_name} { impl ${style_struct.gecko_struct_name} {
#[allow(dead_code, unused_variables)] #[allow(dead_code, unused_variables)]
@ -340,12 +356,7 @@ fn static_assert() {
<% border_style_keyword = Keyword("border-style", <% border_style_keyword = Keyword("border-style",
"none solid double dotted dashed hidden groove ridge inset outset") %> "none solid double dotted dashed hidden groove ridge inset outset") %>
<% <% skip_border_longhands = " ".join(["border-{0}-style border-{0}-width ".format(x.ident) for x in SIDES]) %>
skip_border_longhands = ""
for side in SIDES:
skip_border_longhands += "border-{0}-style border-{0}-width ".format(side.ident)
%>
<%self:impl_trait style_struct_name="Border" <%self:impl_trait style_struct_name="Border"
skip_longhands="${skip_border_longhands}" skip_longhands="${skip_border_longhands}"
skip_additionals="*"> skip_additionals="*">
@ -362,6 +373,26 @@ for side in SIDES:
% endfor % endfor
</%self:impl_trait> </%self:impl_trait>
<% skip_margin_longhands = " ".join(["margin-%s" % x.ident for x in SIDES]) %>
<%self:impl_trait style_struct_name="Margin"
skip_longhands="${skip_margin_longhands}">
% for side in SIDES:
<% impl_style_coord("margin_%s" % side.ident,
"mMargin.mUnits[%s]" % side.index, "mMargin.mValues[%s]" % side.index) %>
% endfor
</%self:impl_trait>
<% skip_padding_longhands = " ".join(["padding-%s" % x.ident for x in SIDES]) %>
<%self:impl_trait style_struct_name="Padding"
skip_longhands="${skip_padding_longhands}">
% for side in SIDES:
<% impl_style_coord("padding_%s" % side.ident,
"mPadding.mUnits[%s]" % side.index, "mPadding.mValues[%s]" % side.index) %>
% endfor
</%self:impl_trait>
<%self:impl_trait style_struct_name="Outline" <%self:impl_trait style_struct_name="Outline"
skip_longhands="outline-style" skip_longhands="outline-style"
skip_additionals="*"> skip_additionals="*">
@ -375,8 +406,20 @@ for side in SIDES:
<%self:impl_trait style_struct_name="Font" skip_longhands="font-size" skip_additionals="*"> <%self:impl_trait style_struct_name="Font" skip_longhands="font-size" skip_additionals="*">
// FIXME(bholley): This doesn't handle zooming properly. // FIXME(bholley): Gecko has two different sizes, one of which (mSize) is the
<% impl_app_units("font_size", "mSize", need_clone=True) %> // 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.
fn set_font_size(&mut self, v: longhands::font_size::computed_value::T) {
self.gecko.mFont.size = v.0;
self.gecko.mSize = v.0;
}
fn copy_font_size_from(&mut self, other: &Self) {
self.gecko.mFont.size = other.gecko.mFont.size;
self.gecko.mSize = other.gecko.mSize;
}
fn clone_font_size(&self) -> longhands::font_size::computed_value::T {
Au(self.gecko.mSize)
}
// This is used for PartialEq, which we don't implement for gecko style structs. // This is used for PartialEq, which we don't implement for gecko style structs.
fn compute_font_hash(&mut self) {} fn compute_font_hash(&mut self) {}

46
ports/geckolib/values.rs Normal file
View file

@ -0,0 +1,46 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use gecko_style_structs::{nsStyleUnion, nsStyleUnit};
use style::values::computed::{LengthOrPercentage, LengthOrPercentageOrAuto};
pub trait ToGeckoStyleCoord {
fn to_gecko_style_coord(&self, unit: &mut nsStyleUnit, union: &mut nsStyleUnion);
}
impl ToGeckoStyleCoord for LengthOrPercentage {
fn to_gecko_style_coord(&self, unit: &mut nsStyleUnit, union: &mut nsStyleUnion) {
match *self {
LengthOrPercentage::Length(au) => {
*unit = nsStyleUnit::eStyleUnit_Coord;
unsafe { *union.mInt.as_mut() = au.0; }
},
LengthOrPercentage::Percentage(p) => {
*unit = nsStyleUnit::eStyleUnit_Percent;
unsafe { *union.mFloat.as_mut() = p; }
},
LengthOrPercentage::Calc(_) => unimplemented!(),
};
}
}
impl ToGeckoStyleCoord for LengthOrPercentageOrAuto {
fn to_gecko_style_coord(&self, unit: &mut nsStyleUnit, union: &mut nsStyleUnion) {
match *self {
LengthOrPercentageOrAuto::Length(au) => {
*unit = nsStyleUnit::eStyleUnit_Coord;
unsafe { *union.mInt.as_mut() = au.0; }
},
LengthOrPercentageOrAuto::Percentage(p) => {
*unit = nsStyleUnit::eStyleUnit_Percent;
unsafe { *union.mFloat.as_mut() = p; }
},
LengthOrPercentageOrAuto::Auto => {
*unit = nsStyleUnit::eStyleUnit_Auto;
unsafe { *union.mInt.as_mut() = 0; }
},
LengthOrPercentageOrAuto::Calc(_) => unimplemented!(),
};
}
}

View file

@ -454,8 +454,10 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
self.get_attr(&ns!(), &atom!("id")).map(|s| Atom::from(s)) self.get_attr(&ns!(), &atom!("id")).map(|s| Atom::from(s))
} }
fn has_class(&self, _name: &Atom) -> bool { fn has_class(&self, name: &Atom) -> bool {
unimplemented!() // FIXME(bholley): Do this smarter.
self.get_attr(&ns!(), &atom!("class"))
.map_or(false, |classes| classes.split(" ").any(|n| &Atom::from(n) == name))
} }
fn each_class<F>(&self, mut callback: F) where F: FnMut(&Atom) { fn each_class<F>(&self, mut callback: F) where F: FnMut(&Atom) {