aboutsummaryrefslogtreecommitdiffstats
path: root/sass/src
diff options
context:
space:
mode:
authorMarc Englund <marc@vaadin.com>2012-08-29 18:19:21 +0300
committerMarc Englund <marc@vaadin.com>2012-08-29 18:19:21 +0300
commit269746aa7843e41a7aa4dd3cf9da731dc18a7d43 (patch)
tree6542c377886d48c9333ef9d8c7be4fa73f4d503b /sass/src
parentcac34cbc8f8ca82c44525985b4b422d89388ca79 (diff)
downloadvaadin-framework-269746aa7843e41a7aa4dd3cf9da731dc18a7d43.tar.gz
vaadin-framework-269746aa7843e41a7aa4dd3cf9da731dc18a7d43.zip
Applied patch fixing #9347 (mixin w/ args + nested blocks), includes test
Diffstat (limited to 'sass/src')
-rw-r--r--sass/src/com/vaadin/sass/tree/BlockNode.java21
-rw-r--r--sass/src/com/vaadin/sass/util/Clonable.java7
-rw-r--r--sass/src/com/vaadin/sass/util/DeepCopy.java15
3 files changed, 37 insertions, 6 deletions
diff --git a/sass/src/com/vaadin/sass/tree/BlockNode.java b/sass/src/com/vaadin/sass/tree/BlockNode.java
index 2879cd57ea..685c3ac3f0 100644
--- a/sass/src/com/vaadin/sass/tree/BlockNode.java
+++ b/sass/src/com/vaadin/sass/tree/BlockNode.java
@@ -20,8 +20,10 @@ import org.w3c.css.sac.SelectorList;
import com.vaadin.sass.parser.SelectorListImpl;
import com.vaadin.sass.selector.SelectorUtil;
+import com.vaadin.sass.util.Clonable;
+import com.vaadin.sass.util.DeepCopy;
-public class BlockNode extends Node {
+public class BlockNode extends Node implements Clonable {
private static final long serialVersionUID = 5742962631468325048L;
@@ -62,12 +64,21 @@ public class BlockNode extends Node {
}
@Override
- protected Object clone() throws CloneNotSupportedException {
- SelectorListImpl clonedSelectorList = new SelectorListImpl();
+ public Object clone() throws CloneNotSupportedException {
+
+ SelectorListImpl clonedSelectorList = null;
+
+ if (selectorList != null) {
+ clonedSelectorList = new SelectorListImpl();
for (int i = 0; i < selectorList.getLength(); i++) {
clonedSelectorList.addSelector(selectorList.item(i));
}
- return null;
- // BlockNode clone = new BlockNode()
}
+ final BlockNode clone = new BlockNode(clonedSelectorList);
+ for (Node child : getChildren()) {
+ clone.getChildren().add((Node) DeepCopy.copy(child));
+ }
+ return clone;
+ }
+
}
diff --git a/sass/src/com/vaadin/sass/util/Clonable.java b/sass/src/com/vaadin/sass/util/Clonable.java
new file mode 100644
index 0000000000..639f158fb0
--- /dev/null
+++ b/sass/src/com/vaadin/sass/util/Clonable.java
@@ -0,0 +1,7 @@
+package com.vaadin.sass.util;
+
+public interface Clonable {
+
+ public Object clone() throws CloneNotSupportedException;
+
+}
diff --git a/sass/src/com/vaadin/sass/util/DeepCopy.java b/sass/src/com/vaadin/sass/util/DeepCopy.java
index 712b8ecc11..23f8386714 100644
--- a/sass/src/com/vaadin/sass/util/DeepCopy.java
+++ b/sass/src/com/vaadin/sass/util/DeepCopy.java
@@ -35,7 +35,9 @@ public class DeepCopy {
* Returns a copy of the object, or null if the object cannot be serialized.
*/
public static Object copy(Object orig) {
+
Object obj = null;
+ if (!(orig instanceof Clonable)) {
try {
// Write the object out to a byte array
FastByteArrayOutputStream fbos = new FastByteArrayOutputStream();
@@ -46,7 +48,8 @@ public class DeepCopy {
// Retrieve an input stream from the byte array and read
// a copy of the object back in.
- ObjectInputStream in = new ObjectInputStream(fbos.getInputStream());
+ ObjectInputStream in = new ObjectInputStream(
+ fbos.getInputStream());
obj = in.readObject();
in.close();
} catch (IOException e) {
@@ -55,6 +58,16 @@ public class DeepCopy {
cnfe.printStackTrace();
}
return obj;
+ } else {
+ try {
+ obj = ((Clonable) orig).clone();
+ } catch (ClassCastException e2) {
+ // Can't clone, return obj as null
+ } catch (CloneNotSupportedException e2) {
+ // Can't clone, return obj as null
+ }
+ return obj;
+ }
}
} \ No newline at end of file