From 370762744fc90fdb0f9ab2e2209e37cbe09258a0 Mon Sep 17 00:00:00 2001 From: "jim_nance%yahoo.com" Date: Fri, 28 Jan 2000 04:37:13 +0000 Subject: [PATCH] Implemented idea from shaver for speeding up SelectorMatches(). We wait until we know we are going to need the contentTag before we create it. r=shaver git-svn-id: svn://10.0.0.236/trunk@59021 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/content/html/style/src/nsCSSStyleSheet.cpp | 13 ++++++++++--- mozilla/layout/html/style/src/nsCSSStyleSheet.cpp | 13 ++++++++++--- mozilla/layout/style/nsCSSStyleSheet.cpp | 13 ++++++++++--- 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/mozilla/content/html/style/src/nsCSSStyleSheet.cpp b/mozilla/content/html/style/src/nsCSSStyleSheet.cpp index 78e6731c331..9f04a210c75 100644 --- a/mozilla/content/html/style/src/nsCSSStyleSheet.cpp +++ b/mozilla/content/html/style/src/nsCSSStyleSheet.cpp @@ -2294,7 +2294,8 @@ static PRBool SelectorMatches(nsIPresContext* aPresContext, PRBool aTestState) { PRBool result = PR_FALSE; - nsIAtom* contentTag; + PRBool tagset = PR_FALSE; + nsIAtom* contentTag = NULL; // Make sure this is NULL for NS_IF_RELEASE // Bail out early if we can if(kNameSpaceID_Unknown != aSelector->mNameSpace) { @@ -2305,9 +2306,11 @@ static PRBool SelectorMatches(nsIPresContext* aPresContext, } } - aContent->GetTag(contentTag); + if (((nsnull == aSelector->mTag) || ( + aContent->GetTag(contentTag), + tagset=PR_TRUE, + aSelector->mTag == contentTag))) { - if (((nsnull == aSelector->mTag) || (aSelector->mTag == contentTag))) { result = PR_TRUE; // namespace/tag match if (nsnull != aSelector->mAttrList) { // test for attribute match @@ -2482,6 +2485,10 @@ static PRBool SelectorMatches(nsIPresContext* aPresContext, } else if (IsLinkPseudo(pseudoClass->mAtom)) { // XXX xml link too + if(!tagset) { + tagset=PR_TRUE; + aContent->GetTag(contentTag); + } if (nsHTMLAtoms::a == contentTag) { if (aTestState) { if (! linkHandler) { diff --git a/mozilla/layout/html/style/src/nsCSSStyleSheet.cpp b/mozilla/layout/html/style/src/nsCSSStyleSheet.cpp index 78e6731c331..9f04a210c75 100644 --- a/mozilla/layout/html/style/src/nsCSSStyleSheet.cpp +++ b/mozilla/layout/html/style/src/nsCSSStyleSheet.cpp @@ -2294,7 +2294,8 @@ static PRBool SelectorMatches(nsIPresContext* aPresContext, PRBool aTestState) { PRBool result = PR_FALSE; - nsIAtom* contentTag; + PRBool tagset = PR_FALSE; + nsIAtom* contentTag = NULL; // Make sure this is NULL for NS_IF_RELEASE // Bail out early if we can if(kNameSpaceID_Unknown != aSelector->mNameSpace) { @@ -2305,9 +2306,11 @@ static PRBool SelectorMatches(nsIPresContext* aPresContext, } } - aContent->GetTag(contentTag); + if (((nsnull == aSelector->mTag) || ( + aContent->GetTag(contentTag), + tagset=PR_TRUE, + aSelector->mTag == contentTag))) { - if (((nsnull == aSelector->mTag) || (aSelector->mTag == contentTag))) { result = PR_TRUE; // namespace/tag match if (nsnull != aSelector->mAttrList) { // test for attribute match @@ -2482,6 +2485,10 @@ static PRBool SelectorMatches(nsIPresContext* aPresContext, } else if (IsLinkPseudo(pseudoClass->mAtom)) { // XXX xml link too + if(!tagset) { + tagset=PR_TRUE; + aContent->GetTag(contentTag); + } if (nsHTMLAtoms::a == contentTag) { if (aTestState) { if (! linkHandler) { diff --git a/mozilla/layout/style/nsCSSStyleSheet.cpp b/mozilla/layout/style/nsCSSStyleSheet.cpp index 78e6731c331..9f04a210c75 100644 --- a/mozilla/layout/style/nsCSSStyleSheet.cpp +++ b/mozilla/layout/style/nsCSSStyleSheet.cpp @@ -2294,7 +2294,8 @@ static PRBool SelectorMatches(nsIPresContext* aPresContext, PRBool aTestState) { PRBool result = PR_FALSE; - nsIAtom* contentTag; + PRBool tagset = PR_FALSE; + nsIAtom* contentTag = NULL; // Make sure this is NULL for NS_IF_RELEASE // Bail out early if we can if(kNameSpaceID_Unknown != aSelector->mNameSpace) { @@ -2305,9 +2306,11 @@ static PRBool SelectorMatches(nsIPresContext* aPresContext, } } - aContent->GetTag(contentTag); + if (((nsnull == aSelector->mTag) || ( + aContent->GetTag(contentTag), + tagset=PR_TRUE, + aSelector->mTag == contentTag))) { - if (((nsnull == aSelector->mTag) || (aSelector->mTag == contentTag))) { result = PR_TRUE; // namespace/tag match if (nsnull != aSelector->mAttrList) { // test for attribute match @@ -2482,6 +2485,10 @@ static PRBool SelectorMatches(nsIPresContext* aPresContext, } else if (IsLinkPseudo(pseudoClass->mAtom)) { // XXX xml link too + if(!tagset) { + tagset=PR_TRUE; + aContent->GetTag(contentTag); + } if (nsHTMLAtoms::a == contentTag) { if (aTestState) { if (! linkHandler) {