Search in sources :

Example 1 with CSSLinkConverter

use of org.eclipse.wst.css.core.internal.util.CSSLinkConverter 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

Enumeration (java.util.Enumeration)1 PropCMProperty (org.eclipse.wst.css.core.internal.contentmodel.PropCMProperty)1 ICSSStyleDeclItem (org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleDeclItem)1 CSSLinkConverter (org.eclipse.wst.css.core.internal.util.CSSLinkConverter)1