ElementDefinition.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529
  1. /*
  2. * This source file is part of libRocket, the HTML/CSS Interface Middleware
  3. *
  4. * For the latest information, see http://www.librocket.com
  5. *
  6. * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
  7. *
  8. * Permission is hereby granted, free of charge, to any person obtaining a copy
  9. * of this software and associated documentation files (the "Software"), to deal
  10. * in the Software without restriction, including without limitation the rights
  11. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12. * copies of the Software, and to permit persons to whom the Software is
  13. * furnished to do so, subject to the following conditions:
  14. *
  15. * The above copyright notice and this permission notice shall be included in
  16. * all copies or substantial portions of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  23. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  24. * THE SOFTWARE.
  25. *
  26. */
  27. #include "precompiled.h"
  28. #include "ElementDefinition.h"
  29. #include "../../Include/Rocket/Core/Decorator.h"
  30. #include "../../Include/Rocket/Core/Factory.h"
  31. #include "../../Include/Rocket/Core/FontDatabase.h"
  32. #include "../../Include/Rocket/Core/Log.h"
  33. #include "../../Include/Rocket/Core/PropertyIterators.h"
  34. namespace Rocket {
  35. namespace Core {
  36. ElementDefinition::ElementDefinition()
  37. {
  38. structurally_volatile = false;
  39. }
  40. ElementDefinition::~ElementDefinition()
  41. {
  42. for (DecoratorMap::iterator i = decorators.begin(); i != decorators.end(); ++i)
  43. (*i).second->RemoveReference();
  44. for (PseudoClassDecoratorMap::iterator i = pseudo_class_decorators.begin(); i != pseudo_class_decorators.end(); ++i)
  45. {
  46. for (DecoratorMap::iterator j = (*i).second.begin(); j != (*i).second.end(); ++j)
  47. {
  48. if ((*j).second != NULL)
  49. (*j).second->RemoveReference();
  50. }
  51. }
  52. for (size_t i = 0; i < font_effects.size(); ++i)
  53. font_effects[i]->RemoveReference();
  54. }
  55. // Initialises the element definition from a list of style sheet nodes.
  56. void ElementDefinition::Initialise(const std::vector< const StyleSheetNode* >& style_sheet_nodes, const PseudoClassList& volatile_pseudo_classes, bool _structurally_volatile)
  57. {
  58. // Set the volatile structure flag.
  59. structurally_volatile = _structurally_volatile;
  60. // Mark all the volatile pseudo-classes as structurally volatile.
  61. for (PseudoClassList::const_iterator i = volatile_pseudo_classes.begin(); i != volatile_pseudo_classes.end(); ++i)
  62. pseudo_class_volatility[*i] = STRUCTURE_VOLATILE;
  63. // Merge the default (non-pseudo-class) properties.
  64. for (size_t i = 0; i < style_sheet_nodes.size(); ++i)
  65. properties.Merge(style_sheet_nodes[i]->GetProperties());
  66. // Merge the pseudo-class properties.
  67. PseudoClassPropertyMap merged_pseudo_class_properties;
  68. for (size_t i = 0; i < style_sheet_nodes.size(); ++i)
  69. {
  70. // Merge all the pseudo-classes.
  71. PseudoClassPropertyMap node_properties;
  72. style_sheet_nodes[i]->GetPseudoClassProperties(node_properties);
  73. for (PseudoClassPropertyMap::iterator j = node_properties.begin(); j != node_properties.end(); ++j)
  74. {
  75. // Merge the property maps into one uber-map; for the decorators.
  76. PseudoClassPropertyMap::iterator k = merged_pseudo_class_properties.find((*j).first);
  77. if (k == merged_pseudo_class_properties.end())
  78. merged_pseudo_class_properties[(*j).first] = (*j).second;
  79. else
  80. (*k).second.Merge((*j).second);
  81. // Search through all entries in this dictionary; we'll insert each one into our optimised list of
  82. // pseudo-class properties.
  83. for (PropertyMap::const_iterator k = (*j).second.GetProperties().begin(); k != (*j).second.GetProperties().end(); ++k)
  84. {
  85. const String& property_name = (*k).first;
  86. const Property& property = (*k).second;
  87. // Skip this property if its specificity is lower than the base property's, as in
  88. // this case it will never be used.
  89. const Property* default_property = properties.GetProperty(property_name);
  90. if (default_property != NULL &&
  91. default_property->specificity >= property.specificity)
  92. continue;
  93. PseudoClassPropertyDictionary::iterator l = pseudo_class_properties.find(property_name);
  94. if (l == pseudo_class_properties.end())
  95. pseudo_class_properties[property_name] = PseudoClassPropertyList(1, PseudoClassProperty((*j).first, property));
  96. else
  97. {
  98. // Find the location to insert this entry in the map, based on property priorities.
  99. int index = 0;
  100. while (index < (int) (*l).second.size() &&
  101. (*l).second[index].second.specificity > property.specificity)
  102. index++;
  103. (*l).second.insert((*l).second.begin() + index, PseudoClassProperty((*j).first, property));
  104. }
  105. }
  106. }
  107. }
  108. InstanceDecorators(merged_pseudo_class_properties);
  109. InstanceFontEffects(merged_pseudo_class_properties);
  110. }
  111. // Returns a specific property from the element definition's base properties.
  112. const Property* ElementDefinition::GetProperty(const String& name, const PseudoClassList& pseudo_classes) const
  113. {
  114. // Find a pseudo-class override for this property.
  115. if(pseudo_class_properties.size() > 0 && pseudo_classes.size() > 0)
  116. {
  117. PseudoClassPropertyDictionary::const_iterator property_iterator = pseudo_class_properties.find(name);
  118. if (property_iterator != pseudo_class_properties.end())
  119. {
  120. const PseudoClassPropertyList& property_list = (*property_iterator).second;
  121. for (size_t i = 0; i < property_list.size(); ++i)
  122. {
  123. if (!IsPseudoClassRuleApplicable(property_list[i].first, pseudo_classes))
  124. continue;
  125. return &property_list[i].second;
  126. }
  127. }
  128. }
  129. return properties.GetProperty(name);
  130. }
  131. // Returns the list of properties this element definition defines for an element with the given set of pseudo-classes.
  132. void ElementDefinition::GetDefinedProperties(PropertyNameList& property_names, const PseudoClassList& pseudo_classes) const
  133. {
  134. for (PropertyMap::const_iterator i = properties.GetProperties().begin(); i != properties.GetProperties().end(); ++i)
  135. property_names.insert((*i).first);
  136. for (PseudoClassPropertyDictionary::const_iterator i = pseudo_class_properties.begin(); i != pseudo_class_properties.end(); ++i)
  137. {
  138. // If this property is already in the default dictionary, don't bother checking for it here.
  139. if (property_names.find((*i).first) != property_names.end())
  140. continue;
  141. const PseudoClassPropertyList& property_list = (*i).second;
  142. // Search through all the pseudo-class combinations that have a definition for this property; if the calling
  143. // element matches at least one of them, then add it to the list.
  144. bool property_defined = false;
  145. for (size_t j = 0; j < property_list.size(); ++j)
  146. {
  147. if (IsPseudoClassRuleApplicable(property_list[j].first, pseudo_classes))
  148. {
  149. property_defined = true;
  150. break;
  151. }
  152. }
  153. if (property_defined)
  154. property_names.insert((*i).first);
  155. }
  156. }
  157. // Returns the list of properties this element definition has explicit definitions for involving the given
  158. // pseudo-class.
  159. void ElementDefinition::GetDefinedProperties(PropertyNameList& property_names, const PseudoClassList& pseudo_classes, const String& pseudo_class) const
  160. {
  161. for (PseudoClassPropertyDictionary::const_iterator i = pseudo_class_properties.begin(); i != pseudo_class_properties.end(); ++i)
  162. {
  163. // If this property has already been found, don't bother checking for it again.
  164. if (property_names.find((*i).first) != property_names.end())
  165. continue;
  166. const PseudoClassPropertyList& property_list = (*i).second;
  167. bool property_defined = false;
  168. for (size_t j = 0; j < property_list.size(); ++j)
  169. {
  170. bool rule_valid = true;
  171. bool found_toggled_pseudo_class = false;
  172. const StringList& rule_pseudo_classes = property_list[j].first;
  173. for (size_t j = 0; j < rule_pseudo_classes.size(); ++j)
  174. {
  175. if (rule_pseudo_classes[j] == pseudo_class)
  176. {
  177. found_toggled_pseudo_class = true;
  178. continue;
  179. }
  180. if (std::find(pseudo_classes.begin(), pseudo_classes.end(), rule_pseudo_classes[j]) == pseudo_classes.end())
  181. {
  182. rule_valid = false;
  183. break;
  184. }
  185. }
  186. if (rule_valid &&
  187. found_toggled_pseudo_class)
  188. {
  189. property_defined = true;
  190. break;
  191. }
  192. }
  193. if (property_defined)
  194. property_names.insert((*i).first);
  195. }
  196. }
  197. // Returns the list of the element definition's instanced decorators in the default state.
  198. const DecoratorMap& ElementDefinition::GetDecorators() const
  199. {
  200. return decorators;
  201. }
  202. // Returns the map of pseudo-class names to overriding instanced decorators.
  203. const PseudoClassDecoratorMap& ElementDefinition::GetPseudoClassDecorators() const
  204. {
  205. return pseudo_class_decorators;
  206. }
  207. // Appends this definition's font effects into a provided map of effects.
  208. void ElementDefinition::GetFontEffects(FontEffectMap& applicable_font_effects, const PseudoClassList& pseudo_classes) const
  209. {
  210. // Check each set of named effects, looking for applicable ones.
  211. for (FontEffectIndex::const_iterator i = font_effect_index.begin(); i != font_effect_index.end(); ++i)
  212. {
  213. // Search through this list, finding the first effect that is valid (depending on
  214. // pseudo-classes).
  215. const PseudoClassFontEffectIndex& index = i->second;
  216. for (size_t j = 0; j < index.size(); ++j)
  217. {
  218. if (IsPseudoClassRuleApplicable(index[j].first, pseudo_classes))
  219. {
  220. // This is the most specific valid font effect this element has under the name. If
  221. // the map of effects already has an effect with the same name, the effect with the
  222. // highest specificity will prevail.
  223. FontEffect* applicable_effect = font_effects[index[j].second];
  224. FontEffectMap::iterator map_iterator = applicable_font_effects.find(i->first);
  225. if (map_iterator == applicable_font_effects.end() ||
  226. map_iterator->second->GetSpecificity() < applicable_effect->GetSpecificity())
  227. applicable_font_effects[i->first] = applicable_effect;
  228. break;
  229. }
  230. }
  231. }
  232. }
  233. // Returns the volatility of a pseudo-class.
  234. ElementDefinition::PseudoClassVolatility ElementDefinition::GetPseudoClassVolatility(const String& pseudo_class) const
  235. {
  236. PseudoClassVolatilityMap::const_iterator i = pseudo_class_volatility.find(pseudo_class);
  237. if (i == pseudo_class_volatility.end())
  238. return STABLE;
  239. else
  240. return i->second;
  241. }
  242. // Returns true if this definition is built from nodes using structural selectors.
  243. bool ElementDefinition::IsStructurallyVolatile() const
  244. {
  245. return structurally_volatile;
  246. }
  247. ElementDefinitionIterator ElementDefinition::begin(const StringList& pseudo_classes) const {
  248. return ElementDefinitionIterator(pseudo_classes, properties.GetProperties().begin(), pseudo_class_properties.begin(), properties.GetProperties().end(), pseudo_class_properties.end());
  249. }
  250. ElementDefinitionIterator ElementDefinition::end(const StringList& pseudo_classes) const {
  251. return ElementDefinitionIterator(pseudo_classes, properties.GetProperties().end(), pseudo_class_properties.end(), properties.GetProperties().end(), pseudo_class_properties.end());
  252. }
  253. // Destroys the definition.
  254. void ElementDefinition::OnReferenceDeactivate()
  255. {
  256. delete this;
  257. }
  258. // Finds all propery declarations for a group.
  259. void ElementDefinition::BuildPropertyGroup(PropertyGroupMap& groups, const String& group_type, const PropertyDictionary& element_properties, const PropertyGroupMap* default_properties)
  260. {
  261. String property_suffix = "-" + group_type;
  262. for (PropertyMap::const_iterator property_iterator = element_properties.GetProperties().begin(); property_iterator != element_properties.GetProperties().end(); ++property_iterator)
  263. {
  264. const String& property_name = (*property_iterator).first;
  265. if (property_name.size() > property_suffix.size() &&
  266. strcasecmp(property_name.c_str() + (property_name.size() - property_suffix.size()), property_suffix.c_str()) == 0)
  267. {
  268. // We've found a group declaration!
  269. String group_name = property_name.substr(0, property_name.size() - (group_type.size() + 1));
  270. String group_class = (*property_iterator).second.value.Get< String >();
  271. PropertyDictionary* group_properties = NULL;
  272. // Check if we have an existing definition by this name; if so, we're only overriding the type.
  273. PropertyGroupMap::iterator existing_definition = groups.find(group_name);
  274. if (existing_definition != groups.end())
  275. {
  276. (*existing_definition).second.first = group_class;
  277. group_properties = &(*existing_definition).second.second;
  278. }
  279. else
  280. {
  281. // Check if we have any default decorator definitions, and if the new decorator has a default. If so,
  282. // we make a copy of the default properties for the new decorator.
  283. if (default_properties != NULL)
  284. {
  285. PropertyGroupMap::const_iterator default_definition = default_properties->find(group_name);
  286. if (default_definition != default_properties->end())
  287. group_properties = &(*groups.insert(PropertyGroupMap::value_type(group_name, PropertyGroup(group_class, (*default_definition).second.second))).first).second.second;
  288. }
  289. // If we still haven't got somewhere to put the properties for the new decorator, make a new
  290. // definition.
  291. if (group_properties == NULL)
  292. group_properties = &(*groups.insert(PropertyGroupMap::value_type(group_name, PropertyGroup(group_class, PropertyDictionary()))).first).second.second;
  293. }
  294. // Now find all of this decorator's properties.
  295. BuildPropertyGroupDictionary(*group_properties, group_type, group_name, element_properties);
  296. }
  297. }
  298. // Now go through all the default decorator definitions and see if the new property list redefines any properties
  299. // used by them.
  300. if (default_properties != NULL)
  301. {
  302. for (PropertyGroupMap::const_iterator default_definition_iterator = default_properties->begin(); default_definition_iterator != default_properties->end(); ++default_definition_iterator)
  303. {
  304. const String& default_definition_name = (*default_definition_iterator).first;
  305. // Check the list of new definitions hasn't defined this decorator already; if so, it overrode the
  306. // decorator type and so has inherited all the properties anyway.
  307. if (groups.find(default_definition_name) == groups.end())
  308. {
  309. // Nope! Make a copy of the decorator's properties and see if the new dictionary overrides any of the
  310. // properties.
  311. PropertyDictionary decorator_properties = (*default_definition_iterator).second.second;
  312. if (BuildPropertyGroupDictionary(decorator_properties, group_type, default_definition_name, element_properties) > 0)
  313. groups[default_definition_name] = PropertyGroup((*default_definition_iterator).second.first, decorator_properties);
  314. }
  315. }
  316. }
  317. }
  318. // Updates a property dictionary of all properties for a single group.
  319. int ElementDefinition::BuildPropertyGroupDictionary(PropertyDictionary& group_properties, const String& ROCKET_UNUSED_PARAMETER(group_type), const String& group_name, const PropertyDictionary& element_properties)
  320. {
  321. ROCKET_UNUSED(group_type);
  322. int num_properties = 0;
  323. for (PropertyMap::const_iterator property_iterator = element_properties.GetProperties().begin(); property_iterator != element_properties.GetProperties().end(); ++property_iterator)
  324. {
  325. const String& full_property_name = (*property_iterator).first;
  326. if (full_property_name.size() > group_name.size() + 1 &&
  327. strncasecmp(full_property_name.c_str(), group_name.c_str(), group_name.size()) == 0 &&
  328. full_property_name[group_name.size()] == '-')
  329. {
  330. String property_name = full_property_name.substr(group_name.size() + 1);
  331. // if (property_name == group_type)
  332. // continue;
  333. group_properties.SetProperty(property_name, (*property_iterator).second);
  334. num_properties++;
  335. }
  336. }
  337. return num_properties;
  338. }
  339. // Builds decorator definitions from the parsed properties and instances decorators as appropriate.
  340. void ElementDefinition::InstanceDecorators(const PseudoClassPropertyMap& merged_pseudo_class_properties)
  341. {
  342. // Now we have the complete property list, we can compile decorator properties and instance as appropriate.
  343. PropertyGroupMap decorator_definitions;
  344. BuildPropertyGroup(decorator_definitions, "decorator", properties);
  345. for (PropertyGroupMap::iterator i = decorator_definitions.begin(); i != decorator_definitions.end(); ++i)
  346. InstanceDecorator((*i).first, (*i).second.first, (*i).second.second);
  347. // Now go through all the pseudo-class properties ...
  348. for (PseudoClassPropertyMap::const_iterator pseudo_class_iterator = merged_pseudo_class_properties.begin(); pseudo_class_iterator != merged_pseudo_class_properties.end(); ++pseudo_class_iterator)
  349. {
  350. PropertyGroupMap pseudo_class_decorator_definitions;
  351. BuildPropertyGroup(pseudo_class_decorator_definitions, "decorator", (*pseudo_class_iterator).second, &decorator_definitions);
  352. for (PropertyGroupMap::iterator i = pseudo_class_decorator_definitions.begin(); i != pseudo_class_decorator_definitions.end(); ++i)
  353. InstanceDecorator((*i).first, (*i).second.first, (*i).second.second, (*pseudo_class_iterator).first);
  354. }
  355. }
  356. // Attempts to instance a decorator into a given list.
  357. bool ElementDefinition::InstanceDecorator(const String& name, const String& type, const PropertyDictionary& properties, const StringList& pseudo_classes)
  358. {
  359. Decorator* decorator = Factory::InstanceDecorator(type, properties);
  360. if (decorator == NULL)
  361. {
  362. Log::Message(Log::LT_WARNING, "Failed to instance decorator '%s' of type '%s'.", name.c_str(), type.c_str());
  363. return false;
  364. }
  365. if (pseudo_classes.empty())
  366. {
  367. if (decorator != NULL)
  368. decorators[name] = decorator;
  369. }
  370. else
  371. {
  372. PseudoClassDecoratorMap::iterator i = pseudo_class_decorators.find(pseudo_classes);
  373. if (i == pseudo_class_decorators.end())
  374. {
  375. DecoratorMap decorators;
  376. decorators[name] = decorator;
  377. pseudo_class_decorators[pseudo_classes] = decorators;
  378. }
  379. else
  380. (*i).second[name] = decorator;
  381. }
  382. return true;
  383. }
  384. // Builds font effect definitions from the parsed properties and instances font effects as appropriate.
  385. void ElementDefinition::InstanceFontEffects(const PseudoClassPropertyMap& merged_pseudo_class_properties)
  386. {
  387. // Now we have the complete property list, we can compile font-effect properties and instance as appropriate.
  388. PropertyGroupMap font_effect_definitions;
  389. BuildPropertyGroup(font_effect_definitions, "font-effect", properties);
  390. for (PropertyGroupMap::iterator i = font_effect_definitions.begin(); i != font_effect_definitions.end(); ++i)
  391. InstanceFontEffect((*i).first, (*i).second.first, (*i).second.second);
  392. // Now go through all the pseudo-class properties ...
  393. for (PseudoClassPropertyMap::const_iterator pseudo_class_iterator = merged_pseudo_class_properties.begin(); pseudo_class_iterator != merged_pseudo_class_properties.end(); ++pseudo_class_iterator)
  394. {
  395. PropertyGroupMap pseudo_class_font_effect_definitions;
  396. BuildPropertyGroup(pseudo_class_font_effect_definitions, "font-effect", (*pseudo_class_iterator).second, &font_effect_definitions);
  397. for (PropertyGroupMap::iterator i = pseudo_class_font_effect_definitions.begin(); i != pseudo_class_font_effect_definitions.end(); ++i)
  398. InstanceFontEffect((*i).first, (*i).second.first, (*i).second.second, (*pseudo_class_iterator).first);
  399. }
  400. }
  401. // Attempts to instance a font effect.
  402. bool ElementDefinition::InstanceFontEffect(const String& name, const String& type, const PropertyDictionary& properties, const StringList& pseudo_classes)
  403. {
  404. FontEffect* font_effect = FontDatabase::GetFontEffect(type, properties);
  405. if (font_effect == NULL)
  406. {
  407. Log::Message(Log::LT_WARNING, "Failed to instance font effect '%s' of type '%s'.", name.c_str(), type.c_str());
  408. return false;
  409. }
  410. // Push the instanced effect into the list of effects.
  411. int effect_index = (int) font_effects.size();
  412. font_effects.push_back(font_effect);
  413. // Get a reference to the index list we're adding this effect to.
  414. PseudoClassFontEffectIndex* index = NULL;
  415. FontEffectIndex::iterator index_iterator = font_effect_index.find(name);
  416. if (index_iterator == font_effect_index.end())
  417. {
  418. // No others; create a new index for this name.
  419. index = &(font_effect_index.insert(FontEffectIndex::value_type(name, PseudoClassFontEffectIndex())).first->second);
  420. }
  421. else
  422. {
  423. index = &(index_iterator->second);
  424. }
  425. // Add the new effect into the index.
  426. PseudoClassFontEffectIndex::iterator insert_iterator;
  427. for (insert_iterator = index->begin(); insert_iterator != index->end(); ++insert_iterator)
  428. {
  429. // Keep iterating until we find an effect whose specificity is below the new effect's. The
  430. // new effect will be inserted before it in the list.
  431. if (font_effects[insert_iterator->second]->GetSpecificity() < font_effect->GetSpecificity())
  432. break;
  433. }
  434. index->insert(insert_iterator, PseudoClassFontEffectIndex::value_type(pseudo_classes, effect_index));
  435. // Mark the effect's pseudo-classes as volatile.
  436. for (size_t i = 0; i < pseudo_classes.size(); ++i)
  437. {
  438. PseudoClassVolatilityMap::const_iterator j = pseudo_class_volatility.find(pseudo_classes[i]);
  439. if (j == pseudo_class_volatility.end())
  440. pseudo_class_volatility[pseudo_classes[i]] = FONT_VOLATILE;
  441. }
  442. return true;
  443. }
  444. // Returns true if the pseudo-class requirement of a rule is met by a list of an element's pseudo-classes.
  445. bool ElementDefinition::IsPseudoClassRuleApplicable(const StringList& rule_pseudo_classes, const PseudoClassList& element_pseudo_classes)
  446. {
  447. for (StringList::size_type i = 0; i < rule_pseudo_classes.size(); ++i)
  448. {
  449. if (std::find(element_pseudo_classes.begin(), element_pseudo_classes.end(), rule_pseudo_classes[i]) == element_pseudo_classes.end())
  450. return false;
  451. }
  452. return true;
  453. }
  454. }
  455. }