nsHTMLCSSStyleSheet.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. /*
  6. * style sheet and style rule processor representing style attributes
  7. */
  8. #ifndef nsHTMLCSSStyleSheet_h_
  9. #define nsHTMLCSSStyleSheet_h_
  10. #include "mozilla/Attributes.h"
  11. #include "mozilla/MemoryReporting.h"
  12. #include "nsDataHashtable.h"
  13. #include "nsIStyleRuleProcessor.h"
  14. class nsRuleWalker;
  15. struct MiscContainer;
  16. namespace mozilla {
  17. enum class CSSPseudoElementType : uint8_t;
  18. namespace dom {
  19. class Element;
  20. } // namespace dom
  21. } // namespace mozilla
  22. class nsHTMLCSSStyleSheet final : public nsIStyleRuleProcessor
  23. {
  24. public:
  25. nsHTMLCSSStyleSheet();
  26. NS_DECL_ISUPPORTS
  27. // nsIStyleRuleProcessor
  28. virtual void RulesMatching(ElementRuleProcessorData* aData) override;
  29. virtual void RulesMatching(PseudoElementRuleProcessorData* aData) override;
  30. virtual void RulesMatching(AnonBoxRuleProcessorData* aData) override;
  31. #ifdef MOZ_XUL
  32. virtual void RulesMatching(XULTreeRuleProcessorData* aData) override;
  33. #endif
  34. virtual nsRestyleHint HasStateDependentStyle(StateRuleProcessorData* aData) override;
  35. virtual nsRestyleHint HasStateDependentStyle(PseudoElementStateRuleProcessorData* aData) override;
  36. virtual bool HasDocumentStateDependentStyle(StateRuleProcessorData* aData) override;
  37. virtual nsRestyleHint
  38. HasAttributeDependentStyle(AttributeRuleProcessorData* aData,
  39. mozilla::RestyleHintData& aRestyleHintDataResult) override;
  40. virtual bool MediumFeaturesChanged(nsPresContext* aPresContext) override;
  41. virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf)
  42. const MOZ_MUST_OVERRIDE override;
  43. virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf)
  44. const MOZ_MUST_OVERRIDE override;
  45. // Variants of RulesMatching method above that is specific to this
  46. // rule processor.
  47. void ElementRulesMatching(nsPresContext* aPresContext,
  48. mozilla::dom::Element* aElement,
  49. nsRuleWalker* aRuleWalker);
  50. // aPseudoElement here is the content node for the pseudo-element, not
  51. // its corresponding real element.
  52. void PseudoElementRulesMatching(mozilla::dom::Element* aPseudoElement,
  53. mozilla::CSSPseudoElementType aPseudoType,
  54. nsRuleWalker* aRuleWalker);
  55. void CacheStyleAttr(const nsAString& aSerialized, MiscContainer* aValue);
  56. void EvictStyleAttr(const nsAString& aSerialized, MiscContainer* aValue);
  57. MiscContainer* LookupStyleAttr(const nsAString& aSerialized);
  58. private:
  59. ~nsHTMLCSSStyleSheet();
  60. nsHTMLCSSStyleSheet(const nsHTMLCSSStyleSheet& aCopy) = delete;
  61. nsHTMLCSSStyleSheet& operator=(const nsHTMLCSSStyleSheet& aCopy) = delete;
  62. protected:
  63. nsDataHashtable<nsStringHashKey, MiscContainer*> mCachedStyleAttrs;
  64. };
  65. #endif /* !defined(nsHTMLCSSStyleSheet_h_) */