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 CSSDescendantSelector extends AbstractDescendantSelector { 35 36 39 public CSSDescendantSelector(Selector ancestor, SimpleSelector simple) { 40 super(ancestor, simple); 41 } 42 43 47 public short getSelectorType() { 48 return SAC_DESCENDANT_SELECTOR; 49 } 50 51 54 public boolean match(Element e, String pseudoE) { 55 ExtendedSelector p = (ExtendedSelector)getAncestorSelector(); 56 for (Node n = e.getParentNode(); n != null; n = n.getParentNode()) { 57 if (n.getNodeType() == Node.ELEMENT_NODE && 58 p.match((Element )n, null)) { 59 return ((ExtendedSelector)getSimpleSelector()).match(e, 60 pseudoE); 61 } 62 } 63 return false; 64 } 65 66 69 public void fillAttributeSet(Set attrSet) { 70 ((ExtendedSelector)getSimpleSelector()).fillAttributeSet(attrSet); 71 } 72 73 76 public String toString() { 77 return getAncestorSelector() + " " + getSimpleSelector(); 78 } 79 } 80 | Popular Tags |