Revert trial commit of "CssStyleDeclaration performance work"

If all goes well, will be recommited after code review.

TBR=alanknight@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44932 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
sra@google.com 2015-04-07 01:52:05 +00:00
parent 440f677b46
commit f8fb9710ee
4 changed files with 48 additions and 87 deletions

View file

@ -3359,27 +3359,12 @@ class CssRule extends Interceptor {
@DomName('CSSStyleDeclaration.setProperty')
void setProperty(String propertyName, String value, [String priority]) {
return _setPropertyHelper(_browserPropertyName(propertyName),
value, priority);
}
String _browserPropertyName(String propertyName) {
String name = _readCache(propertyName);
if (name is String) return name;
if (_supportsProperty(_camelCase(propertyName))) {
name = propertyName;
return _setPropertyHelper(propertyName, value, priority);
} else {
name = Device.cssPrefix + propertyName;
return _setPropertyHelper(Device.cssPrefix + propertyName, value,
priority);
}
_writeCache(propertyName, name);
return name;
}
static final _propertyCache = JS('', '{}');
static String _readCache(String key) =>
JS('String|Null', '#[#]', _propertyCache, key);
static void _writeCache(String key, String value) {
JS('void', '#[#] = #', _propertyCache, key, value);
}
static String _camelCase(String hyphenated) {
@ -3391,9 +3376,18 @@ class CssRule extends Interceptor {
}
void _setPropertyHelper(String propertyName, String value, [String priority]) {
if (value == null) value = '';
if (priority == null) priority = '';
JS('void', '#.setProperty(#, #, #)', this, propertyName, value, 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) {}
}
/**

View file

@ -4284,25 +4284,14 @@ class CssRule extends NativeFieldWrapperClass2 {
@DomName('CSSStyleDeclaration.setProperty')
void setProperty(String propertyName, String value, [String priority]) {
return _setPropertyHelper(_browserPropertyName(propertyName),
value, priority);
}
String _browserPropertyName(String propertyName) {
String name = _readCache(propertyName);
if (name is String) return name;
if (_supportsProperty(_camelCase(propertyName))) {
name = propertyName;
return _setPropertyHelper(propertyName, value, priority);
} else {
name = Device.cssPrefix + propertyName;
return _setPropertyHelper(Device.cssPrefix + propertyName, value,
priority);
}
_writeCache(propertyName, name);
return name;
}
static String _readCache(String key) => null;
static void _writeCache(String key, value) {}
static String _camelCase(String hyphenated) {
// The "ms" prefix is always lowercased.
return hyphenated.replaceFirst(new RegExp('^-ms-'), 'ms-').replaceAllMapped(

View file

@ -117,34 +117,14 @@ $endif
@DomName('CSSStyleDeclaration.setProperty')
void setProperty(String propertyName, String value, [String priority]) {
return _setPropertyHelper(_browserPropertyName(propertyName),
value, priority);
}
String _browserPropertyName(String propertyName) {
String name = _readCache(propertyName);
if (name is String) return name;
if (_supportsProperty(_camelCase(propertyName))) {
name = propertyName;
return _setPropertyHelper(propertyName, value, priority);
} else {
name = Device.cssPrefix + propertyName;
return _setPropertyHelper(Device.cssPrefix + propertyName, value,
priority);
}
_writeCache(propertyName, name);
return name;
}
$if DART2JS
static final _propertyCache = JS('', '{}');
static String _readCache(String key) =>
JS('String|Null', '#[#]', _propertyCache, key);
static void _writeCache(String key, String value) {
JS('void', '#[#] = #', _propertyCache, key, value);
}
$else
static String _readCache(String key) => null;
static void _writeCache(String key, value) {}
$endif
static String _camelCase(String hyphenated) {
$if DART2JS
var replacedMs = JS('String', r'#.replace(/^-ms-/, "ms-")', hyphenated);
@ -162,9 +142,18 @@ $endif
$if DART2JS
void _setPropertyHelper(String propertyName, String value, [String priority]) {
if (value == null) value = '';
if (priority == null) priority = '';
JS('void', '#.setProperty(#, #, #)', this, propertyName, value, 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) {}
}
/**

View file

@ -67,34 +67,14 @@ $endif
@DomName('CSSStyleDeclaration.setProperty')
void setProperty(String propertyName, String value, [String priority]) {
return _setPropertyHelper(_browserPropertyName(propertyName),
value, priority);
}
String _browserPropertyName(String propertyName) {
String name = _readCache(propertyName);
if (name is String) return name;
if (_supportsProperty(_camelCase(propertyName))) {
name = propertyName;
return _setPropertyHelper(propertyName, value, priority);
} else {
name = Device.cssPrefix + propertyName;
return _setPropertyHelper(Device.cssPrefix + propertyName, value,
priority);
}
_writeCache(propertyName, name);
return name;
}
$if DART2JS
static final _propertyCache = JS('', '{}');
static String _readCache(String key) =>
JS('String|Null', '#[#]', _propertyCache, key);
static void _writeCache(String key, String value) {
JS('void', '#[#] = #', _propertyCache, key, value);
}
$else
static String _readCache(String key) => null;
static void _writeCache(String key, value) {}
$endif
static String _camelCase(String hyphenated) {
$if DART2JS
var replacedMs = JS('String', r'#.replace(/^-ms-/, "ms-")', hyphenated);
@ -112,9 +92,18 @@ $endif
$if DART2JS
void _setPropertyHelper(String propertyName, String value, [String priority]) {
if (value == null) value = '';
if (priority == null) priority = '';
JS('void', '#.setProperty(#, #, #)', this, propertyName, value, 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) {}
}
/**