Esempio n. 1
0
bool Selector::match(const Selector &selector) const {
  const_iterator it;
  
  for (it = selector.begin();
       it != selector.end();
       it++) {
    if (match(*it))
      return true;
  }
  return false;
}
Esempio n. 2
0
bool Mixin::parse(const Selector &selector) {
  
  TokenList::const_iterator i = selector.begin();
  
  for (; i != selector.end() &&
         (*i).type != Token::PAREN_OPEN; i++) {
    this->name.push_back(*i);
  }

  this->name.rtrim();

  parseArguments(i, selector);

  return true;
}
Esempio n. 3
0
void MediaQueryRuleset::process(Stylesheet &s, Selector* prefix, ProcessingContext &context) {
  MediaQuery* query;
  Ruleset* target;
  Selector selector;

#ifdef WITH_LIBGLOG
  VLOG(2) << "Processing Less Ruleset: " <<
    getSelector().toString();
#endif
  
  query = s.createMediaQuery();
  selector = getSelector();
  context.interpolate(selector);

  if (query->getSelector().size() > 0) {
    selector.pop_front();

    query->getSelector().push_back(Token(" ", Token::WHITESPACE));
    query->getSelector().push_back(Token("and", Token::IDENTIFIER));
    query->getSelector().insert(query->getSelector().end(),
                                 selector.begin(),
                                 selector.end());
  } else
    query->setSelector(selector);

  if (prefix != NULL) {
    target = query->createRuleset();
    target->setSelector(*prefix);

#ifdef WITH_LIBGLOG
    VLOG(3) << "Interpolating selector " <<
    target->getSelector().toString();
#endif
    context.interpolate(target->getSelector());
  
    insert(NULL, *target, context);
  } else
    insert(NULL, *query, context);
}
Esempio n. 4
0
void Selector::addPrefix(const Selector &prefix) {
  iterator it;
  const_iterator it2;
  TokenList tl;
  TokenList *inserted;

  const TokenList* tmp;
  TokenList::const_iterator tmp_it;
  
  
  bool containsAmp;

  for (it = begin(); it != end(); ) {
    tmp = &(*it);
    containsAmp = tmp->contains(Token::OTHER, "&");
    
    for (it2 = prefix.begin();
         it2 != prefix.end();
         it2++) {
      inserted = &(*insert(it, tl));
      
      if (containsAmp) {
        for (tmp_it = tmp->begin(); tmp_it != tmp->end(); tmp_it++) {
          if (*tmp_it == "&")
            inserted->insert(inserted->end(), (*it2).begin(), (*it2).end());
          else
            inserted->push_back(*tmp_it);
        }
      } else {
        inserted->insert(inserted->end(), (*it2).begin(), (*it2).end());
        inserted->push_back(Token::BUILTIN_SPACE);
        inserted->insert(inserted->end(), tmp->begin(), tmp->end());
      }
    }
    it = erase(it);
  }

}
Esempio n. 5
0
void Selector::appendSelector(const Selector &selector) {
  insert(end(), selector.begin(), selector.end());
}