Bug 1374999 - stylo: Iterate over manually created editor NAC. r=bholley

MozReview-Commit-ID: 1CiWVfYbxaJ

--HG--
extra : rebase_source : 48ea8a0f1cb0a4072632f706ffd99529bb4447b1
This commit is contained in:
Cameron McCormack 2017-06-27 17:34:48 -07:00
Родитель 237975e280
Коммит e86592ca35
4 изменённых файлов: 33 добавлений и 0 удалений

Просмотреть файл

@ -10268,6 +10268,12 @@ nsContentUtils::AppendNativeAnonymousChildren(
}
}
// Get manually created NAC (editor resize handles, etc.).
if (auto nac = static_cast<ManualNAC*>(
aContent->GetProperty(nsGkAtoms::manualNACProperty))) {
aKids.AppendElements(*nac);
}
// The root scroll frame is not the primary frame of the root element.
// Detect and handle this case.
if (!(aFlags & nsIContent::eSkipDocumentLevelNativeAnonymousContent) &&

Просмотреть файл

@ -195,6 +195,12 @@ struct EventNameMapping
typedef bool (*CallOnRemoteChildFunction) (mozilla::dom::TabParent* aTabParent,
void* aArg);
namespace mozilla {
// 16 seems to be the maximum number of manual NAC nodes that editor
// creates for a given element.
typedef AutoTArray<mozilla::dom::Element*,16> ManualNAC;
}
class nsContentUtils
{
friend class nsAutoScriptBlockerSuppressNodeRemoved;

Просмотреть файл

@ -2161,6 +2161,7 @@ GK_ATOM(apzCallbackTransform, "apzCallbackTransform")
GK_ATOM(restylableAnonymousNode, "restylableAnonymousNode")
GK_ATOM(paintRequestTime, "PaintRequestTime")
GK_ATOM(pseudoProperty, "PseudoProperty") // CSSPseudoElementType
GK_ATOM(manualNACProperty, "ManualNACProperty") // ManualNAC*
// Languages for lang-specific transforms
GK_ATOM(Japanese, "ja")

Просмотреть файл

@ -226,6 +226,16 @@ HTMLEditor::CreateAnonymousElement(nsIAtom* aTag,
}
}
// Record the NAC on the element, so that AllChildrenIterator can find it.
auto nac = static_cast<ManualNAC*>(
parentContent->GetProperty(nsGkAtoms::manualNACProperty));
if (!nac) {
nac = new ManualNAC();
parentContent->SetProperty(nsGkAtoms::manualNACProperty, nac,
nsINode::DeleteProperty<ManualNAC>);
}
nac->AppendElement(newContent);
ElementDeletionObserver* observer =
new ElementDeletionObserver(newContent, parentContent);
NS_ADDREF(observer); // NodeWillBeDestroyed releases.
@ -303,6 +313,16 @@ HTMLEditor::DeleteRefToAnonymousNode(nsIContent* aContent,
}
}
}
// Remove reference from the parent element.
auto nac = static_cast<mozilla::ManualNAC*>(
aParentContent->GetProperty(nsGkAtoms::manualNACProperty));
MOZ_ASSERT(nac);
nac->RemoveElement(aContent);
if (nac->IsEmpty()) {
aParentContent->DeleteProperty(nsGkAtoms::manualNACProperty);
}
aContent->UnbindFromTree();
}