1 18 package org.apache.batik.css.engine.sac; 19 20 import java.util.Set ; 21 22 import org.w3c.css.sac.Selector; 23 import org.w3c.css.sac.SimpleSelector; 24 import org.w3c.dom.Element ; 25 import org.w3c.dom.Node ; 26 27 34 public class CSSChildSelector extends AbstractDescendantSelector { 35 36 39 public CSSChildSelector(Selector ancestor, SimpleSelector simple) { 40 super(ancestor, simple); 41 } 42 43 47 public short getSelectorType() { 48 return SAC_CHILD_SELECTOR; 49 } 50 51 54 public boolean match(Element e, String pseudoE) { 55 Node n = e.getParentNode(); 56 if (n != null && n.getNodeType() == Node.ELEMENT_NODE) { 57 return ((ExtendedSelector)getAncestorSelector()).match((Element )n, 58 null) && 59 ((ExtendedSelector)getSimpleSelector()).match(e, pseudoE); 60 } 61 return false; 62 } 63 64 67 public void fillAttributeSet(Set attrSet) { 68 ((ExtendedSelector)getAncestorSelector()).fillAttributeSet(attrSet); 69 ((ExtendedSelector)getSimpleSelector()).fillAttributeSet(attrSet); 70 } 71 72 75 public String toString() { 76 SimpleSelector s = getSimpleSelector(); 77 if (s.getSelectorType() == SAC_PSEUDO_ELEMENT_SELECTOR) { 78 return "" + getAncestorSelector() + s; 79 } 80 return getAncestorSelector() + " > " + s; 81 } 82 } 83 | Popular Tags |