mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-12 18:50:08 +00:00
Bug 1314442 - Limit editor's editability to the right subtree. r=masayuki
--HG-- extra : rebase_source : bb528d3c82c962dc31883654a81f87285e49e2b9
This commit is contained in:
parent
33daa90e3c
commit
6dabfdba6b
@ -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)) {
|
||||
|
@ -940,6 +940,10 @@ protected:
|
||||
int32_t& aMarginLeft,
|
||||
int32_t& aMarginTop);
|
||||
|
||||
bool IsInObservedSubtree(nsIDocument* aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild);
|
||||
|
||||
// resizing
|
||||
bool mIsObjectResizingEnabled;
|
||||
bool mIsResizing;
|
||||
|
Loading…
x
Reference in New Issue
Block a user