6"""Generates CssStyleDeclaration extension with all property getters and setters
7from css property definitions defined in WebKit."""
11COMMENT_LINE_PREFIX =
' * '
12SOURCE_PATH =
'CSSPropertyNames.in'
13OUTPUT_FILE =
'prototype_css_properties.dart'
19 'cssProperties.CSS21.txt',
20 'cssProperties.ie9.txt',
21 'cssProperties.ie10.txt',
22 'cssProperties.ie11.txt',
23 'cssProperties.ff36.txt',
24 'cssProperties.chrome40.txt',
25 'cssProperties.safari-7.1.3.txt',
26 'cssProperties.mobileSafari-8.2.txt',
27 'cssProperties.iPad4Air.onGoogleSites.txt',
34 @SupportedBrowser(SupportedBrowser.CHROME)
35 @SupportedBrowser(SupportedBrowser.FIREFOX)
36 @SupportedBrowser(SupportedBrowser.IE, '10')
37 @SupportedBrowser(SupportedBrowser.SAFARI)'''
51 """Convert a CSS property name to a lowerCamelCase name."""
52 name = name.replace(
'-webkit-',
'')
54 for word
in name.split(
'-'):
56 words.append(word.title())
65 return '-' + match.group(0).
lower()
67 return re.sub(
r'[A-Z]', fix, camelName)
71 return line.strip() ==
'' or line.startswith(
'#')
or line.startswith(
'//')
82 data = [d.strip()
for d
in data
if not isCommentLine(d)
and not '=' in d]
85 universal_properties = set.intersection(*browser_props)
86 universal_properties = universal_properties.difference([
'cssText'])
87 universal_properties = universal_properties.intersection(
88 list(
map(camelCaseName, data)))
90 output_file = open(OUTPUT_FILE,
'w')
92/// Exposing all the extra CSS property getters and setters.
94library dart.css_properties;
96import 'dart:_js_annotations';
97import 'dart:_js_bindings' as js_bindings;
98import 'dart:html_common';
102class CssStyleDeclaration implements js_bindings.CSSStyleDeclaration {}
104extension CssStyleDeclarationView on CssStyleDeclaration {
105 // dart:html requires a `String?` type for `value`.
106 external Object setProperty(String property, String? value,
107 [String? priority =
'']);
112 for camelName
in sorted(universal_properties):
114 output_file.write(
"""
115 /** Gets the value of "%s" */
116 String get %s => this._%s;
118 /** Sets the value of
"%s" */
119 set %
s(String? value) {
120 _%s = value == null ?
'' : value;
124 external String get _%s;
127 external set _%
s(String value);
128 """ % (property, camelName, camelName, property, camelName, camelName,
129 camelName, camelName, camelName, camelName))
131 output_file.write("""
140 for prop
in sorted(data, key=camelCaseName):
142 upper_camel_case_name = camel_case_name[0].upper() + camel_case_name[1:]
143 css_name = prop.replace(
'-webkit-',
'')
144 base_css_name = prop.replace(
'-webkit-',
'')
146 if base_css_name
in seen
or base_css_name.startswith(
147 '-internal')
or camel_case_name
in universal_properties:
149 seen.add(base_css_name)
151 comment =
' /** %s the value of "' + base_css_name +
'" */'
152 property_lines.append(
'\n')
153 property_lines.append(comment %
'Gets')
154 if base_css_name
in annotated:
155 property_lines.append(annotated[base_css_name])
156 property_lines.append(
"""
158 getPropertyValue('%s');
160""" % (camel_case_name, css_name))
162 property_lines.append(comment % 'Sets')
163 if base_css_name
in annotated:
164 property_lines.append(annotated[base_css_name])
165 property_lines.append(
"""
166 set %s(String value) {
167 setProperty('%s', value,
'');
169""" % (camel_case_name, css_name))
171 output_file.write(''.
join(property_lines))
172 output_file.write(
'}\n')
176if __name__ ==
'__main__':
def __init__(self, message)
static void readlines(const void *data, size_t size, F f)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not set
def readCssProperties(filename)
def dashifyName(camelName)
SI auto map(std::index_sequence< I... >, Fn &&fn, const Args &... args) -> skvx::Vec< sizeof...(I), decltype(fn(args[0]...))>
static SkString join(const CommandLineFlags::StringArray &)