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
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user