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 Details

    • BORDER_RADIUS_PROPERTIES

      public static final com.google.common.collect.ImmutableSet<String> BORDER_RADIUS_PROPERTIES
    • FOUR_PART_PROPERTIES_THAT_SHOULD_FLIP

      public static final com.google.common.collect.ImmutableSet<String> FOUR_PART_PROPERTIES_THAT_SHOULD_FLIP
      Set of properties whose property values may flip if they match the four-part pattern.
  • Constructor Details

    • BiDiFlipper

      public BiDiFlipper(MutatingVisitController visitController, boolean swapLtrRtlInUrl, boolean swapLeftRightInUrl, boolean shouldFlipConstantReferences)
    • BiDiFlipper

      public BiDiFlipper(MutatingVisitController visitController, boolean swapLtrRtlInUrl, boolean swapLeftRightInUrl)
  • Method Details

    • flipPercentageValue

      public static String flipPercentageValue(String value)
      Returns a formatted string representing 100% - value. Neither the input nor the output contains a %.
    • flipLiteralValue

      public static String flipLiteralValue(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: CssTreeVisitor
      Called before visiting a CssDeclarationNode's sub trees
      Specified by:
      enterDeclaration in interface CssTreeVisitor
      Overrides:
      enterDeclaration in class DefaultTreeVisitor
    • runPass

      public void runPass()
      Specified by:
      runPass in interface CssCompilerPass