mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
stylo: Generate eCSSPropertyID_all as a const rather than an enum value.
This commit is contained in:
parent
6f7db7c571
commit
fb26ae7df5
3 changed files with 22 additions and 5 deletions
|
@ -31,6 +31,7 @@ mod common {
|
||||||
#[cfg(feature = "bindgen")]
|
#[cfg(feature = "bindgen")]
|
||||||
mod bindings {
|
mod bindings {
|
||||||
use bindgen::{Builder, CodegenConfig};
|
use bindgen::{Builder, CodegenConfig};
|
||||||
|
use bindgen::chooser::{EnumVariantCustomBehavior, EnumVariantValue, TypeChooser};
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use std::cmp;
|
use std::cmp;
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
@ -258,6 +259,23 @@ mod bindings {
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
struct Callbacks;
|
||||||
|
impl TypeChooser for Callbacks {
|
||||||
|
fn enum_variant_behavior(&self,
|
||||||
|
enum_name: Option<&str>,
|
||||||
|
variant_name: &str,
|
||||||
|
_variant_value: EnumVariantValue)
|
||||||
|
-> Option<EnumVariantCustomBehavior> {
|
||||||
|
if enum_name.map_or(false, |n| n == "nsCSSPropertyID") &&
|
||||||
|
variant_name.starts_with("eCSSProperty_COUNT") {
|
||||||
|
Some(EnumVariantCustomBehavior::Constify)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn generate_structs(build_type: BuildType) {
|
pub fn generate_structs(build_type: BuildType) {
|
||||||
let mut builder = Builder::get_initial_builder(build_type)
|
let mut builder = Builder::get_initial_builder(build_type)
|
||||||
.enable_cxx_namespaces()
|
.enable_cxx_namespaces()
|
||||||
|
@ -296,7 +314,8 @@ mod bindings {
|
||||||
.hide_type("nsString")
|
.hide_type("nsString")
|
||||||
.bitfield_enum("nsChangeHint")
|
.bitfield_enum("nsChangeHint")
|
||||||
.bitfield_enum("nsRestyleHint")
|
.bitfield_enum("nsRestyleHint")
|
||||||
.constified_enum("UpdateAnimationsTasks");
|
.constified_enum("UpdateAnimationsTasks")
|
||||||
|
.type_chooser(Box::new(Callbacks));
|
||||||
let whitelist_vars = [
|
let whitelist_vars = [
|
||||||
"NS_THEME_.*",
|
"NS_THEME_.*",
|
||||||
"NODE_.*",
|
"NODE_.*",
|
||||||
|
|
|
@ -1986,7 +1986,7 @@ fn static_assert() {
|
||||||
${impl_transition_timing_function()}
|
${impl_transition_timing_function()}
|
||||||
|
|
||||||
pub fn set_transition_property(&mut self, v: longhands::transition_property::computed_value::T) {
|
pub fn set_transition_property(&mut self, v: longhands::transition_property::computed_value::T) {
|
||||||
use gecko_bindings::structs::nsCSSPropertyID_eCSSPropertyExtra_no_properties;
|
use gecko_bindings::structs::nsCSSPropertyID::eCSSPropertyExtra_no_properties;
|
||||||
|
|
||||||
if !v.0.is_empty() {
|
if !v.0.is_empty() {
|
||||||
unsafe { self.gecko.mTransitions.ensure_len(v.0.len()) };
|
unsafe { self.gecko.mTransitions.ensure_len(v.0.len()) };
|
||||||
|
@ -1997,7 +1997,7 @@ fn static_assert() {
|
||||||
} else {
|
} else {
|
||||||
// In gecko |none| is represented by eCSSPropertyExtra_no_properties.
|
// In gecko |none| is represented by eCSSPropertyExtra_no_properties.
|
||||||
self.gecko.mTransitionPropertyCount = 1;
|
self.gecko.mTransitionPropertyCount = 1;
|
||||||
self.gecko.mTransitions[0].mProperty = nsCSSPropertyID_eCSSPropertyExtra_no_properties;
|
self.gecko.mTransitions[0].mProperty = eCSSPropertyExtra_no_properties;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -735,8 +735,6 @@
|
||||||
|
|
||||||
<%def name="alias_to_nscsspropertyid(alias)">
|
<%def name="alias_to_nscsspropertyid(alias)">
|
||||||
<%
|
<%
|
||||||
if alias == "word-wrap":
|
|
||||||
return "nsCSSPropertyID_eCSSPropertyAlias_WordWrap"
|
|
||||||
return "nsCSSPropertyID::eCSSPropertyAlias_%s" % to_camel_case(alias)
|
return "nsCSSPropertyID::eCSSPropertyAlias_%s" % to_camel_case(alias)
|
||||||
%>
|
%>
|
||||||
</%def>
|
</%def>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue