blob: 1aece5c16b980e5cc91fb93060c7f264ecfa734e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
* style sheet and style rule processor representing data from presentational
* HTML attributes
*/
#ifndef nsHTMLStyleSheet_h_
#define nsHTMLStyleSheet_h_
#include "nsColor.h"
#include "nsCOMPtr.h"
#include "nsAtom.h"
#include "PLDHashTable.h"
#include "mozilla/Attributes.h"
#include "mozilla/MemoryReporting.h"
#include "nsString.h"
class nsMappedAttributes;
namespace mozilla {
struct StyleLockedDeclarationBlock;
namespace dom {
class Document;
} // namespace dom
} // namespace mozilla
class nsHTMLStyleSheet final {
using StyleLockedDeclarationBlock = mozilla::StyleLockedDeclarationBlock;
public:
explicit nsHTMLStyleSheet(mozilla::dom::Document* aDocument);
void SetOwningDocument(mozilla::dom::Document* aDocument);
NS_INLINE_DECL_REFCOUNTING(nsHTMLStyleSheet)
size_t DOMSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
void Reset();
nsresult SetLinkColor(nscolor aColor);
nsresult SetActiveLinkColor(nscolor aColor);
nsresult SetVisitedLinkColor(nscolor aColor);
const StyleLockedDeclarationBlock* GetServoUnvisitedLinkDecl() const {
return mServoUnvisitedLinkDecl;
}
const StyleLockedDeclarationBlock* GetServoVisitedLinkDecl() const {
return mServoVisitedLinkDecl;
}
const mozilla::StyleLockedDeclarationBlock* GetServoActiveLinkDecl() const {
return mServoActiveLinkDecl;
}
// Mapped Attribute management methods
already_AddRefed<nsMappedAttributes> UniqueMappedAttributes(
nsMappedAttributes* aMapped);
void DropMappedAttributes(nsMappedAttributes* aMapped);
// For each mapped presentation attribute in the cache, resolve
// the attached DeclarationBlock by running the mapping
// and converting the ruledata to Servo specified values.
void CalculateMappedServoDeclarations();
private:
nsHTMLStyleSheet(const nsHTMLStyleSheet& aCopy) = delete;
nsHTMLStyleSheet& operator=(const nsHTMLStyleSheet& aCopy) = delete;
~nsHTMLStyleSheet() = default;
// Implementation of SetLink/VisitedLink/ActiveLinkColor
nsresult ImplLinkColorSetter(
RefPtr<mozilla::StyleLockedDeclarationBlock>& aDecl, nscolor aColor);
public: // for mLangRuleTable structures only
private:
mozilla::dom::Document* mDocument;
RefPtr<StyleLockedDeclarationBlock> mServoUnvisitedLinkDecl;
RefPtr<StyleLockedDeclarationBlock> mServoVisitedLinkDecl;
RefPtr<StyleLockedDeclarationBlock> mServoActiveLinkDecl;
PLDHashTable mMappedAttrTable;
// Whether or not the mapped attributes table
// has been changed since the last call to
// CalculateMappedServoDeclarations()
bool mMappedAttrsDirty;
};
#endif /* !defined(nsHTMLStyleSheet_h_) */
|