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 all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -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"]}
@@ -43,11 +43,8 @@ set(globalgen_deps
${bindings_src}/parser/WebIDL.py
)
set(bindinggen_deps
${globalgen_deps}
${bindings_src}/BindingGen.py
${bindings_src}/Bindings.conf
${bindings_src}/Configuration.py
${bindings_src}/CodegenRust.py
${bindings_src}/parser/WebIDL.py
)

add_custom_command(
@@ -71,26 +68,12 @@ add_custom_command(
${bindings_src}/Bindings.conf
.
${PROJECT_SOURCE_DIR}
DEPENDS Bindings _cache ${globalgen_deps} ${webidls}
VERBATIM
)

add_custom_command(
OUTPUT apis.html
COMMAND ${PYTHON_EXECUTABLE} -B ${bindings_src}/pythonpath.py -I ${bindings_src}/parser -I ${bindings_src}/ply
${bindings_src}/GlobalGen.py
--cachedir=_cache
--filelist=webidls.list
--only-html
${bindings_src}/Bindings.conf
.
${PROJECT_SOURCE_DIR}
DEPENDS _cache ${globalgen_deps} ${webidls}
${PROJECT_BINARY_DIR}/../css-properties.json
${PROJECT_SOURCE_DIR}/../../target/doc/servo
DEPENDS Bindings _cache ${globalgen_deps} ${webidls} ${PROJECT_BINARY_DIR}/../css-properties.json
VERBATIM
)

add_custom_target(supported-apis DEPENDS apis.html)

# We need an intermediate custom target for this, due to this misfeature:
# > If any dependency is an OUTPUT of another custom command in the same
# > directory CMake automatically brings the other custom command into the
@@ -15,6 +15,11 @@ use std::time::Instant;
fn main() {
let start = Instant::now();

let style_out_dir = PathBuf::from(env::var_os("DEP_SERVO_STYLE_CRATE_OUT_DIR").unwrap());
let out_dir = PathBuf::from(env::var_os("OUT_DIR").unwrap());
let json = "css-properties.json";
std::fs::copy(style_out_dir.join(json), out_dir.join(json)).unwrap();

// This must use the Ninja generator -- it's the only one that
// parallelizes cmake's output properly. (Cmake generates
// separate makefiles, each of which try to build
@@ -35,9 +40,7 @@ fn main() {
start.elapsed().as_secs()
);

let json = PathBuf::from(env::var_os("OUT_DIR").unwrap())
.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() {
@@ -7550,7 +7550,7 @@ def UnionTypes(config):
def SupportedDomApis(config):
descriptors = config.getDescriptors(isExposedConditionally=False)

base_path = os.path.join('dom', 'bindings', 'codegen')
base_path = os.path.dirname(__file__)
with open(os.path.join(base_path, 'apis.html.template')) as f:
base_template = f.read()
with open(os.path.join(base_path, 'api.html.template')) as f:
@@ -7,6 +7,7 @@

import sys
import os
import json
sys.path.append(os.path.join(".", "parser"))
sys.path.append(os.path.join(".", "ply"))
import WebIDL
@@ -28,12 +29,10 @@ def generate_file(config, name, filename):
def main():
# Parse arguments.
from optparse import OptionParser
usageString = "usage: %prog [options] configFile outputdir webidldir [files]"
usageString = "usage: %prog [options] configFile outputdir webidldir cssProperties.json docServoDir [files]"
o = OptionParser(usage=usageString)
o.add_option("--cachedir", dest='cachedir', default=None,
help="Directory in which to cache lex/parse tables.")
o.add_option("--only-html", dest='only_html', action="store_true",
help="Only generate HTML from WebIDL inputs")
o.add_option("--filelist", dest='filelist', default=None,
help="A file containing the list (one per line) of webidl files to process.")
(options, args) = o.parse_args()
@@ -44,8 +43,10 @@ def main():
configFile = args[0]
outputdir = args[1]
baseDir = args[2]
css_properties_json = args[3]
doc_servo = args[4]
if options.filelist is not None:
fileList = (l.strip() for l in open(options.filelist).xreadlines())
fileList = [l.strip() for l in open(options.filelist).xreadlines()]
else:
fileList = args[3:]

@@ -56,35 +57,87 @@ def main():
with open(fullPath, 'rb') as f:
lines = f.readlines()
parser.parse(''.join(lines), fullPath)

add_css_properties_attributes(fileList, css_properties_json, parser)

parserResults = parser.finish()

if not options.only_html:
# Write the parser results out to a pickle.
resultsPath = os.path.join(outputdir, 'ParserResults.pkl')
with open(resultsPath, 'wb') as resultsFile:
cPickle.dump(parserResults, resultsFile, -1)
# Write the parser results out to a pickle.
resultsPath = os.path.join(outputdir, 'ParserResults.pkl')
with open(resultsPath, 'wb') as resultsFile:
cPickle.dump(parserResults, resultsFile, -1)

# Load the configuration.
config = Configuration(configFile, parserResults)

to_generate = [
('SupportedDomApis', 'apis.html'),
('PrototypeList', 'PrototypeList.rs'),
('RegisterBindings', 'RegisterBindings.rs'),
('InterfaceObjectMap', 'InterfaceObjectMap.rs'),
('InterfaceObjectMapData', 'InterfaceObjectMapData.json'),
('InterfaceTypes', 'InterfaceTypes.rs'),
('InheritTypes', 'InheritTypes.rs'),
('Bindings', os.path.join('Bindings', 'mod.rs')),
('UnionTypes', 'UnionTypes.rs'),
]

if not options.only_html:
to_generate = [
('PrototypeList', 'PrototypeList.rs'),
('RegisterBindings', 'RegisterBindings.rs'),
('InterfaceObjectMap', 'InterfaceObjectMap.rs'),
('InterfaceObjectMapData', 'InterfaceObjectMapData.json'),
('InterfaceTypes', 'InterfaceTypes.rs'),
('InheritTypes', 'InheritTypes.rs'),
('Bindings', os.path.join('Bindings', 'mod.rs')),
('UnionTypes', 'UnionTypes.rs'),
]

for name, filename in to_generate:
generate_file(config, name, os.path.join(outputdir, filename))

generate_file(config, 'SupportedDomApis', os.path.join(doc_servo, 'apis.html'))


def add_css_properties_attributes(webidl_files, css_properties_json, parser):
for filename in webidl_files:
if os.path.basename(filename) == "CSSStyleDeclaration.webidl":
break
else:
return

css_properties = json.load(open(css_properties_json, "rb"))
idl = "partial interface CSSStyleDeclaration {\n%s\n};\n" % "\n".join(
" [%sCEReactions, SetterThrows] attribute [TreatNullAs=EmptyString] DOMString %s;" % (
('Pref="%s", ' % data["pref"] if data["pref"] else ""),
attribute_name
)
for (kind, properties_list) in sorted(css_properties.items())
for (property_name, data) in sorted(properties_list.items())
for attribute_name in attribute_names(property_name)
)
parser.parse(idl.encode("utf-8"), "CSSStyleDeclaration_generated.webidl")


def attribute_names(property_name):
# https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-dashed-attribute
if property_name != "float":
yield property_name
else:
yield "_float"

# https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-camel-cased-attribute
if "-" in property_name:
yield "".join(camel_case(property_name))

# https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-webkit-cased-attribute
if property_name.startswith("-webkit-"):
yield "".join(camel_case(property_name), True)


# https://drafts.csswg.org/cssom/#css-property-to-idl-attribute
def camel_case(chars, webkit_prefixed=False):
if webkit_prefixed:
chars = chars[1:]
next_is_uppercase = False
for c in chars:
if c == '-':
next_is_uppercase = True
elif next_is_uppercase:
next_is_uppercase = False
# Should be ASCII-uppercase, but all non-custom CSS property names are within ASCII
yield c.upper()
else:
yield c


if __name__ == '__main__':
main()
@@ -3344,7 +3344,7 @@ def withExtendedAttributes(self, attrs):
[self.location, attribute.location])
assert not self.nullable()
if not attribute.hasValue():
raise WebIDLError("[TreatNullAs] must take an identifier argument"
raise WebIDLError("[TreatNullAs] must take an identifier argument",
[attribute.location])
value = attribute.value()
if value != 'EmptyString':
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.