Пример #1
0
 public boolean appendMediaExpression(FixedMediaExpression expression) {
   cssOnly.ensureSeparator().append('(');
   append(expression.getFeature());
   if (expression.getExpression() != null) {
     cssOnly.append(':');
     if (!isCompressing()) cssOnly.ensureSeparator();
     append(expression.getExpression());
   }
   cssOnly.append(')');
   return true;
 }
Пример #2
0
  protected void appendComments(List<Comment> comments, boolean ensureSeparator) {
    if (comments == null || comments.isEmpty() || isCompressing()) return;

    cssOnly.ensureSeparator();

    for (Comment comment : comments) {
      String text = comment.getComment();
      if (text != null) cssOnly.append(text);
      if (comment.hasNewLine()) cssOnly.ensureNewLine();
    }

    if (ensureSeparator) cssOnly.ensureSeparator();
  }
Пример #3
0
  public boolean appendSelectorCombinator(SelectorCombinator combinator) {
    SelectorCombinator.CombinatorType realCombinator = combinator.getCombinatorType();
    switch (realCombinator) {
      case DESCENDANT:
        cssOnly.ensureSeparator();
        break;

      default:
        cssOnly.ensureSeparator().append(combinator.getSymbol());
    }

    return true;
  }
Пример #4
0
  private boolean appendSupportsConditionLogical(SupportsLogicalCondition node) {
    Iterator<SupportsLogicalOperator> operators = node.getLogicalOperators().iterator();
    Iterator<SupportsCondition> conditions = node.getConditions().iterator();

    append(conditions.next());

    while (operators.hasNext()) {
      cssOnly.ensureSeparator();
      append(operators.next());
      cssOnly.ensureSeparator();
      append(conditions.next());
    }
    return true;
  }
Пример #5
0
  public boolean appendMediaQuery(MediaQuery mediaQuery) {
    cssOnly.ensureSeparator();
    append(mediaQuery.getMedium());
    boolean needSeparator = (mediaQuery.getMedium() != null);
    for (MediaExpression mediaExpression : mediaQuery.getExpressions()) {
      if (needSeparator) {
        cssOnly.ensureSeparator().append("and");
      }
      append(mediaExpression);
      needSeparator = true;
    }

    return true;
  }
Пример #6
0
  private boolean appendPage(Page node) {
    cssOnly.append("@page").ensureSeparator();
    if (node.hasName()) {
      append(node.getName());
      if (!node.hasDockedPseudopage()) cssOnly.ensureSeparator();
    }

    if (node.hasPseudopage()) {
      append(node.getPseudopage());
      cssOnly.ensureSeparator();
    }

    appendBodySortDeclarations(node.getBody());
    return true;
  }
Пример #7
0
  private void appendBodySortDeclarations(Body node) {
    // this is sort of hack, bypass the usual append method
    appendComments(node.getOpeningComments(), true);

    if (!isCompressing()) cssOnly.ensureSeparator();
    append(node.getOpeningCurlyBrace());
    if (!isCompressing()) cssOnly.ensureNewLine().increaseIndentationLevel();

    Iterator<ASTCssNode> declarations = node.getDeclarations().iterator();
    List<ASTCssNode> notDeclarations = node.getNotDeclarations();
    while (declarations.hasNext()) {
      ASTCssNode declaration = declarations.next();
      append(declaration);
      if (!isCompressing() && (declarations.hasNext() || notDeclarations.isEmpty()))
        cssOnly.ensureNewLine();
    }

    appendAll(notDeclarations);

    appendComments(node.getOrphanComments(), false);
    if (!isCompressing()) cssOnly.decreaseIndentationLevel();
    append(node.getClosingCurlyBrace());

    // this is sort of hack, bypass the usual append method
    appendComments(node.getTrailingComments(), false);
  }
Пример #8
0
 private boolean appendSupports(Supports node) {
   cssOnly.append(node.getDialect()).ensureSeparator();
   append(node.getCondition());
   cssOnly.ensureSeparator();
   append(node.getBody());
   return true;
 }
Пример #9
0
 private void appendSimpleSelectorHead(SimpleSelector selector) {
   cssOnly.ensureSeparator();
   if (!selector.isStar() || !selector.isEmptyForm()) {
     InterpolableName elementName = selector.getElementName();
     cssAndSM.appendIgnoreNull(elementName.getName(), elementName.getUnderlyingStructure());
   }
 }
Пример #10
0
  public boolean appendListExpressionOperator(ListExpressionOperator operator) {
    ListExpressionOperator.Operator realOperator = operator.getOperator();
    switch (realOperator) {
      case COMMA:
        cssOnly.append(realOperator.getSymbol());
        if (!isCompressing()) cssOnly.ensureSeparator();
        break;

      case EMPTY_OPERATOR:
        cssOnly.ensureSeparator();
        break;

      default:
        cssOnly.append(realOperator.getSymbol());
    }

    return true;
  }
Пример #11
0
  public boolean appendDeclaration(Declaration declaration) {
    cssOnly.appendIgnoreNull(declaration.getNameAsString());
    cssOnly.append(':');
    if (!isCompressing()) cssOnly.ensureSeparator();
    if (declaration.getExpression() != null) append(declaration.getExpression());

    if (shouldHaveSemicolon(declaration)) cssOnly.appendIgnoreNull(";");

    return true;
  }
Пример #12
0
  public boolean appendMediumModifier(MediumModifier modifier) {
    Modifier kind = modifier.getModifier();
    switch (kind) {
      case ONLY:
        cssOnly.ensureSeparator().append("only");
        break;

      case NOT:
        cssOnly.ensureSeparator().append("not");
        break;

      case NONE:
        break;

      default:
        throw new IllegalStateException("Unknown modifier type.");
    }

    return true;
  }
Пример #13
0
  public boolean appendCommaSeparated(List<? extends ASTCssNode> values) {
    boolean result = false;
    Iterator<? extends ASTCssNode> names = values.iterator();
    if (names.hasNext()) {
      result |= append(names.next());
    }
    while (names.hasNext()) {
      cssOnly.append(',');
      if (!isCompressing()) cssOnly.ensureSeparator();
      append(names.next());
      result = true;
    }

    return result;
  }
Пример #14
0
  public boolean appendBinaryExpressionOperator(BinaryExpressionOperator operator) {
    BinaryExpressionOperator.Operator realOperator = operator.getOperator();
    switch (realOperator) {
        // TODO this is a huge hack which goes around
        // "we do not parse fonts and less.js does" lack of feature
        // left here intentionally, so we can have correct unit test and can come
        // back to it later
      case MINUS:
        cssOnly.ensureSeparator().append('-');
        break;

      default:
        cssOnly.append(realOperator.getSymbol());
    }

    return true;
  }
Пример #15
0
  private boolean appendBodyOptimizeDuplicates(Body body) {
    if (body.isEmpty()) return false;

    if (!isCompressing()) cssOnly.ensureSeparator();
    append(body.getOpeningCurlyBrace());
    if (!isCompressing()) cssOnly.ensureNewLine().increaseIndentationLevel();
    Iterable<CssPrinter> declarationsBuilders = collectUniqueBodyMembersStrings(body);
    for (CssPrinter miniBuilder : declarationsBuilders) {
      append(miniBuilder);
    }

    appendComments(body.getOrphanComments(), false);
    cssOnly.decreaseIndentationLevel();
    append(body.getClosingCurlyBrace());

    return true;
  }
Пример #16
0
 private boolean appendInterpolatedMediaExpression(InterpolatedMediaExpression expression) {
   cssOnly.ensureSeparator();
   return append(expression.getExpression());
 }
Пример #17
0
  public boolean appendMediumType(MediumType medium) {
    cssOnly.ensureSeparator().append(medium.getName());

    return true;
  }
Пример #18
0
 private boolean appendSupportsConditionNegation(SupportsConditionNegation node) {
   append(node.getNegation());
   cssOnly.ensureSeparator();
   append(node.getCondition());
   return true;
 }