diff options
author | Leif Åstrand <leif@vaadin.com> | 2013-02-05 13:16:04 +0200 |
---|---|---|
committer | Leif Åstrand <leif@vaadin.com> | 2013-02-06 16:24:48 +0200 |
commit | cd49f193b5de7d8fb344ba3aa5ea078dac1c1975 (patch) | |
tree | 4ba64a38c59d2768acd7fb9a0aac06decf861605 /client/src | |
parent | 216e557e11dae53ba352dfed59b510b840db8d5b (diff) | |
download | vaadin-framework-cd49f193b5de7d8fb344ba3aa5ea078dac1c1975.tar.gz vaadin-framework-cd49f193b5de7d8fb344ba3aa5ea078dac1c1975.zip |
Optimize stylename handling in AbstractComponentConnector (#10937)
Change-Id: I91b05d0d794a2809c13f5f68d73eddb9f4c0a641
Diffstat (limited to 'client/src')
-rw-r--r-- | client/src/com/vaadin/client/ui/AbstractComponentConnector.java | 31 |
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(); } } |