зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1460509 - part 35: Make HTMLEditRules::ApplyBlockStyle() return NS_ERROR_EDITOR_DESTROYED if it causes destroying the editor r=m_kato
MozReview-Commit-ID: 1ddHNx7lF9P --HG-- extra : rebase_source : 660c205f47473daade92145385d047d482ded72e
This commit is contained in:
Родитель
76e7240d35
Коммит
6cb4ec14c0
|
@ -8156,10 +8156,6 @@ HTMLEditRules::RemoveBlockStyle(nsTArray<OwningNonNull<nsINode>>& aNodeArray)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* ApplyBlockStyle() does whatever it takes to make the list of nodes into one
|
||||
* or more blocks of type aBlockTag.
|
||||
*/
|
||||
nsresult
|
||||
HTMLEditRules::ApplyBlockStyle(nsTArray<OwningNonNull<nsINode>>& aNodeArray,
|
||||
nsAtom& aBlockTag)
|
||||
|
@ -8194,6 +8190,9 @@ HTMLEditRules::ApplyBlockStyle(nsTArray<OwningNonNull<nsINode>>& aNodeArray,
|
|||
newBlock =
|
||||
HTMLEditorRef().ReplaceContainerAndCloneAttributesWithTransaction(
|
||||
*curNode->AsElement(), aBlockTag);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
if (NS_WARN_IF(!newBlock)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -8230,6 +8229,9 @@ HTMLEditRules::ApplyBlockStyle(nsTArray<OwningNonNull<nsINode>>& aNodeArray,
|
|||
RefPtr<Element> theBlock =
|
||||
HTMLEditorRef().CreateNodeWithTransaction(aBlockTag,
|
||||
splitNodeResult.SplitPoint());
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
if (NS_WARN_IF(!theBlock)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -8245,6 +8247,9 @@ HTMLEditRules::ApplyBlockStyle(nsTArray<OwningNonNull<nsINode>>& aNodeArray,
|
|||
// Forget any previous block used for previous inline nodes
|
||||
curBlock = nullptr;
|
||||
nsresult rv = HTMLEditorRef().DeleteNodeWithTransaction(*curNode);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -8261,6 +8266,9 @@ HTMLEditRules::ApplyBlockStyle(nsTArray<OwningNonNull<nsINode>>& aNodeArray,
|
|||
curBlock =
|
||||
HTMLEditorRef().CreateNodeWithTransaction(aBlockTag,
|
||||
splitNodeResult.SplitPoint());
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
if (NS_WARN_IF(!curBlock)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -8270,6 +8278,9 @@ HTMLEditRules::ApplyBlockStyle(nsTArray<OwningNonNull<nsINode>>& aNodeArray,
|
|||
nsresult rv =
|
||||
HTMLEditorRef().MoveNodeToEndWithTransaction(*curNode->AsContent(),
|
||||
*curBlock);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -8302,6 +8313,9 @@ HTMLEditRules::ApplyBlockStyle(nsTArray<OwningNonNull<nsINode>>& aNodeArray,
|
|||
curBlock =
|
||||
HTMLEditorRef().CreateNodeWithTransaction(
|
||||
aBlockTag, splitNodeResult.SplitPoint());
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
if (NS_WARN_IF(!curBlock)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -8322,6 +8336,9 @@ HTMLEditRules::ApplyBlockStyle(nsTArray<OwningNonNull<nsINode>>& aNodeArray,
|
|||
nsresult rv =
|
||||
HTMLEditorRef().MoveNodeToEndWithTransaction(*curNode->AsContent(),
|
||||
*curBlock);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
return NS_ERROR_EDITOR_DESTROYED;
|
||||
}
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -505,8 +505,9 @@ protected:
|
|||
* @param aNodeArray Must be descendants of a node.
|
||||
* @param aBlockTag The element name of new block elements.
|
||||
*/
|
||||
nsresult ApplyBlockStyle(nsTArray<OwningNonNull<nsINode>>& aNodeArray,
|
||||
nsAtom& aBlockTag);
|
||||
MOZ_MUST_USE nsresult
|
||||
ApplyBlockStyle(nsTArray<OwningNonNull<nsINode>>& aNodeArray,
|
||||
nsAtom& aBlockTag);
|
||||
|
||||
nsresult MakeBlockquote(nsTArray<OwningNonNull<nsINode>>& aNodeArray);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче