Line data Source code
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/. */
6 :
7 : #ifndef mozilla_ServoStyleContext_h
8 : #define mozilla_ServoStyleContext_h
9 :
10 : #include "nsStyleContext.h"
11 :
12 : namespace mozilla {
13 :
14 : class ServoStyleContext final : public nsStyleContext {
15 : public:
16 :
17 : static already_AddRefed<ServoStyleContext>
18 : Create(nsStyleContext* aParentContext,
19 : nsPresContext* aPresContext,
20 : nsIAtom* aPseudoTag,
21 : mozilla::CSSPseudoElementType aPseudoType,
22 : already_AddRefed<ServoComputedValues> aComputedValues);
23 :
24 : ServoStyleContext(nsStyleContext* aParent,
25 : nsPresContext* aPresContext,
26 : nsIAtom* aPseudoTag,
27 : CSSPseudoElementType aPseudoType,
28 : already_AddRefed<ServoComputedValues> aComputedValues);
29 :
30 0 : nsPresContext* PresContext() const {
31 0 : return mPresContext;
32 : }
33 :
34 0 : ServoComputedValues* ComputedValues() const {
35 0 : return mSource;
36 : }
37 0 : ~ServoStyleContext() {
38 0 : Destructor();
39 0 : }
40 :
41 : /**
42 : * Makes this context match |aOther| in terms of which style structs have
43 : * been resolved.
44 : */
45 0 : void ResolveSameStructsAs(nsPresContext* aPresContext, ServoStyleContext* aOther) {
46 : // NB: This function is only called on newly-minted style contexts, but
47 : // those may already have resolved style structs given the SetStyleBits call
48 : // in FinishConstruction. So we carefully xor out the bits that are new so
49 : // that we don't call FinishStyle twice.
50 0 : uint64_t ourBits = mBits & NS_STYLE_INHERIT_MASK;
51 0 : uint64_t otherBits = aOther->mBits & NS_STYLE_INHERIT_MASK;
52 0 : MOZ_ASSERT((otherBits | ourBits) == otherBits, "otherBits should be a superset");
53 0 : uint64_t newBits = (ourBits ^ otherBits) & NS_STYLE_INHERIT_MASK;
54 :
55 : #define STYLE_STRUCT(name_, checkdata_cb) \
56 : if (nsStyle##name_::kHasFinishStyle && newBits & NS_STYLE_INHERIT_BIT(name_)) { \
57 : const nsStyle##name_* data = Servo_GetStyle##name_(ComputedValues()); \
58 : const_cast<nsStyle##name_*>(data)->FinishStyle(aPresContext); \
59 : }
60 : #include "nsStyleStructList.h"
61 : #undef STYLE_STRUCT
62 :
63 0 : mBits |= newBits;
64 0 : }
65 :
66 : private:
67 : nsPresContext* mPresContext;
68 : RefPtr<ServoComputedValues> mSource;
69 : };
70 :
71 : }
72 :
73 : #endif // mozilla_ServoStyleContext_h
|