You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ah...@apache.org on 2016/11/28 22:29:12 UTC
git commit: [flex-falcon] [refs/heads/develop] - FLEX-35171 handle
more CSS scenarios
Repository: flex-falcon
Updated Branches:
refs/heads/develop b628a01d0 -> 3c4cd6cd8
FLEX-35171 handle more CSS scenarios
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/3c4cd6cd
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/3c4cd6cd
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/3c4cd6cd
Branch: refs/heads/develop
Commit: 3c4cd6cd8ca4015a9fbadeeb7a81760a938bf4bc
Parents: b628a01
Author: Alex Harui <ah...@apache.org>
Authored: Mon Nov 28 14:29:00 2016 -0800
Committer: Alex Harui <ah...@apache.org>
Committed: Mon Nov 28 14:29:00 2016 -0800
----------------------------------------------------------------------
.../mxml/flexjs/TestFlexJSMXMLApplication.java | 24 +++++++
.../flex/compiler/internal/test/TestBase.java | 9 +++
.../test/resources/flexjs/files/CSSTest.mxml | 28 ++++++++
.../resources/flexjs/files/CSSTestSource.css | 73 +++++++++++++++++++
.../flexjs/files/CSSTestSource_result.css | 76 ++++++++++++++++++++
.../apache/flex/compiler/css/ICSSSelector.java | 10 +++
.../flex/compiler/internal/css/CSSProperty.java | 14 ++--
.../flex/compiler/internal/css/CSSSelector.java | 1 +
.../css/codegen/CSSCompilationSession.java | 2 +-
9 files changed, 229 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3c4cd6cd/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/mxml/flexjs/TestFlexJSMXMLApplication.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/mxml/flexjs/TestFlexJSMXMLApplication.java b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/mxml/flexjs/TestFlexJSMXMLApplication.java
index f1c87b3..95f5476 100644
--- a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/mxml/flexjs/TestFlexJSMXMLApplication.java
+++ b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/mxml/flexjs/TestFlexJSMXMLApplication.java
@@ -18,7 +18,11 @@
*/
package org.apache.flex.compiler.internal.codegen.mxml.flexjs;
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+
import org.apache.flex.compiler.internal.codegen.js.flexjs.JSFlexJSEmitter;
+import org.apache.flex.compiler.internal.driver.js.flexjs.JSCSSCompilationSession;
import org.apache.flex.compiler.internal.driver.js.goog.JSGoogConfiguration;
import org.apache.flex.compiler.internal.projects.FlexJSProject;
import org.apache.flex.compiler.internal.test.FlexJSTestBase;
@@ -29,6 +33,7 @@ import org.apache.flex.utils.TestAdapterFactory;
import org.junit.Test;
import java.io.File;
+import java.util.ArrayList;
public class TestFlexJSMXMLApplication extends FlexJSTestBase
{
@@ -42,6 +47,25 @@ public class TestFlexJSMXMLApplication extends FlexJSTestBase
}
@Test
+ public void testCSSComplexSelectors()
+ {
+ String fileName = "CSSTest";
+
+ IMXMLFileNode node = compileMXML(fileName, true,
+ new File(testAdapter.getUnitTestBaseDir(), "flexjs/files").getPath(), false);
+
+ mxmlBlockWalker.visitFile(node);
+
+ JSCSSCompilationSession jscss = (JSCSSCompilationSession)project.getCSSCompilationSession();
+ jscss.setExcludeDefaultsCSSFiles(new ArrayList<String>());
+
+ String result = getCodeFromFile("CSSTestSource_result.css", "flexjs/files");
+ String output = jscss.emitCSS();
+ assertThat(output, is(result));
+
+ }
+
+ @Test
public void testFile()
{
String fileName = "wildcard_import";
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3c4cd6cd/compiler-jx/src/test/java/org/apache/flex/compiler/internal/test/TestBase.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/test/TestBase.java b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/test/TestBase.java
index c0234fa..626b079 100644
--- a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/test/TestBase.java
+++ b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/test/TestBase.java
@@ -626,6 +626,15 @@ public class TestBase implements ITestBase
return readCodeFile(testFile);
}
+ protected String getCodeFromFile(String fileName,
+ String sourceDir)
+ {
+ File testFile = new File(TestAdapterFactory.getTestAdapter().getUnitTestBaseDir(),
+ sourceDir + "/" + fileName);
+
+ return readCodeFile(testFile);
+ }
+
protected String readCodeFile(File file)
{
boolean isResult = file.getName().contains("_result") || file.getName().equals("output.js");
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3c4cd6cd/compiler-jx/src/test/resources/flexjs/files/CSSTest.mxml
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/resources/flexjs/files/CSSTest.mxml b/compiler-jx/src/test/resources/flexjs/files/CSSTest.mxml
new file mode 100644
index 0000000..809272d
--- /dev/null
+++ b/compiler-jx/src/test/resources/flexjs/files/CSSTest.mxml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+
+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.
+
+-->
+<basic:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
+ xmlns:basic="library://ns.apache.org/flexjs/basic"
+ >
+ <fx:Script>
+ <![CDATA[
+ ]]>
+ </fx:Script>
+ <fx:Style source="CSSTestSource.css" />
+</basic:Application>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3c4cd6cd/compiler-jx/src/test/resources/flexjs/files/CSSTestSource.css
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/resources/flexjs/files/CSSTestSource.css b/compiler-jx/src/test/resources/flexjs/files/CSSTestSource.css
new file mode 100755
index 0000000..85523f8
--- /dev/null
+++ b/compiler-jx/src/test/resources/flexjs/files/CSSTestSource.css
@@ -0,0 +1,73 @@
+/*******************************************************************************
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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.
+//
+////////////////////////////////////////////////////////////////////////////////
+*/
+
+@namespace basic "library://ns.apache.org/flexjs/basic";
+
+/*
+//----------------------------
+// Named styles
+//----------------------------
+*/
+.glass {
+ borderColor: #767473;
+ fillAlphas: .60, .60, .60, .60;
+ fillColors: #888888, #F3F3F3, #9E9E9E, #FCFCFC;
+ highlightAlphas: .07, .45;
+}
+
+.glassSlider
+{
+ fillAlphas: .80, .80, .80, .80;
+ fillColors: #F3F3F3, #BBBBBB, #FCFCFC, #CCCCCC;
+}
+
+.listItem
+{
+ paddingLeft: 4;
+ paddingRight: 4;
+ horizontalGap: 5;
+ verticalAlign: "middle";
+ backgroundColor: #FFFFFF;
+ backgroundAlpha: .5;
+ borderStyle: "outset";
+}
+
+.outer.inner {
+ width: 512px;
+}
+.outer > .innerTitle {
+ color: #fff;
+ height: 176px;
+ background: url('assets/welcome_card.jpg') center / cover;
+}
+.outer > .innerMenu {
+ color: #fff;
+}
+
+.outerother.inner {
+ width: 320px;
+ height: 320px;
+}
+
+.outerother-square > .innerTitle {
+ color: #fff;
+ background: url('assets/dog.png') bottom right 15% no-repeat #46B6AC;
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3c4cd6cd/compiler-jx/src/test/resources/flexjs/files/CSSTestSource_result.css
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/resources/flexjs/files/CSSTestSource_result.css b/compiler-jx/src/test/resources/flexjs/files/CSSTestSource_result.css
new file mode 100755
index 0000000..b3f8b21
--- /dev/null
+++ b/compiler-jx/src/test/resources/flexjs/files/CSSTestSource_result.css
@@ -0,0 +1,76 @@
+/*******************************************************************************
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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.
+//
+////////////////////////////////////////////////////////////////////////////////
+*/
+/* Generated by Apache Flex Cross-Compiler */
+.glass {
+ border-color: #767473;
+ highlight-alphas: .07 .45;
+ fill-colors: #888888 #F3F3F3 #9E9E9E #FCFCFC;
+ fill-alphas: .60 .60 .60 .60;
+}
+
+
+.glassSlider {
+ fill-colors: #F3F3F3 #BBBBBB #FCFCFC #CCCCCC;
+ fill-alphas: .80 .80 .80 .80;
+}
+
+
+.listItem {
+ border-style: outset;
+ background-color: #FFFFFF;
+ vertical-align: middle;
+ horizontal-gap: 5;
+ background-alpha: .5;
+ padding-left: 4;
+ padding-right: 4;
+}
+
+
+.outer.inner {
+ width: 512px;
+}
+
+
+.outer > .innerTitle {
+ height: 176px;
+ color: #fff;
+ background: url('assets/welcome_card.jpg') center / cover;
+}
+
+
+.outer > .innerMenu {
+ color: #fff;
+}
+
+
+.outerother.inner {
+ height: 320px;
+ width: 320px;
+}
+
+
+.outerother-square > .innerTitle {
+ color: #fff;
+ background: url('assets/dog.png') bottom right 15% no-repeat #46B6AC;
+}
+
+
+
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3c4cd6cd/compiler/src/main/java/org/apache/flex/compiler/css/ICSSSelector.java
----------------------------------------------------------------------
diff --git a/compiler/src/main/java/org/apache/flex/compiler/css/ICSSSelector.java b/compiler/src/main/java/org/apache/flex/compiler/css/ICSSSelector.java
index 5ea7ba3..bb1a841 100644
--- a/compiler/src/main/java/org/apache/flex/compiler/css/ICSSSelector.java
+++ b/compiler/src/main/java/org/apache/flex/compiler/css/ICSSSelector.java
@@ -19,6 +19,8 @@
package org.apache.flex.compiler.css;
+import java.util.List;
+
import com.google.common.collect.ImmutableList;
/**
@@ -87,6 +89,14 @@ public interface ICSSSelector extends ICSSNode
String getCSSSyntax();
/**
+ * This API is explicitly added so that no CSS compilation logic will depend
+ * on {@code toString()} value of an {@link ICSSNode}.
+ *
+ * @return The CSS text from which this selector is generated.
+ */
+ String stringifyConditions(List<ICSSSelectorCondition> conditions);
+
+ /**
* Check if a selector uses Flex 4 advanced syntax. An advanced selector
* can't be used in {@code -compatibility-version=3} mode.
*
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3c4cd6cd/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 bab839e..c977341 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
@@ -60,9 +60,9 @@ public class CSSProperty extends CSSNodeBase implements ICSSProperty
if (rawName.equalsIgnoreCase("border"))
{
CSSArrayPropertyValue borderValues = (CSSArrayPropertyValue)value;
- return String.format("%s : %s ;", rawName, Joiner.on(" ").join(borderValues.getElements()));
+ return String.format("%s: %s;", rawName, Joiner.on(" ").join(borderValues.getElements()));
}
- return String.format("%s : %s ;", rawName, value.toString());
+ return String.format("%s: %s;", rawName, value.toString());
}
public String toCSSString()
@@ -74,24 +74,24 @@ public class CSSProperty extends CSSNodeBase implements ICSSProperty
}
if (cssName.equals("content"))
{
- return String.format("%s : \"%s\" ;", cssName, escape(((CSSStringPropertyValue)value).getValue()));
+ return String.format("%s: \"%s\";", cssName, escape(((CSSStringPropertyValue)value).getValue()));
}
if (value instanceof CSSStringPropertyValue)
{
- return String.format("%s : %s ;", cssName, ((CSSStringPropertyValue)value).getValue());
+ return String.format("%s: %s;", cssName, ((CSSStringPropertyValue)value).getValue());
}
if (value instanceof CSSFunctionCallPropertyValue)
{
- return String.format("%s : %s ;", cssName, ((CSSFunctionCallPropertyValue)value).toString());
+ 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, Joiner.on(" ").join(borderValues.getElements()));
}
}
- return String.format("%s : %s ;", cssName, value.toString());
+ return String.format("%s: %s;", cssName, value.toString());
}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3c4cd6cd/compiler/src/main/java/org/apache/flex/compiler/internal/css/CSSSelector.java
----------------------------------------------------------------------
diff --git a/compiler/src/main/java/org/apache/flex/compiler/internal/css/CSSSelector.java b/compiler/src/main/java/org/apache/flex/compiler/internal/css/CSSSelector.java
index b3290b8..a28c9b9 100644
--- a/compiler/src/main/java/org/apache/flex/compiler/internal/css/CSSSelector.java
+++ b/compiler/src/main/java/org/apache/flex/compiler/internal/css/CSSSelector.java
@@ -106,6 +106,7 @@ public class CSSSelector extends CSSNodeBase implements ICSSSelector
return result.toString();
}
+ @Override
public String stringifyConditions(List<ICSSSelectorCondition> conditions)
{
StringBuilder s = new StringBuilder();
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3c4cd6cd/compiler/src/main/java/org/apache/flex/compiler/internal/css/codegen/CSSCompilationSession.java
----------------------------------------------------------------------
diff --git a/compiler/src/main/java/org/apache/flex/compiler/internal/css/codegen/CSSCompilationSession.java b/compiler/src/main/java/org/apache/flex/compiler/internal/css/codegen/CSSCompilationSession.java
index c6e7560..347163f 100644
--- a/compiler/src/main/java/org/apache/flex/compiler/internal/css/codegen/CSSCompilationSession.java
+++ b/compiler/src/main/java/org/apache/flex/compiler/internal/css/codegen/CSSCompilationSession.java
@@ -312,7 +312,7 @@ public class CSSCompilationSession
selectorQname = qname;
}
final String resolvedSelectorName = selectorQname.concat(
- Joiner.on("").join(selector.getConditions()));
+ selector.getCSSSyntax());
return resolvedSelectorName;
}