Chromium Code Reviews| Index: tools/dom/templates/html/impl/impl_CSSStyleDeclaration.darttemplate |
| diff --git a/tools/dom/templates/html/impl/impl_CSSStyleDeclaration.darttemplate b/tools/dom/templates/html/impl/impl_CSSStyleDeclaration.darttemplate |
| index 984f10d488dc72090da58ce0bfdccd9eed6f7568..192e95992f7ca8114a24526fb7a04728c1a0c7d0 100644 |
| --- a/tools/dom/templates/html/impl/impl_CSSStyleDeclaration.darttemplate |
| +++ b/tools/dom/templates/html/impl/impl_CSSStyleDeclaration.darttemplate |
| @@ -4,7 +4,8 @@ |
| part of $LIBRARYNAME; |
| -$(ANNOTATIONS)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { |
| +$(ANNOTATIONS)$(CLASS_MODIFIERS) class $CLASSNAME $EXTENDS with |
| + $(CLASSNAME)Mixin $IMPLEMENTS$NATIVESPEC { |
| factory $CLASSNAME() => new CssStyleDeclaration.css(''); |
| factory $CLASSNAME.css(String css) { |
| @@ -12,9 +13,44 @@ $(ANNOTATIONS)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { |
| style.cssText = css; |
| return style; |
| } |
| +} |
| -$!MEMBERS |
| +/** |
| + * A collection of [CssStyleDeclaration]s that are associated with an |
| + * [ElementList]. |
| + * |
| + * Grouping the style objects all together provides easy editing of specific |
| + * properties of a collection of elements. Setting a specific property value |
| + * will set that property in all [Element]s in the [ElementList]. Getting a |
| + * specific property value will return the value of the property of the first |
| + * element in the [ElementList]. |
| + */ |
| +class $(CLASSNAME)Set $EXTENDS with $(CLASSNAME)Mixin { |
|
blois
2013/07/30 00:45:18
I don't think that this one should extend Intercep
|
| + final Iterable<Element> _elementIterable; |
| + Iterable<$(CLASSNAME)> _elementCssStyleDeclarationSetIterable; |
| + |
| + $(CLASSNAME)Set._(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 $(CLASSNAME)Mixin { |
| +$!MEMBERS |
| String getPropertyValue(String propertyName) { |
|
blois
2013/07/30 00:45:18
This should probably be on the single element one,
|
| var propValue = _getPropertyValue(propertyName); |
| return propValue != null ? propValue : ''; |