Search in sources :

Example 21 with PropCMProperty

use of org.eclipse.wst.css.core.internal.contentmodel.PropCMProperty in project webtools.sourceediting by eclipse.

the class CSSQueryContext method overrideWithExpand.

/**
 */
public void overrideWithExpand(ICSSStyleDeclaration decl, int specificity) {
    if (decl == null)
        return;
    CSSLinkConverter conv = new CSSLinkConverter(decl.getOwnerDocument().getModel());
    int nProperties = decl.getLength();
    for (int i = 0; i < nProperties; i++) {
        String propName = decl.item(i);
        if (propName != null) {
            String propN = propName.trim().toLowerCase();
            if (propN.length() != 0) {
                PropCMProperty prop = PropCMProperty.getInstanceOf(propN);
                String priority = decl.getPropertyPriority(propName);
                boolean important = priority != null && priority.length() > 0;
                if (prop != null && prop.isShorthand()) {
                    // expand shorthand property
                    CSSQueryContext context = new CSSQueryContext();
                    expandToLeaf(prop, decl.getPropertyValue(propName), context);
                    Enumeration properties = context.properties();
                    while (properties.hasMoreElements()) {
                        propN = properties.nextElement().toString();
                        if (check(propN, important, specificity)) {
                            fProperties.put(propN, new CSSQueryValueData(conv.toAbsolute(context.get(propN)), important, specificity));
                        }
                    }
                } else {
                    if (check(propN, important, specificity)) {
                        ICSSStyleDeclItem declItem = (ICSSStyleDeclItem) decl.getDeclItemNode(propName).cloneNode(true);
                        int nValues = declItem.getLength();
                        for (int j = 0; j < nValues; j++) {
                            conv.toAbsolute(declItem.item(j));
                        }
                        declItem.setPriority(null);
                        fProperties.put(propN, new CSSQueryDeclarationData(declItem, important, specificity));
                    }
                }
            }
        }
    }
}
Also used : PropCMProperty(org.eclipse.wst.css.core.internal.contentmodel.PropCMProperty) Enumeration(java.util.Enumeration) ICSSStyleDeclItem(org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleDeclItem) CSSLinkConverter(org.eclipse.wst.css.core.internal.util.CSSLinkConverter)

Aggregations

PropCMProperty (org.eclipse.wst.css.core.internal.contentmodel.PropCMProperty)21 CSSTextParser (org.eclipse.wst.css.core.internal.parserz.CSSTextParser)18 CSSTextToken (org.eclipse.wst.css.core.internal.parserz.CSSTextToken)16 PropCMSubProperty (org.eclipse.wst.css.core.internal.contentmodel.PropCMSubProperty)2 ICSSPrimitiveValue (org.eclipse.wst.css.core.internal.provisional.document.ICSSPrimitiveValue)2 ICSSValue (org.eclipse.wst.css.core.internal.provisional.document.ICSSValue)2 ICSSValueList (org.eclipse.wst.css.core.internal.provisional.document.ICSSValueList)2 Enumeration (java.util.Enumeration)1 ICSSStyleDeclItem (org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleDeclItem)1 CSSLinkConverter (org.eclipse.wst.css.core.internal.util.CSSLinkConverter)1