Bug 1457920: Remove DidDirty. r?xidorn draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Mon, 30 Apr 2018 18:11:41 +0200
changeset 789948 1a393fd2a638f25da128b315b50ae9bd1044bb86
parent 789947 12ae383a830ecd36a0cdf0d7ae298be8772a9b3b
child 789949 44a4c6ad78eefc210fd96fed40f1ad7ec7e6d9d9
push id108371
push userbmo:emilio@crisal.io
push dateMon, 30 Apr 2018 19:53:45 +0000
reviewersxidorn
bugs1457920
milestone61.0a1
Bug 1457920: Remove DidDirty. r?xidorn MozReview-Commit-ID: 54sVDiRkLze
layout/style/GroupRule.h
layout/style/ServoStyleRule.cpp
layout/style/ServoStyleSheet.cpp
layout/style/StyleSheet.cpp
layout/style/StyleSheet.h
--- a/layout/style/GroupRule.h
+++ b/layout/style/GroupRule.h
@@ -54,18 +54,17 @@ public:
   int32_t StyleRuleCount() const { return mRuleList->Length(); }
 
   Rule* GetStyleRuleAt(int32_t aIndex) const {
     return mRuleList->GetRule(aIndex);
   }
 
   /*
    * The next method should never be called unless you have first called
-   * WillDirty() on the parent stylesheet. After it's called, DidDirty()
-   * needs to be called on the sheet.
+   * WillDirty() on the parent stylesheet.
    */
   nsresult DeleteStyleRuleAt(uint32_t aIndex) {
     return mRuleList->DeleteRule(aIndex);
   }
 
   // non-virtual -- it is only called by subclasses
   size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
   virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const override = 0;
--- a/layout/style/ServoStyleRule.cpp
+++ b/layout/style/ServoStyleRule.cpp
@@ -214,17 +214,16 @@ ServoStyleRule::SetSelectorText(const ns
 
     // StyleRule lives inside of the Inner, it is unsafe to call WillDirty
     // if sheet does not already have a unique Inner.
     sheet->AssertHasUniqueInner();
     sheet->WillDirty();
 
     const RawServoStyleSheetContents* contents = servoSheet->RawContents();
     if (Servo_StyleRule_SetSelectorText(contents, mRawRule, &aSelectorText)) {
-      sheet->DidDirty();
       sheet->RuleChanged(this);
     }
   }
 }
 
 uint32_t
 ServoStyleRule::GetSelectorCount()
 {
--- a/layout/style/ServoStyleSheet.cpp
+++ b/layout/style/ServoStyleSheet.cpp
@@ -266,17 +266,16 @@ ServoStyleSheet::ReparseSheet(const nsAS
 
   DropRuleList();
 
   ParseSheetSync(loader,
                  NS_ConvertUTF16toUTF8(aInput),
                  /* aLoadData = */ nullptr,
                  lineNumber,
                  &reusableSheets);
-  DidDirty();
 
   // Notify the stylesets about the new rules.
   {
     // Get the rule list (which will need to be regenerated after ParseSheet).
     ServoCSSRuleList* ruleList = GetCssRulesInternal();
     MOZ_ASSERT(ruleList);
 
     uint32_t ruleCount = ruleList->Length();
--- a/layout/style/StyleSheet.cpp
+++ b/layout/style/StyleSheet.cpp
@@ -575,41 +575,38 @@ StyleSheet::GetContainingShadow() const
     }                                                     \
     current = current->mParent;                           \
   } while (current);                                      \
 } while (0)
 
 void
 StyleSheet::RuleAdded(css::Rule& aRule)
 {
-  DidDirty();
   mDirtyFlags |= MODIFIED_RULES;
   NOTIFY(RuleAdded, (*AsServo(), aRule));
 
   if (mDocument) {
     mDocument->StyleRuleAdded(this, &aRule);
   }
 }
 
 void
 StyleSheet::RuleRemoved(css::Rule& aRule)
 {
-  DidDirty();
   mDirtyFlags |= MODIFIED_RULES;
   NOTIFY(RuleRemoved, (*AsServo(), aRule));
 
   if (mDocument) {
     mDocument->StyleRuleRemoved(this, &aRule);
   }
 }
 
 void
 StyleSheet::RuleChanged(css::Rule* aRule)
 {
-  DidDirty();
   mDirtyFlags |= MODIFIED_RULES;
   NOTIFY(RuleChanged, (*AsServo(), aRule));
 
   if (mDocument) {
     mDocument->StyleRuleChanged(this, aRule);
   }
 }
 
@@ -716,18 +713,16 @@ StyleSheet::SubjectSubsumesInnerPrincipa
   if (!info.mComplete) {
     aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
     return;
   }
 
   WillDirty();
 
   info.mPrincipal = &aSubjectPrincipal;
-
-  DidDirty();
 }
 
 bool
 StyleSheet::AreRulesAvailable(nsIPrincipal& aSubjectPrincipal,
                               ErrorResult& aRv)
 {
   // Rules are not available on incomplete sheets.
   if (!SheetInfo().mComplete) {
@@ -776,17 +771,16 @@ StyleSheet::ClearAssociatedDocument()
   SetAssociatedDocument(nullptr, NotOwnedByDocument);
 }
 
 void
 StyleSheet::PrependStyleSheet(StyleSheet* aSheet)
 {
   WillDirty();
   PrependStyleSheetSilently(aSheet);
-  DidDirty();
 }
 
 void
 StyleSheet::PrependStyleSheetSilently(StyleSheet* aSheet)
 {
   MOZ_ASSERT(aSheet);
 
   aSheet->mNext = SheetInfo().mFirstChild;
--- a/layout/style/StyleSheet.h
+++ b/layout/style/StyleSheet.h
@@ -108,17 +108,16 @@ public:
     Inner()->mContents = aContents;
   }
 
   URLExtraData* URLData() const { return Inner()->mURLData; }
 
   // FIXME(emilio): Remove.
   StyleSheet* AsServo() { return this; }
   const StyleSheet* AsServo() const { return this; }
-  void DidDirty() {}
 
   // nsICSSLoaderObserver interface
   NS_IMETHOD StyleSheetLoaded(StyleSheet* aSheet, bool aWasAlternate,
                               nsresult aStatus) final;
 
   // Internal GetCssRules methods which do not have security check and
   // completeness check.
   ServoCSSRuleList* GetCssRulesInternal();
@@ -239,17 +238,17 @@ public:
 
   void SetOwnerRule(dom::CSSImportRule* aOwnerRule) {
     mOwnerRule = aOwnerRule; /* Not ref counted */
   }
   dom::CSSImportRule* GetOwnerRule() const { return mOwnerRule; }
 
   void PrependStyleSheet(StyleSheet* aSheet);
 
-  // Prepend a stylesheet to the child list without calling Will/DidDirty.
+  // Prepend a stylesheet to the child list without calling WillDirty.
   void PrependStyleSheetSilently(StyleSheet* aSheet);
 
   StyleSheet* GetFirstChild() const;
   StyleSheet* GetMostRecentlyAddedChildSheet() const {
     // New child sheet can only be prepended into the linked list of
     // child sheets, so the most recently added one is always the first.
     return GetFirstChild();
   }
@@ -305,19 +304,17 @@ public:
   void DeleteRule(uint32_t aIndex,
                   nsIPrincipal& aSubjectPrincipal,
                   ErrorResult& aRv);
 
   // WebIDL miscellaneous bits
   inline dom::ParentObject GetParentObject() const;
   JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) final;
 
-  // Changes to sheets should be inside of a WillDirty-DidDirty pair.
-  // However, the calls do not need to be matched; it's ok to call
-  // WillDirty and then make no change and skip the DidDirty call.
+  // Changes to sheets should be after a WillDirty call.
   void WillDirty();
 
   // Called when a rule changes from CSSOM.
   //
   // FIXME(emilio): This shouldn't allow null, but MediaList doesn't know about
   // it's owning media rule, plus it's used for the stylesheet media itself.
   void RuleChanged(css::Rule*);