Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stylo: replace product={gecko,servo} with engine={gecko,servo-2013,servo-2020} #23856

Merged
merged 3 commits into from Jul 30, 2019
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Stylo: replace product={gecko,servo} with engine={gecko,servo-2013,se…

…rvo-2020}

Renaming the variable helped make sure I looked at every use.
  • Loading branch information
SimonSapin committed Jul 29, 2019
commit ddb4e369ddb8d9bb20142d34e320370cd3be196f
@@ -49,7 +49,7 @@ serde_json = "1.0"
servo_config = {path = "../config"}
servo_url = {path = "../url"}
smallvec = { version = "0.6", features = ["std", "union"] }
style = {path = "../style", features = ["servo"]}
style = {path = "../style", features = ["servo", "servo-layout-2013"]}
style_traits = {path = "../style_traits"}
unicode-bidi = {version = "0.3", features = ["with_serde"]}
unicode-script = {version = "0.3", features = ["harfbuzz"]}
@@ -42,9 +42,7 @@ fn main() {
start.elapsed().as_secs()
);

let json = out_dir
.join("build")
.join("InterfaceObjectMapData.json");
let json = out_dir.join("build").join("InterfaceObjectMapData.json");
let json: Value = serde_json::from_reader(File::open(&json).unwrap()).unwrap();
let mut map = phf_codegen::Map::new();
for (key, value) in json.as_object().unwrap() {
@@ -20,7 +20,8 @@ gecko = ["style_traits/gecko", "fallible/known_system_malloc", "bindgen", "regex
servo = ["serde", "style_traits/servo", "servo_atoms", "servo_config", "html5ever",
"cssparser/serde", "encoding_rs", "malloc_size_of/servo", "arrayvec/use_union",
"servo_url", "string_cache", "crossbeam-channel", "to_shmem/servo", "servo_arc/servo"]
"servo-layout-2020" = []
servo-layout-2013 = []
servo-layout-2020 = []
gecko_debug = []
gecko_refcount_logging = []
gecko_profiler = []
@@ -89,14 +89,19 @@ fn generate_properties() {
let script = Path::new(&env::var_os("CARGO_MANIFEST_DIR").unwrap())
.join("properties")
.join("build.py");
let product = if cfg!(feature = "gecko") {
"gecko"
} else {
"servo"
};

#[cfg(feature = "gecko")]
let engine = "gecko";

#[cfg(feature = "servo-layout-2013")]
let engine = "servo-2013";

#[cfg(feature = "servo-layout-2020")]
let engine = "servo-2020";

let status = Command::new(&*PYTHON)
.arg(&script)
.arg(product)
.arg(engine)
.arg("style-crate")
.status()
.unwrap();
@@ -117,6 +122,9 @@ fn main() {
feature flags at the same time."
);
}
if gecko && (cfg!(feature = "servo-layout-2013") || cfg!(feature = "servo-layout-2020")) {
panic!("The 'servo-layout-*' features can only be enabled together with 'servo'.");
}
println!("cargo:rerun-if-changed=build.rs");
println!("cargo:out_dir={}", env::var("OUT_DIR").unwrap());
generate_properties();
@@ -30,35 +30,36 @@
"effects",
"font",
"inherited_box",
"inherited_svg",
"inherited_table",
"inherited_text",
"inherited_ui",
"inherited_svg",
"list",
"margin",
"outline",
"padding",
"position",
"svg",
"table",
"text",
"ui",
"svg",
"xul",
]


def main():
usage = ("Usage: %s [ servo | gecko ] [ style-crate | geckolib <template> | html ]" %
usage = ("Usage: %s [ servo-2013 | servo-2020 | gecko ] [ style-crate | geckolib <template> | html ]" %
sys.argv[0])
if len(sys.argv) < 3:
abort(usage)
product = sys.argv[1]
engine = sys.argv[1]
output = sys.argv[2]

if product not in ["servo", "gecko"] or output not in ["style-crate", "geckolib", "html"]:
if engine not in ["servo-2013", "servo-2020", "gecko"] \
or output not in ["style-crate", "geckolib", "html"]:
abort(usage)

properties = data.PropertiesData(product=product)
properties = data.PropertiesData(engine=engine)
files = {}
for kind in ["longhands", "shorthands"]:
files[kind] = {}
@@ -69,13 +70,13 @@ def main():
continue
files[kind][struct] = render(
file_name,
product=product,
engine=engine,
data=properties,
)
properties_template = os.path.join(BASE, "properties.mako.rs")
files["properties"] = render(
properties_template,
product=product,
engine=engine,
data=properties,
__file__=properties_template,
OUT_DIR=OUT_DIR,
@@ -90,14 +91,18 @@ def main():
files[kind][struct],
)

if product == "gecko":
if engine == "gecko":
template = os.path.join(BASE, "gecko.mako.rs")
rust = render(template, data=properties)
write(OUT_DIR, "gecko_properties.rs", rust)

if product == "servo":
if engine in ["servo-2013", "servo-2020"]:
if engine == "servo-2013":
pref_attr = "servo_2013_pref"
if engine == "servo-2020":
pref_attr = "servo_2020_pref"
names_and_prefs = [
(prop.name, prop.servo_pref)
(prop.name, getattr(prop, pref_attr))
for p in properties.longhands + properties.shorthands
if p.enabled_in_content()
for prop in [p] + p.alias
@@ -151,7 +156,7 @@ def write(directory, filename, content):
def write_html(properties):
properties = dict(
(p.name, {
"flag": p.servo_pref,
"flag": p.servo_2013_pref,
"shorthand": hasattr(p, "sub_properties")
})
for p in properties.longhands + properties.shorthands
@@ -639,13 +639,8 @@ impl<'a, 'b: 'a> Cascade<'a, 'b> {

#[cfg(feature = "servo")]
{
// TODO(emilio): Use get_font_if_mutated instead.
if self.seen.contains(LonghandId::FontStyle) ||
self.seen.contains(LonghandId::FontWeight) ||
self.seen.contains(LonghandId::FontStretch) ||
self.seen.contains(LonghandId::FontFamily)
{
builder.mutate_font().compute_font_hash();
if let Some(font) = builder.get_font_if_mutated() {
font.compute_font_hash();
}
}
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.