flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [1/5] git commit: [flex-falcon] [refs/heads/develop] - support fancier font-face src and attribute selectors without crashing. We aren't currently doing anything with them
Date Sat, 14 Feb 2015 06:44:11 GMT
Repository: flex-falcon
Updated Branches:
  refs/heads/develop 743fe1571 -> 982ecfb9b


support fancier font-face src and attribute selectors without crashing.  We aren't currently
doing anything with them


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

Branch: refs/heads/develop
Commit: ccbcceb1595f6db6a230a02820f1fb43da86a2be
Parents: 743fe15
Author: Alex Harui <aharui@apache.org>
Authored: Fri Feb 6 22:21:11 2015 -0800
Committer: Alex Harui <aharui@apache.org>
Committed: Fri Feb 6 22:21:11 2015 -0800

----------------------------------------------------------------------
 .../apache/flex/compiler/css/ConditionType.java |  9 +++-
 .../org/apache/flex/compiler/internal/css/CSS.g | 40 +++++++++++++++--
 .../flex/compiler/internal/css/CSSFontFace.java |  5 ++-
 .../apache/flex/compiler/internal/css/CSSTree.g | 46 +++++++++++++++++++-
 4 files changed, 93 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/ccbcceb1/compiler/src/org/apache/flex/compiler/css/ConditionType.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/css/ConditionType.java b/compiler/src/org/apache/flex/compiler/css/ConditionType.java
index 2699f15..d506bc9 100644
--- a/compiler/src/org/apache/flex/compiler/css/ConditionType.java
+++ b/compiler/src/org/apache/flex/compiler/css/ConditionType.java
@@ -35,9 +35,14 @@ public enum ConditionType
     ID("#"),
 
     /**
-     * For example: <code>s|Label#loadingState</code>
+     * For example: <code>s|Label:loadingState</code>
      */
-    PSEUDO(":");
+    PSEUDO(":"),
+
+    /**
+     * For example: <code>s|Label[loadingState]</code>
+     */
+    ATTRIBUTE("[");
 
     /**
      * Prefix character of the condition type.

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/ccbcceb1/compiler/src/org/apache/flex/compiler/internal/css/CSS.g
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/internal/css/CSS.g b/compiler/src/org/apache/flex/compiler/internal/css/CSS.g
index 074bff3..321deaa 100644
--- a/compiler/src/org/apache/flex/compiler/internal/css/CSS.g
+++ b/compiler/src/org/apache/flex/compiler/internal/css/CSS.g
@@ -315,6 +315,7 @@ condition
     :   ( DOT^ ID
         | HASH_WORD 
         | COLON^ ID 
+        | attributeSelector
         ) 
     ;
   
@@ -402,17 +403,49 @@ singleValue
     								-> ^(PROPERTY_REFERENCE ARGUMENTS)
     |   EMBED ARGUMENTS
     								-> ^(EMBED ARGUMENTS)
-    |   URL ARGUMENTS			    -> ^(URL ARGUMENTS)
+    |   URL ARGUMENTS formatOption*   -> ^(URL ARGUMENTS formatOption*)
     |   LOCAL ARGUMENTS		        -> ^(LOCAL ARGUMENTS)
     |   RGB
     |   STRING						
     |   ID 
     ;
 
+formatOption
+    :   FORMAT ARGUMENTS	-> ^(FORMAT ARGUMENTS)
+	;
+
+attributeSelector
+    :   SQUARE_OPEN attributeName attributeOperator* attributeValue* SQUARE_END
+    ;
+    
+attributeName
+    :    ID
+    ;
+    
+attributeOperator
+    :    BEGINS_WITH
+    |    ENDS_WITH
+    |    CONTAINS
+    |    LIST_MATCH
+    |    HREFLANG_MATCH
+    |    EQUALS
+    ;
+    
+attributeValue
+    :    STRING
+    ;
+    	
 /* Lexer Rules */
   
+BEGINS_WITH : '^=' ;
+ENDS_WITH : '$=' ;
+CONTAINS : '*=' ;
+LIST_MATCH : '~=' ;
+HREFLANG_MATCH : '|=' ;
 BLOCK_OPEN : '{' ;
 BLOCK_END :  '}' ;
+SQUARE_OPEN : '[' ;
+SQUARE_END :  ']' ;
 COMMA : ',' ;
 PERCENT : '%' ;
 PIPE : '|' ; 
@@ -427,6 +460,7 @@ CLASS_REFERENCE : 'ClassReference' ;
 PROPERTY_REFERENCE : 'PropertyReference' ;
 EMBED : 'Embed' ;
 URL : 'url' ;
+FORMAT : 'format' ;
 LOCAL : 'local' ;
 NULL : 'null' ;
 
@@ -455,7 +489,7 @@ SEMI_COLONS : ';'+ ;
 HASH_WORD
     :   '#' ( LETTER | DIGIT | '-' | '_' )+
     ;
-  
+
 ID  :   ( '-' | '_'  )? LETTER ( LETTER | DIGIT | '-' | '_'  )*
     ;
     
@@ -477,7 +511,7 @@ NUMBER
     ;    
 
 /**
- * Matches a number with optinal unit string.
+ * Matches a number with optional unit string.
  * For example:
  *   2.5
  *   2.5em

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/ccbcceb1/compiler/src/org/apache/flex/compiler/internal/css/CSSFontFace.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/internal/css/CSSFontFace.java b/compiler/src/org/apache/flex/compiler/internal/css/CSSFontFace.java
index ac00854..3a679cc 100644
--- a/compiler/src/org/apache/flex/compiler/internal/css/CSSFontFace.java
+++ b/compiler/src/org/apache/flex/compiler/internal/css/CSSFontFace.java
@@ -95,7 +95,10 @@ public class CSSFontFace extends CSSNodeBase implements ICSSFontFace
         }
 
         checkNotNull(srcValue, "'src' is required in @font-face");
-        source = (CSSFunctionCallPropertyValue)srcValue;
+        if (srcValue instanceof CSSArrayPropertyValue)
+            source = (CSSFunctionCallPropertyValue)((CSSArrayPropertyValue)srcValue).getNthChild(0);
+        else
+            source = (CSSFunctionCallPropertyValue)srcValue;
 
         checkNotNull(fontFamilyValue, "'fontFamily' is required in @font-face");
         fontFamily = fontFamilyValue.toString();

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/ccbcceb1/compiler/src/org/apache/flex/compiler/internal/css/CSSTree.g
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/internal/css/CSSTree.g b/compiler/src/org/apache/flex/compiler/internal/css/CSSTree.g
index 59d241e..fe5b921 100644
--- a/compiler/src/org/apache/flex/compiler/internal/css/CSSTree.g
+++ b/compiler/src/org/apache/flex/compiler/internal/css/CSSTree.g
@@ -79,6 +79,13 @@ private final TokenStream tokenStream = getTreeNodeStream().getTokenStream();
 protected List<CSSParserProblem> problems = new ArrayList<CSSParserProblem>();
 
 /**
+ * Used for building up attribute selector strings until we implement a data
+ * structure for it.
+ */
+protected String curAttribute;
+
+
+/**
  * Collect problems.
  */
 @Override
@@ -253,6 +260,7 @@ conditionSelector
     :   ^(DOT c=ID)   { type = ConditionType.CLASS; name = $c.text; }  
     |   HASH_WORD   { type = ConditionType.ID; name = $HASH_WORD.text.substring(1); }
     |   ^(COLON s=ID) { type = ConditionType.PSEUDO; name = $s.text; } 
+    |   attributeSelector { type = ConditionType.ATTRIBUTE; name = curAttribute; }
     ;
   
 elementSelector
@@ -265,6 +273,37 @@ elementSelector
         { $simpleSelector::element = $STAR.text; }
     ;
     
+attributeSelector
+    :   open = SQUARE_OPEN attributeName attributeOperator* attributeValue* close = SQUARE_END
+	{ curAttribute = $open.text + curAttribute + $close.text; }
+    ;
+    
+attributeName
+    :    n1 = ID
+         { curAttribute = $n1.text; }
+    ;
+    
+attributeOperator
+    :    o1 = BEGINS_WITH
+         { curAttribute += $o1.text; }
+    |    o2 = ENDS_WITH
+         { curAttribute += $o2.text; }
+    |    o3 = CONTAINS
+         { curAttribute += $o3.text; }
+    |    o4 = LIST_MATCH
+         { curAttribute += $o4.text; }
+    |    o5 = HREFLANG_MATCH
+         { curAttribute += $o5.text; }
+    |    o6 = EQUALS
+         { curAttribute += $o6.text; }
+    ;
+    
+attributeValue
+    :    s = STRING
+         { curAttribute += $s.text; }
+    ;
+    	
+
 declarationsBlock returns [List<CSSProperty> properties]
 @init 
 {
@@ -308,7 +347,7 @@ singleValue returns [CSSPropertyValue propertyValue]
         { $propertyValue = new CSSFunctionCallPropertyValue($PROPERTY_REFERENCE.text, $pr.text,
$start, tokenStream); }
     |   ^(EMBED es=ARGUMENTS)
         { $propertyValue = new CSSFunctionCallPropertyValue($EMBED.text, $es.text, $start,
tokenStream); }
-    |   ^(URL url=ARGUMENTS)
+    |   ^(URL url=ARGUMENTS format=formatOption*)
         { $propertyValue = new CSSFunctionCallPropertyValue($URL.text, $url.text, $start,
tokenStream); }
     |   ^(LOCAL l=ARGUMENTS)
         { $propertyValue = new CSSFunctionCallPropertyValue($LOCAL.text, $l.text, $start,
tokenStream); }
@@ -318,6 +357,11 @@ singleValue returns [CSSPropertyValue propertyValue]
         { $propertyValue = CSSKeywordPropertyValue.create($start, tokenStream); } 
     ;
     
+formatOption returns [CSSPropertyValue propertyValue]
+    :   ^(FORMAT format=ARGUMENTS)
+        { $propertyValue = new CSSFunctionCallPropertyValue($FORMAT.text, $format.text, $start,
tokenStream); } 
+    ;
+
 argumentList returns [List<String> labels, List<String> values]
 @init 
 {


Mime
View raw message