From d934c405c05dc93ff0a07aef2b8cd4815c8d4f92 Mon Sep 17 00:00:00 2001 From: "bzbarsky%mit.edu" Date: Tue, 16 Aug 2005 01:43:53 +0000 Subject: [PATCH] Make content lists smarter about match functions that don't actually depend on attributes. Bug 299703, r+sr=jst git-svn-id: svn://10.0.0.236/trunk@177803 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/content/base/src/nsContentList.cpp | 12 ++++++++---- mozilla/content/base/src/nsContentList.h | 8 +++++++- .../html/content/src/nsHTMLTableRowElement.cpp | 3 +++ 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/mozilla/content/base/src/nsContentList.cpp b/mozilla/content/base/src/nsContentList.cpp index 2089faf77e9..45b2245a9b7 100644 --- a/mozilla/content/base/src/nsContentList.cpp +++ b/mozilla/content/base/src/nsContentList.cpp @@ -326,7 +326,8 @@ nsContentList::nsContentList(nsIDocument *aDocument, mFunc(nsnull), mData(nsnull), mState(LIST_DIRTY), - mDeep(aDeep) + mDeep(aDeep), + mFuncMayDependOnAttr(PR_FALSE) { NS_ASSERTION(mDeep || mRootContent, "Must have root content for non-deep list!"); if (nsLayoutAtoms::wildcard == mMatchAtom) { @@ -344,14 +345,16 @@ nsContentList::nsContentList(nsIDocument *aDocument, nsIContent* aRootContent, PRBool aDeep, nsIAtom* aMatchAtom, - PRInt32 aMatchNameSpaceId) + PRInt32 aMatchNameSpaceId, + PRBool aFuncMayDependOnAttr) : nsBaseContentList(), nsContentListKey(aDocument, aMatchAtom, aMatchNameSpaceId, aRootContent), mFunc(aFunc), mData(&EmptyString()), mMatchAll(PR_FALSE), mState(LIST_DIRTY), - mDeep(aDeep) + mDeep(aDeep), + mFuncMayDependOnAttr(aFuncMayDependOnAttr) { NS_ASSERTION(mDeep || mRootContent, "Must have root content for non-deep list!"); if (!aData.IsEmpty()) { @@ -526,7 +529,8 @@ nsContentList::AttributeChanged(nsIDocument *aDocument, nsIContent* aContent, { NS_PRECONDITION(aContent, "Must have a content node to work with"); - if (!mFunc || mState == LIST_DIRTY || IsContentAnonymous(aContent)) { + if (!mFunc || !mFuncMayDependOnAttr || mState == LIST_DIRTY || + IsContentAnonymous(aContent)) { // Either we're already dirty or this notification doesn't affect // whether we might match aContent. return; diff --git a/mozilla/content/base/src/nsContentList.h b/mozilla/content/base/src/nsContentList.h index 3d08734ce72..4160e660f8e 100644 --- a/mozilla/content/base/src/nsContentList.h +++ b/mozilla/content/base/src/nsContentList.h @@ -173,7 +173,8 @@ public: nsIContent* aRootContent = nsnull, PRBool aDeep = PR_TRUE, nsIAtom* aMatchAtom = nsnull, - PRInt32 aMatchNameSpaceId = kNameSpaceID_None); + PRInt32 aMatchNameSpaceId = kNameSpaceID_None, + PRBool aFuncMayDependOnAttr = PR_TRUE); virtual ~nsContentList(); // nsIDOMHTMLCollection @@ -333,6 +334,11 @@ protected: * consider grandkids of mRootContent. */ PRPackedBool mDeep; + /** + * Whether the return value of mFunc could depend on the values of + * attributes. + */ + PRPackedBool mFuncMayDependOnAttr; }; /** diff --git a/mozilla/content/html/content/src/nsHTMLTableRowElement.cpp b/mozilla/content/html/content/src/nsHTMLTableRowElement.cpp index e30adaa5de8..678a68cf101 100644 --- a/mozilla/content/html/content/src/nsHTMLTableRowElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLTableRowElement.cpp @@ -273,6 +273,9 @@ nsHTMLTableRowElement::GetCells(nsIDOMHTMLCollection** aValue) IsCell, EmptyString(), this, + PR_FALSE, + nsnull, + kNameSpaceID_None, PR_FALSE); NS_ENSURE_TRUE(mCells, NS_ERROR_OUT_OF_MEMORY);