public RuleBlock<?> prepareInlineRuleSet(List<Declaration> dlist, List<PseudoPage> pseudos) { if(dlist==null || dlist.isEmpty()) { log.debug("Empty RuleSet (inline) was ommited"); return null; } // create selector with element CombinedSelector cs = (CombinedSelector) rf.createCombinedSelector() .unlock(); Selector sel = (Selector) rf.createSelector().unlock(); sel.add(rf.createElementDOM(elem, inlinePriority)); if(pseudos!=null) sel.addAll(pseudos); cs.add(sel); RuleSet rs = rf.createSet(); rs.replaceAll(dlist); rs.setSelectors(Arrays.asList(cs)); log.info("Create @media as with:\n{}", rs); return (RuleBlock<?>) rs; }
private PseudoElementImpl(String name, String functionValue, Selector nestedSelector) { this.name = name; type = PseudoElementType.forName(name); this.functionValue = functionValue; this.nestedSelector = nestedSelector; // Type-specific initialization if (type != null) { switch (type) { case CUE: if (nestedSelector == null && functionValue != null) { nestedSelector = new SelectorImpl(); nestedSelector.add(new ElementNameImpl(functionValue)); } break; } } }
public RuleBlock<?> prepareInlineRuleSet(List<Declaration> dlist, List<PseudoPage> pseudos) { if(dlist==null || dlist.isEmpty()) { log.debug("Empty RuleSet (inline) was ommited"); return null; } // create selector with element CombinedSelector cs = (CombinedSelector) rf.createCombinedSelector() .unlock(); Selector sel = (Selector) rf.createSelector().unlock(); sel.add(rf.createElementDOM(elem, inlinePriority)); if(pseudos!=null) sel.addAll(pseudos); cs.add(sel); RuleSet rs = rf.createSet(); rs.replaceAll(dlist); rs.setSelectors(Arrays.asList(cs)); log.info("Create @media as with:\n{}", rs); return (RuleBlock<?>) rs; }
ident = extractIdUnescaped(ctx.HASH().getText()); if (ident != null) { selector_stack.peek().s.add(rf.createID(ident)); } else { combined_selector_stack.peek().invalid = true; selector_stack.peek().s.add(rf.createClass(extractTextUnescaped(ctx.CLASSKEYWORD().getText()))); } else if (ctx.attribute() != null) { Selector.ElementAttribute ea = visitAttribute(ctx.attribute()); selector_stack.peek().s.add(ea); selector_stack.peek().s.add(p); } else { combined_selector_stack.peek().invalid = true;
@Override public RuleBlock<?> prepareInlineRuleSet(List<Declaration> dlist, List<Selector.SelectorPart> pseudos) { if(dlist==null || dlist.isEmpty()) { log.debug("Empty RuleSet (inline) was ommited"); return null; } // create selector with element CombinedSelector cs = (CombinedSelector) rf.createCombinedSelector() .unlock(); Selector sel = (Selector) rf.createSelector().unlock(); sel.add(rf.createElementDOM(elem, inlinePriority)); if(pseudos!=null) sel.addAll(pseudos); cs.add(sel); RuleSet rs = rf.createSet(); rs.replaceAll(dlist); rs.setSelectors(Arrays.asList(cs)); log.info("Create inline ruleset as with:\n{}", rs); return (RuleBlock<?>) rs; }
ident = extractIdUnescaped(ctx.HASH().getText()); if (ident != null) { selector_stack.peek().s.add(rf.createID(ident)); } else { combined_selector_stack.peek().invalid = true; selector_stack.peek().s.add(rf.createClass(extractTextUnescaped(ctx.CLASSKEYWORD().getText()))); } else if (ctx.attribute() != null) { Selector.ElementAttribute ea = visitAttribute(ctx.attribute()); selector_stack.peek().s.add(ea); selector_stack.peek().s.add(p); } else { combined_selector_stack.peek().invalid = true;
public RuleBlock<?> prepareInlineRuleSet(List<Declaration> dlist, List<PseudoPage> pseudos) { if(dlist==null || dlist.isEmpty()) { log.debug("Empty RuleSet (inline) was ommited"); return null; } // create selector with element CombinedSelector cs = (CombinedSelector) rf.createCombinedSelector() .unlock(); Selector sel = (Selector) rf.createSelector().unlock(); sel.add(rf.createElementDOM(elem, inlinePriority)); if(pseudos!=null) sel.addAll(pseudos); cs.add(sel); Priority prio = ps.getAndIncrement(); RuleSet rs = rf.createSet(prio); rs.replaceAll(dlist); rs.setSelectors(Arrays.asList(cs)); log.info("Create @media as {}th with:\n{}", prio, rs); return (RuleBlock<?>) rs; }
private PseudoClassImpl(String name, String functionValue, Selector nestedSelector) { this.name = name; type = PseudoClassType.forName(name); this.functionValue = functionValue; this.nestedSelector = nestedSelector; // Type-specific initialization if (type != null) { switch (type) { case NOT: if (nestedSelector == null && functionValue != null) { nestedSelector = new SelectorImpl(); nestedSelector.unlock(); nestedSelector.add(new ElementNameImpl(functionValue)); } break; case NTH_CHILD: case NTH_LAST_CHILD: case NTH_OF_TYPE: case NTH_LAST_OF_TYPE: elementIndex = decodeIndex(functionValue); break; } } }
/** * selector * : (IDENT | ASTERISK) selpart* S* * | selpart+ S* * ; */ public Selector visitSelector(CSSParser.SelectorContext ctx) { if (ctxHasErrorNode(ctx)) { statement_stack.peek().invalid = true; return null; } selector_stack.push(new selector_scope()); cz.vutbr.web.css.Selector sel; logEnter("selector"); selector_stack.peek().s = sel = (cz.vutbr.web.css.Selector) rf.createSelector().unlock(); if (ctx.IDENT() != null || ctx.ASTERISK() != null) { cz.vutbr.web.css.Selector.ElementName en = rf.createElement(cz.vutbr.web.css.Selector.ElementName.WILDCARD); if (ctx.IDENT() != null) { en.setName(extractTextUnescaped(ctx.IDENT().getText())); } //log.debug("Adding element name: {}.", en.getName()); selector_stack.peek().s.add(en); } for (CSSParser.SelpartContext selpartctx : ctx.selpart()) { visitSelpart(selpartctx); } logLeave("selector"); selector_stack.pop(); return sel; }
/** * selector * : (IDENT | ASTERISK) selpart* S* * | selpart+ S* * ; */ public Selector visitSelector(CSSParser.SelectorContext ctx) { if (ctxHasErrorNode(ctx)) { statement_stack.peek().invalid = true; return null; } selector_stack.push(new selector_scope()); cz.vutbr.web.css.Selector sel; logEnter("selector"); selector_stack.peek().s = sel = (cz.vutbr.web.css.Selector) rf.createSelector().unlock(); if (ctx.IDENT() != null || ctx.ASTERISK() != null) { cz.vutbr.web.css.Selector.ElementName en = rf.createElement(cz.vutbr.web.css.Selector.ElementName.WILDCARD); if (ctx.IDENT() != null) { en.setName(extractTextUnescaped(ctx.IDENT().getText())); } //log.debug("Adding element name: {}.", en.getName()); selector_stack.peek().s.add(en); } for (CSSParser.SelpartContext selpartctx : ctx.selpart()) { visitSelpart(selpartctx); } logLeave("selector"); selector_stack.pop(); return sel; }
((selector_scope)selector_stack.peek()).s.add(en);