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 b4eef09 handle elements in child and preceded selectors. fixes #37
b4eef09 is described below
commit b4eef0922feaee924f6b89beb50cf2c92c47c4c1
Author: Alex Harui <[email protected]>
AuthorDate: Fri Mar 30 15:25:17 2018 -0700
handle elements in child and preceded selectors. fixes #37
---
.../driver/js/royale/JSCSSCompilationSession.java | 18 ++++++++++++++++++
.../src/test/resources/royale/files/CSSTestSource.css | 4 ++++
.../royale/files/CSSTestSource_encoded_result.txt | 3 ++-
.../resources/royale/files/CSSTestSource_result.css | 5 +++++
.../org/apache/royale/compiler/internal/css/CSS.g | 15 ++++++++++++++-
5 files changed, 43 insertions(+), 2 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 0900975..40fc8de 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
@@ -150,6 +150,24 @@ public class JSCSSCompilationSession extends
CSSCompilationSession
condition = s.substring(brace);
s = s.substring(0, brace);
}
+ else
+ {
+ int child = s.indexOf(">");
+ if (child != -1)
+ {
+ condition = s.substring(child);
+ s = s.substring(0, child);
+ }
+ else
+ {
+ int preceded = s.indexOf("+");
+ if (preceded != -1)
+ {
+ condition =
s.substring(preceded);
+ s = s.substring(0,
preceded);
+ }
+ }
+ }
}
if (!htmlElementNames.contains(s.toLowerCase()))
{
diff --git a/compiler-jx/src/test/resources/royale/files/CSSTestSource.css
b/compiler-jx/src/test/resources/royale/files/CSSTestSource.css
index f5c670e..2fb4dab 100755
--- a/compiler-jx/src/test/resources/royale/files/CSSTestSource.css
+++ b/compiler-jx/src/test/resources/royale/files/CSSTestSource.css
@@ -148,6 +148,10 @@ input[type="range"] {
content: '\2714';
}
+input + .innerMenu {
+ color: #fff;
+}
+
.complex {
background: url("data:image/svg+xml;utf8,<svg viewBox='0 0 16 13'
version='1.1' xmlns='http://www.w3.org/2000/svg'><g transform='translate(-763,
-290)'><g transform='translate(760, 285)'><g><polygon fill='#ffffff' points='3
13 9 18 19 7 16 5 9 13 6 10'></polygon></g></g></g></svg>"), #b3dffa;
}
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 e107431..ceead6c 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
@@ -35,5 +35,6 @@ this["border"] = 0.0;
this["WebkitTransform"] = null;
this["top"] = 50.0},
0,
1,
"input",
function() {this["padding"] = 0.0},
0,
1,
"input[type=\"checkbox\"]",
function() {this["padding"] = 0.0},
0,
1,
".slider::-webkit-slider-thumb",
function() {this["padding"] = 0.0},
0,
1,
"input[type=\"range\"]",
function() {this["content"] = "assets/checkbox-tick.svg";
-this["padding"] = 0.0},
0,
1,
"input[type=\"range\"]",
function() {this["content"] = "✔";
this["padding"] = 0.0},
0,
1,
".complex",
function() {this["background"] = ["url(\"data:image/svg+xml;utf8,<svg
viewBox='0 0 16 13' version='1.1' xmlns='http://www.w3.org/2000/svg'><g
transform='translate(-763, -290)'><g transform='translate(760,
285)'><g><polygon fill='#ffffff' points='3 13 9 18 19 7 16 5 9 13 6
10'></polygon></g></g></g></svg>\")", 11788282]}];
+this["padding"] = 0.0},
0,
1,
"input[type=\"range\"]",
function() {this["content"] = "✔";
this["padding"] = 0.0},
0,
1,
"input+.innerMenu",
function() {this["color"] = 16777215},
0,
1,
+".complex",
function() {this["background"] = ["url(\"data:image/svg+xml;utf8,<svg
viewBox='0 0 16 13' version='1.1' xmlns='http://www.w3.org/2000/svg'><g
transform='translate(-763, -290)'><g transform='translate(760,
285)'><g><polygon fill='#ffffff' points='3 13 9 18 19 7 16 5 9 13 6
10'></polygon></g></g></g></svg>\")", 11788282]}];
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 ba88e0a..6b77bea 100755
--- a/compiler-jx/src/test/resources/royale/files/CSSTestSource_result.css
+++ b/compiler-jx/src/test/resources/royale/files/CSSTestSource_result.css
@@ -163,6 +163,11 @@ input[type="range"] {
}
+input+.innerMenu {
+ color: #fff;
+}
+
+
.complex {
background: url("data:image/svg+xml;utf8,<svg viewBox='0 0 16 13'
version='1.1' xmlns='http://www.w3.org/2000/svg'><g transform='translate(-763,
-290)'><g transform='translate(760, 285)'><g><polygon fill='#ffffff' points='3
13 9 18 19 7 16 5 9 13 6 10'></polygon></g></g></g></svg>"), #b3dffa;
}
diff --git
a/compiler/src/main/antlr3/org/apache/royale/compiler/internal/css/CSS.g
b/compiler/src/main/antlr3/org/apache/royale/compiler/internal/css/CSS.g
index 4401435..cf74090 100644
--- a/compiler/src/main/antlr3/org/apache/royale/compiler/internal/css/CSS.g
+++ b/compiler/src/main/antlr3/org/apache/royale/compiler/internal/css/CSS.g
@@ -140,6 +140,19 @@ private final int endOfSimpleSelector()
// Check if there's white space between the previous token and the next
token.
final CommonToken lastToken = (CommonToken) getTokenStream().LT(-1);
+ final int lastType = lastToken.getType();
+ if (lastType == CHILD)
+ {
+ return 1;
+ }
+ if (lastType == PRECEDED)
+ {
+ return 2;
+ }
+ if (lastType == TILDE)
+ {
+ return 3;
+ }
if (lastToken != null && nextToken != null)
{
final int lastStop = lastToken.getStopIndex();
@@ -288,7 +301,7 @@ compoundSelector
for(final Object simpleSelectorNode : simpleSelectorNodeList)
adaptor.addChild($compoundSelector.tree, simpleSelectorNode);
}
- : ( l=simpleSelectorFraction
+ : ( l=simpleSelectorFraction ( '+' | '>' )?
{
// expand token range of the current simple selector
if (simpleSelectorStartToken == null)
--
To stop receiving notification emails like this one, please contact
[email protected].