Bug 1384232: Let ServoStyleset know what its purpose is. r?TYLin
MozReview-Commit-ID: IwC6FcxhYMT
--- a/dom/xbl/nsXBLPrototypeResources.cpp
+++ b/dom/xbl/nsXBLPrototypeResources.cpp
@@ -162,17 +162,17 @@ nsXBLPrototypeResources::GatherRuleProce
SheetType::Doc,
nullptr,
mRuleProcessor);
}
void
nsXBLPrototypeResources::ComputeServoStyleSet(nsPresContext* aPresContext)
{
- mServoStyleSet.reset(new ServoStyleSet());
+ mServoStyleSet.reset(new ServoStyleSet(ServoStyleSet::Kind::ForXBL));
mServoStyleSet->Init(aPresContext, nullptr);
for (StyleSheet* sheet : mStyleSheetList) {
MOZ_ASSERT(sheet->IsServo(),
"This should only be called with Servo-flavored style backend!");
// The XBL style sheets aren't document level sheets, but we need to
// decide a particular SheetType to add them to style set. This type
// doesn't affect the place where we pull those rules from
// stylist::push_applicable_declarations_as_xbl_only_stylist().
--- a/layout/base/nsDocumentViewer.cpp
+++ b/layout/base/nsDocumentViewer.cpp
@@ -2314,17 +2314,17 @@ nsDocumentViewer::CreateStyleSet(nsIDocu
// different sets for different media
StyleBackendType backendType = aDocument->GetStyleBackendType();
StyleSetHandle styleSet;
if (backendType == StyleBackendType::Gecko) {
styleSet = new nsStyleSet();
} else {
- styleSet = new ServoStyleSet();
+ styleSet = new ServoStyleSet(ServoStyleSet::Kind::Master);
}
styleSet->BeginUpdate();
// The document will fill in the document sheets when we create the presshell
if (aDocument->IsBeingUsedAsImage()) {
MOZ_ASSERT(aDocument->IsSVGDocument(),
--- a/layout/style/ServoStyleSet.cpp
+++ b/layout/style/ServoStyleSet.cpp
@@ -80,18 +80,19 @@ public:
private:
AutoRestyleTimelineMarker mTimelineMarker;
AutoSetInServoTraversal mSetInServoTraversal;
};
} // namespace mozilla
-ServoStyleSet::ServoStyleSet()
- : mPresContext(nullptr)
+ServoStyleSet::ServoStyleSet(Kind aKind)
+ : mKind(aKind)
+ , mPresContext(nullptr)
, mAuthorStyleDisabled(false)
, mStylistState(StylistState::NotDirty)
, mUserFontSetUpdateGeneration(0)
, mUserFontCacheUpdateGeneration(0)
, mNeedsRestyleAfterEnsureUniqueInner(false)
{
}
--- a/layout/style/ServoStyleSet.h
+++ b/layout/style/ServoStyleSet.h
@@ -92,17 +92,31 @@ public:
return sInServoTraversal;
}
static ServoStyleSet* Current()
{
return sInServoTraversal;
}
- ServoStyleSet();
+ // The kind of styleset we have.
+ //
+ // We use ServoStyleSet also from XBL bindings, and some stuff needs to be
+ // different between them.
+ enum class Kind : uint8_t {
+ // A "master" StyleSet.
+ //
+ // This one is owned by a pres shell for a given document.
+ Master,
+
+ // A StyleSet for XBL, which is owned by a given XBL binding.
+ ForXBL,
+ };
+
+ explicit ServoStyleSet(Kind aKind);
~ServoStyleSet();
void Init(nsPresContext* aPresContext, nsBindingManager* aBindingManager);
void BeginShutdown();
void Shutdown();
void RecordStyleSheetChange(mozilla::ServoStyleSheet*, StyleSheet::ChangeType);
@@ -460,16 +474,19 @@ private:
friend class AutoSetInServoTraversal;
friend class AutoPrepareTraversal;
/**
* Gets the pending snapshots to handle from the restyle manager.
*/
const SnapshotTable& Snapshots();
+ bool IsMaster() const { return mKind == Kind::Master; }
+ bool IsForXBL() const { return mKind == Kind::ForXBL; }
+
/**
* Resolve all ServoDeclarationBlocks attached to mapped
* presentation attributes cached on the document.
*
* Call this before jumping into Servo's style system.
*/
void ResolveMappedAttrDeclarationBlocks();
@@ -540,16 +557,17 @@ private:
void InsertSheetOfType(SheetType aType,
ServoStyleSheet* aSheet,
ServoStyleSheet* aBeforeSheet);
void RemoveSheetOfType(SheetType aType,
ServoStyleSheet* aSheet);
+ const Kind mKind;
nsPresContext* mPresContext;
UniquePtr<RawServoStyleSet> mRawSet;
EnumeratedArray<SheetType, SheetType::Count,
nsTArray<RefPtr<ServoStyleSheet>>> mSheets;
bool mAuthorStyleDisabled;
StylistState mStylistState;
uint64_t mUserFontSetUpdateGeneration;
uint32_t mUserFontCacheUpdateGeneration;