#375: M1347634 1352235
This commit is contained in:
parent
06fcc091fc
commit
aa6b13c599
|
@ -191,6 +191,14 @@ Element::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
|||
aInstancePtr);
|
||||
}
|
||||
|
||||
void
|
||||
Element::SetCustomElementData(CustomElementData* aData)
|
||||
{
|
||||
nsDOMSlots *slots = DOMSlots();
|
||||
MOZ_ASSERT(!slots->mCustomElementData, "Custom element data may not be changed once set.");
|
||||
slots->mCustomElementData = aData;
|
||||
}
|
||||
|
||||
EventStates
|
||||
Element::IntrinsicState() const
|
||||
{
|
||||
|
|
|
@ -361,6 +361,29 @@ public:
|
|||
|
||||
Directionality GetComputedDirectionality() const;
|
||||
|
||||
/**
|
||||
* Gets the custom element data used by web components' custom element.
|
||||
* Custom element data is created at the first attempt to enqueue a callback.
|
||||
*
|
||||
* @return The custom element data or null if none.
|
||||
*/
|
||||
inline CustomElementData* GetCustomElementData() const
|
||||
{
|
||||
nsDOMSlots *slots = GetExistingDOMSlots();
|
||||
if (slots) {
|
||||
return slots->mCustomElementData;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the custom element data, ownership of the
|
||||
* callback data is taken by this element.
|
||||
*
|
||||
* @param aData The custom element data.
|
||||
*/
|
||||
void SetCustomElementData(CustomElementData* aData);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Method to get the _intrinsic_ content state of this element. This is the
|
||||
|
|
|
@ -1116,24 +1116,6 @@ FragmentOrElement::SetXBLInsertionParent(nsIContent* aContent)
|
|||
}
|
||||
}
|
||||
|
||||
CustomElementData*
|
||||
FragmentOrElement::GetCustomElementData() const
|
||||
{
|
||||
nsDOMSlots *slots = GetExistingDOMSlots();
|
||||
if (slots) {
|
||||
return slots->mCustomElementData;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
FragmentOrElement::SetCustomElementData(CustomElementData* aData)
|
||||
{
|
||||
nsDOMSlots *slots = DOMSlots();
|
||||
MOZ_ASSERT(!slots->mCustomElementData, "Custom element data may not be changed once set.");
|
||||
slots->mCustomElementData = aData;
|
||||
}
|
||||
|
||||
nsresult
|
||||
FragmentOrElement::InsertChildAt(nsIContent* aKid,
|
||||
uint32_t aIndex,
|
||||
|
|
|
@ -34,6 +34,7 @@ class nsIURI;
|
|||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
struct CustomElementData;
|
||||
class Element;
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
@ -157,9 +158,6 @@ public:
|
|||
virtual void SetXBLInsertionParent(nsIContent* aContent) override;
|
||||
virtual bool IsLink(nsIURI** aURI) const override;
|
||||
|
||||
virtual CustomElementData *GetCustomElementData() const override;
|
||||
virtual void SetCustomElementData(CustomElementData* aData) override;
|
||||
|
||||
virtual void DestroyContent() override;
|
||||
virtual void SaveSubtreeState() override;
|
||||
|
||||
|
|
|
@ -771,17 +771,6 @@ nsGenericDOMDataNode::SetXBLInsertionParent(nsIContent* aContent)
|
|||
}
|
||||
}
|
||||
|
||||
CustomElementData *
|
||||
nsGenericDOMDataNode::GetCustomElementData() const
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
nsGenericDOMDataNode::SetCustomElementData(CustomElementData* aData)
|
||||
{
|
||||
}
|
||||
|
||||
bool
|
||||
nsGenericDOMDataNode::IsNodeOfType(uint32_t aFlags) const
|
||||
{
|
||||
|
|
|
@ -163,9 +163,6 @@ public:
|
|||
virtual bool IsNodeOfType(uint32_t aFlags) const override;
|
||||
virtual bool IsLink(nsIURI** aURI) const override;
|
||||
|
||||
virtual mozilla::dom::CustomElementData* GetCustomElementData() const override;
|
||||
virtual void SetCustomElementData(mozilla::dom::CustomElementData* aData) override;
|
||||
|
||||
NS_IMETHOD WalkContentStyleRules(nsRuleWalker* aRuleWalker) override;
|
||||
NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const;
|
||||
virtual nsChangeHint GetAttributeChangeHint(const nsIAtom* aAttribute,
|
||||
|
|
|
@ -25,7 +25,6 @@ namespace mozilla {
|
|||
class EventChainPreVisitor;
|
||||
namespace dom {
|
||||
class ShadowRoot;
|
||||
struct CustomElementData;
|
||||
} // namespace dom
|
||||
namespace widget {
|
||||
struct IMEState;
|
||||
|
@ -703,22 +702,6 @@ public:
|
|||
*/
|
||||
nsIContent *GetFlattenedTreeParent() const;
|
||||
|
||||
/**
|
||||
* Gets the custom element data used by web components custom element.
|
||||
* Custom element data is created at the first attempt to enqueue a callback.
|
||||
*
|
||||
* @return The custom element data or null if none.
|
||||
*/
|
||||
virtual mozilla::dom::CustomElementData *GetCustomElementData() const = 0;
|
||||
|
||||
/**
|
||||
* Sets the custom element data, ownership of the
|
||||
* callback data is taken by this content.
|
||||
*
|
||||
* @param aCallbackData The custom element data.
|
||||
*/
|
||||
virtual void SetCustomElementData(mozilla::dom::CustomElementData* aData) = 0;
|
||||
|
||||
/**
|
||||
* API to check if this is a link that's traversed in response to user input
|
||||
* (e.g. a click event). Specializations for HTML/SVG/generic XML allow for
|
||||
|
|
|
@ -111,7 +111,8 @@ nsNodeInfoManager::nsNodeInfoManager()
|
|||
mNonDocumentNodeInfos(0),
|
||||
mTextNodeInfo(nullptr),
|
||||
mCommentNodeInfo(nullptr),
|
||||
mDocumentNodeInfo(nullptr)
|
||||
mDocumentNodeInfo(nullptr),
|
||||
mRecentlyUsedNodeInfos{}
|
||||
{
|
||||
nsLayoutStatics::AddRef();
|
||||
|
||||
|
@ -232,11 +233,19 @@ nsNodeInfoManager::GetNodeInfo(nsIAtom *aName, nsIAtom *aPrefix,
|
|||
NodeInfo::NodeInfoInner tmpKey(aName, aPrefix, aNamespaceID, aNodeType,
|
||||
aExtraName);
|
||||
|
||||
uint32_t index =
|
||||
GetNodeInfoInnerHashValue(&tmpKey) % RECENTLY_USED_NODEINFOS_SIZE;
|
||||
NodeInfo* ni = mRecentlyUsedNodeInfos[index];
|
||||
if (ni && NodeInfoInnerKeyCompare(&(ni->mInner), &tmpKey)) {
|
||||
RefPtr<NodeInfo> nodeInfo = ni;
|
||||
return nodeInfo.forget();
|
||||
}
|
||||
|
||||
void *node = PL_HashTableLookup(mNodeInfoHash, &tmpKey);
|
||||
|
||||
if (node) {
|
||||
RefPtr<NodeInfo> nodeInfo = static_cast<NodeInfo*>(node);
|
||||
|
||||
mRecentlyUsedNodeInfos[index] = nodeInfo;
|
||||
return nodeInfo.forget();
|
||||
}
|
||||
|
||||
|
@ -254,6 +263,7 @@ nsNodeInfoManager::GetNodeInfo(nsIAtom *aName, nsIAtom *aPrefix,
|
|||
NS_IF_ADDREF(mDocument);
|
||||
}
|
||||
|
||||
mRecentlyUsedNodeInfos[index] = newNodeInfo;
|
||||
return newNodeInfo.forget();
|
||||
}
|
||||
|
||||
|
@ -272,12 +282,21 @@ nsNodeInfoManager::GetNodeInfo(const nsAString& aName, nsIAtom *aPrefix,
|
|||
|
||||
NodeInfo::NodeInfoInner tmpKey(aName, aPrefix, aNamespaceID, aNodeType);
|
||||
|
||||
uint32_t index =
|
||||
GetNodeInfoInnerHashValue(&tmpKey) % RECENTLY_USED_NODEINFOS_SIZE;
|
||||
NodeInfo* ni = mRecentlyUsedNodeInfos[index];
|
||||
if (ni && NodeInfoInnerKeyCompare(&(ni->mInner), &tmpKey)) {
|
||||
RefPtr<NodeInfo> nodeInfo = ni;
|
||||
nodeInfo.forget(aNodeInfo);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void *node = PL_HashTableLookup(mNodeInfoHash, &tmpKey);
|
||||
|
||||
if (node) {
|
||||
NodeInfo* nodeInfo = static_cast<NodeInfo *>(node);
|
||||
|
||||
NS_ADDREF(*aNodeInfo = nodeInfo);
|
||||
RefPtr<NodeInfo> nodeInfo = static_cast<NodeInfo*>(node);
|
||||
mRecentlyUsedNodeInfos[index] = nodeInfo;
|
||||
nodeInfo.forget(aNodeInfo);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -298,6 +317,7 @@ nsNodeInfoManager::GetNodeInfo(const nsAString& aName, nsIAtom *aPrefix,
|
|||
NS_IF_ADDREF(mDocument);
|
||||
}
|
||||
|
||||
mRecentlyUsedNodeInfos[index] = newNodeInfo;
|
||||
newNodeInfo.forget(aNodeInfo);
|
||||
|
||||
return NS_OK;
|
||||
|
@ -420,6 +440,12 @@ nsNodeInfoManager::RemoveNodeInfo(NodeInfo *aNodeInfo)
|
|||
}
|
||||
}
|
||||
|
||||
uint32_t index =
|
||||
GetNodeInfoInnerHashValue(&aNodeInfo->mInner) % RECENTLY_USED_NODEINFOS_SIZE;
|
||||
if (mRecentlyUsedNodeInfos[index] == aNodeInfo) {
|
||||
mRecentlyUsedNodeInfos[index] = nullptr;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
bool ret =
|
||||
#endif
|
||||
|
|
|
@ -33,6 +33,8 @@ class NodeInfo;
|
|||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#define RECENTLY_USED_NODEINFOS_SIZE 31
|
||||
|
||||
class nsNodeInfoManager final
|
||||
{
|
||||
private:
|
||||
|
@ -138,6 +140,7 @@ private:
|
|||
mozilla::dom::NodeInfo * MOZ_NON_OWNING_REF mCommentNodeInfo; // WEAK to avoid circular ownership
|
||||
mozilla::dom::NodeInfo * MOZ_NON_OWNING_REF mDocumentNodeInfo; // WEAK to avoid circular ownership
|
||||
RefPtr<nsBindingManager> mBindingManager;
|
||||
mozilla::dom::NodeInfo* mRecentlyUsedNodeInfos[RECENTLY_USED_NODEINFOS_SIZE];
|
||||
};
|
||||
|
||||
#endif /* nsNodeInfoManager_h___ */
|
||||
|
|
Loading…
Reference in New Issue