From 62c2420626ac15e5d5de5060c79cd6c62462dd07 Mon Sep 17 00:00:00 2001 From: "bzbarsky%mit.edu" Date: Thu, 2 Oct 2003 21:29:40 +0000 Subject: [PATCH] Make presshell batch processing of style changes (using BeginUpdate/EndUpdate notifications). Bug 200931, r=peterv, sr=jst git-svn-id: svn://10.0.0.236/trunk@147516 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/content/base/public/nsIDocument.h | 11 +- .../content/base/public/nsIDocumentObserver.h | 19 +++- mozilla/content/base/src/nsContentList.cpp | 4 +- mozilla/content/base/src/nsDocument.cpp | 106 +++++------------- mozilla/content/base/src/nsDocument.h | 16 ++- .../content/base/src/nsGenericDOMDataNode.cpp | 12 +- mozilla/content/base/src/nsGenericElement.cpp | 28 ++--- .../content/base/src/nsStyleLinkElement.cpp | 4 + .../events/src/nsEventStateManager.cpp | 12 +- .../html/content/src/nsGenericHTMLElement.cpp | 32 +++--- .../html/content/src/nsHTMLUnknownElement.cpp | 4 +- .../html/document/src/nsHTMLContentSink.cpp | 79 +------------ .../content/html/style/src/nsCSSLoader.cpp | 2 + .../content/html/style/src/nsCSSStyleRule.cpp | 6 +- .../html/style/src/nsCSSStyleSheet.cpp | 30 +++-- .../svg/content/src/nsSVGAttributes.cpp | 8 +- .../content/svg/content/src/nsSVGElement.cpp | 16 +-- .../xml/document/src/nsXMLContentSink.cpp | 4 + .../xml/document/src/nsXMLPrettyPrinter.cpp | 4 +- .../content/xul/content/src/nsXULElement.cpp | 4 +- .../templates/src/nsXULTemplateBuilder.cpp | 6 +- .../libeditor/base/nsStyleSheetTxns.cpp | 20 +++- .../editor/libeditor/html/nsHTMLEditor.cpp | 10 +- .../source/xslt/txMozillaXSLTProcessor.cpp | 6 +- mozilla/layout/base/nsPresShell.cpp | 54 +++++---- mozilla/layout/generic/nsFrameSetFrame.cpp | 4 +- mozilla/layout/html/base/src/nsPresShell.cpp | 54 +++++---- .../html/document/src/nsFrameSetFrame.cpp | 4 +- mozilla/layout/style/nsCSSLoader.cpp | 2 + mozilla/layout/style/nsCSSStyleRule.cpp | 6 +- mozilla/layout/style/nsCSSStyleSheet.cpp | 30 +++-- .../base/src/tree/src/nsTreeContentView.cpp | 4 +- mozilla/widget/src/cocoa/nsMenuBarX.cpp | 4 +- mozilla/widget/src/mac/nsMenuBar.cpp | 4 +- mozilla/widget/src/mac/nsMenuBarX.cpp | 4 +- 35 files changed, 289 insertions(+), 324 deletions(-) diff --git a/mozilla/content/base/public/nsIDocument.h b/mozilla/content/base/public/nsIDocument.h index b321ab2e7dd..4b24c797ce5 100644 --- a/mozilla/content/base/public/nsIDocument.h +++ b/mozilla/content/base/public/nsIDocument.h @@ -43,10 +43,10 @@ #include "nsAString.h" #include "nsChangeHint.h" #include "nsCOMArray.h" +#include "nsIDocumentObserver.h" class nsIAtom; class nsIContent; -class nsIDocumentObserver; class nsIPresContext; class nsIPresShell; @@ -381,10 +381,11 @@ public: */ virtual PRBool RemoveObserver(nsIDocumentObserver* aObserver) = 0; - // Observation hooks used by content nodes to propagate - // notifications to document observers. - NS_IMETHOD BeginUpdate() = 0; - NS_IMETHOD EndUpdate() = 0; + // Observation hooks used to propagate notifications to document observers. + // BeginUpdate must be called before any batch of modifications of the + // content model or of style data, EndUpdate must be called afterward. + NS_IMETHOD BeginUpdate(nsUpdateType aUpdateType) = 0; + NS_IMETHOD EndUpdate(nsUpdateType aUpdateType) = 0; NS_IMETHOD BeginLoad() = 0; NS_IMETHOD EndLoad() = 0; NS_IMETHOD ContentChanged(nsIContent* aContent, diff --git a/mozilla/content/base/public/nsIDocumentObserver.h b/mozilla/content/base/public/nsIDocumentObserver.h index 4028806afac..fc1cbf0f6b4 100644 --- a/mozilla/content/base/public/nsIDocumentObserver.h +++ b/mozilla/content/base/public/nsIDocumentObserver.h @@ -52,6 +52,13 @@ class nsIDocument; #define NS_IDOCUMENT_OBSERVER_IID \ { 0xb3f92460, 0x944c, 0x11d1, {0x93, 0x23, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}} +typedef PRUint32 nsUpdateType; + +#define UPDATE_CONTENT_MODEL 0x00000001 +#define UPDATE_STYLE 0x00000002 +#define UPDATE_CONTENT_STATE 0x00000004 +#define UPDATE_ALL (UPDATE_CONTENT_MODEL | UPDATE_STYLE | UPDATE_CONTENT_STATE) + // Document observer interface class nsIDocumentObserver : public nsISupports { public: @@ -61,13 +68,13 @@ public: * Notify that a content model update is beginning. This call can be * nested. */ - NS_IMETHOD BeginUpdate(nsIDocument *aDocument) = 0; + NS_IMETHOD BeginUpdate(nsIDocument *aDocument, nsUpdateType aUpdateType) = 0; /** * Notify that a content model update is finished. This call can be * nested. */ - NS_IMETHOD EndUpdate(nsIDocument *aDocument) = 0; + NS_IMETHOD EndUpdate(nsIDocument *aDocument, nsUpdateType aUpdateType) = 0; /** * Notify the observer that a document load is beginning. @@ -341,8 +348,8 @@ public: }; #define NS_DECL_NSIDOCUMENTOBSERVER \ - NS_IMETHOD BeginUpdate(nsIDocument* aDocument); \ - NS_IMETHOD EndUpdate(nsIDocument* aDocument); \ + NS_IMETHOD BeginUpdate(nsIDocument* aDocument, nsUpdateType aUpdateType);\ + NS_IMETHOD EndUpdate(nsIDocument* aDocument, nsUpdateType aUpdateType); \ NS_IMETHOD BeginLoad(nsIDocument* aDocument); \ NS_IMETHOD EndLoad(nsIDocument* aDocument); \ NS_IMETHOD BeginReflow(nsIDocument* aDocument, \ @@ -399,12 +406,12 @@ public: #define NS_IMPL_NSIDOCUMENTOBSERVER_CORE_STUB(_class) \ NS_IMETHODIMP \ -_class::BeginUpdate(nsIDocument* aDocument) \ +_class::BeginUpdate(nsIDocument* aDocument, nsUpdateType aUpdateType) \ { \ return NS_OK; \ } \ NS_IMETHODIMP \ -_class::EndUpdate(nsIDocument* aDocument) \ +_class::EndUpdate(nsIDocument* aDocument, nsUpdateType aUpdateType) \ { \ return NS_OK; \ } \ diff --git a/mozilla/content/base/src/nsContentList.cpp b/mozilla/content/base/src/nsContentList.cpp index 9c7f12fd992..a03e0f8dc51 100644 --- a/mozilla/content/base/src/nsContentList.cpp +++ b/mozilla/content/base/src/nsContentList.cpp @@ -519,13 +519,13 @@ NS_IMPL_NSIDOCUMENTOBSERVER_STATE_STUB(nsContentList) NS_IMPL_NSIDOCUMENTOBSERVER_STYLE_STUB(nsContentList) NS_IMETHODIMP -nsContentList::BeginUpdate(nsIDocument *aDocument) +nsContentList::BeginUpdate(nsIDocument *aDocument, nsUpdateType aUpdateType) { return NS_OK; } NS_IMETHODIMP -nsContentList::EndUpdate(nsIDocument *aDocument) +nsContentList::EndUpdate(nsIDocument *aDocument, nsUpdateType aUpdateType) { return NS_OK; } diff --git a/mozilla/content/base/src/nsDocument.cpp b/mozilla/content/base/src/nsDocument.cpp index 0015adaee4a..a8093ae8bbb 100644 --- a/mozilla/content/base/src/nsDocument.cpp +++ b/mozilla/content/base/src/nsDocument.cpp @@ -1580,6 +1580,16 @@ NS_IMETHODIMP nsDocument::UpdateStyleSheets(nsCOMArray& aOldSheets, nsCOMArray& aNewSheets) { + // if an observer removes itself, we're ok (not if it removes + // others though) + PRInt32 obsIndx; + for (obsIndx = mObservers.Count() - 1; obsIndx >= 0; --obsIndx) { + nsIDocumentObserver *observer = + NS_STATIC_CAST(nsIDocumentObserver *, mObservers.ElementAt(obsIndx)); + + observer->BeginUpdate(this, UPDATE_STYLE); + } + // XXX Need to set the sheet on the ownernode, if any NS_PRECONDITION(aOldSheets.Count() == aNewSheets.Count(), "The lists must be the same length!"); @@ -1593,19 +1603,7 @@ nsDocument::UpdateStyleSheets(nsCOMArray& aOldSheets, // First remove the old sheet. NS_ASSERTION(oldSheet, "None of the old sheets should be null"); PRInt32 oldIndex = mStyleSheets.IndexOf(oldSheet); - NS_ASSERTION(oldIndex != -1, "stylesheet not found"); - mStyleSheets.RemoveObjectAt(oldIndex); - - PRBool applicable = PR_TRUE; - oldSheet->GetApplicable(applicable); - if (applicable) { - RemoveStyleSheetFromStyleSets(oldSheet); - } - // XXX we should really notify here, but right now that would - // force things like a full reframe on every sheet. We really - // need a way to batch this sucker... - - oldSheet->SetOwningDocument(nsnull); + RemoveStyleSheet(oldSheet); // This does the right notifications // Now put the new one in its place. If it's null, just ignore it. nsIStyleSheet* newSheet = aNewSheets[i]; @@ -1618,21 +1616,20 @@ nsDocument::UpdateStyleSheets(nsCOMArray& aOldSheets, AddStyleSheetToStyleSets(newSheet); } - // XXX we should be notifying here too. + for (obsIndx = mObservers.Count() - 1; obsIndx >= 0; --obsIndx) { + nsIDocumentObserver *observer = + NS_STATIC_CAST(nsIDocumentObserver *, mObservers.ElementAt(obsIndx)); + + observer->StyleSheetAdded(this, newSheet); + } } } - // Now notify so _something_ happens, assuming we did anything - if (oldSheet) { - // if an observer removes itself, we're ok (not if it removes - // others though) - // XXXldb Hopefully the observer doesn't care which sheet you use. - for (PRInt32 indx = mObservers.Count() - 1; indx >= 0; --indx) { - nsIDocumentObserver *observer = - NS_STATIC_CAST(nsIDocumentObserver *, mObservers.ElementAt(indx)); + for (obsIndx = mObservers.Count() - 1; obsIndx >= 0; --obsIndx) { + nsIDocumentObserver *observer = + NS_STATIC_CAST(nsIDocumentObserver *, mObservers.ElementAt(obsIndx)); - observer->StyleSheetRemoved(this, oldSheet); - } + observer->EndUpdate(this, UPDATE_STYLE); } return NS_OK; @@ -1814,24 +1811,24 @@ nsDocument::RemoveObserver(nsIDocumentObserver* aObserver) } NS_IMETHODIMP -nsDocument::BeginUpdate() +nsDocument::BeginUpdate(nsUpdateType aUpdateType) { PRInt32 i; for (i = mObservers.Count() - 1; i >= 0; --i) { nsIDocumentObserver* observer = (nsIDocumentObserver*) mObservers[i]; - observer->BeginUpdate(this); + observer->BeginUpdate(this, aUpdateType); } return NS_OK; } NS_IMETHODIMP -nsDocument::EndUpdate() +nsDocument::EndUpdate(nsUpdateType aUpdateType) { PRInt32 i; for (i = mObservers.Count() - 1; i >= 0; --i) { nsIDocumentObserver* observer = (nsIDocumentObserver*) mObservers[i]; - observer->EndUpdate(this); + observer->EndUpdate(this, aUpdateType); } return NS_OK; @@ -2156,26 +2153,12 @@ nsDocument::StyleRuleChanged(nsIStyleSheet* aStyleSheet, { PRInt32 i; - // Get new value of count for every iteration in case observers - // remove themselves during the loop. - for (i = 0; i < mObservers.Count(); i++) { + // Loop backwards to handle observers removing themselves + for (i = mObservers.Count() - 1; i >= 0; --i) { nsIDocumentObserver *observer = NS_STATIC_CAST(nsIDocumentObserver *, mObservers.ElementAt(i)); - // XXXbz We should _not_ be calling BeginUpdate from in here! The - // caller of StyleRuleChanged should do that! - observer->BeginUpdate(this); observer->StyleRuleChanged(this, aStyleSheet, aOldStyleRule, aNewStyleRule); - - // Make sure that the observer didn't remove itself during the - // notification. If it did, update our index and count. - if (i < mObservers.Count() && - observer != (nsIDocumentObserver*)mObservers[i]) { - i--; - } - else { - observer->EndUpdate(this); - } } return NS_OK; @@ -2187,25 +2170,12 @@ nsDocument::StyleRuleAdded(nsIStyleSheet* aStyleSheet, { PRInt32 i; - // Get new value of count for every iteration in case - // observers remove themselves during the loop. - for (i = 0; i < mObservers.Count(); i++) { + // Loop backwards to handle observers removing themselves + for (i = mObservers.Count() - 1; i >= 0; --i) { nsIDocumentObserver *observer = NS_STATIC_CAST(nsIDocumentObserver *, mObservers.ElementAt(i)); - // XXXbz We should _not_ be calling BeginUpdate from in here! The - // caller of StyleRuleAdded should do that! - observer->BeginUpdate(this); observer->StyleRuleAdded(this, aStyleSheet, aStyleRule); - // Make sure that the observer didn't remove itself during the - // notification. If it did, update our index and count. - if (i < mObservers.Count() && - observer != (nsIDocumentObserver*)mObservers[i]) { - i--; - } - else { - observer->EndUpdate(this); - } } return NS_OK; @@ -2217,26 +2187,12 @@ nsDocument::StyleRuleRemoved(nsIStyleSheet* aStyleSheet, { PRInt32 i; - // Get new value of count for every iteration in case - // observers remove themselves during the loop. - for (i = 0; i < mObservers.Count(); i++) { + // Loop backwards to handle observers removing themselves + for (i = mObservers.Count() - 1; i >= 0; --i) { nsIDocumentObserver *observer = NS_STATIC_CAST(nsIDocumentObserver *, mObservers.ElementAt(i)); - // XXXbz We should _not_ be calling BeginUpdate from in here! The - // caller of StyleRuleRemoved should do that! - observer->BeginUpdate(this); observer->StyleRuleRemoved(this, aStyleSheet, aStyleRule); - - // Make sure that the observer didn't remove itself during the - // notification. If it did, update our index and count. - if (i < mObservers.Count() && - observer != (nsIDocumentObserver*)mObservers[i]) { - i--; - } - else { - observer->EndUpdate(this); - } } return NS_OK; diff --git a/mozilla/content/base/src/nsDocument.h b/mozilla/content/base/src/nsDocument.h index 505badb006f..f356beea352 100644 --- a/mozilla/content/base/src/nsDocument.h +++ b/mozilla/content/base/src/nsDocument.h @@ -149,8 +149,12 @@ public: NS_DECL_NSIDOMSTYLESHEETLIST - NS_IMETHOD BeginUpdate(nsIDocument *aDocument) { return NS_OK; } - NS_IMETHOD EndUpdate(nsIDocument *aDocument) { return NS_OK; } + NS_IMETHOD BeginUpdate(nsIDocument *aDocument, nsUpdateType aUpdateType) { + return NS_OK; + } + NS_IMETHOD EndUpdate(nsIDocument *aDocument, nsUpdateType aUpdateType) { + return NS_OK; + } NS_IMETHOD BeginLoad(nsIDocument *aDocument) { return NS_OK; } NS_IMETHOD EndLoad(nsIDocument *aDocument) { return NS_OK; } NS_IMETHOD BeginReflow(nsIDocument *aDocument, @@ -443,10 +447,10 @@ public: */ virtual PRBool RemoveObserver(nsIDocumentObserver* aObserver); - // Observation hooks used by content nodes to propagate - // notifications to document observers. - NS_IMETHOD BeginUpdate(); - NS_IMETHOD EndUpdate(); + // Observation hooks used to propagate notifications to document + // observers. + NS_IMETHOD BeginUpdate(nsUpdateType aUpdateType); + NS_IMETHOD EndUpdate(nsUpdateType aUpdateType); NS_IMETHOD BeginLoad(); NS_IMETHOD EndLoad(); NS_IMETHOD ContentChanged(nsIContent* aContent, diff --git a/mozilla/content/base/src/nsGenericDOMDataNode.cpp b/mozilla/content/base/src/nsGenericDOMDataNode.cpp index 610d650919b..634b4c70d3b 100644 --- a/mozilla/content/base/src/nsGenericDOMDataNode.cpp +++ b/mozilla/content/base/src/nsGenericDOMDataNode.cpp @@ -1176,7 +1176,7 @@ nsGenericDOMDataNode::SetText(const PRUnichar* aBuffer, } if (aNotify && mDocument) { - mDocument->BeginUpdate(); + mDocument->BeginUpdate(UPDATE_CONTENT_MODEL); } mText.SetTo(aBuffer, aLength); @@ -1202,7 +1202,7 @@ nsGenericDOMDataNode::SetText(const PRUnichar* aBuffer, // Trigger a reflow if (aNotify && mDocument) { mDocument->ContentChanged(this, nsnull); - mDocument->EndUpdate(); + mDocument->EndUpdate(UPDATE_CONTENT_MODEL); } return NS_OK; } @@ -1220,7 +1220,7 @@ nsGenericDOMDataNode::SetText(const char* aBuffer, PRInt32 aLength, } if (aNotify && mDocument) { - mDocument->BeginUpdate(); + mDocument->BeginUpdate(UPDATE_CONTENT_MODEL); } mText.SetTo(aBuffer, aLength); @@ -1244,7 +1244,7 @@ nsGenericDOMDataNode::SetText(const char* aBuffer, PRInt32 aLength, // Trigger a reflow if (aNotify && mDocument) { mDocument->ContentChanged(this, nsnull); - mDocument->EndUpdate(); + mDocument->EndUpdate(UPDATE_CONTENT_MODEL); } return NS_OK; @@ -1255,7 +1255,7 @@ nsGenericDOMDataNode::SetText(const nsAString& aStr, PRBool aNotify) { if (aNotify && mDocument) { - mDocument->BeginUpdate(); + mDocument->BeginUpdate(UPDATE_CONTENT_MODEL); } mText = aStr; @@ -1281,7 +1281,7 @@ nsGenericDOMDataNode::SetText(const nsAString& aStr, // Trigger a reflow if (aNotify && mDocument) { mDocument->ContentChanged(this, nsnull); - mDocument->EndUpdate(); + mDocument->EndUpdate(UPDATE_CONTENT_MODEL); } return NS_OK; diff --git a/mozilla/content/base/src/nsGenericElement.cpp b/mozilla/content/base/src/nsGenericElement.cpp index d9f514ad474..dc75fe157e1 100644 --- a/mozilla/content/base/src/nsGenericElement.cpp +++ b/mozilla/content/base/src/nsGenericElement.cpp @@ -2614,7 +2614,7 @@ nsGenericElement::doInsertBefore(nsIDOMNode* aNewChild, PRBool do_notify = !!aRefChild; if (count && !do_notify && mDocument) { - mDocument->BeginUpdate(); + mDocument->BeginUpdate(UPDATE_CONTENT_MODEL); } /* @@ -2653,7 +2653,7 @@ nsGenericElement::doInsertBefore(nsIDOMNode* aNewChild, if (count && !do_notify && mDocument) { mDocument->ContentAppended(this, old_count); - mDocument->EndUpdate(); + mDocument->EndUpdate(UPDATE_CONTENT_MODEL); } doc_fragment->DropChildReferences(); @@ -3403,7 +3403,7 @@ nsGenericContainerElement::SetAttr(nsINodeInfo* aNodeInfo, // Begin the update _before_ changing the attr value if (aNotify && mDocument) { - mDocument->BeginUpdate(); + mDocument->BeginUpdate(UPDATE_CONTENT_MODEL); mDocument->AttributeWillChange(this, nameSpaceID, name); } @@ -3466,7 +3466,7 @@ nsGenericContainerElement::SetAttr(nsINodeInfo* aNodeInfo, PRInt32 modHint = modification ? PRInt32(nsIDOMMutationEvent::MODIFICATION) : PRInt32(nsIDOMMutationEvent::ADDITION); mDocument->AttributeChanged(this, nameSpaceID, name, modHint); - mDocument->EndUpdate(); + mDocument->EndUpdate(UPDATE_CONTENT_MODEL); } } @@ -3574,7 +3574,7 @@ nsGenericContainerElement::UnsetAttr(PRInt32 aNameSpaceID, attr->mNodeInfo->NamespaceEquals(aNameSpaceID)) && attr->mNodeInfo->Equals(aName)) { if (aNotify && (nsnull != mDocument)) { - mDocument->BeginUpdate(); + mDocument->BeginUpdate(UPDATE_CONTENT_MODEL); mDocument->AttributeWillChange(this, aNameSpaceID, aName); } @@ -3620,7 +3620,7 @@ nsGenericContainerElement::UnsetAttr(PRInt32 aNameSpaceID, if (aNotify) { mDocument->AttributeChanged(this, aNameSpaceID, aName, nsIDOMMutationEvent::REMOVAL); - mDocument->EndUpdate(); + mDocument->EndUpdate(UPDATE_CONTENT_MODEL); } } } @@ -3820,7 +3820,7 @@ nsGenericContainerElement::InsertChildAt(nsIContent* aKid, NS_PRECONDITION(nsnull != aKid, "null ptr"); nsIDocument* doc = mDocument; if (aNotify && (nsnull != doc)) { - doc->BeginUpdate(); + doc->BeginUpdate(UPDATE_CONTENT_MODEL); } PRBool rv = mChildren.InsertElementAt(aKid, aIndex);/* XXX fix up void array api to use nsresult's*/ if (rv) { @@ -3850,7 +3850,7 @@ nsGenericContainerElement::InsertChildAt(nsIContent* aKid, } } if (aNotify && (nsnull != doc)) { - doc->EndUpdate(); + doc->EndUpdate(UPDATE_CONTENT_MODEL); } return NS_OK; } @@ -3864,7 +3864,7 @@ nsGenericContainerElement::ReplaceChildAt(nsIContent* aKid, NS_PRECONDITION(nsnull != aKid, "null ptr"); nsIDocument* doc = mDocument; if (aNotify && (nsnull != mDocument)) { - doc->BeginUpdate(); + doc->BeginUpdate(UPDATE_CONTENT_MODEL); } nsIContent* oldKid = (nsIContent *)mChildren.ElementAt(aIndex); nsRange::OwnerChildReplaced(this, aIndex, oldKid); @@ -3883,7 +3883,7 @@ nsGenericContainerElement::ReplaceChildAt(nsIContent* aKid, NS_RELEASE(oldKid); } if (aNotify && (nsnull != mDocument)) { - doc->EndUpdate(); + doc->EndUpdate(UPDATE_CONTENT_MODEL); } return NS_OK; } @@ -3895,7 +3895,7 @@ nsGenericContainerElement::AppendChildTo(nsIContent* aKid, PRBool aNotify, NS_PRECONDITION(nsnull != aKid, "null ptr"); nsIDocument* doc = mDocument; if (aNotify && (nsnull != doc)) { - doc->BeginUpdate(); + doc->BeginUpdate(UPDATE_CONTENT_MODEL); } PRBool rv = mChildren.AppendElement(aKid); if (rv) { @@ -3925,7 +3925,7 @@ nsGenericContainerElement::AppendChildTo(nsIContent* aKid, PRBool aNotify, } } if (aNotify && doc) { - doc->EndUpdate(); + doc->EndUpdate(UPDATE_CONTENT_MODEL); } return NS_OK; } @@ -3937,7 +3937,7 @@ nsGenericContainerElement::RemoveChildAt(PRUint32 aIndex, PRBool aNotify) if (oldKid) { nsIDocument* doc = mDocument; if (aNotify && doc) { - doc->BeginUpdate(); + doc->BeginUpdate(UPDATE_CONTENT_MODEL); } if (HasMutationListeners(this, NS_EVENT_BITS_MUTATION_NODEREMOVED)) { @@ -3968,7 +3968,7 @@ nsGenericContainerElement::RemoveChildAt(PRUint32 aIndex, PRBool aNotify) oldKid->SetParent(nsnull); NS_RELEASE(oldKid); if (aNotify && doc) { - doc->EndUpdate(); + doc->EndUpdate(UPDATE_CONTENT_MODEL); } } diff --git a/mozilla/content/base/src/nsStyleLinkElement.cpp b/mozilla/content/base/src/nsStyleLinkElement.cpp index 8680b89c95d..af1b6d2bd0b 100644 --- a/mozilla/content/base/src/nsStyleLinkElement.cpp +++ b/mozilla/content/base/src/nsStyleLinkElement.cpp @@ -174,7 +174,9 @@ nsStyleLinkElement::UpdateStyleSheet(nsIDocument *aOldDocument, // stylesheet. We want to do this even if updates are disabled, since // otherwise a sheet with a stale linking element pointer will be hanging // around -- not good! + aOldDocument->BeginUpdate(UPDATE_STYLE); aOldDocument->RemoveStyleSheet(mStyleSheet); + aOldDocument->EndUpdate(UPDATE_STYLE); mStyleSheet = nsnull; } @@ -218,7 +220,9 @@ nsStyleLinkElement::UpdateStyleSheet(nsIDocument *aOldDocument, } if (mStyleSheet) { + doc->BeginUpdate(UPDATE_STYLE); doc->RemoveStyleSheet(mStyleSheet); + doc->EndUpdate(UPDATE_STYLE); mStyleSheet = nsnull; } diff --git a/mozilla/content/events/src/nsEventStateManager.cpp b/mozilla/content/events/src/nsEventStateManager.cpp index d99b507e68c..65b8d467b85 100644 --- a/mozilla/content/events/src/nsEventStateManager.cpp +++ b/mozilla/content/events/src/nsEventStateManager.cpp @@ -4052,7 +4052,7 @@ nsEventStateManager::SetContentState(nsIContent *aContent, PRInt32 aState) doc1 = oldHover->GetDocument(); } if (doc1) { - doc1->BeginUpdate(); + doc1->BeginUpdate(UPDATE_CONTENT_STATE); // Notify all content from newHover to the commonHoverAncestor while (newHover && newHover != commonHoverAncestor) { @@ -4083,17 +4083,17 @@ nsEventStateManager::SetContentState(nsIContent *aContent, PRInt32 aState) } } } - doc1->EndUpdate(); + doc1->EndUpdate(UPDATE_CONTENT_STATE); if (doc2) { - doc2->BeginUpdate(); + doc2->BeginUpdate(UPDATE_CONTENT_STATE); doc2->ContentStatesChanged(notifyContent[1], notifyContent[2], aState & ~NS_EVENT_STATE_HOVER); if (notifyContent[3]) { doc1->ContentStatesChanged(notifyContent[3], notifyContent[4], aState & ~NS_EVENT_STATE_HOVER); } - doc2->EndUpdate(); + doc2->EndUpdate(UPDATE_CONTENT_STATE); } } @@ -4757,10 +4757,10 @@ void nsEventStateManager::FocusElementButNotDocument(nsIContent *aContent) // Temporarily set mCurrentFocus so that esm::GetContentState() tells // layout system to show focus on this element. mCurrentFocus = aContent; // Reset back to null at the end of this method. - mDocument->BeginUpdate(); + mDocument->BeginUpdate(UPDATE_CONTENT_STATE); mDocument->ContentStatesChanged(oldFocusedContent, aContent, NS_EVENT_STATE_FOCUS); - mDocument->EndUpdate(); + mDocument->EndUpdate(UPDATE_CONTENT_STATE); // Reset mCurrentFocus = nsnull for this doc, so when this document // does get focus next time via preHandleEvent() NS_GOTFOCUS, diff --git a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp index b335b65bafc..527956b255a 100644 --- a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp +++ b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp @@ -1696,7 +1696,7 @@ nsGenericHTMLElement::SetAttr(PRInt32 aNameSpaceID, modification = (result != NS_CONTENT_ATTR_NOT_THERE); if (aNotify && (nsnull != mDocument)) { - mDocument->BeginUpdate(); + mDocument->BeginUpdate(UPDATE_CONTENT_MODEL); mDocument->AttributeWillChange(this, aNameSpaceID, aAttribute); } @@ -1757,7 +1757,7 @@ nsGenericHTMLElement::SetAttr(PRInt32 aNameSpaceID, PRInt32(nsIDOMMutationEvent::ADDITION); mDocument->AttributeChanged(this, aNameSpaceID, aAttribute, modHint); - mDocument->EndUpdate(); + mDocument->EndUpdate(UPDATE_CONTENT_MODEL); } } @@ -1796,7 +1796,7 @@ nsGenericHTMLElement::SetAttr(nsINodeInfo* aNodeInfo, PRBool modification = (rv != NS_CONTENT_ATTR_NOT_THERE); if (aNotify && mDocument) { - mDocument->BeginUpdate(); + mDocument->BeginUpdate(UPDATE_CONTENT_MODEL); mDocument->AttributeWillChange(this, namespaceID, localName); } @@ -1851,7 +1851,7 @@ nsGenericHTMLElement::SetAttr(nsINodeInfo* aNodeInfo, modification ? PRInt32(nsIDOMMutationEvent::MODIFICATION) : PRInt32(nsIDOMMutationEvent::ADDITION); mDocument->AttributeChanged(this, namespaceID, localName, modHint); - mDocument->EndUpdate(); + mDocument->EndUpdate(UPDATE_CONTENT_MODEL); } } @@ -1946,7 +1946,7 @@ nsGenericHTMLElement::SetHTMLAttribute(nsIAtom* aAttribute, GetAttr(kNameSpaceID_None, aAttribute, oldValueStr)); } if (aNotify) { - mDocument->BeginUpdate(); + mDocument->BeginUpdate(UPDATE_CONTENT_MODEL); mDocument->AttributeWillChange(this, kNameSpaceID_None, aAttribute); } @@ -2004,7 +2004,7 @@ nsGenericHTMLElement::SetHTMLAttribute(nsIAtom* aAttribute, if (aNotify) { mDocument->AttributeChanged(this, kNameSpaceID_None, aAttribute, nsIDOMMutationEvent::MODIFICATION); - mDocument->EndUpdate(); + mDocument->EndUpdate(UPDATE_CONTENT_MODEL); } } if (!sheet) { // manage this ourselves and re-sync when we connect to doc @@ -2043,7 +2043,7 @@ nsGenericHTMLElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute, if (mDocument) { if (aNotify) { - mDocument->BeginUpdate(); + mDocument->BeginUpdate(UPDATE_CONTENT_MODEL); mDocument->AttributeWillChange(this, aNameSpaceID, aAttribute); } @@ -2098,7 +2098,7 @@ nsGenericHTMLElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute, if (aNotify) { mDocument->AttributeChanged(this, aNameSpaceID, aAttribute, nsIDOMMutationEvent::REMOVAL); - mDocument->EndUpdate(); + mDocument->EndUpdate(UPDATE_CONTENT_MODEL); } } @@ -3701,7 +3701,7 @@ nsGenericHTMLContainerElement::InsertChildAt(nsIContent* aKid, NS_PRECONDITION(nsnull != aKid, "null ptr"); nsIDocument* doc = mDocument; if (aNotify && (nsnull != doc)) { - doc->BeginUpdate(); + doc->BeginUpdate(UPDATE_CONTENT_MODEL); } PRBool rv = mChildren.InsertElementAt(aKid, aIndex);/* XXX fix up void array api to use nsresult's*/ if (rv) { @@ -3730,7 +3730,7 @@ nsGenericHTMLContainerElement::InsertChildAt(nsIContent* aKid, } } if (aNotify && (nsnull != doc)) { - doc->EndUpdate(); + doc->EndUpdate(UPDATE_CONTENT_MODEL); } return NS_OK; } @@ -3746,7 +3746,7 @@ nsGenericHTMLContainerElement::ReplaceChildAt(nsIContent* aKid, mChildren.SafeElementAt(aIndex)); nsIDocument* doc = mDocument; if (aNotify && (nsnull != doc)) { - doc->BeginUpdate(); + doc->BeginUpdate(UPDATE_CONTENT_MODEL); } nsRange::OwnerChildReplaced(this, aIndex, oldKid); PRBool rv = mChildren.ReplaceElementAt(aKid, aIndex); @@ -3778,7 +3778,7 @@ nsGenericHTMLContainerElement::ReplaceChildAt(nsIContent* aKid, } } if (aNotify && (nsnull != doc)) { - doc->EndUpdate(); + doc->EndUpdate(UPDATE_CONTENT_MODEL); } return NS_OK; } @@ -3790,7 +3790,7 @@ nsGenericHTMLContainerElement::AppendChildTo(nsIContent* aKid, PRBool aNotify, NS_PRECONDITION(nsnull != aKid && this != aKid, "null ptr"); nsIDocument* doc = mDocument; if (aNotify && (nsnull != doc)) { - doc->BeginUpdate(); + doc->BeginUpdate(UPDATE_CONTENT_MODEL); } PRBool rv = mChildren.AppendElement(aKid); if (rv) { @@ -3819,7 +3819,7 @@ nsGenericHTMLContainerElement::AppendChildTo(nsIContent* aKid, PRBool aNotify, } } if (aNotify && (nsnull != doc)) { - doc->EndUpdate(); + doc->EndUpdate(UPDATE_CONTENT_MODEL); } return NS_OK; } @@ -3829,7 +3829,7 @@ nsGenericHTMLContainerElement::RemoveChildAt(PRUint32 aIndex, PRBool aNotify) { nsIDocument* doc = mDocument; if (aNotify && (nsnull != doc)) { - doc->BeginUpdate(); + doc->BeginUpdate(UPDATE_CONTENT_MODEL); } nsIContent* oldKid = NS_STATIC_CAST(nsIContent *, mChildren.SafeElementAt(aIndex)); @@ -3863,7 +3863,7 @@ nsGenericHTMLContainerElement::RemoveChildAt(PRUint32 aIndex, PRBool aNotify) NS_RELEASE(oldKid); } if (aNotify && (nsnull != doc)) { - doc->EndUpdate(); + doc->EndUpdate(UPDATE_CONTENT_MODEL); } return NS_OK; diff --git a/mozilla/content/html/content/src/nsHTMLUnknownElement.cpp b/mozilla/content/html/content/src/nsHTMLUnknownElement.cpp index a6cd400f16c..e9e7de91ed4 100644 --- a/mozilla/content/html/content/src/nsHTMLUnknownElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLUnknownElement.cpp @@ -198,7 +198,7 @@ nsHTMLUnknownElement::SetAttribute(PRInt32 aNameSpaceID, } if (aNotify && (mDocument)) { - mDocument->BeginUpdate(); + mDocument->BeginUpdate(UPDATE_CONTENT_MODEL); mDocument->AttributeWillChange(this, aNameSpaceID, aAttribute); } @@ -218,7 +218,7 @@ nsHTMLUnknownElement::SetAttribute(PRInt32 aNameSpaceID, if (aNotify && (mDocument)) { result = mDocument->AttributeChanged(this, aNameSpaceID, aAttribute, nsIDOMMutationEvent::MODIFICATION); - mDocument->EndUpdate(); + mDocument->EndUpdate(UPDATE_CONTENT_MODEL); } return result; diff --git a/mozilla/content/html/document/src/nsHTMLContentSink.cpp b/mozilla/content/html/document/src/nsHTMLContentSink.cpp index cf71e60032b..8d195bee36a 100644 --- a/mozilla/content/html/document/src/nsHTMLContentSink.cpp +++ b/mozilla/content/html/document/src/nsHTMLContentSink.cpp @@ -5094,9 +5094,10 @@ NS_IMPL_NSIDOCUMENTOBSERVER_LOAD_STUB(HTMLContentSink) NS_IMPL_NSIDOCUMENTOBSERVER_REFLOW_STUB(HTMLContentSink) NS_IMPL_NSIDOCUMENTOBSERVER_STATE_STUB(HTMLContentSink) NS_IMPL_NSIDOCUMENTOBSERVER_CONTENT(HTMLContentSink) +NS_IMPL_NSIDOCUMENTOBSERVER_STYLE_STUB(HTMLContentSink) NS_IMETHODIMP -HTMLContentSink::BeginUpdate(nsIDocument *aDocument) +HTMLContentSink::BeginUpdate(nsIDocument *aDocument, nsUpdateType aUpdateType) { nsresult result = NS_OK; // If we're in a script and we didn't do the notification, @@ -5112,7 +5113,7 @@ HTMLContentSink::BeginUpdate(nsIDocument *aDocument) } NS_IMETHODIMP -HTMLContentSink::EndUpdate(nsIDocument *aDocument) +HTMLContentSink::EndUpdate(nsIDocument *aDocument, nsUpdateType aUpdateType) { // If we're in a script and we didn't do the notification, @@ -5126,80 +5127,6 @@ HTMLContentSink::EndUpdate(nsIDocument *aDocument) return NS_OK; } -NS_IMETHODIMP -HTMLContentSink::StyleSheetAdded(nsIDocument *aDocument, - nsIStyleSheet* aStyleSheet) -{ - // We only care when applicable sheets are added - NS_PRECONDITION(aStyleSheet, "Must have a style sheet!"); - PRBool applicable; - aStyleSheet->GetApplicable(applicable); - if (applicable) { - // Processing of a new style sheet causes recreation of the frame - // model. As a result, all contexts should update their notion of - // how much frame creation has happened. - UpdateAllContexts(); - } - - return NS_OK; -} - -NS_IMETHODIMP -HTMLContentSink::StyleSheetRemoved(nsIDocument *aDocument, - nsIStyleSheet* aStyleSheet) -{ - // We only care when applicable sheets are removed - NS_PRECONDITION(aStyleSheet, "Must have a style sheet!"); - PRBool applicable; - aStyleSheet->GetApplicable(applicable); - if (applicable) { - // Removing a style sheet causes recreation of the frame model. - // As a result, all contexts should update their notion of how - // much frame creation has happened. - UpdateAllContexts(); - } - - return NS_OK; -} - -NS_IMETHODIMP -HTMLContentSink::StyleSheetApplicableStateChanged(nsIDocument *aDocument, - nsIStyleSheet* aStyleSheet, - PRBool aApplicable) -{ - // Changing a style sheet's applicable state causes recreation of - // the frame model. As a result, all contexts should update their - // notion of how much frame creation has happened. - UpdateAllContexts(); - - return NS_OK; -} - -NS_IMETHODIMP -HTMLContentSink::StyleRuleChanged(nsIDocument *aDocument, - nsIStyleSheet* aStyleSheet, - nsIStyleRule* aOldStyleRule, - nsIStyleRule* aNewStyleRule) -{ - return NS_OK; -} - -NS_IMETHODIMP -HTMLContentSink::StyleRuleAdded(nsIDocument *aDocument, - nsIStyleSheet* aStyleSheet, - nsIStyleRule* aStyleRule) -{ - return NS_OK; -} - -NS_IMETHODIMP -HTMLContentSink::StyleRuleRemoved(nsIDocument *aDocument, - nsIStyleSheet* aStyleSheet, - nsIStyleRule* aStyleRule) -{ - return NS_OK; -} - NS_IMETHODIMP HTMLContentSink::DocumentWillBeDestroyed(nsIDocument *aDocument) { diff --git a/mozilla/content/html/style/src/nsCSSLoader.cpp b/mozilla/content/html/style/src/nsCSSLoader.cpp index 5bff7ab529a..0e054804167 100644 --- a/mozilla/content/html/style/src/nsCSSLoader.cpp +++ b/mozilla/content/html/style/src/nsCSSLoader.cpp @@ -1164,7 +1164,9 @@ CSSLoaderImpl::InsertSheetInDoc(nsICSSStyleSheet* aSheet, linkingElement->SetStyleSheet(aSheet); // This sets the ownerNode on the sheet } + aDocument->BeginUpdate(UPDATE_STYLE); aDocument->InsertStyleSheetAt(aSheet, insertionPoint); + aDocument->EndUpdate(UPDATE_STYLE); LOG((" Inserting into document at position %d", insertionPoint)); return NS_OK; diff --git a/mozilla/content/html/style/src/nsCSSStyleRule.cpp b/mozilla/content/html/style/src/nsCSSStyleRule.cpp index bfb0d500870..729079a6b8a 100644 --- a/mozilla/content/html/style/src/nsCSSStyleRule.cpp +++ b/mozilla/content/html/style/src/nsCSSStyleRule.cpp @@ -1033,9 +1033,7 @@ DOMCSSDeclarationImpl::DeclarationChanged() } if (owningDoc) { - // XXXldb Do we need to bother with this? We're now doing it in - // more places than we used to, but it probably doesn't matter... - owningDoc->BeginUpdate(); + owningDoc->BeginUpdate(UPDATE_STYLE); } nsCOMPtr oldRule = mRule; @@ -1051,7 +1049,7 @@ DOMCSSDeclarationImpl::DeclarationChanged() if (owningDoc) { owningDoc->StyleRuleChanged(sheet, oldRule, mRule); - owningDoc->EndUpdate(); + owningDoc->EndUpdate(UPDATE_STYLE); } return NS_OK; } diff --git a/mozilla/content/html/style/src/nsCSSStyleSheet.cpp b/mozilla/content/html/style/src/nsCSSStyleSheet.cpp index bb12cacb294..23ef8b8dadf 100644 --- a/mozilla/content/html/style/src/nsCSSStyleSheet.cpp +++ b/mozilla/content/html/style/src/nsCSSStyleSheet.cpp @@ -1338,7 +1338,7 @@ DOMMediaListImpl::BeginMediaChange(void) if (mStyleSheet) { rv = mStyleSheet->GetOwningDocument(*getter_AddRefs(doc)); NS_ENSURE_SUCCESS(rv, rv); - rv = doc->BeginUpdate(); + rv = doc->BeginUpdate(UPDATE_STYLE); NS_ENSURE_SUCCESS(rv, rv); rv = mStyleSheet->WillDirty(); NS_ENSURE_SUCCESS(rv, rv); @@ -1358,7 +1358,7 @@ DOMMediaListImpl::EndMediaChange(void) // XXXldb Pass something meaningful? rv = doc->StyleRuleChanged(mStyleSheet, nsnull, nsnull); NS_ENSURE_SUCCESS(rv, rv); - rv = doc->EndUpdate(); + rv = doc->EndUpdate(UPDATE_STYLE); NS_ENSURE_SUCCESS(rv, rv); } return NS_OK; @@ -1913,7 +1913,9 @@ CSSStyleSheetImpl::SetEnabled(PRBool aEnabled) mDisabled = !aEnabled; if (mDocument && mInner && mInner->mComplete && oldDisabled != mDisabled) { + mDocument->BeginUpdate(UPDATE_STYLE); mDocument->SetStyleSheetApplicableState(this, !mDisabled); + mDocument->EndUpdate(UPDATE_STYLE); } return NS_OK; @@ -1935,7 +1937,9 @@ CSSStyleSheetImpl::SetComplete() mInner->mComplete = PR_TRUE; if (mDocument && !mDisabled) { // Let the document know + mDocument->BeginUpdate(UPDATE_STYLE); mDocument->SetStyleSheetApplicableState(this, PR_TRUE); + mDocument->EndUpdate(UPDATE_STYLE); } return NS_OK; } @@ -2476,7 +2480,9 @@ CSSStyleSheetImpl::SetDisabled(PRBool aDisabled) mDisabled = aDisabled; if (mDocument && mInner && mInner->mComplete && oldDisabled != mDisabled) { + mDocument->BeginUpdate(UPDATE_STYLE); mDocument->SetStyleSheetApplicableState(this, !mDisabled); + mDocument->EndUpdate(UPDATE_STYLE); } return NS_OK; @@ -2668,7 +2674,7 @@ CSSStyleSheetImpl::InsertRule(const nsAString& aRule, return result; if (mDocument) { - result = mDocument->BeginUpdate(); + result = mDocument->BeginUpdate(UPDATE_STYLE); if (NS_FAILED(result)) return result; } @@ -2795,7 +2801,7 @@ CSSStyleSheetImpl::InsertRule(const nsAString& aRule, } if (mDocument) { - result = mDocument->EndUpdate(); + result = mDocument->EndUpdate(UPDATE_STYLE); NS_ENSURE_SUCCESS(result, result); } @@ -2821,7 +2827,7 @@ CSSStyleSheetImpl::DeleteRule(PRUint32 aIndex) // XXX TBI: handle @rule types if (mInner && mInner->mOrderedRules) { if (mDocument) { - result = mDocument->BeginUpdate(); + result = mDocument->BeginUpdate(UPDATE_STYLE); if (NS_FAILED(result)) return result; } @@ -2844,7 +2850,7 @@ CSSStyleSheetImpl::DeleteRule(PRUint32 aIndex) result = mDocument->StyleRuleRemoved(this, rule); NS_ENSURE_SUCCESS(result, result); - result = mDocument->EndUpdate(); + result = mDocument->EndUpdate(UPDATE_STYLE); NS_ENSURE_SUCCESS(result, result); } } @@ -2873,7 +2879,7 @@ CSSStyleSheetImpl::DeleteRuleFromGroup(nsICSSGroupRule* aGroup, PRUint32 aIndex) } if (mDocument) { - result = mDocument->BeginUpdate(); + result = mDocument->BeginUpdate(UPDATE_STYLE); NS_ENSURE_SUCCESS(result, result); } @@ -2891,7 +2897,7 @@ CSSStyleSheetImpl::DeleteRuleFromGroup(nsICSSGroupRule* aGroup, PRUint32 aIndex) result = mDocument->StyleRuleRemoved(this, rule); NS_ENSURE_SUCCESS(result, result); - result = mDocument->EndUpdate(); + result = mDocument->EndUpdate(UPDATE_STYLE); NS_ENSURE_SUCCESS(result, result); } @@ -2933,7 +2939,7 @@ CSSStyleSheetImpl::InsertRuleIntoGroup(const nsAString & aRule, nsICSSGroupRule* // parse and grab the rule if (mDocument) { - result = mDocument->BeginUpdate(); + result = mDocument->BeginUpdate(UPDATE_STYLE); NS_ENSURE_SUCCESS(result, result); } @@ -2975,7 +2981,7 @@ CSSStyleSheetImpl::InsertRuleIntoGroup(const nsAString & aRule, nsICSSGroupRule* } if (mDocument) { - result = mDocument->EndUpdate(); + result = mDocument->EndUpdate(UPDATE_STYLE); NS_ENSURE_SUCCESS(result, result); } @@ -3027,7 +3033,7 @@ CSSStyleSheetImpl::StyleSheetLoaded(nsICSSStyleSheet*aSheet, PRBool aNotify) nsCOMPtr ownerRule; aSheet->GetOwnerRule(getter_AddRefs(ownerRule)); - nsresult rv = mDocument->BeginUpdate(); + nsresult rv = mDocument->BeginUpdate(UPDATE_STYLE); NS_ENSURE_SUCCESS(rv, rv); // XXXldb @import rules shouldn't even implement nsIStyleRule (but @@ -3037,7 +3043,7 @@ CSSStyleSheetImpl::StyleSheetLoaded(nsICSSStyleSheet*aSheet, PRBool aNotify) rv = mDocument->StyleRuleAdded(this, styleRule); NS_ENSURE_SUCCESS(rv, rv); - rv = mDocument->EndUpdate(); + rv = mDocument->EndUpdate(UPDATE_STYLE); NS_ENSURE_SUCCESS(rv, rv); } diff --git a/mozilla/content/svg/content/src/nsSVGAttributes.cpp b/mozilla/content/svg/content/src/nsSVGAttributes.cpp index fb8607652ed..2f46fdcd9c2 100644 --- a/mozilla/content/svg/content/src/nsSVGAttributes.cpp +++ b/mozilla/content/svg/content/src/nsSVGAttributes.cpp @@ -608,7 +608,7 @@ nsSVGAttributes::SetAttr(nsINodeInfo* aNodeInfo, // Send the notification before making any updates if (aNotify && document) { - document->BeginUpdate(); + document->BeginUpdate(UPDATE_CONTENT_MODEL); document->AttributeWillChange(mContent, nameSpaceID, name); } @@ -671,7 +671,7 @@ nsSVGAttributes::SetAttr(nsINodeInfo* aNodeInfo, : PRInt32(nsIDOMMutationEvent::ADDITION); document->AttributeChanged(mContent, nameSpaceID, name, modHint); - document->EndUpdate(); + document->EndUpdate(UPDATE_CONTENT_MODEL); } } @@ -704,7 +704,7 @@ nsSVGAttributes::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, !attr->IsRequired() && !attr->IsFixed()) { if (aNotify && document) { - document->BeginUpdate(); + document->BeginUpdate(UPDATE_CONTENT_MODEL); } if (mContent && nsGenericElement::HasMutationListeners(mContent, NS_EVENT_BITS_MUTATION_ATTRMODIFIED)) { @@ -747,7 +747,7 @@ nsSVGAttributes::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, if (aNotify) { document->AttributeChanged(mContent, aNameSpaceID, aName, nsIDOMMutationEvent::REMOVAL); - document->EndUpdate(); + document->EndUpdate(UPDATE_CONTENT_MODEL); } } diff --git a/mozilla/content/svg/content/src/nsSVGElement.cpp b/mozilla/content/svg/content/src/nsSVGElement.cpp index e2d3935d067..e39a5412708 100644 --- a/mozilla/content/svg/content/src/nsSVGElement.cpp +++ b/mozilla/content/svg/content/src/nsSVGElement.cpp @@ -159,7 +159,7 @@ nsSVGElement::InsertChildAt(nsIContent* aKid, PRUint32 aIndex, NS_PRECONDITION(nsnull != aKid, "null ptr"); nsIDocument* doc = mDocument; if (aNotify && (nsnull != doc)) { - doc->BeginUpdate(); + doc->BeginUpdate(UPDATE_CONTENT_MODEL); } PRBool rv = mChildren.InsertElementAt(aKid, aIndex);/* XXX fix up void array api to use nsresult's*/ if (rv) { @@ -189,7 +189,7 @@ nsSVGElement::InsertChildAt(nsIContent* aKid, PRUint32 aIndex, } } if (aNotify && (nsnull != doc)) { - doc->EndUpdate(); + doc->EndUpdate(UPDATE_CONTENT_MODEL); } return NS_OK; } @@ -202,7 +202,7 @@ nsSVGElement::ReplaceChildAt(nsIContent* aKid, PRUint32 aIndex, NS_PRECONDITION(nsnull != aKid, "null ptr"); nsIDocument* doc = mDocument; if (aNotify && (nsnull != mDocument)) { - doc->BeginUpdate(); + doc->BeginUpdate(UPDATE_CONTENT_MODEL); } nsIContent* oldKid = (nsIContent *)mChildren.ElementAt(aIndex); nsRange::OwnerChildReplaced(this, aIndex, oldKid); @@ -221,7 +221,7 @@ nsSVGElement::ReplaceChildAt(nsIContent* aKid, PRUint32 aIndex, NS_RELEASE(oldKid); } if (aNotify && (nsnull != mDocument)) { - doc->EndUpdate(); + doc->EndUpdate(UPDATE_CONTENT_MODEL); } return NS_OK; } @@ -233,7 +233,7 @@ nsSVGElement::AppendChildTo(nsIContent* aKid, PRBool aNotify, NS_PRECONDITION(nsnull != aKid && this != aKid, "null ptr"); nsIDocument* doc = mDocument; if (aNotify && (nsnull != doc)) { - doc->BeginUpdate(); + doc->BeginUpdate(UPDATE_CONTENT_MODEL); } PRBool rv = mChildren.AppendElement(aKid); if (rv) { @@ -263,7 +263,7 @@ nsSVGElement::AppendChildTo(nsIContent* aKid, PRBool aNotify, } } if (aNotify && (nsnull != doc)) { - doc->EndUpdate(); + doc->EndUpdate(UPDATE_CONTENT_MODEL); } return NS_OK; } @@ -273,7 +273,7 @@ nsSVGElement::RemoveChildAt(PRUint32 aIndex, PRBool aNotify) { nsIDocument* doc = mDocument; if (aNotify && (nsnull != doc)) { - doc->BeginUpdate(); + doc->BeginUpdate(UPDATE_CONTENT_MODEL); } nsIContent* oldKid = (nsIContent *)mChildren.ElementAt(aIndex); if (nsnull != oldKid ) { @@ -307,7 +307,7 @@ nsSVGElement::RemoveChildAt(PRUint32 aIndex, PRBool aNotify) NS_RELEASE(oldKid); } if (aNotify && (nsnull != doc)) { - doc->EndUpdate(); + doc->EndUpdate(UPDATE_CONTENT_MODEL); } return NS_OK; diff --git a/mozilla/content/xml/document/src/nsXMLContentSink.cpp b/mozilla/content/xml/document/src/nsXMLContentSink.cpp index 388b9d6dea3..957f4d0954d 100644 --- a/mozilla/content/xml/document/src/nsXMLContentSink.cpp +++ b/mozilla/content/xml/document/src/nsXMLContentSink.cpp @@ -1649,7 +1649,9 @@ MathMLElementFactoryImpl::CreateInstanceByTag(nsINodeInfo* aNodeInfo, NS_ASSERTION(uriStr.Equals(kMathMLStyleSheetURI), "resolved URI unexpected"); #endif if (sheet) { + doc->BeginUpdate(UPDATE_STYLE); doc->AddStyleSheet(sheet, NS_STYLESHEET_FROM_CATALOG); + doc->EndUpdate(UPDATE_STYLE); } } } @@ -1882,7 +1884,9 @@ nsXMLContentSink::HandleDoctypeDecl(const nsAString & aSubset, printf("Loading catalog stylesheet: %s ... %s\n", uriStr.get(), sheet.get() ? "Done" : "Failed"); #endif if (sheet) { + mDocument->BeginUpdate(UPDATE_STYLE); mDocument->AddStyleSheet(sheet, NS_STYLESHEET_FROM_CATALOG); + mDocument->EndUpdate(UPDATE_STYLE); } } } diff --git a/mozilla/content/xml/document/src/nsXMLPrettyPrinter.cpp b/mozilla/content/xml/document/src/nsXMLPrettyPrinter.cpp index 1f7f1f1af21..6817ba7fdf3 100644 --- a/mozilla/content/xml/document/src/nsXMLPrettyPrinter.cpp +++ b/mozilla/content/xml/document/src/nsXMLPrettyPrinter.cpp @@ -217,14 +217,14 @@ NS_IMPL_NSIDOCUMENTOBSERVER_STATE_STUB(nsXMLPrettyPrinter) NS_IMPL_NSIDOCUMENTOBSERVER_STYLE_STUB(nsXMLPrettyPrinter) NS_IMETHODIMP -nsXMLPrettyPrinter::BeginUpdate(nsIDocument* aDocument) +nsXMLPrettyPrinter::BeginUpdate(nsIDocument* aDocument, nsUpdateType aUpdateType) { mUpdateDepth++; return NS_OK; } NS_IMETHODIMP -nsXMLPrettyPrinter::EndUpdate(nsIDocument* aDocument) +nsXMLPrettyPrinter::EndUpdate(nsIDocument* aDocument, nsUpdateType aUpdateType) { mUpdateDepth--; diff --git a/mozilla/content/xul/content/src/nsXULElement.cpp b/mozilla/content/xul/content/src/nsXULElement.cpp index cd021e7e2bd..d80ebb3697c 100644 --- a/mozilla/content/xul/content/src/nsXULElement.cpp +++ b/mozilla/content/xul/content/src/nsXULElement.cpp @@ -2335,7 +2335,7 @@ nsXULElement::SetAttr(nsINodeInfo* aNodeInfo, // Send the update notification _before_ changing anything if (mDocument && aNotify) { - mDocument->BeginUpdate(); + mDocument->BeginUpdate(UPDATE_CONTENT_MODEL); mDocument->AttributeWillChange(this, attrns, attrName); } @@ -2433,7 +2433,7 @@ nsXULElement::SetAttr(nsINodeInfo* aNodeInfo, : PRInt32(nsIDOMMutationEvent::ADDITION); mDocument->AttributeChanged(this, attrns, attrName, modHint); - mDocument->EndUpdate(); + mDocument->EndUpdate(UPDATE_CONTENT_MODEL); } } diff --git a/mozilla/content/xul/templates/src/nsXULTemplateBuilder.cpp b/mozilla/content/xul/templates/src/nsXULTemplateBuilder.cpp index b1b521c53ea..87677f18856 100644 --- a/mozilla/content/xul/templates/src/nsXULTemplateBuilder.cpp +++ b/mozilla/content/xul/templates/src/nsXULTemplateBuilder.cpp @@ -289,13 +289,15 @@ NS_IMPL_NSIDOCUMENTOBSERVER_STATE_STUB(nsXULTemplateBuilder) NS_IMPL_NSIDOCUMENTOBSERVER_STYLE_STUB(nsXULTemplateBuilder) NS_IMETHODIMP -nsXULTemplateBuilder::BeginUpdate(nsIDocument *aDocument) +nsXULTemplateBuilder::BeginUpdate(nsIDocument *aDocument, + nsUpdateType aUpdateType) { return NS_OK; } NS_IMETHODIMP -nsXULTemplateBuilder::EndUpdate(nsIDocument *aDocument) +nsXULTemplateBuilder::EndUpdate(nsIDocument *aDocument, + nsUpdateType aUpdateType) { return NS_OK; } diff --git a/mozilla/editor/libeditor/base/nsStyleSheetTxns.cpp b/mozilla/editor/libeditor/base/nsStyleSheetTxns.cpp index 467fd30cf69..0ad5a30d260 100644 --- a/mozilla/editor/libeditor/base/nsStyleSheetTxns.cpp +++ b/mozilla/editor/libeditor/base/nsStyleSheetTxns.cpp @@ -102,8 +102,11 @@ AddStyleSheetTxn::DoTransaction() nsCOMPtr document; rv = presShell->GetDocument(getter_AddRefs(document)); - if (NS_SUCCEEDED(rv) && document) + if (NS_SUCCEEDED(rv) && document) { + document->BeginUpdate(UPDATE_STYLE); document->AddStyleSheet(styleSheet, 0); + document->EndUpdate(UPDATE_STYLE); + } } return rv; @@ -135,8 +138,11 @@ AddStyleSheetTxn::UndoTransaction() rv = presShell->GetDocument(getter_AddRefs(document)); - if (NS_SUCCEEDED(rv) && document && observer && styleSheet) + if (NS_SUCCEEDED(rv) && document && observer && styleSheet) { + observer->BeginUpdate(document, UPDATE_STYLE); rv = observer->StyleSheetRemoved(document, styleSheet); + observer->EndUpdate(document, UPDATE_STYLE); + } } return rv; @@ -223,8 +229,11 @@ RemoveStyleSheetTxn::DoTransaction() rv = presShell->GetDocument(getter_AddRefs(document)); - if (NS_SUCCEEDED(rv) && document && observer && styleSheet) + if (NS_SUCCEEDED(rv) && document && observer && styleSheet) { + observer->BeginUpdate(document, UPDATE_STYLE); rv = observer->StyleSheetRemoved(document, styleSheet); + observer->EndUpdate(document, UPDATE_STYLE); + } } return rv; @@ -255,8 +264,11 @@ RemoveStyleSheetTxn::UndoTransaction() nsCOMPtr document; rv = presShell->GetDocument(getter_AddRefs(document)); - if (NS_SUCCEEDED(rv) && document) + if (NS_SUCCEEDED(rv) && document) { + document->BeginUpdate(UPDATE_STYLE); document->AddStyleSheet(styleSheet, 0); + document->EndUpdate(UPDATE_STYLE); + } } } diff --git a/mozilla/editor/libeditor/html/nsHTMLEditor.cpp b/mozilla/editor/libeditor/html/nsHTMLEditor.cpp index 5352a0a74ea..8927ff6fd78 100644 --- a/mozilla/editor/libeditor/html/nsHTMLEditor.cpp +++ b/mozilla/editor/libeditor/html/nsHTMLEditor.cpp @@ -3710,9 +3710,12 @@ nsHTMLEditor::AddOverrideStyleSheet(const nsAString& aURL) return NS_ERROR_NULL_POINTER; styleSheet->SetOwningDocument(document); - // This notifies document observers to rebuild all frames + // This notifies document observers to recompute style data // (this doesn't affect style sheet because it is not a doc sheet) + // XXXbz this is a major misuse of the API.... + document->BeginUpdate(UPDATE_STYLE); document->SetStyleSheetApplicableState(styleSheet, PR_TRUE); + document->EndUpdate(UPDATE_STYLE); // Save as the last-loaded sheet mLastOverrideStyleSheetURL = aURL; @@ -3769,9 +3772,12 @@ nsHTMLEditor::RemoveOverrideStyleSheet(const nsAString &aURL) styleSet->RemoveOverrideStyleSheet(styleSheet); - // This notifies document observers to rebuild all frames + // This notifies document observers to recompute style data // (this doesn't affect style sheet because it is not a doc sheet) + // XXXbz this is a major misuse of the API.... + document->BeginUpdate(UPDATE_STYLE); document->SetStyleSheetApplicableState(styleSheet, PR_FALSE); + document->EndUpdate(UPDATE_STYLE); // Remove it from our internal list return RemoveStyleSheetFromList(aURL); diff --git a/mozilla/extensions/transformiix/source/xslt/txMozillaXSLTProcessor.cpp b/mozilla/extensions/transformiix/source/xslt/txMozillaXSLTProcessor.cpp index bbc7817a228..e21a56fbd45 100644 --- a/mozilla/extensions/transformiix/source/xslt/txMozillaXSLTProcessor.cpp +++ b/mozilla/extensions/transformiix/source/xslt/txMozillaXSLTProcessor.cpp @@ -821,13 +821,15 @@ NS_IMPL_NSIDOCUMENTOBSERVER_STYLE_STUB(txMozillaXSLTProcessor) NS_IMPL_NSIDOCUMENTOBSERVER_STATE_STUB(txMozillaXSLTProcessor) NS_IMETHODIMP -txMozillaXSLTProcessor::BeginUpdate(nsIDocument* aDocument) +txMozillaXSLTProcessor::BeginUpdate(nsIDocument* aDocument, + nsUpdateType aUpdateType) { return NS_OK; } NS_IMETHODIMP -txMozillaXSLTProcessor::EndUpdate(nsIDocument* aDocument) +txMozillaXSLTProcessor::EndUpdate(nsIDocument* aDocument, + nsUpdateType aUpdateType) { return NS_OK; } diff --git a/mozilla/layout/base/nsPresShell.cpp b/mozilla/layout/base/nsPresShell.cpp index ecf77d5266f..7d82884353b 100644 --- a/mozilla/layout/base/nsPresShell.cpp +++ b/mozilla/layout/base/nsPresShell.cpp @@ -1291,7 +1291,9 @@ protected: nsresult GetSelectionForCopy(nsISelection** outSelection); nsICSSStyleSheet* mPrefStyleSheet; // mStyleSet owns it but we maintain a ref, may be null +#ifdef DEBUG PRUint32 mUpdateCount; +#endif // normal reflow commands nsVoidArray mReflowCommands; @@ -1302,6 +1304,7 @@ protected: PRPackedBool mDidInitialReflow; PRPackedBool mIgnoreFrameDestruction; + PRPackedBool mStylesHaveChanged; nsIFrame* mCurrentEventFrame; nsIContent* mCurrentEventContent; @@ -3632,19 +3635,27 @@ PresShell::GetPageSequenceFrame(nsIPageSequenceFrame** aResult) const } NS_IMETHODIMP -PresShell::BeginUpdate(nsIDocument *aDocument) +PresShell::BeginUpdate(nsIDocument *aDocument, nsUpdateType aUpdateType) { +#ifdef DEBUG mUpdateCount++; +#endif return NS_OK; } NS_IMETHODIMP -PresShell::EndUpdate(nsIDocument *aDocument) +PresShell::EndUpdate(nsIDocument *aDocument, nsUpdateType aUpdateType) { +#ifdef DEBUG NS_PRECONDITION(0 != mUpdateCount, "too many EndUpdate's"); - if (--mUpdateCount == 0) { - // XXX do something here + --mUpdateCount; +#endif + + if (mStylesHaveChanged && (aUpdateType & UPDATE_STYLE)) { + mStylesHaveChanged = PR_FALSE; + return ReconstructStyleData(); } + return NS_OK; } @@ -5469,11 +5480,11 @@ PresShell::StyleSheetAdded(nsIDocument *aDocument, PRBool applicable; aStyleSheet->GetApplicable(applicable); - if (!applicable || !aStyleSheet->HasRules()) { - return NS_OK; + if (applicable && aStyleSheet->HasRules()) { + mStylesHaveChanged = PR_TRUE; } - return ReconstructStyleData(); + return NS_OK; } NS_IMETHODIMP @@ -5484,11 +5495,11 @@ PresShell::StyleSheetRemoved(nsIDocument *aDocument, NS_PRECONDITION(aStyleSheet, "Must have a style sheet!"); PRBool applicable; aStyleSheet->GetApplicable(applicable); - if (!applicable || !aStyleSheet->HasRules()) { - return NS_OK; + if (applicable && aStyleSheet->HasRules()) { + mStylesHaveChanged = PR_TRUE; } - return ReconstructStyleData(); + return NS_OK; } NS_IMETHODIMP @@ -5503,11 +5514,11 @@ PresShell::StyleSheetApplicableStateChanged(nsIDocument *aDocument, return rv; } - if (!aStyleSheet->HasRules()) { - return NS_OK; + if (aStyleSheet->HasRules()) { + mStylesHaveChanged = PR_TRUE; } - return ReconstructStyleData(); + return NS_OK; } NS_IMETHODIMP @@ -5516,23 +5527,26 @@ PresShell::StyleRuleChanged(nsIDocument *aDocument, nsIStyleRule* aOldStyleRule, nsIStyleRule* aNewStyleRule) { - return ReconstructStyleData(); + mStylesHaveChanged = PR_TRUE; + return NS_OK; } NS_IMETHODIMP PresShell::StyleRuleAdded(nsIDocument *aDocument, nsIStyleSheet* aStyleSheet, nsIStyleRule* aStyleRule) -{ - return ReconstructStyleData(); +{ + mStylesHaveChanged = PR_TRUE; + return NS_OK; } NS_IMETHODIMP PresShell::StyleRuleRemoved(nsIDocument *aDocument, nsIStyleSheet* aStyleSheet, nsIStyleRule* aStyleRule) -{ - return ReconstructStyleData(); +{ + mStylesHaveChanged = PR_TRUE; + return NS_OK; } NS_IMETHODIMP @@ -6451,8 +6465,8 @@ PresShell::ProcessReflowCommands(PRBool aInterruptible) deadline = PR_IntervalNow() + PR_MicrosecondsToInterval(gMaxRCProcessingTime); // force flushing of any pending notifications - mDocument->BeginUpdate(); - mDocument->EndUpdate(); + mDocument->BeginUpdate(UPDATE_ALL); + mDocument->EndUpdate(UPDATE_ALL); mIsReflowing = PR_TRUE; diff --git a/mozilla/layout/generic/nsFrameSetFrame.cpp b/mozilla/layout/generic/nsFrameSetFrame.cpp index f351c859d42..975707378fd 100644 --- a/mozilla/layout/generic/nsFrameSetFrame.cpp +++ b/mozilla/layout/generic/nsFrameSetFrame.cpp @@ -286,7 +286,7 @@ nsHTMLFramesetFrame::Observe(nsISupports* aObject, const char* aAction, if (prefName.Equals(NS_LITERAL_STRING(kFrameResizePref))) { nsCOMPtr doc = mContent->GetDocument(); if (doc) { - doc->BeginUpdate(); + doc->BeginUpdate(UPDATE_CONTENT_MODEL); doc->AttributeWillChange(mContent, kNameSpaceID_None, nsHTMLAtoms::frameborder); @@ -301,7 +301,7 @@ nsHTMLFramesetFrame::Observe(nsISupports* aObject, const char* aAction, kNameSpaceID_None, nsHTMLAtoms::frameborder, nsIDOMMutationEvent::MODIFICATION); - doc->EndUpdate(); + doc->EndUpdate(UPDATE_CONTENT_MODEL); } } return NS_OK; diff --git a/mozilla/layout/html/base/src/nsPresShell.cpp b/mozilla/layout/html/base/src/nsPresShell.cpp index ecf77d5266f..7d82884353b 100644 --- a/mozilla/layout/html/base/src/nsPresShell.cpp +++ b/mozilla/layout/html/base/src/nsPresShell.cpp @@ -1291,7 +1291,9 @@ protected: nsresult GetSelectionForCopy(nsISelection** outSelection); nsICSSStyleSheet* mPrefStyleSheet; // mStyleSet owns it but we maintain a ref, may be null +#ifdef DEBUG PRUint32 mUpdateCount; +#endif // normal reflow commands nsVoidArray mReflowCommands; @@ -1302,6 +1304,7 @@ protected: PRPackedBool mDidInitialReflow; PRPackedBool mIgnoreFrameDestruction; + PRPackedBool mStylesHaveChanged; nsIFrame* mCurrentEventFrame; nsIContent* mCurrentEventContent; @@ -3632,19 +3635,27 @@ PresShell::GetPageSequenceFrame(nsIPageSequenceFrame** aResult) const } NS_IMETHODIMP -PresShell::BeginUpdate(nsIDocument *aDocument) +PresShell::BeginUpdate(nsIDocument *aDocument, nsUpdateType aUpdateType) { +#ifdef DEBUG mUpdateCount++; +#endif return NS_OK; } NS_IMETHODIMP -PresShell::EndUpdate(nsIDocument *aDocument) +PresShell::EndUpdate(nsIDocument *aDocument, nsUpdateType aUpdateType) { +#ifdef DEBUG NS_PRECONDITION(0 != mUpdateCount, "too many EndUpdate's"); - if (--mUpdateCount == 0) { - // XXX do something here + --mUpdateCount; +#endif + + if (mStylesHaveChanged && (aUpdateType & UPDATE_STYLE)) { + mStylesHaveChanged = PR_FALSE; + return ReconstructStyleData(); } + return NS_OK; } @@ -5469,11 +5480,11 @@ PresShell::StyleSheetAdded(nsIDocument *aDocument, PRBool applicable; aStyleSheet->GetApplicable(applicable); - if (!applicable || !aStyleSheet->HasRules()) { - return NS_OK; + if (applicable && aStyleSheet->HasRules()) { + mStylesHaveChanged = PR_TRUE; } - return ReconstructStyleData(); + return NS_OK; } NS_IMETHODIMP @@ -5484,11 +5495,11 @@ PresShell::StyleSheetRemoved(nsIDocument *aDocument, NS_PRECONDITION(aStyleSheet, "Must have a style sheet!"); PRBool applicable; aStyleSheet->GetApplicable(applicable); - if (!applicable || !aStyleSheet->HasRules()) { - return NS_OK; + if (applicable && aStyleSheet->HasRules()) { + mStylesHaveChanged = PR_TRUE; } - return ReconstructStyleData(); + return NS_OK; } NS_IMETHODIMP @@ -5503,11 +5514,11 @@ PresShell::StyleSheetApplicableStateChanged(nsIDocument *aDocument, return rv; } - if (!aStyleSheet->HasRules()) { - return NS_OK; + if (aStyleSheet->HasRules()) { + mStylesHaveChanged = PR_TRUE; } - return ReconstructStyleData(); + return NS_OK; } NS_IMETHODIMP @@ -5516,23 +5527,26 @@ PresShell::StyleRuleChanged(nsIDocument *aDocument, nsIStyleRule* aOldStyleRule, nsIStyleRule* aNewStyleRule) { - return ReconstructStyleData(); + mStylesHaveChanged = PR_TRUE; + return NS_OK; } NS_IMETHODIMP PresShell::StyleRuleAdded(nsIDocument *aDocument, nsIStyleSheet* aStyleSheet, nsIStyleRule* aStyleRule) -{ - return ReconstructStyleData(); +{ + mStylesHaveChanged = PR_TRUE; + return NS_OK; } NS_IMETHODIMP PresShell::StyleRuleRemoved(nsIDocument *aDocument, nsIStyleSheet* aStyleSheet, nsIStyleRule* aStyleRule) -{ - return ReconstructStyleData(); +{ + mStylesHaveChanged = PR_TRUE; + return NS_OK; } NS_IMETHODIMP @@ -6451,8 +6465,8 @@ PresShell::ProcessReflowCommands(PRBool aInterruptible) deadline = PR_IntervalNow() + PR_MicrosecondsToInterval(gMaxRCProcessingTime); // force flushing of any pending notifications - mDocument->BeginUpdate(); - mDocument->EndUpdate(); + mDocument->BeginUpdate(UPDATE_ALL); + mDocument->EndUpdate(UPDATE_ALL); mIsReflowing = PR_TRUE; diff --git a/mozilla/layout/html/document/src/nsFrameSetFrame.cpp b/mozilla/layout/html/document/src/nsFrameSetFrame.cpp index f351c859d42..975707378fd 100644 --- a/mozilla/layout/html/document/src/nsFrameSetFrame.cpp +++ b/mozilla/layout/html/document/src/nsFrameSetFrame.cpp @@ -286,7 +286,7 @@ nsHTMLFramesetFrame::Observe(nsISupports* aObject, const char* aAction, if (prefName.Equals(NS_LITERAL_STRING(kFrameResizePref))) { nsCOMPtr doc = mContent->GetDocument(); if (doc) { - doc->BeginUpdate(); + doc->BeginUpdate(UPDATE_CONTENT_MODEL); doc->AttributeWillChange(mContent, kNameSpaceID_None, nsHTMLAtoms::frameborder); @@ -301,7 +301,7 @@ nsHTMLFramesetFrame::Observe(nsISupports* aObject, const char* aAction, kNameSpaceID_None, nsHTMLAtoms::frameborder, nsIDOMMutationEvent::MODIFICATION); - doc->EndUpdate(); + doc->EndUpdate(UPDATE_CONTENT_MODEL); } } return NS_OK; diff --git a/mozilla/layout/style/nsCSSLoader.cpp b/mozilla/layout/style/nsCSSLoader.cpp index 5bff7ab529a..0e054804167 100644 --- a/mozilla/layout/style/nsCSSLoader.cpp +++ b/mozilla/layout/style/nsCSSLoader.cpp @@ -1164,7 +1164,9 @@ CSSLoaderImpl::InsertSheetInDoc(nsICSSStyleSheet* aSheet, linkingElement->SetStyleSheet(aSheet); // This sets the ownerNode on the sheet } + aDocument->BeginUpdate(UPDATE_STYLE); aDocument->InsertStyleSheetAt(aSheet, insertionPoint); + aDocument->EndUpdate(UPDATE_STYLE); LOG((" Inserting into document at position %d", insertionPoint)); return NS_OK; diff --git a/mozilla/layout/style/nsCSSStyleRule.cpp b/mozilla/layout/style/nsCSSStyleRule.cpp index bfb0d500870..729079a6b8a 100644 --- a/mozilla/layout/style/nsCSSStyleRule.cpp +++ b/mozilla/layout/style/nsCSSStyleRule.cpp @@ -1033,9 +1033,7 @@ DOMCSSDeclarationImpl::DeclarationChanged() } if (owningDoc) { - // XXXldb Do we need to bother with this? We're now doing it in - // more places than we used to, but it probably doesn't matter... - owningDoc->BeginUpdate(); + owningDoc->BeginUpdate(UPDATE_STYLE); } nsCOMPtr oldRule = mRule; @@ -1051,7 +1049,7 @@ DOMCSSDeclarationImpl::DeclarationChanged() if (owningDoc) { owningDoc->StyleRuleChanged(sheet, oldRule, mRule); - owningDoc->EndUpdate(); + owningDoc->EndUpdate(UPDATE_STYLE); } return NS_OK; } diff --git a/mozilla/layout/style/nsCSSStyleSheet.cpp b/mozilla/layout/style/nsCSSStyleSheet.cpp index bb12cacb294..23ef8b8dadf 100644 --- a/mozilla/layout/style/nsCSSStyleSheet.cpp +++ b/mozilla/layout/style/nsCSSStyleSheet.cpp @@ -1338,7 +1338,7 @@ DOMMediaListImpl::BeginMediaChange(void) if (mStyleSheet) { rv = mStyleSheet->GetOwningDocument(*getter_AddRefs(doc)); NS_ENSURE_SUCCESS(rv, rv); - rv = doc->BeginUpdate(); + rv = doc->BeginUpdate(UPDATE_STYLE); NS_ENSURE_SUCCESS(rv, rv); rv = mStyleSheet->WillDirty(); NS_ENSURE_SUCCESS(rv, rv); @@ -1358,7 +1358,7 @@ DOMMediaListImpl::EndMediaChange(void) // XXXldb Pass something meaningful? rv = doc->StyleRuleChanged(mStyleSheet, nsnull, nsnull); NS_ENSURE_SUCCESS(rv, rv); - rv = doc->EndUpdate(); + rv = doc->EndUpdate(UPDATE_STYLE); NS_ENSURE_SUCCESS(rv, rv); } return NS_OK; @@ -1913,7 +1913,9 @@ CSSStyleSheetImpl::SetEnabled(PRBool aEnabled) mDisabled = !aEnabled; if (mDocument && mInner && mInner->mComplete && oldDisabled != mDisabled) { + mDocument->BeginUpdate(UPDATE_STYLE); mDocument->SetStyleSheetApplicableState(this, !mDisabled); + mDocument->EndUpdate(UPDATE_STYLE); } return NS_OK; @@ -1935,7 +1937,9 @@ CSSStyleSheetImpl::SetComplete() mInner->mComplete = PR_TRUE; if (mDocument && !mDisabled) { // Let the document know + mDocument->BeginUpdate(UPDATE_STYLE); mDocument->SetStyleSheetApplicableState(this, PR_TRUE); + mDocument->EndUpdate(UPDATE_STYLE); } return NS_OK; } @@ -2476,7 +2480,9 @@ CSSStyleSheetImpl::SetDisabled(PRBool aDisabled) mDisabled = aDisabled; if (mDocument && mInner && mInner->mComplete && oldDisabled != mDisabled) { + mDocument->BeginUpdate(UPDATE_STYLE); mDocument->SetStyleSheetApplicableState(this, !mDisabled); + mDocument->EndUpdate(UPDATE_STYLE); } return NS_OK; @@ -2668,7 +2674,7 @@ CSSStyleSheetImpl::InsertRule(const nsAString& aRule, return result; if (mDocument) { - result = mDocument->BeginUpdate(); + result = mDocument->BeginUpdate(UPDATE_STYLE); if (NS_FAILED(result)) return result; } @@ -2795,7 +2801,7 @@ CSSStyleSheetImpl::InsertRule(const nsAString& aRule, } if (mDocument) { - result = mDocument->EndUpdate(); + result = mDocument->EndUpdate(UPDATE_STYLE); NS_ENSURE_SUCCESS(result, result); } @@ -2821,7 +2827,7 @@ CSSStyleSheetImpl::DeleteRule(PRUint32 aIndex) // XXX TBI: handle @rule types if (mInner && mInner->mOrderedRules) { if (mDocument) { - result = mDocument->BeginUpdate(); + result = mDocument->BeginUpdate(UPDATE_STYLE); if (NS_FAILED(result)) return result; } @@ -2844,7 +2850,7 @@ CSSStyleSheetImpl::DeleteRule(PRUint32 aIndex) result = mDocument->StyleRuleRemoved(this, rule); NS_ENSURE_SUCCESS(result, result); - result = mDocument->EndUpdate(); + result = mDocument->EndUpdate(UPDATE_STYLE); NS_ENSURE_SUCCESS(result, result); } } @@ -2873,7 +2879,7 @@ CSSStyleSheetImpl::DeleteRuleFromGroup(nsICSSGroupRule* aGroup, PRUint32 aIndex) } if (mDocument) { - result = mDocument->BeginUpdate(); + result = mDocument->BeginUpdate(UPDATE_STYLE); NS_ENSURE_SUCCESS(result, result); } @@ -2891,7 +2897,7 @@ CSSStyleSheetImpl::DeleteRuleFromGroup(nsICSSGroupRule* aGroup, PRUint32 aIndex) result = mDocument->StyleRuleRemoved(this, rule); NS_ENSURE_SUCCESS(result, result); - result = mDocument->EndUpdate(); + result = mDocument->EndUpdate(UPDATE_STYLE); NS_ENSURE_SUCCESS(result, result); } @@ -2933,7 +2939,7 @@ CSSStyleSheetImpl::InsertRuleIntoGroup(const nsAString & aRule, nsICSSGroupRule* // parse and grab the rule if (mDocument) { - result = mDocument->BeginUpdate(); + result = mDocument->BeginUpdate(UPDATE_STYLE); NS_ENSURE_SUCCESS(result, result); } @@ -2975,7 +2981,7 @@ CSSStyleSheetImpl::InsertRuleIntoGroup(const nsAString & aRule, nsICSSGroupRule* } if (mDocument) { - result = mDocument->EndUpdate(); + result = mDocument->EndUpdate(UPDATE_STYLE); NS_ENSURE_SUCCESS(result, result); } @@ -3027,7 +3033,7 @@ CSSStyleSheetImpl::StyleSheetLoaded(nsICSSStyleSheet*aSheet, PRBool aNotify) nsCOMPtr ownerRule; aSheet->GetOwnerRule(getter_AddRefs(ownerRule)); - nsresult rv = mDocument->BeginUpdate(); + nsresult rv = mDocument->BeginUpdate(UPDATE_STYLE); NS_ENSURE_SUCCESS(rv, rv); // XXXldb @import rules shouldn't even implement nsIStyleRule (but @@ -3037,7 +3043,7 @@ CSSStyleSheetImpl::StyleSheetLoaded(nsICSSStyleSheet*aSheet, PRBool aNotify) rv = mDocument->StyleRuleAdded(this, styleRule); NS_ENSURE_SUCCESS(rv, rv); - rv = mDocument->EndUpdate(); + rv = mDocument->EndUpdate(UPDATE_STYLE); NS_ENSURE_SUCCESS(rv, rv); } diff --git a/mozilla/layout/xul/base/src/tree/src/nsTreeContentView.cpp b/mozilla/layout/xul/base/src/tree/src/nsTreeContentView.cpp index 887848aad95..f4418c8f598 100644 --- a/mozilla/layout/xul/base/src/tree/src/nsTreeContentView.cpp +++ b/mozilla/layout/xul/base/src/tree/src/nsTreeContentView.cpp @@ -687,13 +687,13 @@ NS_IMPL_NSIDOCUMENTOBSERVER_REFLOW_STUB(nsTreeContentView) NS_IMPL_NSIDOCUMENTOBSERVER_STYLE_STUB(nsTreeContentView) NS_IMETHODIMP -nsTreeContentView::BeginUpdate(nsIDocument *aDocument) +nsTreeContentView::BeginUpdate(nsIDocument *aDocument, nsUpdateType aUpdateType) { return NS_OK; } NS_IMETHODIMP -nsTreeContentView::EndUpdate(nsIDocument *aDocument) +nsTreeContentView::EndUpdate(nsIDocument *aDocument, nsUpdateType aUpdateType) { return NS_OK; } diff --git a/mozilla/widget/src/cocoa/nsMenuBarX.cpp b/mozilla/widget/src/cocoa/nsMenuBarX.cpp index 2231876d21c..a801bbd1344 100644 --- a/mozilla/widget/src/cocoa/nsMenuBarX.cpp +++ b/mozilla/widget/src/cocoa/nsMenuBarX.cpp @@ -726,13 +726,13 @@ NS_IMPL_NSIDOCUMENTOBSERVER_STATE_STUB(nsMenuBarX) NS_IMPL_NSIDOCUMENTOBSERVER_STYLE_STUB(nsMenuBarX) NS_IMETHODIMP -nsMenuBarX::BeginUpdate( nsIDocument * aDocument ) +nsMenuBarX::BeginUpdate( nsIDocument * aDocument, nsUpdateType aUpdateType ) { return NS_OK; } NS_IMETHODIMP -nsMenuBarX::EndUpdate( nsIDocument * aDocument ) +nsMenuBarX::EndUpdate( nsIDocument * aDocument, nsUpdateType aUpdateType ) { return NS_OK; } diff --git a/mozilla/widget/src/mac/nsMenuBar.cpp b/mozilla/widget/src/mac/nsMenuBar.cpp index 067da938c5a..01fa935da10 100644 --- a/mozilla/widget/src/mac/nsMenuBar.cpp +++ b/mozilla/widget/src/mac/nsMenuBar.cpp @@ -620,13 +620,13 @@ NS_IMPL_NSIDOCUMENTOBSERVER_STATE_STUB(nsMenuBar) NS_IMPL_NSIDOCUMENTOBSERVER_STYLE_STUB(nsMenuBar) NS_IMETHODIMP -nsMenuBar::BeginUpdate( nsIDocument * aDocument ) +nsMenuBar::BeginUpdate( nsIDocument * aDocument, nsUpdateType aUpdateType ) { return NS_OK; } NS_IMETHODIMP -nsMenuBar::EndUpdate( nsIDocument * aDocument ) +nsMenuBar::EndUpdate( nsIDocument * aDocument, nsUpdateType aUpdateType ) { return NS_OK; } diff --git a/mozilla/widget/src/mac/nsMenuBarX.cpp b/mozilla/widget/src/mac/nsMenuBarX.cpp index cef3289c566..86293a1897c 100644 --- a/mozilla/widget/src/mac/nsMenuBarX.cpp +++ b/mozilla/widget/src/mac/nsMenuBarX.cpp @@ -733,13 +733,13 @@ NS_IMPL_NSIDOCUMENTOBSERVER_STATE_STUB(nsMenuBarX) NS_IMPL_NSIDOCUMENTOBSERVER_STYLE_STUB(nsMenuBarX) NS_IMETHODIMP -nsMenuBarX::BeginUpdate( nsIDocument * aDocument ) +nsMenuBarX::BeginUpdate( nsIDocument * aDocument, nsUpdateType aUpdateType ) { return NS_OK; } NS_IMETHODIMP -nsMenuBarX::EndUpdate( nsIDocument * aDocument ) +nsMenuBarX::EndUpdate( nsIDocument * aDocument, nsUpdateType aUpdateType ) { return NS_OK; }