mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 968766 - Part k: Move the hashmap for named access to document.all into HTMLAllCollection; r=jst
This commit is contained in:
parent
ce843f3b65
commit
a570615379
@ -69,12 +69,14 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(HTMLAllCollection)
|
|||||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
|
||||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDocument)
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDocument)
|
||||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCollection)
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCollection)
|
||||||
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mNamedMap)
|
||||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||||
|
|
||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(HTMLAllCollection)
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(HTMLAllCollection)
|
||||||
tmp->mObject = nullptr;
|
tmp->mObject = nullptr;
|
||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mDocument)
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mDocument)
|
||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mCollection)
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mCollection)
|
||||||
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mNamedMap)
|
||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||||
|
|
||||||
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(HTMLAllCollection)
|
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(HTMLAllCollection)
|
||||||
@ -130,11 +132,65 @@ HTMLAllCollection::Collection()
|
|||||||
return mCollection;
|
return mCollection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
DocAllResultMatch(nsIContent* aContent, int32_t aNamespaceID, nsIAtom* aAtom,
|
||||||
|
void* aData)
|
||||||
|
{
|
||||||
|
if (aContent->GetID() == aAtom) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsGenericHTMLElement* elm = nsGenericHTMLElement::FromContent(aContent);
|
||||||
|
if (!elm) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsIAtom* tag = elm->Tag();
|
||||||
|
if (tag != nsGkAtoms::a &&
|
||||||
|
tag != nsGkAtoms::applet &&
|
||||||
|
tag != nsGkAtoms::button &&
|
||||||
|
tag != nsGkAtoms::embed &&
|
||||||
|
tag != nsGkAtoms::form &&
|
||||||
|
tag != nsGkAtoms::iframe &&
|
||||||
|
tag != nsGkAtoms::img &&
|
||||||
|
tag != nsGkAtoms::input &&
|
||||||
|
tag != nsGkAtoms::map &&
|
||||||
|
tag != nsGkAtoms::meta &&
|
||||||
|
tag != nsGkAtoms::object &&
|
||||||
|
tag != nsGkAtoms::select &&
|
||||||
|
tag != nsGkAtoms::textarea) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const nsAttrValue* val = elm->GetParsedAttr(nsGkAtoms::name);
|
||||||
|
return val && val->Type() == nsAttrValue::eAtom &&
|
||||||
|
val->GetAtomValue() == aAtom;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsContentList*
|
||||||
|
HTMLAllCollection::GetDocumentAllList(const nsAString& aID)
|
||||||
|
{
|
||||||
|
if (nsContentList* docAllList = mNamedMap.GetWeak(aID)) {
|
||||||
|
return docAllList;
|
||||||
|
}
|
||||||
|
|
||||||
|
Element* root = mDocument->GetRootElement();
|
||||||
|
if (!root) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsCOMPtr<nsIAtom> id = do_GetAtom(aID);
|
||||||
|
nsRefPtr<nsContentList> docAllList =
|
||||||
|
new nsContentList(root, DocAllResultMatch, nullptr, nullptr, true, id);
|
||||||
|
mNamedMap.Put(aID, docAllList);
|
||||||
|
return docAllList;
|
||||||
|
}
|
||||||
|
|
||||||
nsISupports*
|
nsISupports*
|
||||||
HTMLAllCollection::GetNamedItem(const nsAString& aID,
|
HTMLAllCollection::GetNamedItem(const nsAString& aID,
|
||||||
nsWrapperCache** aCache)
|
nsWrapperCache** aCache)
|
||||||
{
|
{
|
||||||
nsContentList* docAllList = mDocument->GetDocumentAllList(aID);
|
nsContentList* docAllList = GetDocumentAllList(aID);
|
||||||
if (!docAllList) {
|
if (!docAllList) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include "nsAutoPtr.h"
|
#include "nsAutoPtr.h"
|
||||||
#include "nsCycleCollectionParticipant.h"
|
#include "nsCycleCollectionParticipant.h"
|
||||||
#include "nsISupportsImpl.h"
|
#include "nsISupportsImpl.h"
|
||||||
|
#include "nsRefPtrHashtable.h"
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
@ -43,9 +44,15 @@ public:
|
|||||||
private:
|
private:
|
||||||
nsContentList* Collection();
|
nsContentList* Collection();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the NodeList for document.all[aID], or null if there isn't one.
|
||||||
|
*/
|
||||||
|
nsContentList* GetDocumentAllList(const nsAString& aID);
|
||||||
|
|
||||||
JS::Heap<JSObject*> mObject;
|
JS::Heap<JSObject*> mObject;
|
||||||
nsRefPtr<nsHTMLDocument> mDocument;
|
nsRefPtr<nsHTMLDocument> mDocument;
|
||||||
nsRefPtr<nsContentList> mCollection;
|
nsRefPtr<nsContentList> mCollection;
|
||||||
|
nsRefPtrHashtable<nsStringHashKey, nsContentList> mNamedMap;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace dom
|
} // namespace dom
|
||||||
|
@ -199,9 +199,8 @@ nsHTMLDocument::~nsHTMLDocument()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMPL_CYCLE_COLLECTION_INHERITED_12(nsHTMLDocument, nsDocument,
|
NS_IMPL_CYCLE_COLLECTION_INHERITED_11(nsHTMLDocument, nsDocument,
|
||||||
mAll,
|
mAll,
|
||||||
mAllMap,
|
|
||||||
mImages,
|
mImages,
|
||||||
mApplets,
|
mApplets,
|
||||||
mEmbeds,
|
mEmbeds,
|
||||||
@ -2556,61 +2555,6 @@ nsHTMLDocument::DeferredContentEditableCountChange(nsIContent *aElement)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
|
||||||
DocAllResultMatch(nsIContent* aContent, int32_t aNamespaceID, nsIAtom* aAtom,
|
|
||||||
void* aData)
|
|
||||||
{
|
|
||||||
if (aContent->GetID() == aAtom) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsGenericHTMLElement* elm = nsGenericHTMLElement::FromContent(aContent);
|
|
||||||
if (!elm) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsIAtom* tag = elm->Tag();
|
|
||||||
if (tag != nsGkAtoms::a &&
|
|
||||||
tag != nsGkAtoms::applet &&
|
|
||||||
tag != nsGkAtoms::button &&
|
|
||||||
tag != nsGkAtoms::embed &&
|
|
||||||
tag != nsGkAtoms::form &&
|
|
||||||
tag != nsGkAtoms::iframe &&
|
|
||||||
tag != nsGkAtoms::img &&
|
|
||||||
tag != nsGkAtoms::input &&
|
|
||||||
tag != nsGkAtoms::map &&
|
|
||||||
tag != nsGkAtoms::meta &&
|
|
||||||
tag != nsGkAtoms::object &&
|
|
||||||
tag != nsGkAtoms::select &&
|
|
||||||
tag != nsGkAtoms::textarea) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const nsAttrValue* val = elm->GetParsedAttr(nsGkAtoms::name);
|
|
||||||
return val && val->Type() == nsAttrValue::eAtom &&
|
|
||||||
val->GetAtomValue() == aAtom;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
nsContentList*
|
|
||||||
nsHTMLDocument::GetDocumentAllList(const nsAString& aID)
|
|
||||||
{
|
|
||||||
if (nsContentList* docAllList = mAllMap.GetWeak(aID)) {
|
|
||||||
return docAllList;
|
|
||||||
}
|
|
||||||
|
|
||||||
Element* root = GetRootElement();
|
|
||||||
if (!root) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsCOMPtr<nsIAtom> id = do_GetAtom(aID);
|
|
||||||
nsRefPtr<nsContentList> docAllList =
|
|
||||||
new nsContentList(root, DocAllResultMatch, nullptr, nullptr, true, id);
|
|
||||||
mAllMap.Put(aID, docAllList);
|
|
||||||
return docAllList;
|
|
||||||
}
|
|
||||||
|
|
||||||
HTMLAllCollection*
|
HTMLAllCollection*
|
||||||
nsHTMLDocument::All()
|
nsHTMLDocument::All()
|
||||||
{
|
{
|
||||||
|
@ -102,10 +102,6 @@ public:
|
|||||||
// nsIDOMHTMLDocument interface
|
// nsIDOMHTMLDocument interface
|
||||||
NS_DECL_NSIDOMHTMLDOCUMENT
|
NS_DECL_NSIDOMHTMLDOCUMENT
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the NodeList for document.all[aID], or null if there isn't one.
|
|
||||||
*/
|
|
||||||
nsContentList* GetDocumentAllList(const nsAString& aID);
|
|
||||||
mozilla::dom::HTMLAllCollection* All();
|
mozilla::dom::HTMLAllCollection* All();
|
||||||
JSObject* GetAll(JSContext* aCx, mozilla::ErrorResult& aRv);
|
JSObject* GetAll(JSContext* aCx, mozilla::ErrorResult& aRv);
|
||||||
|
|
||||||
@ -292,7 +288,6 @@ protected:
|
|||||||
nsRefPtr<nsContentList> mFormControls;
|
nsRefPtr<nsContentList> mFormControls;
|
||||||
|
|
||||||
nsRefPtr<mozilla::dom::HTMLAllCollection> mAll;
|
nsRefPtr<mozilla::dom::HTMLAllCollection> mAll;
|
||||||
nsRefPtrHashtable<nsStringHashKey, nsContentList> mAllMap;
|
|
||||||
|
|
||||||
/** # of forms in the document, synchronously set */
|
/** # of forms in the document, synchronously set */
|
||||||
int32_t mNumForms;
|
int32_t mNumForms;
|
||||||
|
Loading…
Reference in New Issue
Block a user