Package com.google.gwt.resources.css.ast.CssProperty

Examples of com.google.gwt.resources.css.ast.CssProperty.IdentValue


      sr = sr.substring(1);
      sg = sg.substring(1);
      sb = sb.substring(1);
    }

    return new IdentValue("#" + sr + sg + sb);
  }
View Full Code Here


  }

  private static Value valueOf(LexicalUnit value) {
    switch (value.getLexicalUnitType()) {
      case LexicalUnit.SAC_ATTR:
        return new IdentValue("attr(" + value.getStringValue() + ")");
      case LexicalUnit.SAC_IDENT:
        return new IdentValue(escapeIdent(value.getStringValue()));
      case LexicalUnit.SAC_STRING_VALUE:
        return new StringValue(value.getStringValue());
      case LexicalUnit.SAC_RGBCOLOR:
        // flute models the commas as operators so no separator needed
        return colorValue(value.getParameters());
      case LexicalUnit.SAC_INTEGER:
        return new NumberValue(value.getIntegerValue());
      case LexicalUnit.SAC_REAL:
        return new NumberValue(value.getFloatValue());
      case LexicalUnit.SAC_CENTIMETER:
      case LexicalUnit.SAC_DEGREE:
      case LexicalUnit.SAC_DIMENSION:
      case LexicalUnit.SAC_EM:
      case LexicalUnit.SAC_EX:
      case LexicalUnit.SAC_GRADIAN:
      case LexicalUnit.SAC_HERTZ:
      case LexicalUnit.SAC_KILOHERTZ:
      case LexicalUnit.SAC_MILLIMETER:
      case LexicalUnit.SAC_MILLISECOND:
      case LexicalUnit.SAC_PERCENTAGE:
      case LexicalUnit.SAC_PICA:
      case LexicalUnit.SAC_PIXEL:
      case LexicalUnit.SAC_POINT:
      case LexicalUnit.SAC_RADIAN:
      case LexicalUnit.SAC_SECOND:
        return new NumberValue(value.getFloatValue(),
            value.getDimensionUnitText());
      case LexicalUnit.SAC_URI:
        return new IdentValue("url(" + value.getStringValue() + ")");
      case LexicalUnit.SAC_OPERATOR_COMMA:
        return new TokenValue(",");
      case LexicalUnit.SAC_COUNTER_FUNCTION:
      case LexicalUnit.SAC_COUNTERS_FUNCTION:
      case LexicalUnit.SAC_FUNCTION: {
        if (value.getFunctionName().equals(VALUE_FUNCTION_NAME)) {
          // This is a call to value()
          List<Value> params = new ArrayList<Value>();
          extractValueOf(params, value.getParameters());

          if (params.size() != 1 && params.size() != 3) {
            throw new CSSException(CSSException.SAC_SYNTAX_ERR,
                "Incorrect number of parameters to " + VALUE_FUNCTION_NAME,
                null);
          }

          Value dotPathValue = params.get(0);
          String dotPath = maybeUnquote(((StringValue) dotPathValue).getValue());
          String suffix = params.size() == 3
              ? maybeUnquote(((StringValue) params.get(2)).getValue()) : "";

          return new DotPathValue(dotPath, suffix);
        } else if (value.getFunctionName().equals(LITERAL_FUNCTION_NAME)) {
          // This is a call to value()
          List<Value> params = new ArrayList<Value>();
          extractValueOf(params, value.getParameters());

          if (params.size() != 1) {
            throw new CSSException(CSSException.SAC_SYNTAX_ERR,
                "Incorrect number of parameters to " + LITERAL_FUNCTION_NAME,
                null);
          }

          Value expression = params.get(0);
          if (!(expression instanceof StringValue)) {
            throw new CSSException(CSSException.SAC_SYNTAX_ERR,
                "The single argument to " + LITERAL_FUNCTION_NAME
                    + " must be a string value", null);
          }

          String s = maybeUnquote(((StringValue) expression).getValue());
          s = unescapeLiteral(s);

          return new IdentValue(s);

        } else {
          // Just return a String representation of the original value
          List<Value> parameters = new ArrayList<Value>();
          extractValueOf(parameters, value.getParameters());
          return new IdentValue(value.getFunctionName() + "("
              + join(parameters, "") + ")");
        }
      }
      case LexicalUnit.SAC_INHERIT:
        return new IdentValue("inherit");
      case LexicalUnit.SAC_OPERATOR_EXP:
        return new TokenValue("^");
      case LexicalUnit.SAC_OPERATOR_GE:
        return new TokenValue(">=");
      case LexicalUnit.SAC_OPERATOR_GT:
        return new TokenValue(">");
      case LexicalUnit.SAC_OPERATOR_LE:
        return new TokenValue("<=");
      case LexicalUnit.SAC_OPERATOR_LT:
        return new TokenValue("<");
      case LexicalUnit.SAC_OPERATOR_MINUS:
        return new TokenValue("-");
      case LexicalUnit.SAC_OPERATOR_MOD:
        return new TokenValue("%");
      case LexicalUnit.SAC_OPERATOR_MULTIPLY:
        return new TokenValue("*");
      case LexicalUnit.SAC_OPERATOR_PLUS:
        return new TokenValue("+");
      case LexicalUnit.SAC_OPERATOR_SLASH:
        return new TokenValue("/");
      case LexicalUnit.SAC_OPERATOR_TILDE:
        return new IdentValue("~");
      case LexicalUnit.SAC_RECT_FUNCTION: {
        // Just return this as a String
        List<Value> parameters = new ArrayList<Value>();
        extractValueOf(parameters, value.getParameters());
        return new IdentValue("rect(" + join(parameters, "") + ")");
      }
      case LexicalUnit.SAC_SUB_EXPRESSION:
        // Should have been taken care of by our own traversal
      case LexicalUnit.SAC_UNICODERANGE:
        // Cannot be expressed in CSS2
View Full Code Here

        throw new CSSException(CSSException.SAC_SYNTAX_ERR,
            "@def rules must specify an identifier and one or more values",
            null);
      }

      IdentValue defName = values.get(0).isIdentValue();

      if (defName == null) {
        throw new CSSException(CSSException.SAC_SYNTAX_ERR,
            "First lexical unit must be an identifier", null);
      }

      /*
       * Replace any references to previously-seen @def constructs. We do
       * expansion up-front to prevent the need for cycle-detection later.
       */
      for (ListIterator<Value> it = values.listIterator(1); it.hasNext();) {
        IdentValue maybeDefReference = it.next().isIdentValue();
        if (maybeDefReference != null) {
          CssDef previousDef = defs.get(maybeDefReference.getIdent());
          if (previousDef != null) {
            it.remove();
            for (Value previousValue : previousDef.getValues()) {
              it.add(previousValue);
            }
View Full Code Here

            + selector + "' uses an undefined constant: " + upperCaseString);
        if (lenient) {
          treeLogger.log(Type.WARN, "turning '" + upperCaseString +
              "' to lower case. This is probably not what you wanted here in the " +
              "first place!");
          return new IdentValue(upperCaseString.toLowerCase(Locale.US));
        } else {
          throw new Css2GssConversionException("Found undefined constant in input. "
              + cssPropertyName + "' from rule '" + selector + "' undefined constant: " +
              upperCaseString);
        }
View Full Code Here

    if (repeatStyle == RepeatStyle.None || repeatStyle == RepeatStyle.Vertical) {
      properties.add(new CssProperty("width", new ExpressionValue(instance
          + ".getWidth() + \"px\""), false));
    }
    properties.add(new CssProperty("overflow", new IdentValue("hidden"), false));

    String repeatText;
    switch (repeatStyle) {
      case None:
        repeatText = " no-repeat";
View Full Code Here

  Value propertyHandlerClear(Value v) {
    return propertyHandlerFloat(v);
  }

  Value propertyHandlerCursor(Value v) {
    IdentValue identValue = v.isIdentValue();
    if (identValue == null) {
      return v;
    }

    String ident = StringCase.toLower(identValue.getIdent());
    if (!ident.endsWith("-resize")) {
      return v;
    }

    StringBuffer newIdent = new StringBuffer();

    if (ident.length() == 9) {
      if (ident.charAt(0) == 'n') {
        newIdent.append('n');
        ident = ident.substring(1);
      } else if (ident.charAt(0) == 's') {
        newIdent.append('s');
        ident = ident.substring(1);
      } else {
        return v;
      }
    }

    if (ident.length() == 8) {
      if (ident.charAt(0) == 'e') {
        newIdent.append("w-resize");
      } else if (ident.charAt(0) == 'w') {
        newIdent.append("e-resize");
      } else {
        return v;
      }
      return new IdentValue(newIdent.toString());
    } else {
      return v;
    }
  }
View Full Code Here

  }

  Value propertyHandlerDirection(Value v) {
    if (inBodyRule) {
      if (isIdent(v, "ltr")) {
        return new IdentValue("rtl");
      } else if (isIdent(v, "rtl")) {
        return new IdentValue("ltr");
      }
    }
    return v;
  }
View Full Code Here

    return flipLeftRightIdentValue(v);
  }

  private Value flipLeftRightIdentValue(Value v) {
    if (isIdent(v, "right")) {
      return new IdentValue("left");

    } else if (isIdent(v, "left")) {
      return new IdentValue("right");
    }
    return v;
  }
View Full Code Here

          "Unable to invoke property handler function for " + name, e);
    }
  }

  private boolean isIdent(Value value, String query) {
    IdentValue v = value.isIdentValue();
    return v != null && v.getIdent().equalsIgnoreCase(query);
  }
View Full Code Here

      sr = sr.substring(1);
      sg = sg.substring(1);
      sb = sb.substring(1);
    }

    return new IdentValue("#" + sr + sg + sb);
  }
View Full Code Here

TOP

Related Classes of com.google.gwt.resources.css.ast.CssProperty.IdentValue

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.