Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
If you try to access a constant through CssResource interface with a definition referring to a function or another constant, the returned value was not correct. This patch fixes also the AssertionError introduced in a previous (reverted) patch when using constants with custom function. Bug: issue 9113 Change-Id: Icc5adc94990ddb627d119f8bab06870ffc66450a
- Loading branch information
Showing
6 changed files
with
86 additions
and
84 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
user/src/com/google/gwt/resources/gss/CollectAndRemoveConstantDefinitions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,52 @@ | |||
/* | |||
* Copyright 2014 Google Inc. | |||
* | |||
* Licensed 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 com.google.gwt.resources.gss; | |||
|
|||
import com.google.gwt.thirdparty.common.css.compiler.ast.CssCompilerPass; | |||
import com.google.gwt.thirdparty.common.css.compiler.ast.CssDefinitionNode; | |||
import com.google.gwt.thirdparty.common.css.compiler.ast.CssTree; | |||
import com.google.gwt.thirdparty.common.css.compiler.ast.MutatingVisitController; | |||
import com.google.gwt.thirdparty.common.css.compiler.passes.CollectConstantDefinitions; | |||
|
|||
/** | |||
* A pass that collects the constant definitions inside the tree. This pass removes the constant | |||
* definitions during the collect. | |||
*/ | |||
public class CollectAndRemoveConstantDefinitions extends CollectConstantDefinitions | |||
implements CssCompilerPass { | |||
|
|||
private final MutatingVisitController visitController; | |||
|
|||
public CollectAndRemoveConstantDefinitions(CssTree tree) { | |||
this(tree.getMutatingVisitController()); | |||
} | |||
|
|||
public CollectAndRemoveConstantDefinitions(MutatingVisitController visitController) { | |||
super(visitController); | |||
|
|||
this.visitController = visitController; | |||
} | |||
|
|||
@Override | |||
public boolean enterDefinition(CssDefinitionNode node) { | |||
super.enterDefinition(node); | |||
|
|||
visitController.removeCurrentNode(); | |||
|
|||
return false; | |||
} | |||
} |
74 changes: 0 additions & 74 deletions
74
user/src/com/google/gwt/resources/gss/ConstantResolver.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 14 additions & 1 deletion
15
user/test/com/google/gwt/resources/client/gss/constants.gss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,3 +1,16 @@ | |||
@def COLOR1 #012345; | @if (is("custom.one", "bar")) { | ||
@def COLOR1 #012345; | |||
} | |||
@else { | |||
@def COLOR1 #543210; | |||
} | |||
|
|||
@def MYCOLOR COLOR1; | @def MYCOLOR COLOR1; | ||
@def MYCOLOR1 MYCOLOR; | @def MYCOLOR1 MYCOLOR; | ||
|
|||
@def PADDING add(5px, 5px); | |||
@def PADDING2 PADDING; | |||
|
|||
@def MARGIN1 5px; | |||
@def MARGIN2 5px; | |||
@def MARGIN add(MARGIN1, MARGIN2); |