Bug 1368986: Cleanup stylesheet copy-constructor. r?heycam
MozReview-Commit-ID: I8vUuJfET24
--- a/layout/style/CSSStyleSheet.cpp
+++ b/layout/style/CSSStyleSheet.cpp
@@ -350,25 +350,28 @@ CSSStyleSheet::CSSStyleSheet(css::SheetP
mInner->AddSheet(this);
}
CSSStyleSheet::CSSStyleSheet(const CSSStyleSheet& aCopy,
CSSStyleSheet* aParentToUse,
dom::CSSImportRule* aOwnerRuleToUse,
nsIDocument* aDocumentToUse,
nsINode* aOwningNodeToUse)
- : StyleSheet(aCopy, aOwnerRuleToUse, aDocumentToUse, aOwningNodeToUse),
- mInRuleProcessorCache(false),
- mScopeElement(nullptr),
- mRuleProcessors(nullptr)
+ : StyleSheet(aCopy,
+ aParentToUse,
+ aOwnerRuleToUse,
+ aDocumentToUse,
+ aOwningNodeToUse)
+ , mInRuleProcessorCache(false)
+ , mScopeElement(nullptr)
+ , mRuleProcessors(nullptr)
{
- mParent = aParentToUse;
-
if (mDirty) { // CSSOM's been there, force full copy now
- NS_ASSERTION(mInner->mComplete, "Why have rules been accessed on an incomplete sheet?");
+ NS_ASSERTION(mInner->mComplete,
+ "Why have rules been accessed on an incomplete sheet?");
// FIXME: handle failure?
//
// NOTE: It's important to call this from the subclass, since it could
// access uninitialized members otherwise.
EnsureUniqueInner();
}
}
--- a/layout/style/ServoStyleSheet.cpp
+++ b/layout/style/ServoStyleSheet.cpp
@@ -79,22 +79,25 @@ ServoStyleSheet::ServoStyleSheet(css::Sh
mInner->AddSheet(this);
}
ServoStyleSheet::ServoStyleSheet(const ServoStyleSheet& aCopy,
ServoStyleSheet* aParentToUse,
dom::CSSImportRule* aOwnerRuleToUse,
nsIDocument* aDocumentToUse,
nsINode* aOwningNodeToUse)
- : StyleSheet(aCopy, aOwnerRuleToUse, aDocumentToUse, aOwningNodeToUse)
+ : StyleSheet(aCopy,
+ aParentToUse,
+ aOwnerRuleToUse,
+ aDocumentToUse,
+ aOwningNodeToUse)
{
- mParent = aParentToUse;
-
if (mDirty) { // CSSOM's been there, force full copy now
- NS_ASSERTION(mInner->mComplete, "Why have rules been accessed on an incomplete sheet?");
+ NS_ASSERTION(mInner->mComplete,
+ "Why have rules been accessed on an incomplete sheet?");
// FIXME: handle failure?
//
// NOTE: It's important to call this from the subclass, since this could
// access uninitialized members otherwise.
EnsureUniqueInner();
}
}
--- a/layout/style/StyleSheet.cpp
+++ b/layout/style/StyleSheet.cpp
@@ -29,29 +29,30 @@ StyleSheet::StyleSheet(StyleBackendType
, mDisabled(false)
, mDocumentAssociationMode(NotOwnedByDocument)
, mInner(nullptr)
, mDirty(false)
{
}
StyleSheet::StyleSheet(const StyleSheet& aCopy,
+ StyleSheet* aParentToUse,
dom::CSSImportRule* aOwnerRuleToUse,
nsIDocument* aDocumentToUse,
nsINode* aOwningNodeToUse)
- : mParent(nullptr)
+ : mParent(aParentToUse)
, mTitle(aCopy.mTitle)
, mDocument(aDocumentToUse)
, mOwningNode(aOwningNodeToUse)
, mOwnerRule(aOwnerRuleToUse)
, mParsingMode(aCopy.mParsingMode)
, mType(aCopy.mType)
, mDisabled(aCopy.mDisabled)
- // We only use this constructor during cloning. It's the cloner's
- // responsibility to notify us if we end up being owned by a document.
+ // We only use this constructor during cloning. It's the cloner's
+ // responsibility to notify us if we end up being owned by a document.
, mDocumentAssociationMode(NotOwnedByDocument)
, mInner(aCopy.mInner) // Shallow copy, but concrete subclasses will fix up.
, mDirty(aCopy.mDirty)
{
MOZ_ASSERT(mInner, "Should only copy StyleSheets with an mInner.");
mInner->AddSheet(this);
if (aCopy.mMedia) {
--- a/layout/style/StyleSheet.h
+++ b/layout/style/StyleSheet.h
@@ -48,16 +48,17 @@ class Rule;
*/
class StyleSheet : public nsIDOMCSSStyleSheet
, public nsICSSLoaderObserver
, public nsWrapperCache
{
protected:
StyleSheet(StyleBackendType aType, css::SheetParsingMode aParsingMode);
StyleSheet(const StyleSheet& aCopy,
+ StyleSheet* aParentToUse,
dom::CSSImportRule* aOwnerRuleToUse,
nsIDocument* aDocumentToUse,
nsINode* aOwningNodeToUse);
virtual ~StyleSheet();
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(StyleSheet,