Skip to content

Commit

Permalink
Add static atoms for CSS properties from Gecko
Browse files Browse the repository at this point in the history
  • Loading branch information
upsuper committed Nov 3, 2016
1 parent eb3bbc6 commit e8a3d93
Show file tree
Hide file tree
Showing 2 changed files with 2,901 additions and 7 deletions.
26 changes: 19 additions & 7 deletions components/style/binding_tools/regen_atoms.py
Expand Up @@ -32,14 +32,14 @@ def msvc32_symbolify(source, ident):


class GkAtomSource:
PATTERN = re.compile('^GK_ATOM\((.+),\s*"(.*)"\)')
PATTERN = re.compile('^GK_ATOM\((?P<ident>.+),\s*"(?P<value>.*)"\)', re.M)
FILE = "dist/include/nsGkAtomList.h"
CLASS = "nsGkAtoms"
TYPE = "nsIAtom"


class CSSPseudoElementsAtomSource:
PATTERN = re.compile('^CSS_PSEUDO_ELEMENT\((.+),\s*"(.*)",')
PATTERN = re.compile('^CSS_PSEUDO_ELEMENT\((?P<ident>.+),\s*"(?P<value>.*)",', re.M)
FILE = "dist/include/nsCSSPseudoElementList.h"
CLASS = "nsCSSPseudoElements"
# NB: nsICSSPseudoElement is effectively the same as a nsIAtom, but we need
Expand All @@ -48,16 +48,24 @@ class CSSPseudoElementsAtomSource:


class CSSAnonBoxesAtomSource:
PATTERN = re.compile('^CSS_ANON_BOX\((.+),\s*"(.*)"\)')
PATTERN = re.compile('^CSS_ANON_BOX\((?P<ident>.+),\s*"(?P<value>.*)"\)', re.M)
FILE = "dist/include/nsCSSAnonBoxList.h"
CLASS = "nsCSSAnonBoxes"
TYPE = "nsICSSAnonBoxPseudo"


class CSSPropsAtomSource:
PATTERN = re.compile('^CSS_PROP_[A-Z]+\(\s*(?P<value>[^,]+),\s*(?P<ident>[^,]+)', re.M)
FILE = "dist/include/nsCSSPropList.h"
CLASS = "nsCSSProps"
TYPE = "nsICSSProperty"


SOURCES = [
GkAtomSource,
CSSPseudoElementsAtomSource,
CSSAnonBoxesAtomSource,
CSSPropsAtomSource,
]


Expand Down Expand Up @@ -95,10 +103,14 @@ def collect_atoms(objdir):
atoms = []
for source in SOURCES:
with open(os.path.join(objdir, source.FILE)) as f:
for line in f.readlines():
result = re.match(source.PATTERN, line)
if result:
atoms.append(Atom(source, result.group(1), result.group(2)))
content = f.read()
found = set()
for match in source.PATTERN.finditer(content):
ident = match.group('ident')
if ident in found:
continue
found.add(ident)
atoms.append(Atom(source, ident, match.group('value')))
return atoms


Expand Down

0 comments on commit e8a3d93

Please sign in to comment.