Bug 1839315: part 4) Link from `SheetLoadData::mWasAlternate` to spec. r=emilio DONTBUILD
[gecko.git] / layout / style / AttributeStyles.h
blob82220cdb56d145a0aaceeb10da7d9d280e5ea7df
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 /*
8 * style sheet and style rule processor representing data from presentational
9 * HTML attributes
12 #ifndef mozilla_AttributeStyles_h_
13 #define mozilla_AttributeStyles_h_
15 #include "nsColor.h"
16 #include "nsCOMPtr.h"
17 #include "nsAtom.h"
18 #include "PLDHashTable.h"
19 #include "mozilla/Attributes.h"
20 #include "mozilla/MemoryReporting.h"
21 #include "nsTHashMap.h"
22 #include "nsString.h"
24 struct MiscContainer;
25 namespace mozilla {
26 struct StyleLockedDeclarationBlock;
27 namespace dom {
28 class Document;
29 } // namespace dom
31 class AttributeStyles final {
32 public:
33 explicit AttributeStyles(dom::Document* aDocument);
34 void SetOwningDocument(dom::Document* aDocument);
36 NS_INLINE_DECL_REFCOUNTING(AttributeStyles)
38 size_t DOMSizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const;
40 void Reset();
41 nsresult SetLinkColor(nscolor aColor);
42 nsresult SetActiveLinkColor(nscolor aColor);
43 nsresult SetVisitedLinkColor(nscolor aColor);
45 const StyleLockedDeclarationBlock* GetServoUnvisitedLinkDecl() const {
46 return mServoUnvisitedLinkDecl;
48 const StyleLockedDeclarationBlock* GetServoVisitedLinkDecl() const {
49 return mServoVisitedLinkDecl;
51 const StyleLockedDeclarationBlock* GetServoActiveLinkDecl() const {
52 return mServoActiveLinkDecl;
55 void CacheStyleAttr(const nsAString& aSerialized, MiscContainer* aValue) {
56 mCachedStyleAttrs.InsertOrUpdate(aSerialized, aValue);
58 void EvictStyleAttr(const nsAString& aSerialized, MiscContainer* aValue) {
59 NS_ASSERTION(LookupStyleAttr(aSerialized) == aValue,
60 "Cached value doesn't match?");
61 mCachedStyleAttrs.Remove(aSerialized);
63 MiscContainer* LookupStyleAttr(const nsAString& aSerialized) {
64 return mCachedStyleAttrs.Get(aSerialized);
67 AttributeStyles(const AttributeStyles& aCopy) = delete;
68 AttributeStyles& operator=(const AttributeStyles& aCopy) = delete;
70 private:
71 ~AttributeStyles();
73 // Implementation of SetLink/VisitedLink/ActiveLinkColor
74 nsresult ImplLinkColorSetter(RefPtr<StyleLockedDeclarationBlock>& aDecl,
75 nscolor aColor);
77 dom::Document* mDocument;
78 RefPtr<StyleLockedDeclarationBlock> mServoUnvisitedLinkDecl;
79 RefPtr<StyleLockedDeclarationBlock> mServoVisitedLinkDecl;
80 RefPtr<StyleLockedDeclarationBlock> mServoActiveLinkDecl;
81 nsTHashMap<nsStringHashKey, MiscContainer*> mCachedStyleAttrs;
84 } // namespace mozilla
86 #endif