From 3826313b3485dc944e2ab40867936331374fa93d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Johannes=20Dahlstr=C3=B6m?= Date: Mon, 14 May 2012 08:57:13 +0000 Subject: [PATCH] #8716 Rewrite some CSS classname handling code to prevent overwriting v-scrollable svn changeset:23728/svn branch:6.8 --- .../vaadin/terminal/gwt/client/ui/VPanel.java | 55 ++++++++----------- 1 file changed, 23 insertions(+), 32 deletions(-) diff --git a/src/com/vaadin/terminal/gwt/client/ui/VPanel.java b/src/com/vaadin/terminal/gwt/client/ui/VPanel.java index f754addcf3..1b5c48283b 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VPanel.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VPanel.java @@ -8,6 +8,7 @@ import java.util.Set; import com.google.gwt.dom.client.DivElement; import com.google.gwt.dom.client.Document; +import com.google.gwt.dom.client.Style; import com.google.gwt.event.dom.client.DomEvent.Type; import com.google.gwt.event.shared.EventHandler; import com.google.gwt.event.shared.HandlerRegistration; @@ -159,44 +160,33 @@ public class VPanel extends SimplePanel implements Container, if (!uidl.hasAttribute("cached")) { // Handle caption displaying and style names, prior generics. - // Affects size - // calculations + // Affects size calculations + + final boolean hasCaption = uidl.hasAttribute("caption") + && !uidl.getStringAttribute("caption").equals(""); + + setCaption(hasCaption ? uidl.getStringAttribute("caption") : ""); // Restore default stylenames - contentNode.setClassName(CLASSNAME + "-content"); - bottomDecoration.setClassName(CLASSNAME + "-deco"); - captionNode.setClassName(CLASSNAME + "-caption"); - boolean hasCaption = false; - if (uidl.hasAttribute("caption") - && !uidl.getStringAttribute("caption").equals("")) { - setCaption(uidl.getStringAttribute("caption")); - hasCaption = true; - } else { - setCaption(""); - captionNode.setClassName(CLASSNAME + "-nocaption"); - } + final String captionBaseClass = CLASSNAME + + (hasCaption ? "-caption" : "-nocaption"); + final String contentBaseClass = CLASSNAME + "-content"; + final String decoBaseClass = CLASSNAME + "-deco"; + + captionNode.addClassName(captionBaseClass); + contentNode.addClassName(contentBaseClass); + bottomDecoration.addClassName(decoBaseClass); // Add proper stylenames for all elements. This way we can prevent // unwanted CSS selector inheritance. if (uidl.hasAttribute("style")) { final String[] styles = uidl.getStringAttribute("style").split( " "); - final String captionBaseClass = CLASSNAME - + (hasCaption ? "-caption" : "-nocaption"); - final String contentBaseClass = CLASSNAME + "-content"; - final String decoBaseClass = CLASSNAME + "-deco"; - String captionClass = captionBaseClass; - String contentClass = contentBaseClass; - String decoClass = decoBaseClass; - for (int i = 0; i < styles.length; i++) { - captionClass += " " + captionBaseClass + "-" + styles[i]; - contentClass += " " + contentBaseClass + "-" + styles[i]; - decoClass += " " + decoBaseClass + "-" + styles[i]; + for (String style : styles) { + captionNode.addClassName(captionBaseClass + "-" + style); + contentNode.addClassName(contentBaseClass + "-" + style); + bottomDecoration.addClassName(decoBaseClass + "-" + style); } - captionNode.setClassName(captionClass); - contentNode.setClassName(contentClass); - bottomDecoration.setClassName(decoClass); - } } // Ensure correct implementation @@ -509,12 +499,13 @@ public class VPanel extends SimplePanel implements Container, } private void detectContainerBorders() { - DOM.setStyleAttribute(contentNode, "overflow", "hidden"); + Style contentStyle = contentNode.getStyle(); + String overflow = contentStyle.getProperty("overflow"); + contentStyle.setProperty("overflow", "hidden"); borderPaddingHorizontal = Util.measureHorizontalBorder(contentNode); borderPaddingVertical = Util.measureVerticalBorder(contentNode); - - DOM.setStyleAttribute(contentNode, "overflow", "auto"); + contentStyle.setProperty("overflow", overflow); captionPaddingHorizontal = Util.measureHorizontalPaddingAndBorder( captionNode, 26); -- 2.39.5