Esempio n. 1
0
 public void Visit(PseudoSelector selector)
 {
   switch (selector.Type)
   {
     case PseudoTypes.Active:
     case PseudoTypes.Checked:
     case PseudoTypes.Default:
     case PseudoTypes.Disabled:
     case PseudoTypes.Enabled:
     case PseudoTypes.Focus:
     case PseudoTypes.Hover:
     case PseudoTypes.Indeterminate:
     case PseudoTypes.Inrange:
     case PseudoTypes.Invalid:
     case PseudoTypes.Link:
     case PseudoTypes.Optional:
     case PseudoTypes.Outofrange:
     case PseudoTypes.Readonly:
     case PseudoTypes.Readwrite:
     case PseudoTypes.Required:
     case PseudoTypes.Target:
     case PseudoTypes.Unchecked:
     case PseudoTypes.Valid:
     case PseudoTypes.Visited:
       NotSupported();
       break;
     case PseudoTypes.Empty:
       _matches = _matches.Where(n => n.IsEmpty());
       break;
     case PseudoTypes.Firstchild:
       _matches = _matches.Where(n => _engine.Parents(n).Any()
                                   && !_engine.PrecedingSiblings(n).Any());
       break;
     case PseudoTypes.FirstOfType:
       _matches = _matches.Where(n => _engine.Parents(n).Any()
                                   && !_engine.PrecedingSiblings(n).Any(m => IsMatch(n.Name, m.Name)));
       break;
     case PseudoTypes.Lastchild:
       _matches = _matches.Where(n => _engine.Parents(n).Any()
                                   && !_engine.FollowingSiblings(n).Any());
       break;
     case PseudoTypes.Lastoftype:
       _matches = _matches.Where(n => _engine.Parents(n).Any()
                                   && !_engine.FollowingSiblings(n).Any(m => IsMatch(n.Name, m.Name)));
       break;
     case PseudoTypes.Onlychild:
       _matches = _matches.Where(n => _engine.Parents(n).Any()
                                   && !_engine.PrecedingSiblings(n).Any()
                                   && !_engine.FollowingSiblings(n).Any());
       break;
     case PseudoTypes.OnlyOfType:
       _matches = _matches.Where(n => _engine.Parents(n).Any()
                                   && !_engine.PrecedingSiblings(n).Any(m => IsMatch(n.Name, m.Name))
                                   && !_engine.FollowingSiblings(n).Any(m => IsMatch(n.Name, m.Name)));
       break;
     case PseudoTypes.Root:
       _matches = _matches.Where(n => !_engine.Parents(n).Any());
       break;
     default:
       NotSupported();
       break;
   }
 }
 public void Visit(PseudoSelector selector)
 {
   this.Specificity += (1 << 8);
 }
 public void Visit(PseudoSelector selector)
 {
   _writer.Write(':');
   switch (selector.Type)
   {
     case PseudoTypes.FunctionNthchild:       _writer.Write(PseudoSelectorPrefix.PseudoFunctionNthchild);       break;
     case PseudoTypes.FunctionNthlastchild:   _writer.Write(PseudoSelectorPrefix.PseudoFunctionNthlastchild);   break;
     case PseudoTypes.FunctionNthOfType:      _writer.Write(PseudoSelectorPrefix.PseudoFunctionNthOfType);      break;
     case PseudoTypes.FunctionNthLastOfType:  _writer.Write(PseudoSelectorPrefix.PseudoFunctionNthLastOfType);  break;
     case PseudoTypes.Root:                   _writer.Write(PseudoSelectorPrefix.PseudoRoot);                   break;
     case PseudoTypes.FirstOfType:            _writer.Write(PseudoSelectorPrefix.PseudoFirstOfType);            break;
     case PseudoTypes.Lastoftype:             _writer.Write(PseudoSelectorPrefix.PseudoLastoftype);             break;
     case PseudoTypes.Onlychild:              _writer.Write(PseudoSelectorPrefix.PseudoOnlychild);              break;
     case PseudoTypes.OnlyOfType:             _writer.Write(PseudoSelectorPrefix.PseudoOnlyOfType);             break;
     case PseudoTypes.Firstchild:             _writer.Write(PseudoSelectorPrefix.PseudoFirstchild);             break;
     case PseudoTypes.Lastchild:              _writer.Write(PseudoSelectorPrefix.PseudoLastchild);              break;
     case PseudoTypes.Empty:                  _writer.Write(PseudoSelectorPrefix.PseudoEmpty);                  break;
     case PseudoTypes.Link:                   _writer.Write(PseudoSelectorPrefix.PseudoLink);                   break;
     case PseudoTypes.Visited:                _writer.Write(PseudoSelectorPrefix.PseudoVisited);                break;
     case PseudoTypes.Active:                 _writer.Write(PseudoSelectorPrefix.PseudoActive);                 break;
     case PseudoTypes.Hover:                  _writer.Write(PseudoSelectorPrefix.PseudoHover);                  break;
     case PseudoTypes.Focus:                  _writer.Write(PseudoSelectorPrefix.PseudoFocus);                  break;
     case PseudoTypes.Target:                 _writer.Write(PseudoSelectorPrefix.PseudoTarget);                 break;
     case PseudoTypes.Enabled:                _writer.Write(PseudoSelectorPrefix.PseudoEnabled);                break;
     case PseudoTypes.Disabled:               _writer.Write(PseudoSelectorPrefix.PseudoDisabled);               break;
     case PseudoTypes.Checked:                _writer.Write(PseudoSelectorPrefix.PseudoChecked);                break;
     case PseudoTypes.Unchecked:              _writer.Write(PseudoSelectorPrefix.PseudoUnchecked);              break;
     case PseudoTypes.Indeterminate:          _writer.Write(PseudoSelectorPrefix.PseudoIndeterminate);          break;
     case PseudoTypes.Default:                _writer.Write(PseudoSelectorPrefix.PseudoDefault);                break;
     case PseudoTypes.Valid:                  _writer.Write(PseudoSelectorPrefix.PseudoValid);                  break;
     case PseudoTypes.Invalid:                _writer.Write(PseudoSelectorPrefix.PseudoInvalid);                break;
     case PseudoTypes.Required:               _writer.Write(PseudoSelectorPrefix.PseudoRequired);               break;
     case PseudoTypes.Inrange:                _writer.Write(PseudoSelectorPrefix.PseudoInrange);                break;
     case PseudoTypes.Outofrange:             _writer.Write(PseudoSelectorPrefix.PseudoOutofrange);             break;
     case PseudoTypes.Optional:               _writer.Write(PseudoSelectorPrefix.PseudoOptional);               break;
     case PseudoTypes.Readonly:               _writer.Write(PseudoSelectorPrefix.PseudoReadonly);               break;
     case PseudoTypes.Readwrite:              _writer.Write(PseudoSelectorPrefix.PseudoReadwrite);              break;
     case PseudoTypes.FunctionDir:            _writer.Write(PseudoSelectorPrefix.PseudoFunctionDir);            break;
     case PseudoTypes.FunctionNot:            _writer.Write(PseudoSelectorPrefix.PseudoFunctionNot);            break;
     case PseudoTypes.FunctionLang:           _writer.Write(PseudoSelectorPrefix.PseudoFunctionLang);           break;
     case PseudoTypes.FunctionContains:       _writer.Write(PseudoSelectorPrefix.PseudoFunctionContains);       break;
   }
 }