"Reverting 38996"

TBR because we need CSSPropertyNames.in from DEPS

BUG=

Review URL: https://codereview.chromium.org//451563005

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@38997 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
efortuna@google.com 2014-08-07 17:12:12 +00:00
parent 19c379afd9
commit ceea5ab278
10 changed files with 2154 additions and 2140 deletions

View file

@ -573,8 +573,6 @@ class BlinkCSSStyleDeclaration {
static $parentRule_Getter(mthis) native "CSSStyleDeclaration_parentRule_Getter";
static $__propertyQuery___Callback(mthis, name) native "CSSStyleDeclaration___propertyQuery___Callback_RESOLVER_STRING_1_DOMString";
static $__setter___Callback(mthis, propertyName, propertyValue) native "CSSStyleDeclaration___setter___Callback";
static $getPropertyPriority_Callback(mthis, propertyName) native "CSSStyleDeclaration_getPropertyPriority_Callback_RESOLVER_STRING_1_DOMString";
@ -8383,4 +8381,4 @@ class Blink_DOMStringMap {
static remove(_DOMStringMap, key) native "DOMStringMap_remove_Callback";
static get_keys(_DOMStringMap) native "DOMStringMap_getKeys_Callback";
}
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -150,11 +150,4 @@ main() {
elements = document.queryAll('li');
expect(elements.style.borderLeftWidth, equals('10px'));
});
test('supports property', () {
expect(document.body.style.supportsProperty('bogus-property'), false);
expect(document.body.style.supportsProperty('background'), true);
expect(document.body.style.supportsProperty('borderBottomWidth'), true);
expect(document.body.style.supportsProperty('animation'), true);
});
}

View file

@ -606,9 +606,6 @@
"__getter__": {
"support_level": "untriaged"
},
"__propertyQuery__": {
"support_level": "untriaged"
},
"__setter__": {},
"cssText": {},
"getPropertyCSSValue": {
@ -12171,9 +12168,6 @@
},
"Timing": {
"members": {
"__getter__": {
"support_level": "untriaged"
},
"__setter__": {
"support_level": "untriaged"
},

View file

@ -485,9 +485,4 @@ interface Screen {
[Suppressed] readonly attribute AudioParam gain;
};
[Supplemental]
interface CSSStyleDeclaration {
[Supplemental] boolean __propertyQuery__(DOMString name);
};
Element implements GlobalEventHandlers;

View file

@ -1,28 +1,28 @@
#!/usr/bin/python
#!/usr/bin/python2.6
#
# Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
# Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE file.
"""Generates CSSStyleDeclaration template file from css property definitions
defined in WebKit."""
"""Generates CSSStyleDeclaration from css property definitions defined in WebKit."""
import tempfile, os
COMMENT_LINE_PREFIX = ' * '
# TODO(efortuna): Pull from DEPS so that we have latest css *in sync* with our
# Dartium. Then remove the checked in CSSPropertyNames.in.
SOURCE_PATH = 'CSSPropertyNames.in'
#SOURCE_PATH = 'Source/WebCore/css/CSSPropertyNames.in'
TEMPLATE_FILE = '../templates/html/impl/impl_CSSStyleDeclaration.darttemplate'
SOURCE_PATH = 'Source/WebCore/css/CSSPropertyNames.in'
INPUT_URL = 'http://trac.webkit.org/export/latest/trunk/%s' % SOURCE_PATH
INTERFACE_FILE = '../../html/src/CSSStyleDeclaration.dart'
CLASS_FILE = '../../html/src/CSSStyleDeclarationWrappingImplementation.dart'
# Supported annotations for any specific CSS properties.
annotated = {
'transition': '''@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.FIREFOX)
@SupportedBrowser(SupportedBrowser.IE, '10')
@SupportedBrowser(SupportedBrowser.SAFARI)'''
}
def main():
_, css_names_file = tempfile.mkstemp('.CSSPropertyNames.in')
try:
if os.system('wget %s -O %s' % (INPUT_URL, css_names_file)):
return 1
generate_code(css_names_file)
print 'Successfully generated %s and %s' % (INTERFACE_FILE, CLASS_FILE)
finally:
os.remove(css_names_file)
def camelCaseName(name):
"""Convert a CSS property name to a lowerCamelCase name."""
@ -35,196 +35,165 @@ def camelCaseName(name):
words.append(word)
return ''.join(words)
def GenerateCssTemplateFile():
data = open(SOURCE_PATH).readlines()
def generate_code(input_path):
data = open(input_path).readlines()
# filter CSSPropertyNames.in to only the properties
# TODO(efortuna): do we also want CSSPropertyNames.in?
data = [d[:-1] for d in data
if len(d) > 1
and not d.startswith('#')
and not d.startswith('//')
and not '=' in d]
class_file = open(TEMPLATE_FILE, 'w')
interface_file = open(INTERFACE_FILE, 'w')
class_file = open(CLASS_FILE, 'w')
class_file.write("""
// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
interface_file.write("""
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// WARNING: DO NOT EDIT THIS TEMPLATE FILE.
// The template file was generated by scripts/css_code_generator.py
// WARNING: Do not edit.
// This file was generated by html/scripts/css_code_generator.py
// Source of CSS properties:
// %s
part of $LIBRARYNAME;
// TODO(jacobr): add versions that take numeric values in px, miliseconds, etc.
$(ANNOTATIONS)$(NATIVESPEC)$(CLASS_MODIFIERS) class $CLASSNAME $EXTENDS with
$(CLASSNAME)Base $IMPLEMENTS {
factory $CLASSNAME() => new CssStyleDeclaration.css('');
interface CSSStyleDeclaration {
factory $CLASSNAME.css(String css) {
final style = new Element.tag('div').style;
style.cssText = css;
return style;
String get cssText;
void set cssText(String value);
int get length;
CSSRule get parentRule;
CSSValue getPropertyCSSValue(String propertyName);
String getPropertyPriority(String propertyName);
String getPropertyShorthand(String propertyName);
String getPropertyValue(String propertyName);
bool isPropertyImplicit(String propertyName);
String item(int index);
String removeProperty(String propertyName);
void setProperty(String propertyName, String value, [String priority]);
""".lstrip() % SOURCE_PATH)
class_file.write("""
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// WARNING: Do not edit.
// This file was generated by html/scripts/css_code_generator.py
// Source of CSS properties:
// %s
// TODO(jacobr): add versions that take numeric values in px, miliseconds, etc.
class CSSStyleDeclarationWrappingImplementation extends DOMWrapperBase implements CSSStyleDeclaration {
static String _cachedBrowserPrefix;
CSSStyleDeclarationWrappingImplementation._wrap(ptr) : super._wrap(ptr) {}
static String get _browserPrefix {
if (_cachedBrowserPrefix == null) {
if (_Device.isFirefox) {
_cachedBrowserPrefix = '-moz-';
} else {
_cachedBrowserPrefix = '-webkit-';
}
// TODO(jacobr): support IE 9.0 and Opera as well.
}
return _cachedBrowserPrefix;
}
String get cssText { return _ptr.cssText; }
void set cssText(String value) { _ptr.cssText = value; }
int get length { return _ptr.length; }
CSSRule get parentRule { return LevelDom.wrapCSSRule(_ptr.parentRule); }
CSSValue getPropertyCSSValue(String propertyName) {
return LevelDom.wrapCSSValue(_ptr.getPropertyCSSValue(propertyName));
}
String getPropertyPriority(String propertyName) {
return _ptr.getPropertyPriority(propertyName);
}
String getPropertyShorthand(String propertyName) {
return _ptr.getPropertyShorthand(propertyName);
}
String getPropertyValue(String propertyName) {
var propValue = _getPropertyValueHelper(propertyName);
return propValue != null ? propValue : '';
return _ptr.getPropertyValue(propertyName);
}
String _getPropertyValueHelper(String propertyName) {
if (_supportsProperty(_camelCase(propertyName))) {
return _getPropertyValue(propertyName);
} else {
return _getPropertyValue(Device.cssPrefix + propertyName);
}
bool isPropertyImplicit(String propertyName) {
return _ptr.isPropertyImplicit(propertyName);
}
/**
* Returns true if the provided *CSS* property name is supported on this
* element.
*
* Please note the property name camelCase, not-hyphens. This
* method returns true if the property is accessible via an unprefixed _or_
* prefixed property.
*/
bool supportsProperty(String propertyName) {
return _supportsProperty(propertyName) ||
_supportsProperty(_camelCase(Device.cssPrefix + propertyName));
String item(int index) {
return _ptr.item(index);
}
bool _supportsProperty(String propertyName) {
$if DART2JS
return JS('bool', '# in #', propertyName, this);
$else
// You can't just check the value of a property, because there is no way
// to distinguish between property not being present in the browser and
// not having a value at all. (Ultimately we'll want the native method to
// return null if the property doesn't exist and empty string if it's
// defined but just doesn't have a value.
return _hasProperty(propertyName);
$endif
}
$if DARTIUM
bool _hasProperty(String propertyName) =>
_blink.BlinkCSSStyleDeclaration.$__propertyQuery___Callback(this, propertyName);
$endif
@DomName('CSSStyleDeclaration.setProperty')
void setProperty(String propertyName, String value, [String priority]) {
if (_supportsProperty(_camelCase(propertyName))) {
return _setPropertyHelper(propertyName, value, priority);
} else {
return _setPropertyHelper(Device.cssPrefix + propertyName, value,
priority);
}
String removeProperty(String propertyName) {
return _ptr.removeProperty(propertyName);
}
String _camelCase(String hyphenated) {
bool firstWord = true;
return hyphenated.splitMapJoin('-', onMatch : (_) => '',
onNonMatch : (String word) {
if (word.length > 0) {
if (firstWord) {
firstWord = false;
return word;
}
return word[0].toUpperCase() + word.substring(1);
}
return '';
});
void setProperty(String propertyName, String value, [String priority = '']) {
_ptr.setProperty(propertyName, value, priority);
}
$if DART2JS
void _setPropertyHelper(String propertyName, String value, [String priority]) {
// try/catch for IE9 which throws on unsupported values.
try {
if (value == null) value = '';
if (priority == null) {
priority = '';
}
JS('void', '#.setProperty(#, #, #)', this, propertyName, value, priority);
// Bug #2772, IE9 requires a poke to actually apply the value.
if (JS('bool', '!!#.setAttribute', this)) {
JS('void', '#.setAttribute(#, #)', this, propertyName, value);
}
} catch (e) {}
}
String get typeName { return "CSSStyleDeclaration"; }
/**
* Checks to see if CSS Transitions are supported.
*/
static bool get supportsTransitions {
return supportsProperty('transition');
}
$else
void _setPropertyHelper(String propertyName, String value, [String priority]) {
if (priority == null) {
priority = '';
}
_setProperty(propertyName, value, priority);
}
/**
* Checks to see if CSS Transitions are supported.
*/
static bool get supportsTransitions => true;
$endif
$!MEMBERS
}
class _CssStyleDeclarationSet extends Object with CssStyleDeclarationBase {
final Iterable<Element> _elementIterable;
Iterable<CssStyleDeclaration> _elementCssStyleDeclarationSetIterable;
_CssStyleDeclarationSet(this._elementIterable) {
_elementCssStyleDeclarationSetIterable = new List.from(
_elementIterable).map((e) => e.style);
}
String getPropertyValue(String propertyName) =>
_elementCssStyleDeclarationSetIterable.first.getPropertyValue(
propertyName);
void setProperty(String propertyName, String value, [String priority]) {
_elementCssStyleDeclarationSetIterable.forEach((e) =>
e.setProperty(propertyName, value, priority));
}
// Important note: CssStyleDeclarationSet does NOT implement every method
// available in CssStyleDeclaration. Some of the methods don't make so much
// sense in terms of having a resonable value to return when you're
// considering a list of Elements. You will need to manually add any of the
// items in the MEMBERS set if you want that functionality.
}
abstract class CssStyleDeclarationBase {
String getPropertyValue(String propertyName);
void setProperty(String propertyName, String value, [String priority]);
""" % SOURCE_PATH)
""".lstrip() % SOURCE_PATH)
interface_lines = [];
class_lines = [];
seen = set()
for prop in sorted(data, key=lambda p: camelCaseName(p)):
camel_case_name = camelCaseName(prop)
upper_camel_case_name = camel_case_name[0].upper() + camel_case_name[1:];
css_name = prop.replace('-webkit-', '')
css_name = prop.replace('-webkit-', '${_browserPrefix}')
base_css_name = prop.replace('-webkit-', '')
if base_css_name in seen or base_css_name.startswith('-internal'):
if base_css_name in seen:
continue
seen.add(base_css_name)
comment = ' /** %s the value of "' + base_css_name + '" */'
interface_lines.append(comment % 'Gets')
interface_lines.append("""
String get %s;
""" % camel_case_name)
interface_lines.append(comment % 'Sets')
interface_lines.append("""
void set %s(String value);
""" % camel_case_name)
class_lines.append('\n');
class_lines.append(comment % 'Gets')
if base_css_name in annotated:
class_lines.append(annotated[base_css_name])
class_lines.append("""
String get %s =>
getPropertyValue('%s');
@ -232,14 +201,19 @@ abstract class CssStyleDeclarationBase {
""" % (camel_case_name, css_name))
class_lines.append(comment % 'Sets')
if base_css_name in annotated:
class_lines.append(annotated[base_css_name])
class_lines.append("""
void set %s(String value) {
setProperty('%s', value, '');
}
""" % (camel_case_name, css_name))
interface_file.write(''.join(interface_lines));
interface_file.write('}\n')
interface_file.close()
class_file.write(''.join(class_lines));
class_file.write('}\n')
class_file.close()
if __name__ == '__main__':
main()

View file

@ -5,7 +5,6 @@
"""This is the entry point to create Dart APIs from the IDL database."""
import css_code_generator
import dartgenerator
import database
import fremontcutbuilder
@ -164,12 +163,6 @@ def GenerateSingleFile(library_path, output_dir, generated_output_dir=None):
copy_dart_script, output_dir, library_filename])
subprocess.call([command], shell=True)
def UpdateCssProperties():
"""Regenerate the CssStyleDeclaration template file with the current CSS
properties."""
_logger.info('Updating Css Properties.')
css_code_generator.GenerateCssTemplateFile()
def main():
parser = optparse.OptionParser()
parser.add_option('--parallel', dest='parallel',
@ -217,7 +210,6 @@ def main():
if 'htmldartium' in systems:
dartium_output_dir = os.path.join(output_dir, 'dartium')
UpdateCssProperties()
if options.rebuild:
# Parse the IDL and create the database.
database = fremontcutbuilder.main(options.parallel)

View file

@ -53,7 +53,6 @@ _js_custom_members = monitored.Set('systemhtml._js_custom_members', [
'ConsoleBase.warn',
'WebKitCSSKeyframesRule.insertRule',
'CSSStyleDeclaration.setProperty',
'CSSStyleDeclaration.__propertyQuery__',
'Document.createNodeIterator',
'Document.createTreeWalker',
'DOMException.name',