Bug 1314442 - Limit editor's editability to the right subtree. r=masayuki

--HG--
extra : rebase_source : bb528d3c82c962dc31883654a81f87285e49e2b9
This commit is contained in:
Olli Pettay 2016-11-29 17:07:27 -05:00
parent 33daa90e3c
commit 6dabfdba6b
2 changed files with 30 additions and 1 deletions

View File

@ -3235,6 +3235,27 @@ HTMLEditor::ContentInserted(nsIDocument* aDocument,
eInserted);
}
bool
HTMLEditor::IsInObservedSubtree(nsIDocument* aDocument,
nsIContent* aContainer,
nsIContent* aChild)
{
if (!aChild) {
return false;
}
Element* root = GetRoot();
// To be super safe here, check both ChromeOnlyAccess and GetBindingParent.
// That catches (also unbound) native anonymous content, XBL and ShadowDOM.
if (root &&
(root->ChromeOnlyAccess() != aChild->ChromeOnlyAccess() ||
root->GetBindingParent() != aChild->GetBindingParent())) {
return false;
}
return !aChild->ChromeOnlyAccess() && !aChild->GetBindingParent();
}
void
HTMLEditor::DoContentInserted(nsIDocument* aDocument,
nsIContent* aContainer,
@ -3242,7 +3263,7 @@ HTMLEditor::DoContentInserted(nsIDocument* aDocument,
int32_t aIndexInContainer,
InsertedOrAppended aInsertedOrAppended)
{
if (!aChild) {
if (!IsInObservedSubtree(aDocument, aContainer, aChild)) {
return;
}
@ -3290,6 +3311,10 @@ HTMLEditor::ContentRemoved(nsIDocument* aDocument,
int32_t aIndexInContainer,
nsIContent* aPreviousSibling)
{
if (!IsInObservedSubtree(aDocument, aContainer, aChild)) {
return;
}
nsCOMPtr<nsIHTMLEditor> kungFuDeathGrip(this);
if (SameCOMIdentity(aChild, mRootElement)) {

View File

@ -940,6 +940,10 @@ protected:
int32_t& aMarginLeft,
int32_t& aMarginTop);
bool IsInObservedSubtree(nsIDocument* aDocument,
nsIContent* aContainer,
nsIContent* aChild);
// resizing
bool mIsObjectResizingEnabled;
bool mIsResizing;