royale-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [royale-compiler] branch develop updated: Fix handling of RGBA and add test for it. Fixes #25
Date Tue, 13 Mar 2018 19:43:50 GMT
This is an automated email from the ASF dual-hosted git repository.

aharui pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-compiler.git


The following commit(s) were added to refs/heads/develop by this push:
     new 44d4323  Fix handling of RGBA and add test for it.  Fixes #25
44d4323 is described below

commit 44d43235429ddc0509847df1df61b4280d6988f4
Author: Alex Harui <aharui@apache.org>
AuthorDate: Tue Mar 13 12:43:31 2018 -0700

    Fix handling of RGBA and add test for it.  Fixes #25
---
 .../internal/driver/js/royale/JSCSSCompilationSession.java   |  8 ++++----
 .../src/test/resources/royale/files/CSSTestSource.css        |  1 +
 .../resources/royale/files/CSSTestSource_encoded_result.txt  |  3 ++-
 .../src/test/resources/royale/files/CSSTestSource_result.css |  1 +
 .../compiler/internal/css/CSSRgbaColorPropertyValue.java     | 12 ++++++------
 .../royale/compiler/internal/css/codegen/CSSReducer.java     |  2 +-
 6 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/driver/js/royale/JSCSSCompilationSession.java
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/driver/js/royale/JSCSSCompilationSession.java
index 1cc0791..11b777a 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/driver/js/royale/JSCSSCompilationSession.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/driver/js/royale/JSCSSCompilationSession.java
@@ -291,7 +291,7 @@ public class JSCSSCompilationSession extends CSSCompilationSession
                     else if (value instanceof CSSRgbaColorPropertyValue)
                     {
                         //todo: handle alpha in the RGBA ?
-                        result.append(new Integer(((CSSRgbaColorPropertyValue)value).getColorAsInt()));
+                        result.append(new Long(((CSSRgbaColorPropertyValue)value).getColorAsLong()));
                     }
                     else if (val instanceof CSSKeywordPropertyValue)
                     {
@@ -346,10 +346,10 @@ public class JSCSSCompilationSession extends CSSCompilationSession
                     {
                         result.append(new Integer(((CSSRgbColorPropertyValue)val).getColorAsInt()));
                     }
-                    else if (value instanceof CSSRgbaColorPropertyValue)
+                    else if (val instanceof CSSRgbaColorPropertyValue)
                     {
                         //todo: handle alpha in the RGBA ?
-                        result.append(new Integer(((CSSRgbaColorPropertyValue)value).getColorAsInt()));
+                        result.append(new Long(((CSSRgbaColorPropertyValue)val).getColorAsLong()));
                     }
                     else if (val instanceof CSSKeywordPropertyValue)
                     {
@@ -396,7 +396,7 @@ public class JSCSSCompilationSession extends CSSCompilationSession
             else if (value instanceof CSSRgbaColorPropertyValue)
             {
                 //todo: handle alpha in the RGBA ?
-                result.append(new Integer(((CSSRgbaColorPropertyValue)value).getColorAsInt()));
+                result.append(new Long(((CSSRgbaColorPropertyValue)value).getColorAsLong()));
             }
             else if (value instanceof CSSKeywordPropertyValue)
             {
diff --git a/compiler-jx/src/test/resources/royale/files/CSSTestSource.css b/compiler-jx/src/test/resources/royale/files/CSSTestSource.css
index 4b84e00..068ea30 100755
--- a/compiler-jx/src/test/resources/royale/files/CSSTestSource.css
+++ b/compiler-jx/src/test/resources/royale/files/CSSTestSource.css
@@ -104,6 +104,7 @@
 .FLEX35340D {
 	font-family: Georgia, Times New Roman, Times, serif;
 	box-shadow: 0 2px 2px 0 rgba(0,0,0,.14),0 3px 1px -2px rgba(0,0,0,.2),0 1px 5px 0 rgba(0,0,0,.12);
+	text-shadow: 0 -1px 0 rgba(0,0,0,0.70);
 }
 
 .FLEX35346 {
diff --git a/compiler-jx/src/test/resources/royale/files/CSSTestSource_encoded_result.txt
b/compiler-jx/src/test/resources/royale/files/CSSTestSource_encoded_result.txt
index fecfc43..f440a84 100755
--- a/compiler-jx/src/test/resources/royale/files/CSSTestSource_encoded_result.txt
+++ b/compiler-jx/src/test/resources/royale/files/CSSTestSource_encoded_result.txt
@@ -18,7 +18,8 @@
 //
 ////////////////////////////////////////////////////////////////////////////////
 */
-0,
1,
".glass",
function() {this["borderColor"] = 7763059;
this["highlightAlphas"] = [0.07000000029802322,
0.44999998807907104];
this["fillColors"] = [8947848, 15987699, 10395294, 16579836];
this["fillAlphas"]
= [0.6000000238418579, 0.699999988079071, 0.800000011920929, 0.8999999761581421]},
0,
1,
".glassSlider",
function()
{this["fillColors"] = [15987699, 12303291, 16579836, 13421772];
this["fillAlphas"] = [0.800000011920929,
0.699999988079071, 0.6000000238418579, 0.5]},
0,
1,
".listItem",
function() {this["borderStyle"]
= "outset";
this["backgroundColor"] = 16777215;
this["verticalAlign"] = "middle";
this["horizontalGap"]
= 5.0;
this["backgroundAlpha"] = 0.5;
this["paddingLeft"] = 4.0;
this["paddingRight"] = 4.0},
0,
1,
".outer.inner",
function()
{this["width"] = 512.0},
0,
1,
".outer .inner",
function() {this["width"] = 512.0},
0,
1,
".outer>.innerTitle",
function()
{this["height"] = 176.0;
this["color"] = 16777215;
this["background"] = ["url('assets/welcome_card.jpg')",
"center"
 , "/", "cover"]},
0,
1,
".outer>.innerMenu",
function() {this["color"] = 16777215},
0,
1,
"h4",
function()
{this["color"] = 16777215},
0,
1,
".outerother.inner",
function() {this["height"] = 320.0;
this["width"]
= 320.0},
0,
1,
".outerother-square>.innerTitle",
function() {this["color"] = 16777215;
this["background"]
= ["url('assets/dog.png')", "bottom", "right", 15.0, "no-repeat", 4634284]},
0,
1,
".usescalc",
function()
{this["color"] = 16777215;
this["width"] = null},
0,
1,
".FLEX35340A",
function() {this["transform"]
= null;
this["background"] = null;
this["filter"] = null},
0,
1,
".FLEX35340B",
function()
{this["background"] = null},
0,
1,
".FLEX35340C",
function() {this["background"] = null},
0,
1,
".FLEX35340D",
function()
{this["boxShadow"] = ["0 2px 2px 0 rgba(0,0,0,.14)", "0 3px 1px -2px rgba(0,0,0,.2)", "0 1px
5px 0 rgba(0,0,0,.12)"];
this["fontFamily"] = ["Georgia", "Times New Roman", "Times", "serif"]},
+0,
1,
".glass",
function() {this["borderColor"] = 7763059;
this["highlightAlphas"] = [0.07000000029802322,
0.44999998807907104];
this["fillColors"] = [8947848, 15987699, 10395294, 16579836];
this["fillAlphas"]
= [0.6000000238418579, 0.699999988079071, 0.800000011920929, 0.8999999761581421]},
0,
1,
".glassSlider",
function()
{this["fillColors"] = [15987699, 12303291, 16579836, 13421772];
this["fillAlphas"] = [0.800000011920929,
0.699999988079071, 0.6000000238418579, 0.5]},
0,
1,
".listItem",
function() {this["borderStyle"]
= "outset";
this["backgroundColor"] = 16777215;
this["verticalAlign"] = "middle";
this["horizontalGap"]
= 5.0;
this["backgroundAlpha"] = 0.5;
this["paddingLeft"] = 4.0;
this["paddingRight"] = 4.0},
0,
1,
".outer.inner",
function()
{this["width"] = 512.0},
0,
1,
".outer .inner",
function() {this["width"] = 512.0},
0,
1,
".outer>.innerTitle",
function()
{this["height"] = 176.0;
this["color"] = 16777215;
this["background"] = ["url('assets/welcome_card.jpg')",
"center"
 , "/", "cover"]},
0,
1,
".outer>.innerMenu",
function() {this["color"] = 16777215},
0,
1,
"h4",
function()
{this["color"] = 16777215},
0,
1,
".outerother.inner",
function() {this["height"] = 320.0;
this["width"]
= 320.0},
0,
1,
".outerother-square>.innerTitle",
function() {this["color"] = 16777215;
this["background"]
= ["url('assets/dog.png')", "bottom", "right", 15.0, "no-repeat", 4634284]},
0,
1,
".usescalc",
function()
{this["color"] = 16777215;
this["width"] = null},
0,
1,
".FLEX35340A",
function() {this["transform"]
= null;
this["background"] = null;
this["filter"] = null},
0,
1,
".FLEX35340B",
function()
{this["background"] = null},
0,
1,
".FLEX35340C",
function() {this["background"] = null},
0,
1,
".FLEX35340D",
function()
{this["boxShadow"] = ["0 2px 2px 0 rgba(0,0,0,.14)", "0 3px 1px -2px rgba(0,0,0,.2)", "0 1px
5px 0 rgba(0,0,0,.12)"];
this["textShadow"] = [0.0, -1.0, 0.0, 2986344448];
+this["fontFamily"] = ["Georgia", "Times New Roman", "Times", "serif"]},
 0,
 1,
 ".FLEX35346",
diff --git a/compiler-jx/src/test/resources/royale/files/CSSTestSource_result.css b/compiler-jx/src/test/resources/royale/files/CSSTestSource_result.css
index 42684f0..e306d1d 100755
--- a/compiler-jx/src/test/resources/royale/files/CSSTestSource_result.css
+++ b/compiler-jx/src/test/resources/royale/files/CSSTestSource_result.css
@@ -108,6 +108,7 @@
 
 .FLEX35340D {
         box-shadow: 0 2px 2px 0 rgba(0,0,0,.14), 0 3px 1px -2px rgba(0,0,0,.2), 0 1px 5px
0 rgba(0,0,0,.12);
+        text-shadow: 0 -1px 0 rgba(0,0,0,0.70);
         font-family: Georgia, Times New Roman, Times, serif;
 }
 
diff --git a/compiler/src/main/java/org/apache/royale/compiler/internal/css/CSSRgbaColorPropertyValue.java
b/compiler/src/main/java/org/apache/royale/compiler/internal/css/CSSRgbaColorPropertyValue.java
index fdc9634..af74e70 100644
--- a/compiler/src/main/java/org/apache/royale/compiler/internal/css/CSSRgbaColorPropertyValue.java
+++ b/compiler/src/main/java/org/apache/royale/compiler/internal/css/CSSRgbaColorPropertyValue.java
@@ -55,7 +55,7 @@ public class CSSRgbaColorPropertyValue extends CSSPropertyValue
      * @param rgb definition - rgba(100, 0, 0)
      * @return int value bit color.
      */
-    protected static int getIntValue(String rgb)
+    protected static long getIntValue(String rgb)
     {        
         rgb = rgb.substring(5, rgb.length() - 1);
         
@@ -85,22 +85,22 @@ public class CSSRgbaColorPropertyValue extends CSSPropertyValue
                     Float alpha = Float.valueOf(t);
                     alpha *= 255;
                     digit = alpha.intValue();
-                    sb.append(Character.forDigit((digit >> 4) & 15, 16));
-                    sb.append(Character.forDigit(digit & 15, 16));
+                    sb.insert(0, Character.forDigit((digit >> 4) & 15, 16));
+                    sb.insert(1, Character.forDigit(digit & 15, 16));
                 }
             }            
         }
-        return Integer.parseInt( sb.substring(0, 6).toString(), 16 );
+        return Long.parseLong( sb.substring(0, 8), 16 );
     }
 
     private final Token token;
-    private final int colorInt;
+    private final long colorInt;
     private final String rawRgb;
  
     /**
      * @return Integer value bit color.
      */
-    public int getColorAsInt()
+    public long getColorAsLong()
     {
         return colorInt;
     }
diff --git a/compiler/src/main/java/org/apache/royale/compiler/internal/css/codegen/CSSReducer.java
b/compiler/src/main/java/org/apache/royale/compiler/internal/css/codegen/CSSReducer.java
index 0e03556..293bb40 100644
--- a/compiler/src/main/java/org/apache/royale/compiler/internal/css/codegen/CSSReducer.java
+++ b/compiler/src/main/java/org/apache/royale/compiler/internal/css/codegen/CSSReducer.java
@@ -462,7 +462,7 @@ public class CSSReducer implements ICSSCodeGenResult
         }
         else if (value instanceof CSSRgbaColorPropertyValue)
         {
-            valueInstructions.addInstruction(ABCConstants.OP_pushint, new Integer(((CSSRgbaColorPropertyValue)value).getColorAsInt()));
+            valueInstructions.addInstruction(ABCConstants.OP_pushint, new Long(((CSSRgbaColorPropertyValue)value).getColorAsLong()));
         }
         else if (value instanceof CSSKeywordPropertyValue)
         {

-- 
To stop receiving notification emails like this one, please contact
aharui@apache.org.

Mime
View raw message