Skip to content

Commit a8cc073

Browse files
committed
Bug 1452542 part 6 - Replace uses of PythonCSSProps.h with the data file generated from Servo. r=froydnj
Some content in Makefile.in is removed because after this change, the scripts no longer invoke the preprocessor and thus don't have unknown dependencies anymore outside what is provided in their inputs array. The order of exports.PREFERENCES in properties-db changes because the data file has shorthands placed after longhands. The only usage of it is in test_css-properties-db.js which doesn't care about the order. MozReview-Commit-ID: AMjzTRf2HYN --HG-- extra : rebase_source : 7976e48e7c7bba467d77a34ab0d7709cde1ecdf4
1 parent 113e4d2 commit a8cc073

File tree

10 files changed

+42
-137
lines changed

10 files changed

+42
-137
lines changed

config/recurse.mk

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@ widget/android/bindings/export: build/annotationProcessors/export
171171
# .xpt generation needs the xpidl lex/yacc files
172172
xpcom/xpidl/export: xpcom/idl-parser/xpidl/export
173173

174+
# CSS2Properties.webidl needs ServoCSSPropList.py from layout/style
175+
dom/bindings/export: layout/style/export
176+
174177
ifdef ENABLE_CLANG_PLUGIN
175178
$(filter-out config/host build/unix/stdc++compat/% build/clang-plugin/%,$(compile_targets)): build/clang-plugin/target build/clang-plugin/tests/target
176179
build/clang-plugin/tests/target: build/clang-plugin/target

devtools/shared/css/generated/mach_commands.py

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -50,32 +50,17 @@ def generate_css_db(self):
5050

5151
def get_preferences(self):
5252
"""Get all of the preferences associated with enabling and disabling a property."""
53-
# Build the command to run the preprocessor on PythonCSSProps.h
54-
headerPath = resolve_path(self.topsrcdir, 'layout/style/PythonCSSProps.h')
55-
56-
cpp = self.substs['CPP']
57-
58-
if not cpp:
59-
print("Unable to find the cpp program. Please do a full, nonartifact")
60-
print("build and try this again.")
61-
sys.exit(1)
62-
63-
if type(cpp) is list:
64-
cmd = cpp
65-
else:
66-
cmd = shellutil.split(cpp)
67-
cmd += shellutil.split(self.substs['ACDEFINES'])
68-
cmd.append(headerPath)
69-
70-
# The preprocessed list takes the following form:
53+
# The data takes the following form:
7154
# [ (name, prop, id, flags, pref, proptype), ... ]
72-
preprocessed = eval(subprocess.check_output(cmd))
55+
dataPath = resolve_path(self.topobjdir, 'layout/style/ServoCSSPropList.py')
56+
with open(dataPath, "r") as f:
57+
data = eval(f.read())
7358

7459
# Map this list
7560
# (name, prop, id, flags, pref, proptype) => (name, pref)
7661
preferences = [
7762
(name, pref)
78-
for name, prop, id, flags, pref, proptype in preprocessed
63+
for name, prop, id, flags, pref, proptype in data
7964
if 'CSS_PROPERTY_INTERNAL' not in flags and pref]
8065

8166
return preferences

devtools/shared/css/generated/properties-db.js

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9479,10 +9479,6 @@ exports.PSEUDO_ELEMENTS = [
94799479
* exposed for testing purposes.
94809480
*/
94819481
exports.PREFERENCES = [
9482-
[
9483-
"all",
9484-
"layout.css.all-shorthand.enabled"
9485-
],
94869482
[
94879483
"background-blend-mode",
94889484
"layout.css.background-blend-mode.enabled"
@@ -9531,10 +9527,6 @@ exports.PREFERENCES = [
95319527
"-moz-osx-font-smoothing",
95329528
"layout.css.osx-font-smoothing.enabled"
95339529
],
9534-
[
9535-
"overflow-clip-box",
9536-
"layout.css.overflow-clip-box.enabled"
9537-
],
95389530
[
95399531
"overflow-clip-box-block",
95409532
"layout.css.overflow-clip-box.enabled"
@@ -9543,10 +9535,6 @@ exports.PREFERENCES = [
95439535
"overflow-clip-box-inline",
95449536
"layout.css.overflow-clip-box.enabled"
95459537
],
9546-
[
9547-
"overscroll-behavior",
9548-
"layout.css.overscroll-behavior.enabled"
9549-
],
95509538
[
95519539
"overscroll-behavior-x",
95529540
"layout.css.overscroll-behavior.enabled"
@@ -9583,10 +9571,6 @@ exports.PREFERENCES = [
95839571
"scroll-snap-points-y",
95849572
"layout.css.scroll-snap.enabled"
95859573
],
9586-
[
9587-
"scroll-snap-type",
9588-
"layout.css.scroll-snap.enabled"
9589-
],
95909574
[
95919575
"scroll-snap-type-x",
95929576
"layout.css.scroll-snap.enabled"
@@ -9615,10 +9599,6 @@ exports.PREFERENCES = [
96159599
"text-justify",
96169600
"layout.css.text-justify.enabled"
96179601
],
9618-
[
9619-
"-webkit-text-stroke",
9620-
"layout.css.prefixes.webkit"
9621-
],
96229602
[
96239603
"-webkit-text-stroke-color",
96249604
"layout.css.prefixes.webkit"
@@ -9639,6 +9619,26 @@ exports.PREFERENCES = [
96399619
"translate",
96409620
"layout.css.individual-transform.enabled"
96419621
],
9622+
[
9623+
"all",
9624+
"layout.css.all-shorthand.enabled"
9625+
],
9626+
[
9627+
"overflow-clip-box",
9628+
"layout.css.overflow-clip-box.enabled"
9629+
],
9630+
[
9631+
"overscroll-behavior",
9632+
"layout.css.overscroll-behavior.enabled"
9633+
],
9634+
[
9635+
"scroll-snap-type",
9636+
"layout.css.scroll-snap.enabled"
9637+
],
9638+
[
9639+
"-webkit-text-stroke",
9640+
"layout.css.prefixes.webkit"
9641+
],
96429642
[
96439643
"-moz-animation",
96449644
"layout.css.prefixes.animations"

dom/bindings/GenerateCSS2PropertiesWebIDL.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,18 @@
55
import sys
66
import string
77
import argparse
8-
import subprocess
9-
import buildconfig
10-
from mozbuild import shellutil
118

129
# Generates a line of WebIDL with the given spelling of the property name
1310
# (whether camelCase, _underscorePrefixed, etc.) and the given array of
1411
# extended attributes.
1512
def generateLine(propName, extendedAttrs):
1613
return " [%s] attribute DOMString %s;\n" % (", ".join(extendedAttrs),
1714
propName)
18-
def generate(output, idlFilename, preprocessorHeader):
19-
cpp = list(buildconfig.substs['CPP'])
20-
cpp += shellutil.split(buildconfig.substs['ACDEFINES'])
21-
cpp.append(preprocessorHeader)
22-
preprocessed = subprocess.check_output(cpp)
23-
24-
propList = eval(preprocessed)
15+
def generate(output, idlFilename, dataFile):
16+
with open(dataFile, "r") as f:
17+
propList = eval(f.read())
2518
props = ""
26-
for [name, prop, id, flags, pref, proptype] in propList:
19+
for name, prop, id, flags, pref, proptype in propList:
2720
if "CSS_PROPERTY_INTERNAL" in flags:
2821
continue
2922
# Unfortunately, even some of the getters here are fallible

dom/bindings/Makefile.in

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,6 @@ CPPSRCS += $(globalgen_sources) $(unified_binding_cpp_files)
1515

1616
include $(topsrcdir)/config/rules.mk
1717

18-
# TODO This list should be emitted to a .pp file via
19-
# GenerateCSS2PropertiesWebIDL.py (bug 1281614)
20-
css2properties_dependencies = \
21-
$(topsrcdir)/layout/style/nsCSSPropList.h \
22-
$(topsrcdir)/layout/style/nsCSSPropAliasList.h \
23-
$(webidl_base)/CSS2Properties.webidl.in \
24-
$(topsrcdir)/layout/style/PythonCSSProps.h \
25-
$(srcdir)/GenerateCSS2PropertiesWebIDL.py \
26-
$(GLOBAL_DEPS) \
27-
$(NULL)
28-
29-
CSS2Properties.webidl: $(css2properties_dependencies)
30-
3118
# Most of the logic for dependencies lives inside Python so it can be
3219
# used by multiple build backends. We simply have rules to generate
3320
# and include the .pp file.

dom/bindings/moz.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,5 +179,5 @@ if CONFIG['COMPILE_ENVIRONMENT']:
179179
css_props.script = 'GenerateCSS2PropertiesWebIDL.py:generate'
180180
css_props.inputs = [
181181
'/dom/webidl/CSS2Properties.webidl.in',
182-
'/layout/style/PythonCSSProps.h',
182+
'!/layout/style/ServoCSSPropList.py',
183183
]

layout/style/GenerateCSSPropsGenerated.py

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,13 @@
55
import sys
66
import string
77
import argparse
8-
import subprocess
9-
import buildconfig
10-
from mozbuild import shellutil
11-
12-
def get_properties(preprocessorHeader):
13-
cpp = list(buildconfig.substs['CPP'])
14-
cpp += shellutil.split(buildconfig.substs['ACDEFINES'])
15-
cpp.append(preprocessorHeader)
16-
preprocessed = subprocess.check_output(cpp)
8+
9+
def get_properties(dataFile):
10+
with open(dataFile, "r") as f:
11+
properties = eval(f.read())
1712
properties = [{"name":p[0], "prop":p[1], "id":p[2],
1813
"flags":p[3], "pref":p[4], "proptype":p[5]}
19-
for (i, p) in enumerate(eval(preprocessed))]
14+
for (i, p) in enumerate(properties)]
2015

2116
# Sort the list so that longhand properties are intermingled first,
2217
# shorthand properties follow, then aliases appear last.
@@ -57,7 +52,7 @@ def generate_idl_names(properties):
5752
def generate_assertions(properties):
5853
def enum(p):
5954
if p["proptype"] is "alias":
60-
return "eCSSPropertyAlias_%s" % p["id"]
55+
return "eCSSPropertyAlias_%s" % p["id"][0]
6156
else:
6257
return "eCSSProperty_%s" % p["id"]
6358
msg = ('static_assert(%s == %d, "GenerateCSSPropsGenerated.py did not list '
@@ -79,12 +74,12 @@ def generate_idl_name_positions(properties):
7974

8075
return ",\n".join(map(lambda (p, position): " %d" % position, ps))
8176

82-
def generate(output, cppTemplate, preprocessorHeader):
77+
def generate(output, cppTemplate, dataFile):
8378
cppFile = open(cppTemplate, "r")
8479
cppTemplate = cppFile.read()
8580
cppFile.close()
8681

87-
properties = get_properties(preprocessorHeader)
82+
properties = get_properties(dataFile)
8883
substitutions = {
8984
"idl_names": generate_idl_names(properties),
9085
"assertions": generate_assertions(properties),

layout/style/Makefile.in

Lines changed: 0 additions & 16 deletions
This file was deleted.

layout/style/PythonCSSProps.h

Lines changed: 0 additions & 42 deletions
This file was deleted.

layout/style/moz.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ if CONFIG['COMPILE_ENVIRONMENT']:
301301
css_props.script = 'GenerateCSSPropsGenerated.py:generate'
302302
css_props.inputs = [
303303
'nsCSSPropsGenerated.inc.in',
304-
'PythonCSSProps.h',
304+
'!ServoCSSPropList.py',
305305
]
306306

307307
CONFIGURE_SUBST_FILES += [

0 commit comments

Comments
 (0)