summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2013-02-06 14:25:20 +0000
committerVaadin Code Review <review@vaadin.com>2013-02-06 14:25:20 +0000
commit405333067b1127e2dc7510cb248a4304fb436959 (patch)
treee7ac5a81bd0be680de96cf35fc3ca09f084c4e52
parent01ee88c00763e2bbe95e407a387170aa6b982540 (diff)
parentcd49f193b5de7d8fb344ba3aa5ea078dac1c1975 (diff)
downloadvaadin-framework-405333067b1127e2dc7510cb248a4304fb436959.tar.gz
vaadin-framework-405333067b1127e2dc7510cb248a4304fb436959.zip
Merge "Optimize stylename handling in AbstractComponentConnector (#10937)" into 7.0
-rw-r--r--client/src/com/vaadin/client/ui/AbstractComponentConnector.java31
1 files changed, 12 insertions, 19 deletions
diff --git a/client/src/com/vaadin/client/ui/AbstractComponentConnector.java b/client/src/com/vaadin/client/ui/AbstractComponentConnector.java
index 5890a9a5db..c22bd0905c 100644
--- a/client/src/com/vaadin/client/ui/AbstractComponentConnector.java
+++ b/client/src/com/vaadin/client/ui/AbstractComponentConnector.java
@@ -19,6 +19,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Set;
+import com.google.gwt.core.client.JsArrayString;
import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.ui.Focusable;
import com.google.gwt.user.client.ui.HasEnabled;
@@ -60,7 +61,7 @@ public abstract class AbstractComponentConnector extends AbstractConnector
* The style names from getState().getStyles() which are currently applied
* to the widget.
*/
- protected List<String> styleNames = new ArrayList<String>();
+ private JsArrayString styleNames = JsArrayString.createArray().cast();
/**
* Default constructor
@@ -286,33 +287,25 @@ public abstract class AbstractComponentConnector extends AbstractConnector
// add additional user defined style names as class names, prefixed with
// component default class name. remove nonexistent style names.
- if (ComponentStateUtil.hasStyles(state)) {
- // Remove all old stylenames
- for (String oldStyle : styleNames) {
- setWidgetStyleName(oldStyle, false);
- setWidgetStyleNameWithPrefix(primaryStyleName + "-", oldStyle,
- false);
- }
+ // Remove all old stylenames
+ for (int i = 0; i < styleNames.length(); i++) {
+ String oldStyle = styleNames.get(i);
+ setWidgetStyleName(oldStyle, false);
+ setWidgetStyleNameWithPrefix(primaryStyleName + "-", oldStyle,
+ false);
+ }
+ styleNames.setLength(0);
+ if (ComponentStateUtil.hasStyles(state)) {
// add new style names
for (String newStyle : state.styles) {
setWidgetStyleName(newStyle, true);
setWidgetStyleNameWithPrefix(primaryStyleName + "-", newStyle,
true);
+ styleNames.push(newStyle);
}
- styleNames.clear();
- styleNames.addAll(state.styles);
-
- } else {
- // remove all old style names
- for (String oldStyle : styleNames) {
- setWidgetStyleName(oldStyle, false);
- setWidgetStyleNameWithPrefix(primaryStyleName + "-", oldStyle,
- false);
- }
- styleNames.clear();
}
}