320027: revert 306639 (partially, without SacFactory yet)

Signed-off-by: Florian Thienel <florian@thienel.org>
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/css/PropertyDecl.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/css/PropertyDecl.java
index e28b922..bd7d326 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/css/PropertyDecl.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/css/PropertyDecl.java
@@ -12,12 +12,16 @@
  *******************************************************************************/
 package org.eclipse.wst.xml.vex.core.internal.css;
 
+import java.io.Serializable;
+
 import org.w3c.css.sac.LexicalUnit;
 
 /**
  * Represents a particular CSS property declaration.
  */
-public class PropertyDecl {
+public class PropertyDecl implements Serializable {
+
+	private static final long serialVersionUID = 1L;
 
 	private final Rule rule;
 	private final String property;
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/css/StyleSheet.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/css/StyleSheet.java
index b29623b..eda172a 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/css/StyleSheet.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/css/StyleSheet.java
@@ -16,6 +16,7 @@
  *******************************************************************************/
 package org.eclipse.wst.xml.vex.core.internal.css;
 
+import java.io.Serializable;
 import java.lang.ref.WeakReference;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -33,8 +34,10 @@
 /**
  * Represents a CSS style sheet.
  */
-public class StyleSheet {
+public class StyleSheet implements Serializable {
 
+	private static final long serialVersionUID = -7309907170251446189L;
+	
 	private static final Comparator<PropertyDecl> PROPERTY_CASCADE_ORDERING =
 		new Comparator<PropertyDecl>() {
 		public int compare(PropertyDecl propertyDecl1,
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/css/StyleSheetReader.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/css/StyleSheetReader.java
index e16b160..2b204c7 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/css/StyleSheetReader.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/css/StyleSheetReader.java
@@ -102,6 +102,9 @@
 		// May be null!
 		private final URL url;
 
+		// Factory for creating serializable clones of SAC objects
+		SacFactory factory = new SacFactory();
+
 		public StyleSheetBuilder(List<Rule> rules, URL url) {
 			this.rules = rules;
 			this.url = url;
@@ -156,30 +159,35 @@
 		}
 
 		public void property(String name, LexicalUnit value, boolean important) {
+
+			// Create a serializable clone of the value for storage in our
+			// stylesheet.
+			LexicalUnit val = factory.cloneLexicalUnit(value);
+
 			if (name.equals(CSS.BORDER)) {
-				this.expandBorder(value, important);
+				this.expandBorder(val, important);
 			} else if (name.equals(CSS.BORDER_BOTTOM)) {
-				this.expandBorder(value, CSS.BORDER_BOTTOM, important);
+				this.expandBorder(val, CSS.BORDER_BOTTOM, important);
 			} else if (name.equals(CSS.BORDER_LEFT)) {
-				this.expandBorder(value, CSS.BORDER_LEFT, important);
+				this.expandBorder(val, CSS.BORDER_LEFT, important);
 			} else if (name.equals(CSS.BORDER_RIGHT)) {
-				this.expandBorder(value, CSS.BORDER_RIGHT, important);
+				this.expandBorder(val, CSS.BORDER_RIGHT, important);
 			} else if (name.equals(CSS.BORDER_TOP)) {
-				this.expandBorder(value, CSS.BORDER_TOP, important);
+				this.expandBorder(val, CSS.BORDER_TOP, important);
 			} else if (name.equals(CSS.BORDER_COLOR)) {
-				this.expandBorderColor(value, important);
+				this.expandBorderColor(val, important);
 			} else if (name.equals(CSS.BORDER_STYLE)) {
-				this.expandBorderStyle(value, important);
+				this.expandBorderStyle(val, important);
 			} else if (name.equals(CSS.BORDER_WIDTH)) {
-				this.expandBorderWidth(value, important);
+				this.expandBorderWidth(val, important);
 			} else if (name.equals(CSS.FONT)) {
-				this.expandFont(value, important);
+				this.expandFont(val, important);
 			} else if (name.equals(CSS.MARGIN)) {
-				this.expandMargin(value, important);
+				this.expandMargin(val, important);
 			} else if (name.equals(CSS.PADDING)) {
-				this.expandPadding(value, important);
+				this.expandPadding(val, important);
 			} else {
-				this.addDecl(name, value, important);
+				this.addDecl(name, val, important);
 			}
 		}