Cache the list of form controls, so loading a large page with lots of form
controls outside forms is not O(N^2). Bug 336062, r+sr=sicking git-svn-id: svn://10.0.0.236/trunk@199489 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -3542,6 +3542,21 @@ nsHTMLDocument::GetForms()
|
||||
return mForms;
|
||||
}
|
||||
|
||||
static PRBool MatchFormControls(nsIContent* aContent, PRInt32 aNamespaceID,
|
||||
nsIAtom* aAtom, const nsAString& aData)
|
||||
{
|
||||
return aContent->IsNodeOfType(nsIContent::eHTML_FORM_CONTROL);
|
||||
}
|
||||
|
||||
nsContentList*
|
||||
nsHTMLDocument::GetFormControls()
|
||||
{
|
||||
if (!mFormControls) {
|
||||
mFormControls = new nsContentList(this, MatchFormControls, EmptyString());
|
||||
}
|
||||
|
||||
return mFormControls;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLDocument::CreateAndAddWyciwygChannel(void)
|
||||
|
||||
@@ -120,6 +120,8 @@ public:
|
||||
|
||||
virtual NS_HIDDEN_(nsContentList*) GetForms();
|
||||
|
||||
virtual NS_HIDDEN_(nsContentList*) GetFormControls();
|
||||
|
||||
virtual void ContentAppended(nsIContent* aContainer,
|
||||
PRInt32 aNewIndexInContainer);
|
||||
virtual void ContentInserted(nsIContent* aContainer,
|
||||
@@ -264,6 +266,7 @@ protected:
|
||||
nsCOMPtr<nsIDOMHTMLCollection> mLinks;
|
||||
nsCOMPtr<nsIDOMHTMLCollection> mAnchors;
|
||||
nsRefPtr<nsContentList> mForms;
|
||||
nsRefPtr<nsContentList> mFormControls;
|
||||
|
||||
/** # of forms in the document, synchronously set */
|
||||
PRInt32 mNumForms;
|
||||
|
||||
@@ -55,9 +55,8 @@ class nsIDOMHTMLBodyElement;
|
||||
class nsIScriptElement;
|
||||
|
||||
#define NS_IHTMLDOCUMENT_IID \
|
||||
{ 0x4daadd67, 0x61b4, 0x4423, \
|
||||
{ 0xae, 0x1a, 0x61, 0x6f, 0xed, 0x5d, 0x72, 0x3c } }
|
||||
|
||||
{ 0xd28641ff, 0xd623, 0x40de, \
|
||||
{ 0xb4, 0x64, 0x75, 0x02, 0xd2, 0x4f, 0x4c, 0xdd } }
|
||||
|
||||
|
||||
/**
|
||||
@@ -128,6 +127,12 @@ public:
|
||||
* Get the list of form elements in the document.
|
||||
*/
|
||||
virtual nsContentList* GetForms() = 0;
|
||||
|
||||
/**
|
||||
* Get the list of form controls in the document (all elements in
|
||||
* the document that are of type nsIContent::eHTML_FORM_CONTROL).
|
||||
*/
|
||||
virtual nsContentList* GetFormControls() = 0;
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsIHTMLDocument, NS_IHTMLDOCUMENT_IID)
|
||||
|
||||
Reference in New Issue
Block a user