use of org.eclipse.wst.css.core.internal.provisional.document.ICSSSelector in project webtools.sourceediting by eclipse.
the class CSSSelectorTest method testSelector17.
public void testSelector17() {
ICSSSelectorList list = createSelectorList("MATH + P");
checkSelectorList(list, "MATH + P", 1, 0);
ICSSSelector selector;
ICSSSelectorItem item;
selector = list.getSelector(0);
checkSelector(selector, "MATH + P", 3, 2, 0);
item = selector.getItem(0);
checkSimpleSelector(item, "MATH", false, 0, 0, 0, 0);
item = selector.getItem(1);
checkSelectorCombinator(item, "+", ICSSSelectorCombinator.ADJACENT);
item = selector.getItem(2);
checkSimpleSelector(item, "P", false, 0, 0, 0, 0);
}
use of org.eclipse.wst.css.core.internal.provisional.document.ICSSSelector in project webtools.sourceediting by eclipse.
the class CSSSelectorTest method testSelector30.
public void testSelector30() {
ICSSSelectorList list = createSelectorList("H1.123");
checkSelectorList(list, "H1.123", 1, 1);
ICSSSelector selector;
ICSSSelectorItem item;
selector = list.getSelector(0);
checkSelector(selector, "H1.123", 1, 101, 1);
item = selector.getItem(0);
checkSimpleSelector(item, "H1", false, 0, 1, 0, 0);
checkSimpleSelectorClasses(item, new String[] { "123" });
}
use of org.eclipse.wst.css.core.internal.provisional.document.ICSSSelector in project webtools.sourceediting by eclipse.
the class CSSSelectorTest method testSelector05.
public void testSelector05() {
ICSSSelectorList list = createSelectorList("*.warning");
checkSelectorList(list, "*.warning", 1, 0);
ICSSSelector selector;
ICSSSelectorItem item;
selector = list.getSelector(0);
checkSelector(selector, "*.warning", 1, 100, 0);
item = selector.getItem(0);
checkSimpleSelector(item, "*", true, 0, 1, 0, 0);
checkSimpleSelectorClasses(item, new String[] { "warning" });
}
use of org.eclipse.wst.css.core.internal.provisional.document.ICSSSelector in project webtools.sourceediting by eclipse.
the class CSSQueryTraverser method preNode.
/**
*/
protected short preNode(ICSSNode node) {
if (node instanceof ICSSStyleRule) {
// style rule
ICSSStyleRule style = (ICSSStyleRule) node;
ICSSSelectorList list = style.getSelectors();
int nSelectors = list.getLength();
int maxSpecificity = -1;
for (int iSelector = 0; iSelector < nSelectors; iSelector++) {
// Check each Selector Lists
ICSSSelector selector = list.getSelector(iSelector);
int specificity = selector.getSpecificity();
if (maxSpecificity < specificity && selector.match(element, pseudoName)) {
maxSpecificity = specificity;
}
}
if (maxSpecificity >= 0) {
// apply this style to the element
overwriteDeclaration((ICSSStyleDeclaration) style.getStyle(), maxSpecificity);
}
return TRAV_PRUNE;
}
return TRAV_CONT;
}
use of org.eclipse.wst.css.core.internal.provisional.document.ICSSSelector in project webtools.sourceediting by eclipse.
the class CSSModelImpl method valueChanged.
void valueChanged(CSSNodeImpl node, String oldValue) {
if (!fStructuredDocumentUpdate) {
CSSModelUpdater updater = getUpdater();
updater.valueChanged(node, oldValue);
}
ICSSSelector[] removed = null, added = null;
if (node != null) {
if (node.getNodeType() == ICSSNode.ATTR_NODE && ((CSSAttrImpl) node).getName().equals(ICSSStyleRule.SELECTOR)) {
CSSAttrImpl attr = (CSSAttrImpl) node;
// collect changed selector
ICSSSelectorList list = new CSSSelectorListImpl(attr.getValue());
added = new ICSSSelector[list.getLength()];
for (int i = 0; i < list.getLength(); i++) added[i] = list.getSelector(i);
// get old value
list = new CSSSelectorListImpl(oldValue);
removed = new ICSSSelector[list.getLength()];
for (int i = 0; i < list.getLength(); i++) removed[i] = list.getSelector(i);
} else if (node instanceof ICSSValue) {
ICSSNode rule = node;
while (rule != null) {
if (rule instanceof ICSSStyleRule)
break;
rule = rule.getParentNode();
}
if (rule != null) {
ICSSSelectorList list = ((ICSSStyleRule) rule).getSelectors();
added = new ICSSSelector[list.getLength()];
for (int i = 0; i < list.getLength(); i++) added[i] = list.getSelector(i);
}
}
}
if (removed != null || added != null || getDocument().getNodeType() == ICSSNode.STYLEDECLARATION_NODE) {
// send selector changed event
getStyleNotifier().fire(removed, added, null);
}
// for href attribute
if (getStyleListeners() != null && getStyleListeners().size() > 0) {
if (node != null && node.getNodeType() == ICSSNode.ATTR_NODE && ((CSSAttrImpl) node).getName().equals(ICSSImportRule.HREF)) {
((ICSSImportRule) ((ICSSAttr) node).getOwnerCSSNode()).getStyleSheet();
}
}
}
Aggregations