Bug 1459529: Remove some useless nsIDocumentObserver notifications. r?heycam draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Fri, 11 May 2018 18:36:36 +0200
changeset 794261 8ac5a9265ccb337266c0d886b2585a7ab4f358ed
parent 794260 344706edc85a7bb0db31b3d75735a6d4997e2cd1
child 794262 7cb41862f2f2f343f8e24b0644ca2026333ff2c8
child 794329 16426b39676d0a8a55210299c6c947ca2dee19ea
push id109630
push userbmo:emilio@crisal.io
push dateFri, 11 May 2018 16:44:07 +0000
reviewersheycam
bugs1459529
milestone62.0a1
Bug 1459529: Remove some useless nsIDocumentObserver notifications. r?heycam MozReview-Commit-ID: DzuiqVGKsiu
accessible/generic/DocAccessible.cpp
dom/base/nsDocument.cpp
dom/base/nsIDocumentObserver.h
dom/base/nsStubDocumentObserver.cpp
--- a/accessible/generic/DocAccessible.cpp
+++ b/accessible/generic/DocAccessible.cpp
@@ -694,17 +694,16 @@ DocAccessible::OnPivotChanged(nsIAccessi
   return NS_OK;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsIDocumentObserver
 
 NS_IMPL_NSIDOCUMENTOBSERVER_CORE_STUB(DocAccessible)
 NS_IMPL_NSIDOCUMENTOBSERVER_LOAD_STUB(DocAccessible)
-NS_IMPL_NSIDOCUMENTOBSERVER_STYLE_STUB(DocAccessible)
 
 void
 DocAccessible::AttributeWillChange(dom::Element* aElement,
                                    int32_t aNameSpaceID,
                                    nsAtom* aAttribute,
                                    int32_t aModType,
                                    const nsAttrValue* aNewValue)
 {
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -4305,31 +4305,27 @@ nsIDocument::AddStyleSheetToStyleSets(St
       new AsyncEventDispatcher(this, event);                                  \
     asyncDispatcher->mOnlyChromeDispatch = true;                              \
     asyncDispatcher->PostDOMEvent();                                          \
   } while (0);
 
 void
 nsIDocument::NotifyStyleSheetAdded(StyleSheet* aSheet, bool aDocumentSheet)
 {
-  NS_DOCUMENT_NOTIFY_OBSERVERS(StyleSheetAdded, (aSheet, aDocumentSheet));
-
   if (StyleSheetChangeEventsEnabled()) {
     DO_STYLESHEET_NOTIFICATION(StyleSheetChangeEvent,
                                "StyleSheetAdded",
                                mDocumentSheet,
                                aDocumentSheet);
   }
 }
 
 void
 nsIDocument::NotifyStyleSheetRemoved(StyleSheet* aSheet, bool aDocumentSheet)
 {
-  NS_DOCUMENT_NOTIFY_OBSERVERS(StyleSheetRemoved, (aSheet, aDocumentSheet));
-
   if (StyleSheetChangeEventsEnabled()) {
     DO_STYLESHEET_NOTIFICATION(StyleSheetChangeEvent,
                                "StyleSheetRemoved",
                                mDocumentSheet,
                                aDocumentSheet);
   }
 }
 
@@ -4436,22 +4432,16 @@ nsIDocument::SetStyleSheetApplicableStat
   if (mStyleSheets.IndexOf(aSheet) != mStyleSheets.NoIndex) {
     if (aApplicable) {
       AddStyleSheetToStyleSets(aSheet);
     } else {
       RemoveStyleSheetFromStyleSets(aSheet);
     }
   }
 
-  // We have to always notify, since this will be called for sheets
-  // that are children of sheets in our style set, as well as some
-  // sheets for HTMLEditor.
-
-  NS_DOCUMENT_NOTIFY_OBSERVERS(StyleSheetApplicableStateChanged, (aSheet));
-
   if (StyleSheetChangeEventsEnabled()) {
     DO_STYLESHEET_NOTIFICATION(StyleSheetApplicableStateChangeEvent,
                                "StyleSheetApplicableStateChanged",
                                mApplicable,
                                aApplicable);
   }
 
   if (!mSSApplicableStateNotificationPending) {
--- a/dom/base/nsIDocumentObserver.h
+++ b/dom/base/nsIDocumentObserver.h
@@ -78,53 +78,16 @@ public:
   /**
    * Notification that the state of the document has changed.
    *
    * @param aDocument The document being observed
    * @param aStateMask the state that changed
    */
   virtual void DocumentStatesChanged(nsIDocument* aDocument,
                                      mozilla::EventStates aStateMask) = 0;
-
-  /**
-   * A StyleSheet has just been added to the document.  This method is
-   * called automatically when a StyleSheet gets added to the
-   * document, even if the stylesheet is not applicable. The
-   * notification is passed on to all of the document observers.
-   *
-   * @param aStyleSheet the StyleSheet that has been added
-   * @param aDocumentSheet True if sheet is in document's style sheet list,
-   *                       false if sheet is not (i.e., UA or user sheet)
-   */
-  virtual void StyleSheetAdded(mozilla::StyleSheet* aStyleSheet,
-                               bool aDocumentSheet) = 0;
-
-  /**
-   * A StyleSheet has just been removed from the document.  This
-   * method is called automatically when a StyleSheet gets removed
-   * from the document, even if the stylesheet is not applicable. The
-   * notification is passed on to all of the document observers.
-   *
-   * @param aStyleSheet the StyleSheet that has been removed
-   * @param aDocumentSheet True if sheet is in document's style sheet list,
-   *                       false if sheet is not (i.e., UA or user sheet)
-   */
-  virtual void StyleSheetRemoved(mozilla::StyleSheet* aStyleSheet,
-                                 bool aDocumentSheet) = 0;
-
-  /**
-   * A StyleSheet has just changed its applicable state.
-   * This method is called automatically when the applicable state
-   * of a StyleSheet gets changed. The style sheet passes this
-   * notification to the document. The notification is passed on
-   * to all of the document observers.
-   *
-   * @param aStyleSheet the StyleSheet that has changed state
-   */
-  virtual void StyleSheetApplicableStateChanged(mozilla::StyleSheet* aStyleSheet) = 0;
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(nsIDocumentObserver, NS_IDOCUMENT_OBSERVER_IID)
 
 #define NS_DECL_NSIDOCUMENTOBSERVER_BEGINUPDATE                              \
     virtual void BeginUpdate(nsIDocument* aDocument,                         \
                              nsUpdateType aUpdateType) override;
 
@@ -141,38 +104,23 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsIDocumen
     virtual void ContentStateChanged(nsIDocument* aDocument,                 \
                                      nsIContent* aContent,                   \
                                      mozilla::EventStates aStateMask) override;
 
 #define NS_DECL_NSIDOCUMENTOBSERVER_DOCUMENTSTATESCHANGED                    \
     virtual void DocumentStatesChanged(nsIDocument* aDocument,               \
                                        mozilla::EventStates aStateMask) override;
 
-#define NS_DECL_NSIDOCUMENTOBSERVER_STYLESHEETADDED                          \
-    virtual void StyleSheetAdded(mozilla::StyleSheet* aStyleSheet,           \
-                                 bool aDocumentSheet) override;
-
-#define NS_DECL_NSIDOCUMENTOBSERVER_STYLESHEETREMOVED                        \
-    virtual void StyleSheetRemoved(mozilla::StyleSheet* aStyleSheet,         \
-                                   bool aDocumentSheet) override;
-
-#define NS_DECL_NSIDOCUMENTOBSERVER_STYLESHEETAPPLICABLESTATECHANGED         \
-    virtual void StyleSheetApplicableStateChanged(                           \
-        mozilla::StyleSheet* aStyleSheet) override;
-
 #define NS_DECL_NSIDOCUMENTOBSERVER                                          \
     NS_DECL_NSIDOCUMENTOBSERVER_BEGINUPDATE                                  \
     NS_DECL_NSIDOCUMENTOBSERVER_ENDUPDATE                                    \
     NS_DECL_NSIDOCUMENTOBSERVER_BEGINLOAD                                    \
     NS_DECL_NSIDOCUMENTOBSERVER_ENDLOAD                                      \
     NS_DECL_NSIDOCUMENTOBSERVER_CONTENTSTATECHANGED                          \
     NS_DECL_NSIDOCUMENTOBSERVER_DOCUMENTSTATESCHANGED                        \
-    NS_DECL_NSIDOCUMENTOBSERVER_STYLESHEETADDED                              \
-    NS_DECL_NSIDOCUMENTOBSERVER_STYLESHEETREMOVED                            \
-    NS_DECL_NSIDOCUMENTOBSERVER_STYLESHEETAPPLICABLESTATECHANGED             \
     NS_DECL_NSIMUTATIONOBSERVER
 
 
 #define NS_IMPL_NSIDOCUMENTOBSERVER_CORE_STUB(_class)                     \
 void                                                                      \
 _class::BeginUpdate(nsIDocument* aDocument, nsUpdateType aUpdateType)     \
 {                                                                         \
 }                                                                         \
@@ -204,25 +152,9 @@ void                                    
 _class::DocumentStatesChanged(nsIDocument* aDocument,                     \
                               mozilla::EventStates aStateMask)            \
 {                                                                         \
 }
 
 #define NS_IMPL_NSIDOCUMENTOBSERVER_CONTENT(_class)                       \
 NS_IMPL_NSIMUTATIONOBSERVER_CONTENT(_class)
 
-#define NS_IMPL_NSIDOCUMENTOBSERVER_STYLE_STUB(_class)                    \
-void                                                                      \
-_class::StyleSheetAdded(mozilla::StyleSheet* aStyleSheet,                 \
-                        bool aDocumentSheet)                              \
-{                                                                         \
-}                                                                         \
-void                                                                      \
-_class::StyleSheetRemoved(mozilla::StyleSheet* aStyleSheet,               \
-                          bool aDocumentSheet)                            \
-{                                                                         \
-}                                                                         \
-void                                                                      \
-_class::StyleSheetApplicableStateChanged(mozilla::StyleSheet* aStyleSheet)\
-{                                                                         \
-}                                                                         \
-
 #endif /* nsIDocumentObserver_h___ */
--- a/dom/base/nsStubDocumentObserver.cpp
+++ b/dom/base/nsStubDocumentObserver.cpp
@@ -12,9 +12,8 @@
  */
 
 #include "nsStubDocumentObserver.h"
 
 NS_IMPL_NSIDOCUMENTOBSERVER_CORE_STUB(nsStubDocumentObserver)
 NS_IMPL_NSIDOCUMENTOBSERVER_LOAD_STUB(nsStubDocumentObserver)
 NS_IMPL_NSIDOCUMENTOBSERVER_STATE_STUB(nsStubDocumentObserver)
 NS_IMPL_NSIDOCUMENTOBSERVER_CONTENT(nsStubDocumentObserver)
-NS_IMPL_NSIDOCUMENTOBSERVER_STYLE_STUB(nsStubDocumentObserver)