mirror of
https://github.com/servo/servo.git
synced 2025-06-29 03:23:41 +01:00
Auto merge of #13890 - Wafflespeanut:glue, r=Manishearth
Auto-generate some glue <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build-geckolib` does not report any errors <!-- Either: --> - [x] These changes do not require tests because it's a refactor <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> r? @Manishearth or @emilio <!-- 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/13890) <!-- Reviewable:end -->
This commit is contained in:
commit
97feac079c
4 changed files with 28 additions and 27 deletions
|
@ -63,7 +63,7 @@ class Longhand(object):
|
||||||
def __init__(self, style_struct, name, animatable=None, derived_from=None, keyword=None,
|
def __init__(self, style_struct, name, animatable=None, derived_from=None, keyword=None,
|
||||||
predefined_type=None, custom_cascade=False, experimental=False, internal=False,
|
predefined_type=None, custom_cascade=False, experimental=False, internal=False,
|
||||||
need_clone=False, need_index=False, gecko_ffi_name=None, depend_on_viewport_size=False,
|
need_clone=False, need_index=False, gecko_ffi_name=None, depend_on_viewport_size=False,
|
||||||
allowed_in_keyframe_block=True):
|
allowed_in_keyframe_block=True, complex_color=False):
|
||||||
self.name = name
|
self.name = name
|
||||||
self.keyword = keyword
|
self.keyword = keyword
|
||||||
self.predefined_type = predefined_type
|
self.predefined_type = predefined_type
|
||||||
|
@ -77,6 +77,7 @@ class Longhand(object):
|
||||||
self.gecko_ffi_name = gecko_ffi_name or "m" + self.camel_case
|
self.gecko_ffi_name = gecko_ffi_name or "m" + self.camel_case
|
||||||
self.depend_on_viewport_size = depend_on_viewport_size
|
self.depend_on_viewport_size = depend_on_viewport_size
|
||||||
self.derived_from = (derived_from or "").split()
|
self.derived_from = (derived_from or "").split()
|
||||||
|
self.complex_color = complex_color
|
||||||
|
|
||||||
# https://drafts.csswg.org/css-animations/#keyframes
|
# https://drafts.csswg.org/css-animations/#keyframes
|
||||||
# > The <declaration-list> inside of <keyframe-block> accepts any CSS property
|
# > The <declaration-list> inside of <keyframe-block> accepts any CSS property
|
||||||
|
|
|
@ -481,16 +481,29 @@ impl Debug for ${style_struct.gecko_struct_name} {
|
||||||
|
|
||||||
# Types used with predefined_type()-defined properties that we can auto-generate.
|
# Types used with predefined_type()-defined properties that we can auto-generate.
|
||||||
predefined_types = {
|
predefined_types = {
|
||||||
|
"Length": impl_style_coord,
|
||||||
"LengthOrPercentage": impl_style_coord,
|
"LengthOrPercentage": impl_style_coord,
|
||||||
"LengthOrPercentageOrAuto": impl_style_coord,
|
"LengthOrPercentageOrAuto": impl_style_coord,
|
||||||
"LengthOrPercentageOrNone": impl_style_coord,
|
"LengthOrPercentageOrNone": impl_style_coord,
|
||||||
"Number": impl_simple,
|
"Number": impl_simple,
|
||||||
"Opacity": impl_simple,
|
"Opacity": impl_simple,
|
||||||
|
"CSSColor": impl_color,
|
||||||
}
|
}
|
||||||
|
|
||||||
keyword_longhands = [x for x in longhands if x.keyword and not x.name in force_stub]
|
def predefined_type_method(longhand):
|
||||||
|
args = dict(ident=longhand.ident, gecko_ffi_name=longhand.gecko_ffi_name,
|
||||||
|
need_clone=longhand.need_clone)
|
||||||
|
method = predefined_types[longhand.predefined_type]
|
||||||
|
|
||||||
|
# additional type-specific arguments
|
||||||
|
if longhand.predefined_type in ["CSSColor"]:
|
||||||
|
args.update(complex_color=longhand.complex_color)
|
||||||
|
|
||||||
|
method(**args)
|
||||||
|
|
||||||
|
keyword_longhands = [x for x in longhands if x.keyword and x.name not in force_stub]
|
||||||
predefined_longhands = [x for x in longhands
|
predefined_longhands = [x for x in longhands
|
||||||
if x.predefined_type in predefined_types and not x.name in force_stub]
|
if x.predefined_type in predefined_types and x.name not in force_stub]
|
||||||
stub_longhands = [x for x in longhands if x not in keyword_longhands + predefined_longhands]
|
stub_longhands = [x for x in longhands if x not in keyword_longhands + predefined_longhands]
|
||||||
|
|
||||||
# If one of the longhands is not handled
|
# If one of the longhands is not handled
|
||||||
|
@ -523,8 +536,7 @@ impl ${style_struct.gecko_struct_name} {
|
||||||
for longhand in keyword_longhands:
|
for longhand in keyword_longhands:
|
||||||
impl_keyword(longhand.ident, longhand.gecko_ffi_name, longhand.keyword, longhand.need_clone)
|
impl_keyword(longhand.ident, longhand.gecko_ffi_name, longhand.keyword, longhand.need_clone)
|
||||||
for longhand in predefined_longhands:
|
for longhand in predefined_longhands:
|
||||||
impl_fn = predefined_types[longhand.predefined_type]
|
predefined_type_method(longhand)
|
||||||
impl_fn(longhand.ident, longhand.gecko_ffi_name, need_clone=longhand.need_clone)
|
|
||||||
%>
|
%>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -721,7 +733,7 @@ fn static_assert() {
|
||||||
|
|
||||||
</%self:impl_trait>
|
</%self:impl_trait>
|
||||||
|
|
||||||
<% skip_outline_longhands = " ".join("outline-color outline-style outline-width".split() +
|
<% skip_outline_longhands = " ".join("outline-style outline-width".split() +
|
||||||
["-moz-outline-radius-{0}".format(x.ident.replace("_", ""))
|
["-moz-outline-radius-{0}".format(x.ident.replace("_", ""))
|
||||||
for x in CORNERS]) %>
|
for x in CORNERS]) %>
|
||||||
<%self:impl_trait style_struct_name="Outline"
|
<%self:impl_trait style_struct_name="Outline"
|
||||||
|
@ -730,8 +742,6 @@ fn static_assert() {
|
||||||
|
|
||||||
<% impl_keyword("outline_style", "mOutlineStyle", border_style_keyword, need_clone=True) %>
|
<% impl_keyword("outline_style", "mOutlineStyle", border_style_keyword, need_clone=True) %>
|
||||||
|
|
||||||
<% impl_color("outline_color", "mOutlineColor", need_clone=True) %>
|
|
||||||
|
|
||||||
<% impl_app_units("outline_width", "mActualOutlineWidth", need_clone=True,
|
<% impl_app_units("outline_width", "mActualOutlineWidth", need_clone=True,
|
||||||
round_to_pixels=True) %>
|
round_to_pixels=True) %>
|
||||||
|
|
||||||
|
@ -1440,7 +1450,7 @@ fn static_assert() {
|
||||||
// TODO: Gecko accepts lists in most background-related properties. We just use
|
// TODO: Gecko accepts lists in most background-related properties. We just use
|
||||||
// the first element (which is the common case), but at some point we want to
|
// the first element (which is the common case), but at some point we want to
|
||||||
// add support for parsing these lists in servo and pushing to nsTArray's.
|
// add support for parsing these lists in servo and pushing to nsTArray's.
|
||||||
<% skip_background_longhands = """background-color background-repeat
|
<% skip_background_longhands = """background-repeat
|
||||||
background-image background-clip
|
background-image background-clip
|
||||||
background-origin background-attachment
|
background-origin background-attachment
|
||||||
background-size background-position""" %>
|
background-size background-position""" %>
|
||||||
|
@ -1448,8 +1458,6 @@ fn static_assert() {
|
||||||
skip_longhands="${skip_background_longhands}"
|
skip_longhands="${skip_background_longhands}"
|
||||||
skip_additionals="*">
|
skip_additionals="*">
|
||||||
|
|
||||||
<% impl_color("background_color", "mBackgroundColor", need_clone=True, complex_color=False) %>
|
|
||||||
|
|
||||||
<% impl_common_image_layer_properties("background") %>
|
<% impl_common_image_layer_properties("background") %>
|
||||||
|
|
||||||
<%self:simple_image_array_property name="attachment" shorthand="background" field_name="mAttachment">
|
<%self:simple_image_array_property name="attachment" shorthand="background" field_name="mAttachment">
|
||||||
|
@ -1739,11 +1747,9 @@ fn static_assert() {
|
||||||
</%self:impl_trait>
|
</%self:impl_trait>
|
||||||
|
|
||||||
<%self:impl_trait style_struct_name="Text"
|
<%self:impl_trait style_struct_name="Text"
|
||||||
skip_longhands="text-decoration-color text-decoration-line text-overflow"
|
skip_longhands="text-decoration-line text-overflow"
|
||||||
skip_additionals="*">
|
skip_additionals="*">
|
||||||
|
|
||||||
${impl_color("text_decoration_color", "mTextDecorationColor", need_clone=True)}
|
|
||||||
|
|
||||||
pub fn set_text_decoration_line(&mut self, v: longhands::text_decoration_line::computed_value::T) {
|
pub fn set_text_decoration_line(&mut self, v: longhands::text_decoration_line::computed_value::T) {
|
||||||
let mut bits: u8 = 0;
|
let mut bits: u8 = 0;
|
||||||
if v.underline {
|
if v.underline {
|
||||||
|
@ -1833,7 +1839,6 @@ fn static_assert() {
|
||||||
</%self:impl_trait>
|
</%self:impl_trait>
|
||||||
|
|
||||||
<% skip_svg_longhands = """
|
<% skip_svg_longhands = """
|
||||||
flood-color lighting-color stop-color
|
|
||||||
mask-mode mask-repeat mask-clip mask-origin mask-composite mask-position mask-size mask-image
|
mask-mode mask-repeat mask-clip mask-origin mask-composite mask-position mask-size mask-image
|
||||||
clip-path
|
clip-path
|
||||||
"""
|
"""
|
||||||
|
@ -1842,12 +1847,6 @@ clip-path
|
||||||
skip_longhands="${skip_svg_longhands}"
|
skip_longhands="${skip_svg_longhands}"
|
||||||
skip_additionals="*">
|
skip_additionals="*">
|
||||||
|
|
||||||
<% impl_color("flood_color", "mFloodColor", complex_color=False) %>
|
|
||||||
|
|
||||||
<% impl_color("lighting_color", "mLightingColor", complex_color=False) %>
|
|
||||||
|
|
||||||
<% impl_color("stop_color", "mStopColor", complex_color=False) %>
|
|
||||||
|
|
||||||
<% impl_common_image_layer_properties("mask") %>
|
<% impl_common_image_layer_properties("mask") %>
|
||||||
|
|
||||||
<%self:simple_image_array_property name="mode" shorthand="mask" field_name="mMaskMode">
|
<%self:simple_image_array_property name="mode" shorthand="mask" field_name="mMaskMode">
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
// TODO(pcwalton): `invert`
|
// TODO(pcwalton): `invert`
|
||||||
${helpers.predefined_type("outline-color", "CSSColor", "::cssparser::Color::CurrentColor",
|
${helpers.predefined_type("outline-color", "CSSColor", "::cssparser::Color::CurrentColor",
|
||||||
animatable=True)}
|
animatable=True, complex_color=True, need_clone=True)}
|
||||||
|
|
||||||
<%helpers:longhand name="outline-style" need_clone="True" animatable="False">
|
<%helpers:longhand name="outline-style" need_clone="True" animatable="False">
|
||||||
pub use values::specified::BorderStyle as SpecifiedValue;
|
pub use values::specified::BorderStyle as SpecifiedValue;
|
||||||
|
|
|
@ -209,5 +209,6 @@ ${helpers.single_keyword("text-decoration-style",
|
||||||
${helpers.predefined_type(
|
${helpers.predefined_type(
|
||||||
"text-decoration-color", "CSSColor",
|
"text-decoration-color", "CSSColor",
|
||||||
"CSSParserColor::RGBA(RGBA { red: 0.0, green: 0.0, blue: 0.0, alpha: 1.0 })",
|
"CSSParserColor::RGBA(RGBA { red: 0.0, green: 0.0, blue: 0.0, alpha: 1.0 })",
|
||||||
|
complex_color=True,
|
||||||
products="gecko",
|
products="gecko",
|
||||||
animatable=True)}
|
animatable=True)}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue