Bugzilla
Quick Search
Browse
Advanced Search
Reports
Quick Search Help
Documentation
New Account
Log In
Login with GitHub
Remember
Forgot Password
Mozilla Home
Privacy
Cookies
Legal
Attachment 8917291 Details for
Bug 1406395
[patch]
Patch 1 (v2): Invalidate cached child array when nsAttrAndChildArray::TakeChildAt/RemoveChildAt is called
cc-invalidate.patch (text/plain), 4.29 KB, created by
Ben Tian (inactive)
(
hide
)
Description:
Patch 1 (v2): Invalidate cached child array when nsAttrAndChildArray::TakeChildAt/RemoveChildAt is called
Filename:
MIME Type:
Creator:
Ben Tian (inactive)
Size:
4.29 KB
patch
obsolete
># HG changeset patch ># User btian <btian@mozilla.com> ># Date 1507714042 -28800 ># Wed Oct 11 17:27:22 2017 +0800 ># Node ID ab944a73a0e16c9e0b5852ce95bd5a9385ba5274 ># Parent acfdf5d0d1f33f0550d4f566adb1084d9c724b41 >Bug 1406395 - Invalidate cached child array when nsAttrAndChildArray::TakeChildAt/RemoveChildAt is called > >diff --git a/dom/base/FragmentOrElement.cpp b/dom/base/FragmentOrElement.cpp >--- a/dom/base/FragmentOrElement.cpp >+++ b/dom/base/FragmentOrElement.cpp >@@ -1436,6 +1436,7 @@ public: > FragmentOrElement* container = static_cast<FragmentOrElement*>(aNode); > uint32_t childCount = container->mAttrsAndChildren.ChildCount(); > if (childCount) { >+ container->InvalidateChildNodes(); > while (childCount-- > 0) { > // Hold a strong ref to the node when we remove it, because we may be > // the last reference to it. We need to call TakeChildAt() and >@@ -1556,6 +1557,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(Fr > if (childCount) { > // Don't allow script to run while we're unbinding everything. > nsAutoScriptBlocker scriptBlocker; >+ tmp->InvalidateChildNodes(); > while (childCount-- > 0) { > // Hold a strong ref to the node when we remove it, because we may be > // the last reference to it. We need to call TakeChildAt() and >diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp >--- a/dom/base/nsDocument.cpp >+++ b/dom/base/nsDocument.cpp >@@ -1808,6 +1808,7 @@ nsDocument::~nsDocument() > > nsAutoScriptBlocker scriptBlocker; > >+ InvalidateChildNodes(); > for (uint32_t indx = mChildren.ChildCount(); indx-- != 0; ) { > mChildren.ChildAt(indx)->UnbindFromTree(); > mChildren.RemoveChildAt(indx); >@@ -2106,6 +2107,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(ns > // Unlink the mChildren nsAttrAndChildArray. > uint32_t childCount = tmp->mChildren.ChildCount(); > if (childCount) { >+ tmp->InvalidateChildNodes(); > while (childCount-- > 0) { > // Hold a strong ref to the node when we remove it, because we may be > // the last reference to it. We need to call TakeChildAt() and >@@ -2362,6 +2364,7 @@ nsDocument::ResetToURI(nsIURI *aURI, nsI > uint32_t count = mChildren.ChildCount(); > { // Scope for update > MOZ_AUTO_DOC_UPDATE(this, UPDATE_CONTENT_MODEL, true); >+ InvalidateChildNodes(); > for (int32_t i = int32_t(count) - 1; i >= 0; i--) { > nsCOMPtr<nsIContent> content = mChildren.ChildAt(i); > >diff --git a/dom/base/nsINode.cpp b/dom/base/nsINode.cpp >--- a/dom/base/nsINode.cpp >+++ b/dom/base/nsINode.cpp >@@ -420,6 +420,21 @@ nsINode::ChildNodes() > } > > void >+nsINode::InvalidateChildNodes() >+{ >+ MOZ_ASSERT(IsElement() || !IsNodeOfType(nsINode::eATTRIBUTE)); >+ >+ nsSlots* slots = GetExistingSlots(); >+ if (!slots || !slots->mChildNodes) { >+ return; >+ } >+ >+ auto childNodes = >+ static_cast<nsParentNodeChildContentList*>(slots->mChildNodes.get()); >+ childNodes->InvalidateCache(); >+} >+ >+void > nsINode::GetTextContentInternal(nsAString& aTextContent, OOMReporter& aError) > { > SetDOMStringToNull(aTextContent); >@@ -1602,12 +1617,7 @@ nsINode::doInsertChildAt(nsIContent* aKi > } > > // Invalidate cached array of child nodes >- nsSlots* slots = GetExistingSlots(); >- if (slots && slots->mChildNodes) { >- auto childNodes = >- static_cast<nsParentNodeChildContentList*>(slots->mChildNodes.get()); >- childNodes->InvalidateCache(); >- } >+ InvalidateChildNodes(); > > nsIContent* parent = > IsNodeOfType(eDOCUMENT) ? nullptr : static_cast<nsIContent*>(this); >@@ -1931,12 +1941,7 @@ nsINode::doRemoveChildAt(uint32_t aIndex > aChildArray.RemoveChildAt(aIndex); > > // Invalidate cached array of child nodes >- nsSlots* slots = GetExistingSlots(); >- if (slots && slots->mChildNodes) { >- auto childNodes = >- static_cast<nsParentNodeChildContentList*>(slots->mChildNodes.get()); >- childNodes->InvalidateCache(); >- } >+ InvalidateChildNodes(); > > if (aNotify) { > nsNodeUtils::ContentRemoved(this, aKid, previousSibling); >diff --git a/dom/base/nsINode.h b/dom/base/nsINode.h >--- a/dom/base/nsINode.h >+++ b/dom/base/nsINode.h >@@ -1278,6 +1278,7 @@ public: > nsIContent* GetSelectionRootContent(nsIPresShell* aPresShell); > > virtual nsINodeList* ChildNodes(); >+ void InvalidateChildNodes(); > nsIContent* GetFirstChild() const { return mFirstChild; } > nsIContent* GetLastChild() const > {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
Actions:
View
|
Diff
|
Review
Attachments on
bug 1406395
:
8917285
|
8917291
|
8917653
|
8918160
|
8918161
|
8918162