Repository: flex-falcon
Updated Branches:
  refs/heads/develop caf79f2a6 -> 920cc51f8


FLEX-35340 handle multivalue separate from arrayvalue


Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/98ffba37
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/98ffba37
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/98ffba37

Branch: refs/heads/develop
Commit: 98ffba3718bfab8a4b65afab0e3d56193f000f48
Parents: caf79f2
Author: Alex Harui <aha...@apache.org>
Authored: Fri Jul 14 10:15:37 2017 -0700
Committer: Alex Harui <aha...@apache.org>
Committed: Fri Jul 14 10:15:37 2017 -0700

----------------------------------------------------------------------
 .../org/apache/flex/compiler/internal/css/CSS.g | 38 +++++++++---
 .../apache/flex/compiler/internal/css/CSSTree.g | 14 ++++-
 .../css/CSSMultiValuePropertyValue.java         | 63 ++++++++++++++++++++
 .../flex/compiler/internal/css/CSSProperty.java |  7 ---
 4 files changed, 106 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/98ffba37/compiler/src/main/antlr3/org/apache/flex/compiler/internal/css/CSS.g
----------------------------------------------------------------------
diff --git 
a/compiler/src/main/antlr3/org/apache/flex/compiler/internal/css/CSS.g 
b/compiler/src/main/antlr3/org/apache/flex/compiler/internal/css/CSS.g
index 726b09f..1ed5192 100644
--- a/compiler/src/main/antlr3/org/apache/flex/compiler/internal/css/CSS.g
+++ b/compiler/src/main/antlr3/org/apache/flex/compiler/internal/css/CSS.g
@@ -33,7 +33,7 @@ options
 tokens
 { 
     I_RULES; I_MEDIUM_CONDITIONS; I_DECL; I_RULE; I_SELECTOR_GROUP; 
I_SELECTOR; 
-    I_SIMPLE_SELECTOR; I_CHILD_SELECTOR; I_PRECEDED_SELECTOR; 
I_SIBLING_SELECTOR; I_ARRAY; 
+    I_SIMPLE_SELECTOR; I_CHILD_SELECTOR; I_PRECEDED_SELECTOR; 
I_SIBLING_SELECTOR; I_ARRAY; I_MULTIVALUE; 
 }
 
 @header 
@@ -408,7 +408,7 @@ declaration
     ;
     
 /**
- * This rule matches an array of property values or a single value.
+ * This rule matches an comma-separated array of property values or a single 
value.
  * If it matches an array, the output is an I_ARRAY tree of element values.
  * If it matches an single value, the output is a "singleValue" tree.
  * 
@@ -417,16 +417,32 @@ declaration
  *     "tl", "tr", "bl", "br"
  *     #FFFFFF, #FFFFFF, #FFFFFF, #FFFFFF
  *     Verdana, Times, Sans-Serif
- *     solid 1px #666666
+ *     20px 20px, 40px 40px
  *
  */    
 value  
 @init { int count = 1; }
-    :   singleValue ( COMMA? singleValue { count++; } )*
-        -> {count > 1}? ^(I_ARRAY singleValue+)
-        ->              singleValue
+    :   multiValue ( COMMA multiValue { count++; } )*
+        -> {count > 1}? ^(I_ARRAY multiValue+)
+        ->              multiValue
     ;  
-  
+
+/**
+ * This rule matches an space-separated array of property values or a single 
value.
+ * If it matches an array, the output is an I_MULTIVALUE tree of element 
values.
+ * If it matches an single value, the output is a "singleValue" tree.
+ * 
+ * multiValue example:
+ *     solid 1px #666666
+ *
+ */    
+multiValue
+@init { int count = 1; }
+    :   singleValue ( singleValue { count++; } )*
+        -> {count > 1}? ^(I_MULTIVALUE singleValue+)
+        ->              singleValue
+    ;
+
 /**
  * This rule matches one property value.
  *
@@ -455,6 +471,7 @@ singleValue
     |   URL ARGUMENTS formatOption*   -> ^(URL ARGUMENTS formatOption*)
     |   LOCAL ARGUMENTS                        -> ^(LOCAL ARGUMENTS)
     |   CALC ARGUMENTS                 -> ^(CALC ARGUMENTS)
+    |   FUNCTIONS ARGUMENTS                    -> ^(FUNCTIONS ARGUMENTS)
     |   ALPHA_VALUE
     |   SCALE_VALUE
     |   RECT_VALUE
@@ -531,6 +548,13 @@ NULL : 'null' ;
 ONLY : 'only' ;
 CHILD : '>' ;
 PRECEDED : '+' ;
+FUNCTIONS : '-moz-linear-gradient'
+          | '-webkit-linear-gradient'
+          | 'linear-gradient'
+          | 'progid:DXImageTransform.Microsoft.gradient'
+          | 'translateX'
+          | 'translateY'
+          ;
 NOT
     :  'not'
     ;

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/98ffba37/compiler/src/main/antlr3/org/apache/flex/compiler/internal/css/CSSTree.g
----------------------------------------------------------------------
diff --git 
a/compiler/src/main/antlr3/org/apache/flex/compiler/internal/css/CSSTree.g 
b/compiler/src/main/antlr3/org/apache/flex/compiler/internal/css/CSSTree.g
index d543ccb..94a7f1d 100644
--- a/compiler/src/main/antlr3/org/apache/flex/compiler/internal/css/CSSTree.g
+++ b/compiler/src/main/antlr3/org/apache/flex/compiler/internal/css/CSSTree.g
@@ -368,10 +368,18 @@ declaration returns [CSSProperty property]
 value returns [CSSPropertyValue propertyValue]
     :   ^( I_ARRAY 
                               { final List<CSSPropertyValue> array = new 
ArrayList<CSSPropertyValue>(); }
-           ( s1=singleValue   { array.add($s1.propertyValue); } )+
+           ( s1=multiValue    { array.add($s1.propertyValue); } )+
         )                     { $propertyValue = new 
CSSArrayPropertyValue(array, $start, tokenStream); }
-    |   s2=singleValue        { $propertyValue = $s2.propertyValue; }
+    |   s2=multiValue         { $propertyValue = $s2.propertyValue; }
     ;    
+
+multiValue returns [CSSPropertyValue propertyValue]
+    :   ^( I_MULTIVALUE 
+                              { final List<CSSPropertyValue> array = new 
ArrayList<CSSPropertyValue>(); }
+           ( s1=singleValue   { array.add($s1.propertyValue); } )+
+        )                     { $propertyValue = new 
CSSMultiValuePropertyValue(array, $start, tokenStream); }
+    |   s2=singleValue        { $propertyValue = $s2.propertyValue; }
+    ;
   
 singleValue returns [CSSPropertyValue propertyValue]
     :   NUMBER_WITH_PERCENT         
@@ -406,6 +414,8 @@ singleValue returns [CSSPropertyValue propertyValue]
         { $propertyValue = new CSSFunctionCallPropertyValue($LOCAL.text, 
$l.text, $start, tokenStream); }
     |   ^(CALC l=ARGUMENTS)
         { $propertyValue = new CSSFunctionCallPropertyValue($CALC.text, 
$l.text, $start, tokenStream); }
+    |   ^(FUNCTIONS l=ARGUMENTS)
+        { $propertyValue = new CSSFunctionCallPropertyValue($FUNCTIONS.text, 
$l.text, $start, tokenStream); }
     |   s=STRING   
         { $propertyValue = new CSSStringPropertyValue($s.text, $start, 
tokenStream); }                   
     |   ID

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/98ffba37/compiler/src/main/java/org/apache/flex/compiler/internal/css/CSSMultiValuePropertyValue.java
----------------------------------------------------------------------
diff --git 
a/compiler/src/main/java/org/apache/flex/compiler/internal/css/CSSMultiValuePropertyValue.java
 
b/compiler/src/main/java/org/apache/flex/compiler/internal/css/CSSMultiValuePropertyValue.java
new file mode 100644
index 0000000..89c50b5
--- /dev/null
+++ 
b/compiler/src/main/java/org/apache/flex/compiler/internal/css/CSSMultiValuePropertyValue.java
@@ -0,0 +1,63 @@
+/*
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.internal.css;
+
+import java.util.List;
+
+import org.antlr.runtime.TokenStream;
+import org.antlr.runtime.tree.CommonTree;
+
+import org.apache.flex.compiler.css.ICSSPropertyValue;
+import com.google.common.base.Joiner;
+import com.google.common.collect.ImmutableList;
+
+/**
+ * Array type property values are comma-separated values in CSS properties.
+ * <p>
+ * For example:<br>
+ * <code>fillColors: #FFFFFF, #CCCCCC, #FFFFFF, #EEEEEE;</code>
+ */
+public class CSSMultiValuePropertyValue extends CSSPropertyValue
+{
+    public CSSMultiValuePropertyValue(final List<CSSPropertyValue> elements,
+                                 final CommonTree ast,
+                                 final TokenStream tokens)
+    {
+        super(ast, tokens, CSSModelTreeType.PROPERTY_VALUE);
+        this.elements = ImmutableList.copyOf(elements);
+        super.children.addAll(elements);
+    }
+
+    private final ImmutableList<CSSPropertyValue> elements;
+
+    /**
+     * @return Elements in the array property value.
+     */
+    public ImmutableList<? extends ICSSPropertyValue> getElements()
+    {
+        return elements;
+    }
+
+    @Override
+    public String toString()
+    {
+        return Joiner.on(" ").join(elements);
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/98ffba37/compiler/src/main/java/org/apache/flex/compiler/internal/css/CSSProperty.java
----------------------------------------------------------------------
diff --git 
a/compiler/src/main/java/org/apache/flex/compiler/internal/css/CSSProperty.java 
b/compiler/src/main/java/org/apache/flex/compiler/internal/css/CSSProperty.java
index c977341..fe0fcf5 100644
--- 
a/compiler/src/main/java/org/apache/flex/compiler/internal/css/CSSProperty.java
+++ 
b/compiler/src/main/java/org/apache/flex/compiler/internal/css/CSSProperty.java
@@ -84,13 +84,6 @@ public class CSSProperty extends CSSNodeBase implements 
ICSSProperty
         {
             return String.format("%s: %s;", cssName, 
((CSSFunctionCallPropertyValue)value).toString());
         }
-        if (value instanceof CSSArrayPropertyValue) {
-            if (!cssName.equalsIgnoreCase("font-family"))
-            {
-                CSSArrayPropertyValue borderValues = 
(CSSArrayPropertyValue)value;
-                return String.format("%s: %s;", cssName, Joiner.on(" 
").join(borderValues.getElements()));
-            }
-        }
         return String.format("%s: %s;", cssName, value.toString());
     }
 

Reply via email to