public void computeSpecificity(Specificity spec) { if (declaration != null) { if(declaration.isPseudoElement()) spec.add(Level.D); else spec.add(Level.C); } }
static NodeData makeNodeData(final List<Declaration> decls) { final NodeData main = CSSFactory.createNodeData(); for (final Declaration d : decls) main.push(d); return main; }
public boolean matches(Element e) { // check other items of simple selector for(SelectorPart item : list) { if(item == null || !item.matches(e, CSSFactory.getDefaultMatchCondition())) //null in case of syntax error (missing term) return false; } // we passed checking return true; }
private Term<?> stripSlash(Term<?> src) { if (src.getOperator() == Operator.SLASH) { if (src instanceof TermLength) return tf.createLength((Float) src.getValue(), ((TermLength) src).getUnit()); else if (src instanceof TermPercent) return tf.createPercent((Float) src.getValue()); else return src; } else return src; }
/** * Creates a single property declaration. * @param property Property name. * @param term Property value. * @return The resulting declaration. */ protected Declaration createDeclaration(String property, Term<?> term) { Declaration d = CSSFactory.getRuleFactory().createDeclaration(); d.unlock(); d.setProperty(property); d.add(term); return d; }
/** * Creates an empty block style definition. * @return */ protected NodeData createBlockStyle() { NodeData ret = CSSFactory.createNodeData(); TermFactory tf = CSSFactory.getTermFactory(); ret.push(createDeclaration("display", tf.createIdent("block"))); return ret; }
public static boolean hasPseudoSelector(final OrderedRule[] rules, final Element e, final MatchCondition matchCond, PseudoDeclaration pd) { for (final OrderedRule rule : rules) { for (final CombinedSelector cs : rule.getRule().getSelectors()) { final Selector lastSelector = cs.get(cs.size() - 1); if (lastSelector.hasPseudoDeclaration(pd)) { return true; } } } return false; }
public static boolean hasPseudoSelector(final OrderedRule[] rules, final Element e, final MatchCondition matchCond, PseudoClassType pd) { for (final OrderedRule rule : rules) { for (final CombinedSelector cs : rule.getRule().getSelectors()) { final Selector lastSelector = cs.get(cs.size() - 1); if (lastSelector.hasPseudoClass(pd)) { return true; } } } return false; }
/** * Creates a style definition used for the body element. * @return The body style definition. */ protected NodeData createBodyStyle() { NodeData ret = createBlockStyle(); TermFactory tf = CSSFactory.getTermFactory(); ret.push(createDeclaration("background-color", tf.createColor(255, 255, 255))); return ret; }
public boolean matches(Element e) { // check other items of simple selector for(SelectorPart item : list) { if(item == null || !item.matches(e, CSSFactory.getElementMatcher(), CSSFactory.getDefaultMatchCondition())) //null in case of syntax error (missing term) return false; } // we passed checking return true; }
/** * Registers the pseudo element if the given selector part is a pseudo element. */ private void checkPseudoElement(SelectorPart item) { if(item instanceof PseudoPage) { final PseudoDeclaration ret = ((PseudoPage)item).getDeclaration(); if (ret != null && ret.isPseudoElement()) { pseudoElement = ret; } } }
private Term<?> stripSlash(Term<?> src) { if (src.getOperator() == Operator.SLASH) { if (src instanceof TermLength) return tf.createLength((Float) src.getValue(), ((TermLength) src).getUnit()); else if (src instanceof TermPercent) return tf.createPercent((Float) src.getValue()); else return src; } else return src; }
static NodeData makeNodeData(final List<Declaration> decls) { final NodeData main = CSSFactory.createNodeData(); for (final Declaration d : decls) main.push(d); return main; }
public boolean matches(Element e) { // check other items of simple selector for(SelectorPart item : list) { if(item == null || !item.matches(e, CSSFactory.getElementMatcher(), CSSFactory.getDefaultMatchCondition())) //null in case of syntax error (missing term) return false; } // we passed checking return true; }
public void computeSpecificity(Specificity spec) { if (declaration != null) { if(declaration.isPseudoElement()) spec.add(Level.D); else spec.add(Level.C); } }
public PseudoDeclaration getPseudoElement() { PseudoDeclaration ret = null; for(SelectorPart item : list) { if(item instanceof PseudoPage) { ret = ((PseudoPage)item).getDeclaration(); if (ret.isPseudoElement()) break; //pseudo-elements may only be appended after the last simple selector of the selector else ret = null; //not interested in pseudo-classes } } return ret; }
private Term<?> stripSlash(Term<?> src) { if (src.getOperator() == Operator.SLASH) { if (src instanceof TermLength) return tf.createLength((Float) src.getValue(), ((TermLength) src).getUnit()); else if (src instanceof TermPercent) return tf.createPercent((Float) src.getValue()); else return src; } else return src; }