示例#1
0
// Iterates over the properties in the definition.
bool ElementDefinition::IterateProperties(int& index, const PseudoClassList& pseudo_classes, PseudoClassList& property_pseudo_classes, String& property_name, const Property*& property) const
{
	if (index < properties.GetNumProperties())
	{
		PropertyMap::const_iterator i = properties.GetProperties().begin();
		for (int count = 0; count < index; ++count)
			++i;

		property_pseudo_classes.clear();
		property_name = (*i).first;
		property = &((*i).second);
		++index;

		return true;
	}

	// Not in the base properties; check for pseudo-class overrides.
	int property_count = properties.GetNumProperties();
	for (PseudoClassPropertyDictionary::const_iterator i = pseudo_class_properties.begin(); i != pseudo_class_properties.end(); ++i)
	{
		// Iterate over each pseudo-class set that has a definition for this property; if we find one that matches our
		// pseudo-class, increment our index counter and either return that property (if we hit the requested index) or
		// continue looking if we're still below it.
		for (size_t j = 0; j < (*i).second.size(); ++j)
		{
			if (IsPseudoClassRuleApplicable((*i).second[j].first, pseudo_classes))
			{
				property_count++;
				if (property_count > index)
				{
					// Copy the list of pseudo-classes.
					property_pseudo_classes.clear();
					for (size_t k = 0; k < (*i).second[j].first.size(); ++k)
						property_pseudo_classes.insert((*i).second[j].first[k]);

					property_name = (*i).first;
					property = &((*i).second[j].second);
					++index;

					return true;
				}
				else
				{
					break;
				}
			}
		}
	}

	return false;
}
示例#2
0
// Adds to a list the names of this node's pseudo-classes which are deemed volatile.
bool StyleSheetNode::GetVolatilePseudoClasses(PseudoClassList& volatile_pseudo_classes) const
{
	if (type == PSEUDO_CLASS)
	{
		bool self_volatile = !children[TAG].empty();

		for (NodeMap::const_iterator i = children[PSEUDO_CLASS].begin(); i != children[PSEUDO_CLASS].end(); ++i)
			self_volatile = (*i).second->GetVolatilePseudoClasses(volatile_pseudo_classes) | self_volatile;

		if (self_volatile)
			volatile_pseudo_classes.insert(name);

		return self_volatile;
	}
	else
	{
		for (NodeMap::const_iterator i = children[PSEUDO_CLASS].begin(); i != children[PSEUDO_CLASS].end(); ++i)
			(*i).second->GetVolatilePseudoClasses(volatile_pseudo_classes);
	}

	return false;
}