Search in sources :

Example 6 with ICSSSelectorItem

use of org.eclipse.wst.css.core.internal.provisional.document.ICSSSelectorItem in project webtools.sourceediting by eclipse.

the class CSSImageType method getImageType.

public static CSSImageType getImageType(ICSSSelector selector) {
    CSSImageType imageType = SELECTOR_DEFAULT;
    if (selector == null || selector.getLength() == 0) {
        return imageType;
    }
    ICSSSelectorItem item = selector.getItem(selector.getLength() - 1);
    if (item.getItemType() == ICSSSelectorItem.SIMPLE) {
        ICSSSimpleSelector ss = (ICSSSimpleSelector) item;
        if (0 < ss.getNumOfIDs()) {
            imageType = SELECTOR_ID;
        } else if (0 < ss.getNumOfClasses()) {
            imageType = SELECTOR_CLASS;
        } else if (0 < ss.getNumOfPseudoNames()) {
            imageType = SELECTOR_PSEUDO;
        } else {
            imageType = SELECTOR_TAG;
        }
    }
    return imageType;
}
Also used : ICSSSimpleSelector(org.eclipse.wst.css.core.internal.provisional.document.ICSSSimpleSelector) ICSSSelectorItem(org.eclipse.wst.css.core.internal.provisional.document.ICSSSelectorItem)

Example 7 with ICSSSelectorItem

use of org.eclipse.wst.css.core.internal.provisional.document.ICSSSelectorItem in project webtools.sourceediting by eclipse.

the class CSSSelectorTest method testSelector14.

public void testSelector14() {
    ICSSSelectorList list = createSelectorList("DIV P *[href]");
    checkSelectorList(list, "DIV P *[href]", 1, 0);
    ICSSSelector selector;
    ICSSSelectorItem item;
    selector = list.getSelector(0);
    checkSelector(selector, "DIV P *[href]", 5, 102, 0);
    item = selector.getItem(0);
    checkSimpleSelector(item, "DIV", false, 0, 0, 0, 0);
    item = selector.getItem(1);
    checkSelectorCombinator(item, " ", ICSSSelectorCombinator.DESCENDANT);
    item = selector.getItem(2);
    checkSimpleSelector(item, "P", false, 0, 0, 0, 0);
    item = selector.getItem(3);
    checkSelectorCombinator(item, " ", ICSSSelectorCombinator.DESCENDANT);
    item = selector.getItem(4);
    checkSimpleSelector(item, "*", true, 1, 0, 0, 0);
    checkSimpleSelectorAttributes(item, new String[] { "href" });
}
Also used : ICSSSelectorList(org.eclipse.wst.css.core.internal.provisional.document.ICSSSelectorList) ICSSSelector(org.eclipse.wst.css.core.internal.provisional.document.ICSSSelector) ICSSSelectorItem(org.eclipse.wst.css.core.internal.provisional.document.ICSSSelectorItem)

Example 8 with ICSSSelectorItem

use of org.eclipse.wst.css.core.internal.provisional.document.ICSSSelectorItem in project webtools.sourceediting by eclipse.

the class CSSSelectorTest method testSelector03.

public void testSelector03() {
    ICSSSelectorList list = createSelectorList("H1.pastoral");
    checkSelectorList(list, "H1.pastoral", 1, 0);
    ICSSSelector selector;
    ICSSSelectorItem item;
    selector = list.getSelector(0);
    checkSelector(selector, "H1.pastoral", 1, 101, 0);
    item = selector.getItem(0);
    checkSimpleSelector(item, "H1", false, 0, 1, 0, 0);
    checkSimpleSelectorClasses(item, new String[] { "pastoral" });
}
Also used : ICSSSelectorList(org.eclipse.wst.css.core.internal.provisional.document.ICSSSelectorList) ICSSSelector(org.eclipse.wst.css.core.internal.provisional.document.ICSSSelector) ICSSSelectorItem(org.eclipse.wst.css.core.internal.provisional.document.ICSSSelectorItem)

Example 9 with ICSSSelectorItem

use of org.eclipse.wst.css.core.internal.provisional.document.ICSSSelectorItem in project webtools.sourceediting by eclipse.

the class CSSSelectorTest method testSelector13.

public void testSelector13() {
    ICSSSelectorList list = createSelectorList("DIV * P");
    checkSelectorList(list, "DIV * P", 1, 0);
    ICSSSelector selector;
    ICSSSelectorItem item;
    selector = list.getSelector(0);
    checkSelector(selector, "DIV * P", 5, 2, 0);
    item = selector.getItem(0);
    checkSimpleSelector(item, "DIV", false, 0, 0, 0, 0);
    item = selector.getItem(1);
    checkSelectorCombinator(item, " ", ICSSSelectorCombinator.DESCENDANT);
    item = selector.getItem(2);
    checkSimpleSelector(item, "*", true, 0, 0, 0, 0);
    item = selector.getItem(3);
    checkSelectorCombinator(item, " ", ICSSSelectorCombinator.DESCENDANT);
    item = selector.getItem(4);
    checkSimpleSelector(item, "P", false, 0, 0, 0, 0);
}
Also used : ICSSSelectorList(org.eclipse.wst.css.core.internal.provisional.document.ICSSSelectorList) ICSSSelector(org.eclipse.wst.css.core.internal.provisional.document.ICSSSelector) ICSSSelectorItem(org.eclipse.wst.css.core.internal.provisional.document.ICSSSelectorItem)

Example 10 with ICSSSelectorItem

use of org.eclipse.wst.css.core.internal.provisional.document.ICSSSelectorItem in project webtools.sourceediting by eclipse.

the class CSSSelectorTest method testSelector24.

public void testSelector24() {
    ICSSSelectorList list = createSelectorList("A:link");
    checkSelectorList(list, "A:link", 1, 0);
    ICSSSelector selector;
    ICSSSelectorItem item;
    selector = list.getSelector(0);
    checkSelector(selector, "A:link", 1, 101, 0);
    item = selector.getItem(0);
    checkSimpleSelector(item, "A", false, 0, 0, 0, 1);
    checkSimpleSelectorPseudoNames(item, new String[] { "link" });
}
Also used : ICSSSelectorList(org.eclipse.wst.css.core.internal.provisional.document.ICSSSelectorList) ICSSSelector(org.eclipse.wst.css.core.internal.provisional.document.ICSSSelector) ICSSSelectorItem(org.eclipse.wst.css.core.internal.provisional.document.ICSSSelectorItem)

Aggregations

ICSSSelectorItem (org.eclipse.wst.css.core.internal.provisional.document.ICSSSelectorItem)47 ICSSSelector (org.eclipse.wst.css.core.internal.provisional.document.ICSSSelector)42 ICSSSelectorList (org.eclipse.wst.css.core.internal.provisional.document.ICSSSelectorList)41 ICSSSimpleSelector (org.eclipse.wst.css.core.internal.provisional.document.ICSSSimpleSelector)6 Iterator (java.util.Iterator)4 ICSSSelectorCombinator (org.eclipse.wst.css.core.internal.provisional.document.ICSSSelectorCombinator)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Element (org.w3c.dom.Element)1