Skip to content

Commit

Permalink
Auto merge of #12599 - Manishearth:sync, r=heycam
Browse files Browse the repository at this point in the history
Resync stylo bindings

Now at gecko-dev 13b9d03a21091cfcd797ab89decec2dde9114781

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12599)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo committed Jul 26, 2016
2 parents a3e8199 + c8bff61 commit d6266c7
Show file tree
Hide file tree
Showing 9 changed files with 118 additions and 107 deletions.
17 changes: 16 additions & 1 deletion components/style/properties/data.py
Expand Up @@ -18,11 +18,15 @@ def to_camel_case(ident):

class Keyword(object):
def __init__(self, name, values, gecko_constant_prefix=None,
gecko_enum_prefix=None,
extra_gecko_values=None, extra_servo_values=None):
self.name = name
self.values = values.split()
if gecko_constant_prefix and gecko_enum_prefix:
raise TypeError("Only one of gecko_constant_prefix and gecko_enum_prefix can be specified")
self.gecko_constant_prefix = gecko_constant_prefix or \
"NS_STYLE_" + self.name.upper().replace("-", "_")
self.gecko_enum_prefix = gecko_enum_prefix
self.extra_gecko_values = (extra_gecko_values or "").split()
self.extra_servo_values = (extra_servo_values or "").split()

Expand All @@ -41,7 +45,18 @@ def values_for(self, product):
raise Exception("Bad product: " + product)

def gecko_constant(self, value):
return self.gecko_constant_prefix + "_" + value.replace("-moz-", "").replace("-", "_").upper()
if self.gecko_enum_prefix:
if value == "none":
return self.gecko_enum_prefix + "::None_"
else:
parts = value.replace("-moz-", "").split("-")
parts = [p.title() for p in parts]
return self.gecko_enum_prefix + "::" + "".join(parts)
else:
return self.gecko_constant_prefix + "_" + value.replace("-moz-", "").replace("-", "_").upper()

def needs_cast(self):
return self.gecko_enum_prefix is None


class Longhand(object):
Expand Down
6 changes: 5 additions & 1 deletion components/style/properties/gecko.mako.rs
Expand Up @@ -194,7 +194,11 @@ def set_gecko_property(ffi_name, expr):
// FIXME(bholley): Align binary representations and ditch |match| for cast + static_asserts
let result = match v {
% for value in keyword.values_for('gecko'):
Keyword::${to_rust_ident(value)} => structs::${keyword.gecko_constant(value)} as u8,
% if keyword.needs_cast():
Keyword::${to_rust_ident(value)} => structs::${keyword.gecko_constant(value)} as u8,
% else:
Keyword::${to_rust_ident(value)} => structs::${keyword.gecko_constant(value)},
% endif
% endfor
};
${set_gecko_property(gecko_ffi_name, "result")}
Expand Down
6 changes: 4 additions & 2 deletions components/style/properties/helpers.mako.rs
Expand Up @@ -289,7 +289,8 @@
<%def name="single_keyword_computed(name, values, **kwargs)">
<%
keyword_kwargs = {a: kwargs.pop(a, None) for a in [
'gecko_constant_prefix', 'extra_gecko_values', 'extra_servo_values'
'gecko_constant_prefix', 'gecko_enum_prefix',
'extra_gecko_values', 'extra_servo_values',
]}
%>
<%call expr="longhand(name, keyword=Keyword(name, values, **keyword_kwargs), **kwargs)">
Expand Down Expand Up @@ -317,7 +318,8 @@
<%def name="keyword_list(name, values, **kwargs)">
<%
keyword_kwargs = {a: kwargs.pop(a, None) for a in [
'gecko_constant_prefix', 'extra_gecko_values', 'extra_servo_values'
'gecko_constant_prefix', 'gecko_enum_prefix',
'extra_gecko_values', 'extra_servo_values',
]}
%>
<%call expr="longhand(name, keyword=Keyword(name, values, **keyword_kwargs), **kwargs)">
Expand Down
2 changes: 1 addition & 1 deletion components/style/properties/longhand/border.mako.rs
Expand Up @@ -82,6 +82,6 @@ ${helpers.single_keyword("box-decoration-break", "slice clone",

${helpers.single_keyword("-moz-float-edge", "content-box margin-box",
gecko_ffi_name="mFloatEdge",
gecko_constant_prefix="NS_STYLE_FLOAT_EDGE",
gecko_enum_prefix="StyleFloatEdge",
products="gecko",
animatable=False)}
2 changes: 1 addition & 1 deletion components/style/properties/longhand/pointing.mako.rs
Expand Up @@ -71,5 +71,5 @@ ${helpers.single_keyword("-moz-user-modify", "read-only read-write write-only",
${helpers.single_keyword("-moz-user-focus",
"ignore normal select-after select-before select-menu select-same select-all none",
products="gecko", gecko_ffi_name="mUserFocus",
gecko_constant_prefix="NS_STYLE_USER_FOCUS",
gecko_enum_prefix="StyleUserFocus",
animatable=False)}
2 changes: 1 addition & 1 deletion ports/geckolib/gecko_bindings/bindings.rs
Expand Up @@ -365,11 +365,11 @@ extern "C" {
set: *mut RawServoStyleSet);
pub fn Servo_RestyleSubtree(node: *mut RawGeckoNode,
set: *mut RawServoStyleSet);
pub fn Servo_StyleWorkerThreadCount() -> u32;
pub fn Servo_ComputeRestyleHint(element: *mut RawGeckoElement,
snapshot: *mut ServoElementSnapshot,
set: *mut RawServoStyleSet)
-> nsRestyleHint;
pub fn Servo_StyleWorkerThreadCount() -> u32;
pub fn Gecko_Construct_nsStyleFont(ptr: *mut nsStyleFont);
pub fn Gecko_CopyConstruct_nsStyleFont(ptr: *mut nsStyleFont,
other: *const nsStyleFont);
Expand Down
92 changes: 45 additions & 47 deletions ports/geckolib/gecko_bindings/structs_debug.rs
Expand Up @@ -188,12 +188,6 @@ pub const NS_ERROR_MODULE_BASE_OFFSET: ::std::os::raw::c_uint = 69;
pub const MOZ_STRING_WITH_OBSOLETE_API: ::std::os::raw::c_uint = 1;
pub const NSID_LENGTH: ::std::os::raw::c_uint = 39;
pub const NS_NUMBER_OF_FLAGS_IN_REFCNT: ::std::os::raw::c_uint = 2;
pub const _STL_PAIR_H: ::std::os::raw::c_uint = 1;
pub const _GLIBCXX_UTILITY: ::std::os::raw::c_uint = 1;
pub const __cpp_lib_tuple_element_t: ::std::os::raw::c_uint = 201402;
pub const __cpp_lib_tuples_by_type: ::std::os::raw::c_uint = 201304;
pub const __cpp_lib_exchange_function: ::std::os::raw::c_uint = 201304;
pub const __cpp_lib_integer_sequence: ::std::os::raw::c_uint = 201304;
pub const NS_EVENT_STATE_HIGHEST_SERVO_BIT: ::std::os::raw::c_uint = 6;
pub const DOM_USER_DATA: ::std::os::raw::c_uint = 1;
pub const SMIL_MAPPED_ATTR_ANIMVAL: ::std::os::raw::c_uint = 2;
Expand All @@ -212,29 +206,6 @@ pub const NS_CORNER_BOTTOM_RIGHT_X: ::std::os::raw::c_uint = 4;
pub const NS_CORNER_BOTTOM_RIGHT_Y: ::std::os::raw::c_uint = 5;
pub const NS_CORNER_BOTTOM_LEFT_X: ::std::os::raw::c_uint = 6;
pub const NS_CORNER_BOTTOM_LEFT_Y: ::std::os::raw::c_uint = 7;
pub const NS_STYLE_CLIP_SHAPE_SIZING_NOBOX: ::std::os::raw::c_uint = 0;
pub const NS_STYLE_CLIP_SHAPE_SIZING_CONTENT: ::std::os::raw::c_uint = 1;
pub const NS_STYLE_CLIP_SHAPE_SIZING_PADDING: ::std::os::raw::c_uint = 2;
pub const NS_STYLE_CLIP_SHAPE_SIZING_BORDER: ::std::os::raw::c_uint = 3;
pub const NS_STYLE_CLIP_SHAPE_SIZING_MARGIN: ::std::os::raw::c_uint = 4;
pub const NS_STYLE_CLIP_SHAPE_SIZING_FILL: ::std::os::raw::c_uint = 5;
pub const NS_STYLE_CLIP_SHAPE_SIZING_STROKE: ::std::os::raw::c_uint = 6;
pub const NS_STYLE_CLIP_SHAPE_SIZING_VIEW: ::std::os::raw::c_uint = 7;
pub const NS_STYLE_BASIC_SHAPE_POLYGON: ::std::os::raw::c_uint = 0;
pub const NS_STYLE_BASIC_SHAPE_CIRCLE: ::std::os::raw::c_uint = 1;
pub const NS_STYLE_BASIC_SHAPE_ELLIPSE: ::std::os::raw::c_uint = 2;
pub const NS_STYLE_BASIC_SHAPE_INSET: ::std::os::raw::c_uint = 3;
pub const NS_STYLE_BOX_SHADOW_INSET: ::std::os::raw::c_uint = 0;
pub const NS_STYLE_FLOAT_EDGE_CONTENT_BOX: ::std::os::raw::c_uint = 0;
pub const NS_STYLE_FLOAT_EDGE_MARGIN_BOX: ::std::os::raw::c_uint = 1;
pub const NS_STYLE_USER_FOCUS_NONE: ::std::os::raw::c_uint = 0;
pub const NS_STYLE_USER_FOCUS_IGNORE: ::std::os::raw::c_uint = 1;
pub const NS_STYLE_USER_FOCUS_NORMAL: ::std::os::raw::c_uint = 2;
pub const NS_STYLE_USER_FOCUS_SELECT_ALL: ::std::os::raw::c_uint = 3;
pub const NS_STYLE_USER_FOCUS_SELECT_BEFORE: ::std::os::raw::c_uint = 4;
pub const NS_STYLE_USER_FOCUS_SELECT_AFTER: ::std::os::raw::c_uint = 5;
pub const NS_STYLE_USER_FOCUS_SELECT_SAME: ::std::os::raw::c_uint = 6;
pub const NS_STYLE_USER_FOCUS_SELECT_MENU: ::std::os::raw::c_uint = 7;
pub const NS_STYLE_USER_SELECT_NONE: ::std::os::raw::c_uint = 0;
pub const NS_STYLE_USER_SELECT_TEXT: ::std::os::raw::c_uint = 1;
pub const NS_STYLE_USER_SELECT_ELEMENT: ::std::os::raw::c_uint = 2;
Expand Down Expand Up @@ -511,10 +482,6 @@ pub const NS_STYLE_FLOAT_LEFT: ::std::os::raw::c_uint = 1;
pub const NS_STYLE_FLOAT_RIGHT: ::std::os::raw::c_uint = 2;
pub const NS_STYLE_FLOAT_INLINE_START: ::std::os::raw::c_uint = 3;
pub const NS_STYLE_FLOAT_INLINE_END: ::std::os::raw::c_uint = 4;
pub const NS_STYLE_CLIP_PATH_NONE: ::std::os::raw::c_uint = 0;
pub const NS_STYLE_CLIP_PATH_URL: ::std::os::raw::c_uint = 1;
pub const NS_STYLE_CLIP_PATH_SHAPE: ::std::os::raw::c_uint = 2;
pub const NS_STYLE_CLIP_PATH_BOX: ::std::os::raw::c_uint = 3;
pub const NS_STYLE_FILTER_NONE: ::std::os::raw::c_uint = 0;
pub const NS_STYLE_FILTER_URL: ::std::os::raw::c_uint = 1;
pub const NS_STYLE_FILTER_BLUR: ::std::os::raw::c_uint = 2;
Expand Down Expand Up @@ -2735,12 +2702,6 @@ impl ::std::clone::Clone for nsIExpandedPrincipal {
fn clone(&self) -> Self { *self }
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _Make_integer_sequence<_Tp, _ISeq> {
pub _phantom0: ::std::marker::PhantomData<_Tp>,
pub _phantom1: ::std::marker::PhantomData<_ISeq>,
}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct nsIURI {
pub _base: nsISupports,
Expand Down Expand Up @@ -2792,7 +2753,7 @@ impl ::std::clone::Clone for nsIRequest {
#[repr(C)]
#[derive(Debug, Copy)]
pub struct EventStates {
pub mStates: ::std::os::raw::c_ulong,
pub mStates: ::std::os::raw::c_ulonglong,
}
impl ::std::clone::Clone for EventStates {
fn clone(&self) -> Self { *self }
Expand Down Expand Up @@ -2922,7 +2883,7 @@ fn bindgen_test_layout_nsMutationGuard() {
extern "C" {
#[link_name = "_ZN15nsMutationGuard11sGenerationE"]
pub static mut nsMutationGuard_consts_sGeneration:
::std::os::raw::c_ulong;
::std::os::raw::c_ulonglong;
}
pub type Float = f32;
#[repr(i8)]
Expand Down Expand Up @@ -3022,6 +2983,7 @@ pub enum FontType {
SKIA = 3,
CAIRO = 4,
COREGRAPHICS = 5,
FONTCONFIG = 6,
}
#[repr(i8)]
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
Expand Down Expand Up @@ -3918,7 +3880,43 @@ fn bindgen_test_layout_nsFont() {
}
#[repr(i8)]
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum StyleBasicShape { Polygon = 0, Circle = 1, Ellipse = 2, Inset = 3, }
#[repr(i8)]
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum StyleBoxSizing { Content = 0, Border = 1, }
#[repr(i8)]
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum StyleBoxShadowType { Inset = 0, }
#[repr(i8)]
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum StyleClipPathType { None_ = 0, URL = 1, Shape = 2, Box = 3, }
#[repr(i8)]
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum StyleClipShapeSizing {
NoBox = 0,
Content = 1,
Padding = 2,
Border = 3,
Margin = 4,
Fill = 5,
Stroke = 6,
View = 7,
}
#[repr(i8)]
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum StyleFloatEdge { ContentBox = 0, MarginBox = 1, }
#[repr(i8)]
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum StyleUserFocus {
None_ = 0,
Ignore = 1,
Normal = 2,
SelectAll = 3,
SelectBefore = 4,
SelectAfter = 5,
SelectSame = 6,
SelectMenu = 7,
}
pub const eCSSProperty_COUNT_DUMMY: nsCSSProperty =
nsCSSProperty::eCSSProperty_z_index;
pub const eCSSProperty_all: nsCSSProperty =
Expand Down Expand Up @@ -5598,7 +5596,7 @@ pub struct nsStyleBorder {
pub mBorderImageFill: u8,
pub mBorderImageRepeatH: u8,
pub mBorderImageRepeatV: u8,
pub mFloatEdge: u8,
pub mFloatEdge: StyleFloatEdge,
pub mBoxDecorationBreak: u8,
pub mComputedBorder: nsMargin,
pub mBorder: nsMargin,
Expand Down Expand Up @@ -6171,7 +6169,7 @@ fn bindgen_test_layout_nsCursorImage() {
pub struct nsStyleUserInterface {
pub mUserInput: u8,
pub mUserModify: u8,
pub mUserFocus: u8,
pub mUserFocus: StyleUserFocus,
pub mPointerEvents: u8,
pub mCursor: u8,
pub mCursorArrayLength: u32,
Expand Down Expand Up @@ -6334,9 +6332,9 @@ fn bindgen_test_layout_nsStyleBasicShape() {
#[repr(C)]
#[derive(Debug)]
pub struct nsStyleClipPath {
pub mType: i32,
pub nsStyleClipPath_nsStyleStruct_h_unnamed_29: nsStyleClipPath_nsStyleStruct_h_unnamed_29,
pub mSizingBox: u8,
pub mType: StyleClipPathType,
pub mSizingBox: StyleClipShapeSizing,
}
#[repr(C)]
#[derive(Debug, Copy)]
Expand All @@ -6358,7 +6356,7 @@ fn bindgen_test_layout_nsStyleClipPath_nsStyleStruct_h_unnamed_29() {
}
#[test]
fn bindgen_test_layout_nsStyleClipPath() {
assert_eq!(::std::mem::size_of::<nsStyleClipPath>() , 24usize);
assert_eq!(::std::mem::size_of::<nsStyleClipPath>() , 16usize);
assert_eq!(::std::mem::align_of::<nsStyleClipPath>() , 8usize);
}
#[repr(C)]
Expand Down Expand Up @@ -6406,7 +6404,7 @@ pub struct nsStyleSVGReset {
}
#[test]
fn bindgen_test_layout_nsStyleSVGReset() {
assert_eq!(::std::mem::size_of::<nsStyleSVGReset>() , 216usize);
assert_eq!(::std::mem::size_of::<nsStyleSVGReset>() , 208usize);
assert_eq!(::std::mem::align_of::<nsStyleSVGReset>() , 8usize);
}
#[repr(C)]
Expand Down

0 comments on commit d6266c7

Please sign in to comment.