Skip to content
This repository has been archived by the owner on Feb 23, 2022. It is now read-only.
Permalink
Browse files
Give credit where credit is due.
  • Loading branch information
iflan committed Dec 30, 2011
1 parent d31b2eb commit 2682982
Show file tree
Hide file tree
Showing 44 changed files with 69 additions and 30 deletions.
@@ -19,6 +19,7 @@
/**
* Shim class for the class moved to the passes package.
*
* @author fbenz@google.com (Florian Benz)
*/
public class CreateComponentNodes extends
com.google.common.css.compiler.passes.CreateComponentNodes {
@@ -19,6 +19,7 @@
/**
* Shim class for the class moved to the passes package.
*
* @author fbenz@google.com (Florian Benz)
*/
public class CreateConditionalNodes extends
com.google.common.css.compiler.passes.CreateConditionalNodes {
@@ -19,6 +19,7 @@
/**
* Shim class for the class moved to the passes package.
*
* @author fbenz@google.com (Florian Benz)
*/
public class CreateConstantReferences extends
com.google.common.css.compiler.passes.CreateConstantReferences {
@@ -19,6 +19,7 @@
/**
* Shim class for the class moved to the passes package.
*
* @author fbenz@google.com (Florian Benz)
*/
public class CreateDefinitionNodes extends
com.google.common.css.compiler.passes.CreateDefinitionNodes {
@@ -32,6 +32,7 @@
* because all instances of the provided classes are accepted as valid.
* If invalid children are added, an {@link IllegalStateException} is thrown.
*
* @author fbenz@google.com (Florian Benz)
*/
public abstract class CssAbstractBlockNode
extends CssNodesListNode<CssNode> {
@@ -23,6 +23,7 @@
* A {@link CssRefinerNode} implementation that represents an attribute
* selector. For example: {@code [hreflang|="en"]}
*
* @author fbenz@google.com (Florian Benz)
*/
public class CssAttributeSelectorNode extends CssRefinerNode {
/** Indicates which kind of attribute selector is used. */
@@ -23,6 +23,7 @@
* A {@link CssRefinerNode} implementation that represents a selector for a
* class. For example: {@code .classy}
*
* @author fbenz@google.com (Florian Benz)
*/
public class CssClassSelectorNode extends CssRefinerNode {
public CssClassSelectorNode(String refinerName,
@@ -23,6 +23,7 @@
* A {@link CssRefinerNode} implementation that represents a selector for an id.
* For example: {@code #id}
*
* @author fbenz@google.com (Florian Benz)
*/
public class CssIdSelectorNode extends CssRefinerNode {
public CssIdSelectorNode(String refinerName,
@@ -22,6 +22,7 @@
* animation.
* For example: <code>0%, 33.3%</code>
*
* @author fbenz@google.com (Florian Benz)
*/
public class CssKeyListNode extends CssNodesListNode<CssKeyNode> {

@@ -32,7 +33,7 @@ public CssKeyListNode() {
public CssKeyListNode(CssKeyListNode node) {
super(node);
}

@Override
public CssKeyListNode deepCopy() {
return new CssKeyListNode(this);
@@ -27,6 +27,7 @@
* <code>to</code> (= 100%).
* For example: <code>0%, 33.3% { ... }</code>
*
* @author fbenz@google.com (Florian Benz)
*/
public class CssKeyNode extends CssNode implements ChunkAware {
/** Value of the key held by this node. */
@@ -24,9 +24,10 @@

/**
* A node representing a keyframe style rule.
* This is used inside a Webkit keyframes rule to represent the style of
* This is used inside a Webkit keyframes rule to represent the style of
* one or more points (specified by the keys) in the animation.
*
* @author fbenz@google.com (Florian Benz)
*/
public class CssKeyframeRulesetNode extends CssNode {
/** List of keys. */
@@ -77,20 +78,20 @@ public CssKeyframeRulesetNode(List<CssCommentNode> comments) {

/**
* Copy constructor.
*
*
* @param node
*/
public CssKeyframeRulesetNode(CssKeyframeRulesetNode node) {
this(node.getDeclarations().deepCopy());
this.setComments(node.getComments());
this.keys = node.getKeys().deepCopy();
}

@Override
public CssKeyframeRulesetNode deepCopy() {
return new CssKeyframeRulesetNode(this);
}

public CssKeyListNode getKeys() {
return keys;
}
@@ -109,11 +110,11 @@ public CssDeclarationBlockNode getDeclarations() {
public void addDeclaration(CssDeclarationNode declaration) {
declarations.addChildToBack(declaration);
}

public void addKey(CssKeyNode key) {
keys.addChildToBack(key);
}

/**
* For debugging only.
*/
@@ -31,6 +31,7 @@
* }
* </pre>
*
* @author fbenz@google.com (Florian Benz)
*/
public class CssMixinDefinitionNode extends CssAtRuleNode {
private final String name;
@@ -25,6 +25,7 @@
* replaced by the corresponding mixin definition.
* For example: {@code @mixin gradient(top, 0%, 80%, 70%, #BADA55)}
*
* @author fbenz@google.com (Florian Benz)
*/
public class CssMixinNode extends CssAtRuleNode {
private final String definitionName;
@@ -21,6 +21,7 @@
/**
* A node representing an @page rule.
*
* @author fbenz@google.com (Florian Benz)
*/
public class CssPageRuleNode extends CssAtRuleNode {

@@ -24,6 +24,7 @@
*
* <p>For example: {@code @bottom-left-corner { ... } }
*
* @author fbenz@google.com (Florian Benz)
*/
public class CssPageSelectorNode extends CssAtRuleNode {

@@ -25,6 +25,7 @@
* A {@link CssRefinerNode} implementation that represents a pseudo-class.
* For example: {@code :visited}, {@code :nth-child(2n)}
*
* @author fbenz@google.com (Florian Benz)
*/
public class CssPseudoClassNode extends CssRefinerNode {
private static final ImmutableSet<String> COMPATIBILITY_PSEUDO_ELEMENTS =
@@ -43,7 +44,7 @@ public class CssPseudoClassNode extends CssRefinerNode {
public enum FunctionType {
NONE,
LANG,
// TODO(user): make the arguments for nth-functions real nodes
// TODO(fbenz): make the arguments for nth-functions real nodes
NTH,
NOT;
// No support for 'any' at the moment because it is relatively new and
@@ -154,7 +155,7 @@ public Specificity getSpecificity() {

@Override
public String toString() {
// TODO(user): toString should not be used to print a node. However,
// TODO(fbenz): toString should not be used to print a node. However,
// some tests rely on it. This should be fixed.
StringBuilder sb = new StringBuilder();
sb.append(refinerType.getPrefix());
@@ -23,6 +23,7 @@
* A {@link CssRefinerNode} implementation that represents a pseudo-element.
* For example: {@code ::after}
*
* @author fbenz@google.com (Florian Benz)
*/
public class CssPseudoElementNode extends CssRefinerNode {
public CssPseudoElementNode(String refinerName,
@@ -36,7 +36,7 @@ public abstract class CssRefinerNode extends CssNode {
/**
* Contains the list of all possible CSS refiners.
*/
// TODO(user): The handling of the pre- and suffixes should be moved to
// TODO(fbenz): The handling of the pre- and suffixes should be moved to
// the corresponding classes.
protected enum Refiner {
CLASS(".", ""),
@@ -19,6 +19,7 @@
/**
* A node representing an @-webkit-keyframes rule.
*
* @author fbenz@google.com (Florian Benz)
*/
public class CssWebkitKeyframesNode extends CssAtRuleNode {

@@ -63,3 +64,4 @@ public CssBlockNode getBlock() {
return (CssBlockNode) super.getBlock();
}
}

@@ -998,7 +998,7 @@ class VisitRefinerNodeState extends BaseVisitState<CssNode> {

@Override
public void doVisit() {
// TODO(user): Actually each of these nodes should have its own state
// TODO(fbenz): Actually each of these nodes should have its own state
// here but this adds a bunch of similar code that is not really
// necessary. The problem is the design of the visit controller. I'm
// going to refactor it so that it doesn't make sense to add all the
@@ -1534,7 +1534,7 @@ CssAtRuleNode at_rule() :
// ]
// [ [ '{' S* style_declaration '} ] | ';' ] S*
// ;
// TODO(user): Try to reuse selctor parsing instead of [ IDENT? ':' IDENT S* ].
// TODO(fbenz): Try to reuse selctor parsing instead of [ IDENT? ':' IDENT S* ].
// The problem is that @-rules take a list of value nodes and selectors are not
// value nodes.
CssAtRuleNode atRuleWithDeclBlock() :
@@ -42,6 +42,7 @@
*
* <p>{@link CreateConstantReferences} has to run before.
*
* @author fbenz@google.com (Florian Benz)
*/
public class CollectMixinDefinitions extends DefaultTreeVisitor
implements CssCompilerPass {
@@ -124,7 +124,7 @@ public boolean enterMediaRule(CssMediaRuleNode node) {
* For example: {@code @media all and (color)}
*/
private void appendMediaParameterWithParentheses(CssValueNode node) {
// TODO(user): Try to avoid the special handling of this case.
// TODO(fbenz): Try to avoid the special handling of this case.
sb.append("(");
sb.append(node.getValue());
sb.append(")");
@@ -139,7 +139,7 @@ public void leaveMediaRule(CssMediaRuleNode node) {
public boolean enterPageRule(CssPageRuleNode node) {
sb.append(node.getType().toString());
sb.append(' ');
// TODO(user): There are only two parameters possible ('bla:left') that
// TODO(fbenz): There are only two parameters possible ('bla:left') that
// come with no whitespace in between. So it would be better to have a
// single node (maybe a selector).
for (CssValueNode param : node.getParameters()) {
@@ -39,6 +39,7 @@
* A compiler pass that transforms matching {@link CssUnknownAtRuleNode}s
* into mixins or mixin definitions.
*
* @author fbenz@google.com (Florian Benz)
*/
public class CreateMixins extends DefaultTreeVisitor
implements CssCompilerPass {
@@ -200,7 +200,7 @@ private void createMediaRule(CssUnknownAtRuleNode node) {
return;
}

// TODO(user): Perform this check depending on the CSS version set in the
// TODO(fbenz): Perform this check depending on the CSS version set in the
// options
if (!checkMediaParameter(params)) {
reportError(INVALID_PARAMETERS_ERROR_MESSAGE, node);
@@ -33,6 +33,7 @@
/**
* Utility methods that can be useful for compiler passes.
*
* @author fbenz@google.com (Florian Benz)
*/
public class PassUtil {

@@ -119,7 +119,7 @@ public boolean enterMediaRule(CssMediaRuleNode node) {
* For example: {@code @media all and (color)}
*/
private void appendMediaParamterWithParentheses(CssValueNode node) {
// TODO(user): Try to avoid the special handling of this case.
// TODO(fbenz): Try to avoid the special handling of this case.
sb.append("(");
sb.append(node.getValue());
sb.append(")");
@@ -242,7 +242,7 @@ public boolean enterValueNode(CssValueNode node) {
sb.append(v);
}

// NOTE(user): When visiting function arguments, we don't want to add extra
// NOTE(flan): When visiting function arguments, we don't want to add extra
// spaces because they are already in the arguments list if they are
// required. Yes, this sucks.
if (!(node.getParent() instanceof CssFunctionArgumentsNode)) {
@@ -35,6 +35,7 @@
* a correct nth-format and can make it compact. In addition, the pass checks
* the constraints for the :not pseudo-class.
*
* @author fbenz@google.com (Florian Benz)
*/
public class ProcessRefiners extends DefaultTreeVisitor
implements CssCompilerPass {
@@ -28,19 +28,20 @@
/**
* Compiler pass which ensures that @-webkit-keframes rules are only allowed if
* they are enabled. In addition this pass checks if the keys are between
* 0% and 100%. If CSS simplification is enabled, "from" is replaced by "0%"
* 0% and 100%. If CSS simplification is enabled, "from" is replaced by "0%"
* and "100%" is replaced by "to".
*
*
* @author fbenz@google.com (Florian Benz)
*/
public class ProcessWebkitKeyframes extends DefaultTreeVisitor
implements CssCompilerPass {
@VisibleForTesting
static final String KEYFRAMES_NOT_ALLOWED_ERROR_MESSAGE =
static final String KEYFRAMES_NOT_ALLOWED_ERROR_MESSAGE =
"a @-webkit-keyframes rule occured but the option for it is disabled";
@VisibleForTesting
static final String WRONG_KEY_VALUE_ERROR_MESSAGE =
static final String WRONG_KEY_VALUE_ERROR_MESSAGE =
"the value of the key is not between 0% and 100%";
static final String INVALID_NUMBER_ERROR_MESSAGE =
static final String INVALID_NUMBER_ERROR_MESSAGE =
"the value of the key is invalid (not 'from', 'to', or 'XXX.XXX%')";

private final MutatingVisitController visitController;
@@ -102,7 +103,7 @@ public boolean enterKey(CssKeyNode node) {

/**
* Checks if the percentage is between 0% and 100% inclusive.
*
*
* @param node The {@link CssKeyNode} to get the location in case of an error
* @param percentage The value represented as a float
* @return Returns true if there is no error
@@ -119,7 +120,7 @@ private boolean checkRangeOfPercentage(CssKeyNode node, float percentage) {

/**
* Shortens the representation of the key.
*
*
* @param node The {@link CssKeyNode} where the percentage belongs to.
* @param percentage The value represented as a float
*/
@@ -52,6 +52,7 @@
* <p>{@link CollectMixinDefinitions} has to run before.
* {@link ReplaceConstantReferences} has to run afterwards.
*
* @author fbenz@google.com (Florian Benz)
*/
public class ReplaceMixins extends DefaultTreeVisitor
implements CssCompilerPass {
@@ -36,6 +36,7 @@
* This compiler pass enforces that only correct CSS 2.1 is used.
* See {@link "http://www.w3.org/TR/CSS21/"} for the specification.
*
* @author fbenz@google.com (Florian Benz)
*/
public class StrictCss2 extends StrictCssBase {
private static final ImmutableSet<String> PSEUDO_CLASSES_OR_ELEMENT =
@@ -41,9 +41,10 @@
* <a href="http://en.wikipedia.org/wiki/Comparison_of_layout_engines_(Cascading_Style_Sheets)#Selectors">
* Comparison of layout engines (Cascading Style Sheets)</a>
*
* <p>TODO(user): The ProcessRefiners and ProcessWebkitKeyframes passes should
* <p>TODO(fbenz): The ProcessRefiners and ProcessWebkitKeyframes passes should
* run before.
*
* @author fbenz@google.com (Florian Benz)
*
*/
public class StrictCss3 extends StrictCssBase {

0 comments on commit 2682982

Please sign in to comment.