Auto merge of #10848 - heycam:struct-accessor, r=bholley

Add Servo_GetStyleFoo functions to get style structs from GeckoComputedValues

r?@bholley

<!-- 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/10848)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-04-27 02:20:17 -07:00
commit e079e01320
27 changed files with 71 additions and 37 deletions

View file

@ -98,7 +98,7 @@ class Method(object):
class StyleStruct(object):
def __init__(self, name, inherited, gecko_ffi_name=None, additional_methods=None):
def __init__(self, name, inherited, gecko_name=None, additional_methods=None):
self.servo_struct_name = "Servo" + name
self.gecko_struct_name = "Gecko" + name
self.trait_name = name
@ -106,7 +106,8 @@ class StyleStruct(object):
self.ident = to_rust_ident(self.trait_name_lower)
self.longhands = []
self.inherited = inherited
self.gecko_ffi_name = gecko_ffi_name
self.gecko_name = gecko_name or name
self.gecko_ffi_name = "nsStyle" + self.gecko_name
self.additional_methods = additional_methods or []

View file

@ -4,7 +4,7 @@
<%namespace name="helpers" file="/helpers.mako.rs" />
<% data.new_style_struct("Background", inherited=False, gecko_ffi_name="nsStyleBackground") %>
<% data.new_style_struct("Background", inherited=False) %>
${helpers.predefined_type(
"background-color", "CSSColor",
"::cssparser::Color::RGBA(::cssparser::RGBA { red: 0., green: 0., blue: 0., alpha: 0. }) /* transparent */")}

View file

@ -5,7 +5,7 @@
<%namespace name="helpers" file="/helpers.mako.rs" />
<% from data import Method %>
<% data.new_style_struct("Border", inherited=False, gecko_ffi_name="nsStyleBorder",
<% data.new_style_struct("Border", inherited=False,
additional_methods=[Method("border_" + side + "_has_nonzero_width",
"bool") for side in ["top", "right", "bottom", "left"]]) %>

View file

@ -7,7 +7,7 @@
<% data.new_style_struct("Box",
inherited=False,
gecko_ffi_name="nsStyleDisplay",
gecko_name="Display",
additional_methods=[Method("transition_count", "usize")]) %>
// TODO(SimonSapin): don't parse `inline-table`, since we don't support it

View file

@ -4,7 +4,7 @@
<%namespace name="helpers" file="/helpers.mako.rs" />
<% data.new_style_struct("Color", inherited=True, gecko_ffi_name="nsStyleColor") %>
<% data.new_style_struct("Color", inherited=True) %>
<%helpers:raw_longhand name="color" need_clone="True">
use cssparser::Color as CSSParserColor;

View file

@ -4,7 +4,7 @@
<%namespace name="helpers" file="/helpers.mako.rs" />
<% data.new_style_struct("Column", inherited=False, gecko_ffi_name="nsStyleColumn") %>
<% data.new_style_struct("Column", inherited=False) %>
<%helpers:longhand name="column-width" experimental="True">
use cssparser::ToCss;

View file

@ -4,7 +4,7 @@
<%namespace name="helpers" file="/helpers.mako.rs" />
<% data.new_style_struct("Counters", inherited=False, gecko_ffi_name="nsStyleContent") %>
<% data.new_style_struct("Counters", inherited=False, gecko_name="Content") %>
<%helpers:longhand name="content">
use cssparser::Token;

View file

@ -5,7 +5,7 @@
<%namespace name="helpers" file="/helpers.mako.rs" />
// Box-shadow, etc.
<% data.new_style_struct("Effects", inherited=False, gecko_ffi_name="nsStyleEffects") %>
<% data.new_style_struct("Effects", inherited=False) %>
<%helpers:longhand name="opacity">
use cssparser::ToCss;

View file

@ -7,7 +7,6 @@
<% data.new_style_struct("Font",
inherited=True,
gecko_ffi_name="nsStyleFont",
additional_methods=[Method("compute_font_hash", is_mut=True)]) %>
<%helpers:longhand name="font-family">
use self::computed_value::FontFamily;

View file

@ -4,7 +4,7 @@
<%namespace name="helpers" file="/helpers.mako.rs" />
<% data.new_style_struct("InheritedBox", inherited=True, gecko_ffi_name="nsStyleVisibility") %>
<% data.new_style_struct("InheritedBox", inherited=True, gecko_name="Visibility") %>
${helpers.single_keyword("direction", "ltr rtl", need_clone=True)}

View file

@ -4,7 +4,7 @@
<%namespace name="helpers" file="/helpers.mako.rs" />
<% data.new_style_struct("InheritedTable", inherited=True, gecko_ffi_name="nsStyleTableBorder") %>
<% data.new_style_struct("InheritedTable", inherited=True, gecko_name="TableBorder") %>
${helpers.single_keyword("border-collapse", "separate collapse", gecko_constant_prefix="NS_STYLE_BORDER")}
${helpers.single_keyword("empty-cells", "show hide", gecko_constant_prefix="NS_STYLE_TABLE_EMPTY_CELLS")}

View file

@ -4,7 +4,7 @@
<%namespace name="helpers" file="/helpers.mako.rs" />
<% data.new_style_struct("InheritedText", inherited=True, gecko_ffi_name="nsStyleText") %>
<% data.new_style_struct("InheritedText", inherited=True, gecko_name="Text") %>
<%helpers:longhand name="line-height">
use cssparser::ToCss;

View file

@ -4,7 +4,7 @@
<%namespace name="helpers" file="/helpers.mako.rs" />
<% data.new_style_struct("List", inherited=True, gecko_ffi_name="nsStyleList") %>
<% data.new_style_struct("List", inherited=True) %>
${helpers.single_keyword("list-style-position", "outside inside")}

View file

@ -4,7 +4,7 @@
<%namespace name="helpers" file="/helpers.mako.rs" />
<% data.new_style_struct("Margin", inherited=False, gecko_ffi_name="nsStyleMargin") %>
<% data.new_style_struct("Margin", inherited=False) %>
% for side in ["top", "right", "bottom", "left"]:
${helpers.predefined_type("margin-" + side, "LengthOrPercentageOrAuto",

View file

@ -7,7 +7,6 @@
<% data.new_style_struct("Outline",
inherited=False,
gecko_ffi_name="nsStyleOutline",
additional_methods=[Method("outline_has_nonzero_width", "bool")]) %>
// TODO(pcwalton): `invert`

View file

@ -4,7 +4,7 @@
<%namespace name="helpers" file="/helpers.mako.rs" />
<% data.new_style_struct("Padding", inherited=False, gecko_ffi_name="nsStylePadding") %>
<% data.new_style_struct("Padding", inherited=False) %>
% for side in ["top", "right", "bottom", "left"]:
${helpers.predefined_type("padding-" + side, "LengthOrPercentage",

View file

@ -4,7 +4,7 @@
<%namespace name="helpers" file="/helpers.mako.rs" />
<% data.new_style_struct("Pointing", inherited=True, gecko_ffi_name="nsStyleUserInterface") %>
<% data.new_style_struct("Pointing", inherited=True, gecko_name="UserInterface") %>
<%helpers:longhand name="cursor">
pub use self::computed_value::T as SpecifiedValue;

View file

@ -4,7 +4,7 @@
<%namespace name="helpers" file="/helpers.mako.rs" />
<% data.new_style_struct("Position", inherited=False, gecko_ffi_name="nsStylePosition") %>
<% data.new_style_struct("Position", inherited=False) %>
% for side in ["top", "right", "bottom", "left"]:
${helpers.predefined_type(side, "LengthOrPercentageOrAuto",

View file

@ -4,7 +4,7 @@
<%namespace name="helpers" file="/helpers.mako.rs" />
<% data.new_style_struct("SVG", inherited=False, gecko_ffi_name="nsStyleSVGReset") %>
<% data.new_style_struct("SVG", inherited=False, gecko_name="SVGReset") %>
${helpers.single_keyword("dominant-baseline",
"""auto use-script no-change reset-size ideographic alphabetic hanging

View file

@ -8,7 +8,7 @@
// https://www.w3.org/TR/SVG/
<% data.new_style_struct("SVGInherited",
inherited=True,
gecko_ffi_name="nsStyleSVG") %>
gecko_name="SVG") %>
// Section 10 - Text

View file

@ -4,6 +4,6 @@
<%namespace name="helpers" file="/helpers.mako.rs" />
<% data.new_style_struct("Table", inherited=False, gecko_ffi_name="nsStyleTable") %>
<% data.new_style_struct("Table", inherited=False) %>
${helpers.single_keyword("table-layout", "auto fixed", gecko_ffi_name="mLayoutStrategy")}

View file

@ -7,7 +7,7 @@
<% data.new_style_struct("Text",
inherited=False,
gecko_ffi_name="nsStyleTextReset",
gecko_name="TextReset",
additional_methods=[Method("has_underline", "bool"),
Method("has_overline", "bool"),
Method("has_line_through", "bool")]) %>

View file

@ -0,0 +1,13 @@
/* 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/. */
<%namespace name="helpers" file="/helpers.mako.rs" />
<% from data import Method %>
// CSS Basic User Interface Module Level 1
// https://drafts.csswg.org/css-ui-3/
<% data.new_style_struct("UI", inherited=False, gecko_name="UIReset") %>
${helpers.single_keyword("ime-mode", "normal auto active disabled inactive", products="gecko",
gecko_ffi_name="mIMEMode")}

View file

@ -0,0 +1,12 @@
/* 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/. */
<%namespace name="helpers" file="/helpers.mako.rs" />
<% from data import Method %>
// Non-standard properties that Gecko uses for XUL elements.
<% data.new_style_struct("XUL", inherited=False) %>
${helpers.single_keyword("-moz-box-align", "stretch start center baseline end", products="gecko",
gecko_ffi_name="mBoxAlign", gecko_constant_prefix="NS_STYLE_BOX_ALIGN")}

View file

@ -66,8 +66,10 @@ pub mod longhands {
<%include file="/longhand/position.mako.rs" />
<%include file="/longhand/table.mako.rs" />
<%include file="/longhand/text.mako.rs" />
<%include file="/longhand/ui.mako.rs" />
<%include file="/longhand/svg_inherited.mako.rs" />
<%include file="/longhand/svg.mako.rs" />
<%include file="/longhand/xul.mako.rs" />
}