Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Unified Diff: tools/dom/templates/html/impl/impl_CSSStyleDeclaration.darttemplate

Issue 21182002: Allow "bulk editing" of the CssStyleDeclaration objects in an ElementList as well (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/html/cssstyledeclaration_test.dart ('k') | tools/dom/templates/html/impl/impl_Element.darttemplate » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 : '';
« no previous file with comments | « tests/html/cssstyledeclaration_test.dart ('k') | tools/dom/templates/html/impl/impl_Element.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698