Class RemoveVendorSpecificProperties

java.lang.Object
com.google.common.css.compiler.ast.DefaultTreeVisitor
com.google.common.css.compiler.passes.RemoveVendorSpecificProperties
All Implemented Interfaces:
AtRuleHandler, CssCompilerPass, CssTreeVisitor

public class RemoveVendorSpecificProperties extends DefaultTreeVisitor implements CssCompilerPass
A CssCompilerPass that removes all vendor-specific properties, except for one Vendor that is specified in the constructor. This is designed to facilitate creating a vendor-specific stylesheet. For example, suppose you have the following CSS:
 .button {
   border-radius: 2px;
   -moz-border-radius: 2px;
   -webkit-border-radius: 2px;
 }
 

If Vendor.WEBKIT were specified as the "vendor to keep" when running this pass, then the resulting CSS would be:

 .button {
   border-radius: 2px;
   -webkit-border-radius: 2px;
 }
 
border-radius would not be removed because it is not a vendor-specific property, and -webkit-border-radius would not be removed because Vendor.WEBKIT was specified as the "vendor to keep." Only -moz-border-radius is removed because it is vendor-specific, but it is not the whitelisted vendor. If there were properties prefixed with "-o-" for Opera or "-ms-" for Microsoft, then those would have been removed, as well.
  • Constructor Details

    • RemoveVendorSpecificProperties

      public RemoveVendorSpecificProperties(@Nonnull Vendor vendorToKeep, MutatingVisitController visitController)
      Parameters:
      vendorToKeep - determines the vendor for whose vendor-specific properties will not be stripped. This parameter may not be null: if there is no such venor, then this pass should not be used.
      visitController - to facilitate traversing the AST
  • Method Details