Exemplo n.º 1
0
UnprocessedStatement* LessParser::parseRulesetStatement (LessRuleset &ruleset) {
  UnprocessedStatement* statement;
  Selector tokens;
  size_t property_i;
  
  while (parseProperty(tokens) || parsePropertyVariable(tokens)) {}
  
  property_i = tokens.size();

  parseWhitespace(tokens);
  parseSelector(tokens);
  tokens.trim();

  if (tokens.empty())
    return NULL;

  statement = ruleset.createUnprocessedStatement();
  
  statement->getTokens()->swap(tokens);
  statement->property_i = property_i;
    
  if (tokenizer->getTokenType() == Token::BRACKET_OPEN) 
    return statement;
  
  parseValue(*statement->getTokens());
  
  if (tokenizer->getTokenType() == Token::DELIMITER) {
    tokenizer->readNextToken();
    skipWhitespace();
  } 
  return statement;
}
Exemplo n.º 2
0
Specificity Wt::Render::Match::isMatch(const Block* block, const Selector& selector)
{
  if(!selector.size())
    return Specificity(false);

  if(!isMatch(block, selector.at(selector.size()-1)))
    return Specificity(false);
  const Block* parent = block->parent();
  for(int i = selector.size()-2; i >= 0; --i)
  {
    bool matchFound;
    while(parent)
    {
      matchFound = isMatch(parent, selector.at(i));
      parent = parent->parent();
      if(matchFound)
        break;
    }

    if(!matchFound && !parent)
      return Specificity(false);
  }
  return selector.specificity();
}