From 2d0d3de45db5d438f9e004e487ad0a39afb8b68a Mon Sep 17 00:00:00 2001 From: "pollmann%netscape.com" Date: Tue, 6 Feb 2001 05:46:46 +0000 Subject: [PATCH] Bug 42892: Split FlushPendingNotifications in to content and content+frames cases (speed up content list access), r=jst@netscape.com, sr=vidur@netscape.com git-svn-id: svn://10.0.0.236/trunk@86318 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/content/base/public/nsIDocument.h | 2 +- mozilla/content/base/src/nsContentList.cpp | 4 ++-- mozilla/content/base/src/nsDocument.cpp | 15 +++++++++------ mozilla/content/base/src/nsDocument.h | 2 +- .../html/document/src/nsHTMLDocument.cpp | 17 +++++------------ .../content/html/document/src/nsHTMLDocument.h | 2 +- .../content/xul/document/src/nsXULDocument.cpp | 15 +++++++++------ .../content/xul/document/src/nsXULDocument.h | 2 +- mozilla/layout/base/public/nsIDocument.h | 2 +- mozilla/layout/base/src/nsContentList.cpp | 4 ++-- mozilla/layout/base/src/nsDocument.cpp | 15 +++++++++------ mozilla/layout/base/src/nsDocument.h | 2 +- .../layout/html/document/src/nsHTMLDocument.cpp | 17 +++++------------ .../layout/html/document/src/nsHTMLDocument.h | 2 +- mozilla/rdf/content/src/nsXULDocument.cpp | 15 +++++++++------ mozilla/rdf/content/src/nsXULDocument.h | 2 +- 16 files changed, 58 insertions(+), 60 deletions(-) diff --git a/mozilla/content/base/public/nsIDocument.h b/mozilla/content/base/public/nsIDocument.h index d1d18dfd11d..20ed7c9ba82 100644 --- a/mozilla/content/base/public/nsIDocument.h +++ b/mozilla/content/base/public/nsIDocument.h @@ -295,7 +295,7 @@ public: PRUint32 aFlags, nsEventStatus* aEventStatus) = 0; - NS_IMETHOD FlushPendingNotifications() = 0; + NS_IMETHOD FlushPendingNotifications(PRBool aFlushReflows=PR_TRUE) = 0; NS_IMETHOD GetAndIncrementContentID(PRInt32* aID) = 0; diff --git a/mozilla/content/base/src/nsContentList.cpp b/mozilla/content/base/src/nsContentList.cpp index c1376f48949..cb08c0c7e59 100644 --- a/mozilla/content/base/src/nsContentList.cpp +++ b/mozilla/content/base/src/nsContentList.cpp @@ -160,7 +160,7 @@ nsContentList::Item(PRUint32 aIndex, nsIDOMNode** aReturn) nsresult result = CheckDocumentExistence(); if (NS_OK == result) { if (nsnull != mDocument) { - mDocument->FlushPendingNotifications(); // Flush pending content changes Bug 4891 + mDocument->FlushPendingNotifications(PR_FALSE); // Flush pending content changes Bug 4891 } nsISupports *element = (nsISupports *)mContent.ElementAt(aIndex); @@ -183,7 +183,7 @@ nsContentList::NamedItem(const nsAReadableString& aName, nsIDOMNode** aReturn) if (NS_OK == result) { if (nsnull != mDocument) { - mDocument->FlushPendingNotifications(); // Flush pending content changes Bug 4891 + mDocument->FlushPendingNotifications(PR_FALSE); // Flush pending content changes Bug 4891 } PRInt32 i, count = mContent.Count(); diff --git a/mozilla/content/base/src/nsDocument.cpp b/mozilla/content/base/src/nsDocument.cpp index f33c74627ee..e34807bc70f 100644 --- a/mozilla/content/base/src/nsDocument.cpp +++ b/mozilla/content/base/src/nsDocument.cpp @@ -3116,14 +3116,17 @@ nsDocument::GetFileSpec(nsIFile * *aFileSpec) } NS_IMETHODIMP -nsDocument::FlushPendingNotifications() +nsDocument::FlushPendingNotifications(PRBool aFlushReflows) { - PRInt32 i, count = mPresShells.Count(); + if (aFlushReflows) { - for (i = 0; i < count; i++) { - nsIPresShell* shell = NS_STATIC_CAST(nsIPresShell*, mPresShells[i]); - if (shell) { - shell->FlushPendingNotifications(); + PRInt32 i, count = mPresShells.Count(); + + for (i = 0; i < count; i++) { + nsIPresShell* shell = NS_STATIC_CAST(nsIPresShell*, mPresShells[i]); + if (shell) { + shell->FlushPendingNotifications(); + } } } diff --git a/mozilla/content/base/src/nsDocument.h b/mozilla/content/base/src/nsDocument.h index d4fd9d65d5c..978bd3fdce6 100644 --- a/mozilla/content/base/src/nsDocument.h +++ b/mozilla/content/base/src/nsDocument.h @@ -334,7 +334,7 @@ public: */ NS_IMETHOD FindNext(const nsAReadableString &aSearchStr, PRBool aMatchCase, PRBool aSearchDown, PRBool &aIsFound); - NS_IMETHOD FlushPendingNotifications(); + NS_IMETHOD FlushPendingNotifications(PRBool aFlushReflows = PR_TRUE); NS_IMETHOD GetAndIncrementContentID(PRInt32* aID); NS_IMETHOD GetBindingManager(nsIBindingManager** aResult); NS_IMETHOD GetNodeInfoManager(nsINodeInfoManager*& aNodeInfoManager); diff --git a/mozilla/content/html/document/src/nsHTMLDocument.cpp b/mozilla/content/html/document/src/nsHTMLDocument.cpp index 699991c1e60..fd9adb6e18d 100644 --- a/mozilla/content/html/document/src/nsHTMLDocument.cpp +++ b/mozilla/content/html/document/src/nsHTMLDocument.cpp @@ -125,7 +125,7 @@ static PRBool gPlugDetector = PR_FALSE; #include "prmem.h" #include "prtime.h" -// Find/Serach Includes +// Find/Search Includes const PRInt32 kForward = 0; const PRInt32 kBackward = 1; @@ -1348,7 +1348,7 @@ nsHTMLDocument::ContentRemoved(nsIContent* aContainer, } NS_IMETHODIMP -nsHTMLDocument::FlushPendingNotifications() +nsHTMLDocument::FlushPendingNotifications(PRBool aFlushReflows) { // Determine if it is safe to flush the sink // by determining if it safe to flush all the presshells. @@ -1356,8 +1356,8 @@ nsHTMLDocument::FlushPendingNotifications() PRInt32 i = 0, n = mPresShells.Count(); while ((i < n) && (isSafeToFlush)) { nsIPresShell* shell = NS_STATIC_CAST(nsIPresShell*, mPresShells[i]); - if (nsnull != shell) { - nsresult rv = shell->IsSafeToFlush(isSafeToFlush); + if (shell) { + shell->IsSafeToFlush(isSafeToFlush); } i++; } @@ -1373,7 +1373,7 @@ nsHTMLDocument::FlushPendingNotifications() } } if (NS_SUCCEEDED(result)) { - result = nsDocument::FlushPendingNotifications(); + result = nsDocument::FlushPendingNotifications(aFlushReflows); } return result; @@ -2229,9 +2229,6 @@ nsHTMLDocument::WriteCommon(const nsAReadableString& aText, NS_ConvertASCIItoUCS2("text/html"), PR_FALSE, (!mIsWriting || (mWriteLevel > 1))); mWriteLevel--; - if (NS_OK != result) { - return result; - } return result; } @@ -2256,7 +2253,6 @@ nsHTMLDocument::ScriptWriteCommon(JSContext *cx, { nsresult result = NS_OK; - nsXPIDLCString spec; if (!mDocumentURL || (NS_SUCCEEDED(mDocumentURL->GetSpec(getter_Copies(spec))) && @@ -2327,9 +2323,6 @@ nsHTMLDocument::ScriptWriteCommon(JSContext *cx, NS_ConvertASCIItoUCS2("text/html"), PR_FALSE, (!mIsWriting || (mWriteLevel > 1))); mWriteLevel--; - if (NS_OK != result) { - return result; - } } return result; diff --git a/mozilla/content/html/document/src/nsHTMLDocument.h b/mozilla/content/html/document/src/nsHTMLDocument.h index 217d9bbc925..c5a12aae21b 100644 --- a/mozilla/content/html/document/src/nsHTMLDocument.h +++ b/mozilla/content/html/document/src/nsHTMLDocument.h @@ -113,7 +113,7 @@ public: NS_IMETHOD ContentRemoved(nsIContent* aContainer, nsIContent* aChild, PRInt32 aIndexInContainer); - NS_IMETHOD FlushPendingNotifications(); + NS_IMETHOD FlushPendingNotifications(PRBool aFlushReflows = PR_TRUE); // nsIDOMDocument interface NS_DECL_IDOMDOCUMENT diff --git a/mozilla/content/xul/document/src/nsXULDocument.cpp b/mozilla/content/xul/document/src/nsXULDocument.cpp index 48587bda48b..3d4f224be57 100644 --- a/mozilla/content/xul/document/src/nsXULDocument.cpp +++ b/mozilla/content/xul/document/src/nsXULDocument.cpp @@ -1919,14 +1919,17 @@ nsXULDocument::FindNext(const nsAReadableString &aSearchStr, NS_IMETHODIMP -nsXULDocument::FlushPendingNotifications() +nsXULDocument::FlushPendingNotifications(PRBool aFlushReflows) { - PRInt32 i, count = mPresShells.Count(); + if (aFlushReflows) { - for (i = 0; i < count; i++) { - nsIPresShell* shell = NS_STATIC_CAST(nsIPresShell*, mPresShells[i]); - if (shell) { - shell->FlushPendingNotifications(); + PRInt32 i, count = mPresShells.Count(); + + for (i = 0; i < count; i++) { + nsIPresShell* shell = NS_STATIC_CAST(nsIPresShell*, mPresShells[i]); + if (shell) { + shell->FlushPendingNotifications(); + } } } diff --git a/mozilla/content/xul/document/src/nsXULDocument.h b/mozilla/content/xul/document/src/nsXULDocument.h index 35849d340fb..be5d165392a 100644 --- a/mozilla/content/xul/document/src/nsXULDocument.h +++ b/mozilla/content/xul/document/src/nsXULDocument.h @@ -264,7 +264,7 @@ public: NS_IMETHOD FindNext(const nsAReadableString &aSearchStr, PRBool aMatchCase, PRBool aSearchDown, PRBool &aIsFound); - NS_IMETHOD FlushPendingNotifications(); + NS_IMETHOD FlushPendingNotifications(PRBool aFlushReflows = PR_TRUE); NS_IMETHOD GetAndIncrementContentID(PRInt32* aID); diff --git a/mozilla/layout/base/public/nsIDocument.h b/mozilla/layout/base/public/nsIDocument.h index d1d18dfd11d..20ed7c9ba82 100644 --- a/mozilla/layout/base/public/nsIDocument.h +++ b/mozilla/layout/base/public/nsIDocument.h @@ -295,7 +295,7 @@ public: PRUint32 aFlags, nsEventStatus* aEventStatus) = 0; - NS_IMETHOD FlushPendingNotifications() = 0; + NS_IMETHOD FlushPendingNotifications(PRBool aFlushReflows=PR_TRUE) = 0; NS_IMETHOD GetAndIncrementContentID(PRInt32* aID) = 0; diff --git a/mozilla/layout/base/src/nsContentList.cpp b/mozilla/layout/base/src/nsContentList.cpp index c1376f48949..cb08c0c7e59 100644 --- a/mozilla/layout/base/src/nsContentList.cpp +++ b/mozilla/layout/base/src/nsContentList.cpp @@ -160,7 +160,7 @@ nsContentList::Item(PRUint32 aIndex, nsIDOMNode** aReturn) nsresult result = CheckDocumentExistence(); if (NS_OK == result) { if (nsnull != mDocument) { - mDocument->FlushPendingNotifications(); // Flush pending content changes Bug 4891 + mDocument->FlushPendingNotifications(PR_FALSE); // Flush pending content changes Bug 4891 } nsISupports *element = (nsISupports *)mContent.ElementAt(aIndex); @@ -183,7 +183,7 @@ nsContentList::NamedItem(const nsAReadableString& aName, nsIDOMNode** aReturn) if (NS_OK == result) { if (nsnull != mDocument) { - mDocument->FlushPendingNotifications(); // Flush pending content changes Bug 4891 + mDocument->FlushPendingNotifications(PR_FALSE); // Flush pending content changes Bug 4891 } PRInt32 i, count = mContent.Count(); diff --git a/mozilla/layout/base/src/nsDocument.cpp b/mozilla/layout/base/src/nsDocument.cpp index f33c74627ee..e34807bc70f 100644 --- a/mozilla/layout/base/src/nsDocument.cpp +++ b/mozilla/layout/base/src/nsDocument.cpp @@ -3116,14 +3116,17 @@ nsDocument::GetFileSpec(nsIFile * *aFileSpec) } NS_IMETHODIMP -nsDocument::FlushPendingNotifications() +nsDocument::FlushPendingNotifications(PRBool aFlushReflows) { - PRInt32 i, count = mPresShells.Count(); + if (aFlushReflows) { - for (i = 0; i < count; i++) { - nsIPresShell* shell = NS_STATIC_CAST(nsIPresShell*, mPresShells[i]); - if (shell) { - shell->FlushPendingNotifications(); + PRInt32 i, count = mPresShells.Count(); + + for (i = 0; i < count; i++) { + nsIPresShell* shell = NS_STATIC_CAST(nsIPresShell*, mPresShells[i]); + if (shell) { + shell->FlushPendingNotifications(); + } } } diff --git a/mozilla/layout/base/src/nsDocument.h b/mozilla/layout/base/src/nsDocument.h index d4fd9d65d5c..978bd3fdce6 100644 --- a/mozilla/layout/base/src/nsDocument.h +++ b/mozilla/layout/base/src/nsDocument.h @@ -334,7 +334,7 @@ public: */ NS_IMETHOD FindNext(const nsAReadableString &aSearchStr, PRBool aMatchCase, PRBool aSearchDown, PRBool &aIsFound); - NS_IMETHOD FlushPendingNotifications(); + NS_IMETHOD FlushPendingNotifications(PRBool aFlushReflows = PR_TRUE); NS_IMETHOD GetAndIncrementContentID(PRInt32* aID); NS_IMETHOD GetBindingManager(nsIBindingManager** aResult); NS_IMETHOD GetNodeInfoManager(nsINodeInfoManager*& aNodeInfoManager); diff --git a/mozilla/layout/html/document/src/nsHTMLDocument.cpp b/mozilla/layout/html/document/src/nsHTMLDocument.cpp index 699991c1e60..fd9adb6e18d 100644 --- a/mozilla/layout/html/document/src/nsHTMLDocument.cpp +++ b/mozilla/layout/html/document/src/nsHTMLDocument.cpp @@ -125,7 +125,7 @@ static PRBool gPlugDetector = PR_FALSE; #include "prmem.h" #include "prtime.h" -// Find/Serach Includes +// Find/Search Includes const PRInt32 kForward = 0; const PRInt32 kBackward = 1; @@ -1348,7 +1348,7 @@ nsHTMLDocument::ContentRemoved(nsIContent* aContainer, } NS_IMETHODIMP -nsHTMLDocument::FlushPendingNotifications() +nsHTMLDocument::FlushPendingNotifications(PRBool aFlushReflows) { // Determine if it is safe to flush the sink // by determining if it safe to flush all the presshells. @@ -1356,8 +1356,8 @@ nsHTMLDocument::FlushPendingNotifications() PRInt32 i = 0, n = mPresShells.Count(); while ((i < n) && (isSafeToFlush)) { nsIPresShell* shell = NS_STATIC_CAST(nsIPresShell*, mPresShells[i]); - if (nsnull != shell) { - nsresult rv = shell->IsSafeToFlush(isSafeToFlush); + if (shell) { + shell->IsSafeToFlush(isSafeToFlush); } i++; } @@ -1373,7 +1373,7 @@ nsHTMLDocument::FlushPendingNotifications() } } if (NS_SUCCEEDED(result)) { - result = nsDocument::FlushPendingNotifications(); + result = nsDocument::FlushPendingNotifications(aFlushReflows); } return result; @@ -2229,9 +2229,6 @@ nsHTMLDocument::WriteCommon(const nsAReadableString& aText, NS_ConvertASCIItoUCS2("text/html"), PR_FALSE, (!mIsWriting || (mWriteLevel > 1))); mWriteLevel--; - if (NS_OK != result) { - return result; - } return result; } @@ -2256,7 +2253,6 @@ nsHTMLDocument::ScriptWriteCommon(JSContext *cx, { nsresult result = NS_OK; - nsXPIDLCString spec; if (!mDocumentURL || (NS_SUCCEEDED(mDocumentURL->GetSpec(getter_Copies(spec))) && @@ -2327,9 +2323,6 @@ nsHTMLDocument::ScriptWriteCommon(JSContext *cx, NS_ConvertASCIItoUCS2("text/html"), PR_FALSE, (!mIsWriting || (mWriteLevel > 1))); mWriteLevel--; - if (NS_OK != result) { - return result; - } } return result; diff --git a/mozilla/layout/html/document/src/nsHTMLDocument.h b/mozilla/layout/html/document/src/nsHTMLDocument.h index 217d9bbc925..c5a12aae21b 100644 --- a/mozilla/layout/html/document/src/nsHTMLDocument.h +++ b/mozilla/layout/html/document/src/nsHTMLDocument.h @@ -113,7 +113,7 @@ public: NS_IMETHOD ContentRemoved(nsIContent* aContainer, nsIContent* aChild, PRInt32 aIndexInContainer); - NS_IMETHOD FlushPendingNotifications(); + NS_IMETHOD FlushPendingNotifications(PRBool aFlushReflows = PR_TRUE); // nsIDOMDocument interface NS_DECL_IDOMDOCUMENT diff --git a/mozilla/rdf/content/src/nsXULDocument.cpp b/mozilla/rdf/content/src/nsXULDocument.cpp index 48587bda48b..3d4f224be57 100644 --- a/mozilla/rdf/content/src/nsXULDocument.cpp +++ b/mozilla/rdf/content/src/nsXULDocument.cpp @@ -1919,14 +1919,17 @@ nsXULDocument::FindNext(const nsAReadableString &aSearchStr, NS_IMETHODIMP -nsXULDocument::FlushPendingNotifications() +nsXULDocument::FlushPendingNotifications(PRBool aFlushReflows) { - PRInt32 i, count = mPresShells.Count(); + if (aFlushReflows) { - for (i = 0; i < count; i++) { - nsIPresShell* shell = NS_STATIC_CAST(nsIPresShell*, mPresShells[i]); - if (shell) { - shell->FlushPendingNotifications(); + PRInt32 i, count = mPresShells.Count(); + + for (i = 0; i < count; i++) { + nsIPresShell* shell = NS_STATIC_CAST(nsIPresShell*, mPresShells[i]); + if (shell) { + shell->FlushPendingNotifications(); + } } } diff --git a/mozilla/rdf/content/src/nsXULDocument.h b/mozilla/rdf/content/src/nsXULDocument.h index 35849d340fb..be5d165392a 100644 --- a/mozilla/rdf/content/src/nsXULDocument.h +++ b/mozilla/rdf/content/src/nsXULDocument.h @@ -264,7 +264,7 @@ public: NS_IMETHOD FindNext(const nsAReadableString &aSearchStr, PRBool aMatchCase, PRBool aSearchDown, PRBool &aIsFound); - NS_IMETHOD FlushPendingNotifications(); + NS_IMETHOD FlushPendingNotifications(PRBool aFlushReflows = PR_TRUE); NS_IMETHOD GetAndIncrementContentID(PRInt32* aID);