mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Fixing bug 572615. Speed up nsXULDocuments ID hanling code. r=jonas@sicking.cc
This commit is contained in:
parent
63e3022e0d
commit
c5f4c4eac5
@ -68,7 +68,7 @@ public:
|
||||
* or 'ref' is aID. The nsCOMArray will be truncated and filled in with
|
||||
* nsIContent pointers.
|
||||
*/
|
||||
NS_IMETHOD GetElementsForID(const nsAString& aID, nsCOMArray<nsIContent>& aElements) = 0;
|
||||
virtual void GetElementsForID(const nsAString& aID, nsCOMArray<nsIContent>& aElements) = 0;
|
||||
|
||||
/**
|
||||
* Get the nsIScriptGlobalObjectOwner for this document.
|
||||
|
@ -1133,24 +1133,20 @@ nsXULDocument::ContentRemoved(nsIDocument* aDocument,
|
||||
// nsIXULDocument interface
|
||||
//
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsXULDocument::GetElementsForID(const nsAString& aID,
|
||||
nsCOMArray<nsIContent>& aElements)
|
||||
{
|
||||
aElements.Clear();
|
||||
|
||||
nsCOMPtr<nsIAtom> atom = do_GetAtom(aID);
|
||||
if (!atom)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
nsIdentifierMapEntry *entry = mIdentifierMap.GetEntry(aID);
|
||||
if (entry) {
|
||||
entry->AppendAllIdContent(&aElements);
|
||||
}
|
||||
nsRefMapEntry *refEntry = mRefMap.GetEntry(atom);
|
||||
nsRefMapEntry *refEntry = mRefMap.GetEntry(aID);
|
||||
if (refEntry) {
|
||||
refEntry->AppendAll(&aElements);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -1649,14 +1645,7 @@ nsXULDocument::GetElementById(const nsAString& aId)
|
||||
return element;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAtom> atom(do_GetAtom(aId));
|
||||
if (!atom) {
|
||||
// This can only fail due OOM if the atom doesn't exist, in which
|
||||
// case there couldn't possibly exist an entry for it.
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
nsRefMapEntry* refEntry = mRefMap.GetEntry(atom);
|
||||
nsRefMapEntry* refEntry = mRefMap.GetEntry(aId);
|
||||
if (refEntry) {
|
||||
NS_ASSERTION(refEntry->GetFirstElement(),
|
||||
"nsRefMapEntries should have nonempty content lists");
|
||||
@ -1896,10 +1885,7 @@ nsXULDocument::AddElementToRefMap(Element* aElement)
|
||||
nsAutoString value;
|
||||
GetRefMapAttribute(aElement, &value);
|
||||
if (!value.IsEmpty()) {
|
||||
nsCOMPtr<nsIAtom> atom = do_GetAtom(value);
|
||||
if (!atom)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
nsRefMapEntry *entry = mRefMap.PutEntry(atom);
|
||||
nsRefMapEntry *entry = mRefMap.PutEntry(value);
|
||||
if (!entry)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
if (!entry->AddElement(aElement))
|
||||
@ -1916,14 +1902,11 @@ nsXULDocument::RemoveElementFromRefMap(Element* aElement)
|
||||
nsAutoString value;
|
||||
GetRefMapAttribute(aElement, &value);
|
||||
if (!value.IsEmpty()) {
|
||||
nsCOMPtr<nsIAtom> atom = do_GetAtom(value);
|
||||
if (!atom)
|
||||
return;
|
||||
nsRefMapEntry *entry = mRefMap.GetEntry(atom);
|
||||
nsRefMapEntry *entry = mRefMap.GetEntry(value);
|
||||
if (!entry)
|
||||
return;
|
||||
if (entry->RemoveElement(aElement)) {
|
||||
mRefMap.RemoveEntry(atom);
|
||||
mRefMap.RawRemoveEntry(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -77,15 +77,19 @@ class nsIXULPrototypeScript;
|
||||
struct JSObject;
|
||||
struct PRLogModuleInfo;
|
||||
|
||||
class nsRefMapEntry : public nsISupportsHashKey
|
||||
class nsRefMapEntry : public nsStringHashKey
|
||||
{
|
||||
public:
|
||||
nsRefMapEntry(const nsISupports* aKey) :
|
||||
nsISupportsHashKey(aKey)
|
||||
nsRefMapEntry(const nsAString& aKey) :
|
||||
nsStringHashKey(&aKey)
|
||||
{
|
||||
}
|
||||
nsRefMapEntry(const nsAString *aKey) :
|
||||
nsStringHashKey(aKey)
|
||||
{
|
||||
}
|
||||
nsRefMapEntry(const nsRefMapEntry& aOther) :
|
||||
nsISupportsHashKey(GetKey())
|
||||
nsStringHashKey(&aOther.GetKey())
|
||||
{
|
||||
NS_ERROR("Should never be called");
|
||||
}
|
||||
@ -148,8 +152,8 @@ public:
|
||||
NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTEWILLCHANGE
|
||||
|
||||
// nsIXULDocument interface
|
||||
NS_IMETHOD GetElementsForID(const nsAString& aID,
|
||||
nsCOMArray<nsIContent>& aElements);
|
||||
virtual void GetElementsForID(const nsAString& aID,
|
||||
nsCOMArray<nsIContent>& aElements);
|
||||
|
||||
NS_IMETHOD GetScriptGlobalObjectOwner(nsIScriptGlobalObjectOwner** aGlobalOwner);
|
||||
NS_IMETHOD AddSubtreeToDocument(nsIContent* aContent);
|
||||
|
@ -1380,7 +1380,9 @@ nsXULContentBuilder::GetElementsForResult(nsIXULTemplateResult* aResult,
|
||||
nsAutoString id;
|
||||
aResult->GetId(id);
|
||||
|
||||
return xuldoc->GetElementsForID(id, aElements);
|
||||
xuldoc->GetElementsForID(id, aElements);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
Loading…
Reference in New Issue
Block a user