protected override bool MatchSelectorPart(VisualElement element, StyleSelector selector, StyleSelectorPart part) { bool result; if (part.type == StyleSelectorType.Predicate) { UQuery.IVisualPredicateWrapper visualPredicateWrapper = part.tempData as UQuery.IVisualPredicateWrapper; result = (visualPredicateWrapper != null && visualPredicateWrapper.Predicate(element)); } else { result = base.MatchSelectorPart(element, selector, part); } return(result); }
public static MatchResultInfo MatchesSelector(VisualElement element, StyleSelector selector) { bool match = true; StyleSelectorPart[] parts = selector.parts; int count = parts.Length; for (int i = 0; i < count && match; i++) { switch (parts[i].type) { case StyleSelectorType.Wildcard: break; case StyleSelectorType.Class: match = element.ClassListContains(parts[i].value); break; case StyleSelectorType.ID: match = (element.name == parts[i].value); break; case StyleSelectorType.Type: //TODO: This tests fails to capture instances of sub-classes match = element.typeName == parts[i].value; break; case StyleSelectorType.Predicate: UQuery.IVisualPredicateWrapper w = parts[i].tempData as UQuery.IVisualPredicateWrapper; match = w != null && w.Predicate(element); break; case StyleSelectorType.PseudoClass: break; default: // ignore, all errors should have been warned before hand match = false; break; } } int triggerPseudoStateMask = 0; int dependencyPseudoMask = 0; bool saveMatch = match; if (saveMatch && selector.pseudoStateMask != 0) { match = (selector.pseudoStateMask & (int)element.pseudoStates) == selector.pseudoStateMask; if (match) { // the element matches this selector because it has those flags dependencyPseudoMask = selector.pseudoStateMask; } else { // if the element had those flags defined, it would match this selector triggerPseudoStateMask = selector.pseudoStateMask; } } if (saveMatch && selector.negatedPseudoStateMask != 0) { match &= (selector.negatedPseudoStateMask & ~(int)element.pseudoStates) == selector.negatedPseudoStateMask; if (match) { // the element matches this selector because it does not have those flags triggerPseudoStateMask |= selector.negatedPseudoStateMask; } else { // if the element didn't have those flags, it would match this selector dependencyPseudoMask |= selector.negatedPseudoStateMask; } } return(new MatchResultInfo(match, (PseudoStates)triggerPseudoStateMask, (PseudoStates)dependencyPseudoMask)); }
public static MatchResultInfo MatchesSelector(VisualElement element, StyleSelector selector) { bool flag = true; StyleSelectorPart[] parts = selector.parts; int num = parts.Length; int num2 = 0; while (num2 < num & flag) { switch (parts[num2].type) { case StyleSelectorType.Wildcard: break; case StyleSelectorType.Type: flag = (element.typeName == parts[num2].value); break; case StyleSelectorType.Class: flag = element.ClassListContains(parts[num2].value); break; case StyleSelectorType.PseudoClass: break; case StyleSelectorType.RecursivePseudoClass: goto IL_C7; case StyleSelectorType.ID: flag = (element.name == parts[num2].value); break; case StyleSelectorType.Predicate: { UQuery.IVisualPredicateWrapper visualPredicateWrapper = parts[num2].tempData as UQuery.IVisualPredicateWrapper; flag = (visualPredicateWrapper != null && visualPredicateWrapper.Predicate(element)); break; } default: goto IL_C7; } IL_CB: num2++; continue; IL_C7: flag = false; goto IL_CB; } int num3 = 0; int num4 = 0; bool flag2 = flag; bool flag3 = flag2 && selector.pseudoStateMask != 0; if (flag3) { flag = ((selector.pseudoStateMask & (int)element.pseudoStates) == selector.pseudoStateMask); bool flag4 = flag; if (flag4) { num4 = selector.pseudoStateMask; } else { num3 = selector.pseudoStateMask; } } bool flag5 = flag2 && selector.negatedPseudoStateMask != 0; if (flag5) { flag &= ((selector.negatedPseudoStateMask & (int)(~(int)element.pseudoStates)) == selector.negatedPseudoStateMask); bool flag6 = flag; if (flag6) { num3 |= selector.negatedPseudoStateMask; } else { num4 |= selector.negatedPseudoStateMask; } } return(new MatchResultInfo(flag, (PseudoStates)num3, (PseudoStates)num4)); }