RuleFeature.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
  3. * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
  4. *
  5. * This library is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Library General Public
  7. * License as published by the Free Software Foundation; either
  8. * version 2 of the License, or (at your option) any later version.
  9. *
  10. * This library is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * Library General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Library General Public License
  16. * along with this library; see the file COPYING.LIB. If not, write to
  17. * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  18. * Boston, MA 02110-1301, USA.
  19. *
  20. */
  21. #ifndef RuleFeature_h
  22. #define RuleFeature_h
  23. #include <wtf/Forward.h>
  24. #include <wtf/HashMap.h>
  25. #include <wtf/HashSet.h>
  26. #include <wtf/text/AtomicString.h>
  27. namespace WebCore {
  28. class StyleRule;
  29. class CSSSelector;
  30. struct RuleFeature {
  31. RuleFeature(StyleRule* rule, unsigned selectorIndex, bool hasDocumentSecurityOrigin)
  32. : rule(rule)
  33. , selectorIndex(selectorIndex)
  34. , hasDocumentSecurityOrigin(hasDocumentSecurityOrigin)
  35. {
  36. }
  37. StyleRule* rule;
  38. unsigned selectorIndex;
  39. bool hasDocumentSecurityOrigin;
  40. };
  41. struct RuleFeatureSet {
  42. RuleFeatureSet()
  43. : usesFirstLineRules(false)
  44. , usesBeforeAfterRules(false)
  45. { }
  46. void add(const RuleFeatureSet&);
  47. void clear();
  48. void collectFeaturesFromSelector(const CSSSelector*);
  49. HashSet<AtomicStringImpl*> idsInRules;
  50. HashSet<AtomicStringImpl*> classesInRules;
  51. HashSet<AtomicStringImpl*> attrsInRules;
  52. Vector<RuleFeature> siblingRules;
  53. Vector<RuleFeature> uncommonAttributeRules;
  54. bool usesFirstLineRules;
  55. bool usesBeforeAfterRules;
  56. };
  57. } // namespace WebCore
  58. #endif // RuleFeature_h