Package org.w3c.css.sac

Examples of org.w3c.css.sac.LexicalUnit


    public void setMainProperties
        (CSSStylableElement elt, final MainPropertyReceiver dst,
         String pname, String value, boolean important){
        try {
            element = elt;
            LexicalUnit lu = parser.parsePropertyValue(value);
            ShorthandManager.PropertyHandler ph =
                new ShorthandManager.PropertyHandler() {
                    public void property(String pname, LexicalUnit lu,
                                         boolean important) {
                        int idx = getPropertyIndex(pname);
View Full Code Here


        int idx = getPropertyIndex(prop);
        if (idx == -1) return null;
        ValueManager vm = valueManagers[idx];
        try {
            element = elt;
            LexicalUnit lu;
            lu = parser.parsePropertyValue(value);
            return vm.createValue(lu, this);
        } catch (Exception e) {
            String m = e.getMessage();
            if (m == null) m = "";
View Full Code Here

        switch (evt.getAttrChange()) {
        case MutationEvent.ADDITION:
        case MutationEvent.MODIFICATION:
            element = elt;
            try {
                LexicalUnit lu;
                lu = parser.parsePropertyValue(evt.getNewValue());
                ValueManager vm = valueManagers[idx];
                Value v = vm.createValue(lu, CSSEngine.this);
                style.putMask(idx, (short)0);
                style.putValue(idx, v);
View Full Code Here

    public void handleSystemFont(CSSEngine eng,
                                 ShorthandManager.PropertyHandler ph,
                                 String s,
                                 boolean imp) {
       
        LexicalUnit fontStyle   = NORMAL_LU;
        LexicalUnit fontVariant = NORMAL_LU;
        LexicalUnit fontWeight  = NORMAL_LU;
        LexicalUnit lineHeight  = NORMAL_LU;
        LexicalUnit fontFamily  = FONT_FAMILY_LU;

        LexicalUnit fontSize;
        if (s.equals(CSSConstants.CSS_SMALL_CAPTION_VALUE)) {
            fontSize = SZ_8PT_LU;
        } else {
            fontSize = SZ_10PT_LU;
        }
View Full Code Here

                return;
            }
        }
        }

        LexicalUnit fontStyle   = null;
        LexicalUnit fontVariant = null;
        LexicalUnit fontWeight  = null;
        LexicalUnit fontSize    = null;
        LexicalUnit lineHeight  = null;
        LexicalUnit fontFamily  = null;

        ValueManager[]vMgrs = eng.getValueManagers();
        int fst, fv, fw, fsz, lh, ff;
        fst = eng.getPropertyIndex(CSSConstants.CSS_FONT_STYLE_PROPERTY);
        fv  = eng.getPropertyIndex(CSSConstants.CSS_FONT_VARIANT_PROPERTY);
        fw  = eng.getPropertyIndex(CSSConstants.CSS_FONT_WEIGHT_PROPERTY);
        fsz = eng.getPropertyIndex(CSSConstants.CSS_FONT_SIZE_PROPERTY);
        lh  = eng.getPropertyIndex(CSSConstants.CSS_LINE_HEIGHT_PROPERTY);
        ff  = eng.getPropertyIndex(CSSConstants.CSS_FONT_FAMILY_PROPERTY);

        IdentifierManager fstVM = (IdentifierManager)vMgrs[fst];
        IdentifierManager fvVM  = (IdentifierManager)vMgrs[fv];
        IdentifierManager fwVM  = (IdentifierManager)vMgrs[fw];
        FontSizeManager fszVM = (FontSizeManager)vMgrs[fsz];
        ValueManager      ffVM  = vMgrs[ff];

        StringMap fstSM = fstVM.getIdentifiers();
        StringMap fvSM  = fvVM.getIdentifiers();
        StringMap fwSM  = fwVM.getIdentifiers();
        StringMap fszSM = fszVM.getIdentifiers();


        // Check for font-style, font-varient, & font-weight
        // These are all optional.

        boolean svwDone= false;
        LexicalUnit intLU = null;;
        while (!svwDone && (lu != null)) {
            switch (lu.getLexicalUnitType()) {
            case LexicalUnit.SAC_IDENT: {
                String s= lu.getStringValue().toLowerCase().intern();
                if ((fontStyle   == null) && (fstSM.get(s) != null)) {
                    fontStyle   = lu;
                    if (intLU != null) {
                        if (fontWeight == null) {
                            fontWeight = intLU;
                            intLU = null;
                        } else
                            throw createInvalidLexicalUnitDOMException
                                (intLU.getLexicalUnitType());
                    }
                    break;
                }

                if ((fontVariant == null) && (fvSM.get(s!= null)) {
                    fontVariant = lu;
                    if (intLU != null) {
                        if (fontWeight == null) {
                            fontWeight = intLU;
                            intLU = null;
                        } else
                            throw createInvalidLexicalUnitDOMException
                                (intLU.getLexicalUnitType());
                    }
                    break;
                }

                if ((intLU == null) && (fontWeight  == null) &&
                    (fwSM.get(s!= null)) {
                    fontWeight = lu;
                    break;
                }

                svwDone = true;
                break;
            }
            case LexicalUnit.SAC_INTEGER:
                if ((intLU == null) && (fontWeight == null)) {
                    intLU = lu;
                    break;
                }
                svwDone = true;
                break;

            default: // All other must be size,'/line-height', family
                svwDone = true;
                break;
            }
            if (!svwDone) lu = lu.getNextLexicalUnit();
        }

        // Must have font-size.
        if (lu == null)
            throw createMalformedLexicalUnitDOMException();

        // Now we need to get font-size
        switch (lu.getLexicalUnitType()) {
        case LexicalUnit.SAC_IDENT: {
            String s= lu.getStringValue().toLowerCase().intern();
            if (fszSM.get(s) != null) {
                fontSize = lu; // This is a font-size ident.
                lu = lu.getNextLexicalUnit();
            }
        }
            break;

  case LexicalUnit.SAC_EM:
  case LexicalUnit.SAC_EX:
  case LexicalUnit.SAC_PIXEL:
  case LexicalUnit.SAC_CENTIMETER:
  case LexicalUnit.SAC_MILLIMETER:
  case LexicalUnit.SAC_INCH:
  case LexicalUnit.SAC_POINT:
  case LexicalUnit.SAC_PICA:
  case LexicalUnit.SAC_INTEGER:
  case LexicalUnit.SAC_REAL:
  case LexicalUnit.SAC_PERCENTAGE:
            fontSize = lu;
            lu = lu.getNextLexicalUnit();
            break;
        }
       

        if (fontSize == null) {
            // We must have a font-size so see if we can use intLU...
            if (intLU != null) {
                fontSize = intLU;  // Yup!
                intLU = null;
            } else {
                throw createInvalidLexicalUnitDOMException
                    (lu.getLexicalUnitType());
            }
        }

        if (intLU != null) {
            // We have a intLU left see if we can use it as font-weight
            if (fontWeight == null) {
                fontWeight = intLU; // use intLU as font-weight.
            } else {
                // we have an 'extra' integer in property.
                throw createInvalidLexicalUnitDOMException
                    (intLU.getLexicalUnitType());
            }
        }
       
        // Must have Font-Family, so if it's null now we are done!
        if (lu == null)
View Full Code Here

        if (styleSheetParserUtil == null)
        {
            styleSheetParserUtil = StyleSheetParserUtil.getInstance();
        }

        final LexicalUnit cssValue = styleSheetParserUtil.parseLexicalStyleValue(
                text);
        return CSSValueFactory.createLengthValue(cssValue);
    }
View Full Code Here

   * @param colors a sequence of LexicalUnits, assumed to be
   *          <code>(INT COMMA INT COMMA INT)</code>
   * @return the minimal hex expression for the RGB color values
   */
  private static StringValue colorValue(LexicalUnit colors) {
    LexicalUnit red = colors;
    assert red.getLexicalUnitType() == LexicalUnit.SAC_INTEGER;
    LexicalUnit green = red.getNextLexicalUnit().getNextLexicalUnit();
    assert green.getLexicalUnitType() == LexicalUnit.SAC_INTEGER;
    LexicalUnit blue = green.getNextLexicalUnit().getNextLexicalUnit();
    assert blue.getLexicalUnitType() == LexicalUnit.SAC_INTEGER;

    int r = Math.min(red.getIntegerValue(), 255);
    int g = Math.min(green.getIntegerValue(), 255);
    int b = Math.min(blue.getIntegerValue(), 255);

    String sr = Integer.toHexString(r);
    if (sr.length() == 1) {
      sr = "0" + sr;
    }
View Full Code Here

                 stringFactory.createValue(lu)));
        if (lu != null) {
      lu = lu.getNextLexicalUnit();
        }
    } else {
        LexicalUnit l = lu;
        String s = l.getStringValue();
        lu = lu.getNextLexicalUnit();
        if (lu != null &&
                        lu.getLexicalUnitType() == LexicalUnit.SAC_IDENT) {
      do {
          s += " " + lu.getStringValue();
View Full Code Here

     * Creates a value from its text representation
     * @param text The text that represents the CSS value to create.
     */
    public ImmutableValue createValue(String text) throws DOMException {
  try {
      LexicalUnit lu;
      lu = parser.parsePropertyValue(text);
      return createValue(lu);
  } catch (IOException e) {
            // Should never happen
            throw new InternalError(e.getMessage());
View Full Code Here

    public void setProperty(String propertyName, String value, String prio)
  throws DOMException {
  try {
      ValueFactory f;
            f = factories.get(propertyName.toLowerCase().intern());
      LexicalUnit lu = parser.parsePropertyValue(value);
      f.createCSSValue(lu, this, prio);
  } catch (Exception e) {
            e.printStackTrace();
      throw CSSDOMExceptionFactory.createDOMException
    (DOMException.INVALID_ACCESS_ERR,
View Full Code Here

TOP

Related Classes of org.w3c.css.sac.LexicalUnit

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.