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/. */
8 * style sheet and style rule processor representing data from presentational
12 #ifndef mozilla_AttributeStyles_h_
13 #define mozilla_AttributeStyles_h_
18 #include "PLDHashTable.h"
19 #include "mozilla/Attributes.h"
20 #include "mozilla/MemoryReporting.h"
21 #include "nsTHashMap.h"
26 struct StyleLockedDeclarationBlock
;
31 class AttributeStyles final
{
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;
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;
73 // Implementation of SetLink/VisitedLink/ActiveLinkColor
74 nsresult
ImplLinkColorSetter(RefPtr
<StyleLockedDeclarationBlock
>& aDecl
,
77 dom::Document
* mDocument
;
78 RefPtr
<StyleLockedDeclarationBlock
> mServoUnvisitedLinkDecl
;
79 RefPtr
<StyleLockedDeclarationBlock
> mServoVisitedLinkDecl
;
80 RefPtr
<StyleLockedDeclarationBlock
> mServoActiveLinkDecl
;
81 nsTHashMap
<nsStringHashKey
, MiscContainer
*> mCachedStyleAttrs
;
84 } // namespace mozilla