Class BiDiFlipper
- java.lang.Object
-
- com.google.common.css.compiler.ast.DefaultTreeVisitor
-
- com.google.common.css.compiler.passes.BiDiFlipper
-
- All Implemented Interfaces:
AtRuleHandler,CssCompilerPass,CssTreeVisitor
public class BiDiFlipper extends DefaultTreeVisitor implements CssCompilerPass
Compiler pass that BiDi flips all the flippable nodes. TODO(user): Need to add a function to return tree before flipping.
-
-
Field Summary
Fields Modifier and Type Field Description static com.google.common.collect.ImmutableSet<java.lang.String>BORDER_RADIUS_PROPERTIESstatic com.google.common.collect.ImmutableSet<java.lang.String>FOUR_PART_PROPERTIES_THAT_SHOULD_FLIPSet of properties whose property values may flip if they match the four-part pattern.static java.lang.StringRIGHT
-
Constructor Summary
Constructors Constructor Description BiDiFlipper(MutatingVisitController visitController, boolean swapLtrRtlInUrl, boolean swapLeftRightInUrl)BiDiFlipper(MutatingVisitController visitController, boolean swapLtrRtlInUrl, boolean swapLeftRightInUrl, boolean shouldFlipConstantReferences)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanenterDeclaration(CssDeclarationNode declarationNode)Called before visiting aCssDeclarationNode's sub treesstatic java.lang.StringflipLiteralValue(java.lang.String value)Performs appropriate replacements needed for BiDi flipping a literal value.protected <T extends CssValueNode>
TflipNode(T tNode)Returns flipped node after making appropriate replacements needed for BiDi flipping, if the node is either a LiteralNode or PropertyNode.static java.lang.StringflipPercentageValue(java.lang.String value)Returns a formatted string representing 100% - value.voidrunPass()-
Methods inherited from class com.google.common.css.compiler.ast.DefaultTreeVisitor
enterArgumentNode, enterAttributeSelector, enterBlock, enterCharSet, enterClassSelector, enterCombinator, enterComponent, enterCompositeValueNode, enterCompositeValueNodeOperator, enterConditionalBlock, enterConditionalRule, enterDeclarationBlock, enterDefinition, enterFontFace, enterForLoop, enterFunctionNode, enterIdSelector, enterImportBlock, enterImportRule, enterKey, enterKeyBlock, enterKeyframeRuleset, enterKeyframesRule, enterMediaRule, enterMediaTypeListDelimiter, enterMixin, enterMixinDefinition, enterPageRule, enterPageSelector, enterPropertyValue, enterProvideNode, enterPseudoClass, enterPseudoElement, enterRequireNode, enterRuleset, enterSelector, enterSelectorBlock, enterTree, enterUnknownAtRule, enterValueNode, leaveArgumentNode, leaveAttributeSelector, leaveBlock, leaveCharSet, leaveClassSelector, leaveCombinator, leaveComponent, leaveCompositeValueNode, leaveCompositeValueNodeOperator, leaveConditionalBlock, leaveConditionalRule, leaveDeclaration, leaveDeclarationBlock, leaveDefinition, leaveFontFace, leaveForLoop, leaveFunctionNode, leaveIdSelector, leaveImportBlock, leaveImportRule, leaveKey, leaveKeyBlock, leaveKeyframeRuleset, leaveKeyframesRule, leaveMediaRule, leaveMediaTypeListDelimiter, leaveMixin, leaveMixinDefinition, leavePageRule, leavePageSelector, leavePropertyValue, leaveProvideNode, leavePseudoClass, leavePseudoElement, leaveRequireNode, leaveRuleset, leaveSelector, leaveSelectorBlock, leaveTree, leaveUnknownAtRule, leaveValueNode
-
-
-
-
Field Detail
-
RIGHT
public static final java.lang.String RIGHT
- See Also:
- Constant Field Values
-
BORDER_RADIUS_PROPERTIES
public static final com.google.common.collect.ImmutableSet<java.lang.String> BORDER_RADIUS_PROPERTIES
-
FOUR_PART_PROPERTIES_THAT_SHOULD_FLIP
public static final com.google.common.collect.ImmutableSet<java.lang.String> FOUR_PART_PROPERTIES_THAT_SHOULD_FLIP
Set of properties whose property values may flip if they match the four-part pattern.
-
-
Constructor Detail
-
BiDiFlipper
public BiDiFlipper(MutatingVisitController visitController, boolean swapLtrRtlInUrl, boolean swapLeftRightInUrl, boolean shouldFlipConstantReferences)
-
BiDiFlipper
public BiDiFlipper(MutatingVisitController visitController, boolean swapLtrRtlInUrl, boolean swapLeftRightInUrl)
-
-
Method Detail
-
flipPercentageValue
public static java.lang.String flipPercentageValue(java.lang.String value)
Returns a formatted string representing 100% - value. Neither the input nor the output contains a%.
-
flipLiteralValue
public static java.lang.String flipLiteralValue(java.lang.String value)
Performs appropriate replacements needed for BiDi flipping a literal value.
-
flipNode
protected <T extends CssValueNode> T flipNode(T tNode)
Returns flipped node after making appropriate replacements needed for BiDi flipping, if the node is either a LiteralNode or PropertyNode. Eg: PropertyNode 'padding-right' would become 'padding-left'.Subclasses can override to provide custom flipping behavior.
-
enterDeclaration
public boolean enterDeclaration(CssDeclarationNode declarationNode)
Description copied from interface:CssTreeVisitorCalled before visiting aCssDeclarationNode's sub trees- Specified by:
enterDeclarationin interfaceCssTreeVisitor- Overrides:
enterDeclarationin classDefaultTreeVisitor
-
runPass
public void runPass()
- Specified by:
runPassin interfaceCssCompilerPass
-
-