Bug 1339629 Part 5: Change CSSStyleSet::mStyleSets to use StyleSetHandles.
MozReview-Commit-ID: 7KFbhh4fCW9
--- a/layout/style/CSSStyleSheet.cpp
+++ b/layout/style/CSSStyleSheet.cpp
@@ -590,18 +590,18 @@ CSSStyleSheet::EnsureUniqueInner()
StyleSheet::EnsureUniqueInner();
// otherwise the rule processor has pointers to the old rules
ClearRuleCascades();
// let our containing style sets know that if we call
// nsPresContext::EnsureSafeToHandOutCSSRules we will need to restyle the
// document
- for (nsStyleSet* styleSet : mStyleSets) {
- styleSet->SetNeedsRestyleAfterEnsureUniqueInner();
+ for (StyleSetHandle setHandle : mStyleSets) {
+ setHandle->AsGecko()->SetNeedsRestyleAfterEnsureUniqueInner();
}
}
void
CSSStyleSheet::AppendAllChildSheets(nsTArray<CSSStyleSheet*>& aArray)
{
for (StyleSheet* child = GetFirstChild(); child;
child = child->mNext) {
@@ -646,18 +646,18 @@ CSSStyleSheet::List(FILE* out, int32_t a
void
CSSStyleSheet::ClearRuleCascades()
{
// We might be in ClearRuleCascades because we had a modification
// to the sheet that resulted in an nsCSSSelector being destroyed.
// Tell the RestyleManager for each document we're used in
// so that they can drop any nsCSSSelector pointers (used for
// eRestyle_SomeDescendants) in their mPendingRestyles.
- for (nsStyleSet* styleSet : mStyleSets) {
- styleSet->ClearSelectors();
+ for (StyleSetHandle setHandle : mStyleSets) {
+ setHandle->AsGecko()->ClearSelectors();
}
bool removedSheetFromRuleProcessorCache = false;
if (mRuleProcessors) {
nsCSSRuleProcessor **iter = mRuleProcessors->Elements(),
**end = iter + mRuleProcessors->Length();
for(; iter != end; ++iter) {
if (!removedSheetFromRuleProcessorCache && (*iter)->IsShared()) {
--- a/layout/style/CSSStyleSheet.h
+++ b/layout/style/CSSStyleSheet.h
@@ -7,16 +7,17 @@
/* representation of a CSS style sheet */
#ifndef mozilla_CSSStyleSheet_h
#define mozilla_CSSStyleSheet_h
#include "mozilla/Attributes.h"
#include "mozilla/IncrementalClearCOMRuleArray.h"
#include "mozilla/MemoryReporting.h"
+#include "mozilla/StyleSetHandle.h"
#include "mozilla/StyleSheet.h"
#include "mozilla/StyleSheetInfo.h"
#include "mozilla/css/SheetParsingMode.h"
#include "nscore.h"
#include "nsCOMPtr.h"
#include "nsAutoPtr.h"
#include "nsTArrayForwardDeclare.h"
@@ -219,17 +220,17 @@ protected:
css::ImportRule* mOwnerRule; // weak ref
RefPtr<CSSRuleListImpl> mRuleCollection;
bool mInRuleProcessorCache;
RefPtr<dom::Element> mScopeElement;
AutoTArray<nsCSSRuleProcessor*, 8>* mRuleProcessors;
- nsTArray<nsStyleSet*> mStyleSets;
+ nsTArray<StyleSetHandle> mStyleSets;
friend class mozilla::StyleSheet;
friend class ::nsCSSRuleProcessor;
};
NS_DEFINE_STATIC_IID_ACCESSOR(CSSStyleSheet, NS_CSS_STYLE_SHEET_IMPL_CID)
} // namespace mozilla
--- a/layout/style/StyleSetHandle.h
+++ b/layout/style/StyleSetHandle.h
@@ -210,16 +210,21 @@ public:
MOZ_CRASH("should not have a ServoStyleSet object when MOZ_STYLO is "
"disabled");
#endif
}
// Make StyleSetHandle usable in boolean contexts.
explicit operator bool() const { return !!mPtr.mValue; }
bool operator!() const { return !mPtr.mValue; }
+ bool operator==(const StyleSetHandle& aOth) const
+ {
+ return mPtr.mValue == aOth.mPtr.mValue;
+ }
+ bool operator!=(const StyleSetHandle& aOth) const { return !(*this == aOth); }
// Make StyleSetHandle behave like a smart pointer.
Ptr* operator->() { return &mPtr; }
const Ptr* operator->() const { return &mPtr; }
private:
Ptr mPtr;
};