mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 08:15:31 +00:00
Bug 1574852 - part 35: Move HTMLEditRules::SplitRangeOffFromBlockAndRemoveMiddleContainer()
to HTMLEditor
r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D43196 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
627c9ff582
commit
72ea02b6a7
@ -5822,22 +5822,20 @@ SplitRangeOffFromNodeResult HTMLEditRules::OutdentAroundSelection() {
|
||||
}
|
||||
|
||||
SplitRangeOffFromNodeResult
|
||||
HTMLEditRules::SplitRangeOffFromBlockAndRemoveMiddleContainer(
|
||||
HTMLEditor::SplitRangeOffFromBlockAndRemoveMiddleContainer(
|
||||
Element& aBlockElement, nsIContent& aStartOfRange,
|
||||
nsIContent& aEndOfRange) {
|
||||
MOZ_ASSERT(IsEditorDataAvailable());
|
||||
MOZ_ASSERT(IsEditActionDataAvailable());
|
||||
|
||||
SplitRangeOffFromNodeResult splitResult =
|
||||
MOZ_KnownLive(HTMLEditorRef())
|
||||
.SplitRangeOffFromBlock(aBlockElement, aStartOfRange, aEndOfRange);
|
||||
SplitRangeOffFromBlock(aBlockElement, aStartOfRange, aEndOfRange);
|
||||
if (NS_WARN_IF(splitResult.Rv() == NS_ERROR_EDITOR_DESTROYED)) {
|
||||
return splitResult;
|
||||
}
|
||||
NS_WARNING_ASSERTION(splitResult.Succeeded(),
|
||||
"Failed to split the range off from the block element");
|
||||
nsresult rv = MOZ_KnownLive(HTMLEditorRef())
|
||||
.RemoveBlockContainerWithTransaction(aBlockElement);
|
||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||
nsresult rv = RemoveBlockContainerWithTransaction(aBlockElement);
|
||||
if (NS_WARN_IF(Destroyed())) {
|
||||
return SplitRangeOffFromNodeResult(NS_ERROR_EDITOR_DESTROYED);
|
||||
}
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
@ -8790,8 +8788,9 @@ nsresult HTMLEditRules::RemoveBlockStyle(
|
||||
// Process any partial progress saved
|
||||
if (curBlock) {
|
||||
SplitRangeOffFromNodeResult removeMiddleContainerResult =
|
||||
SplitRangeOffFromBlockAndRemoveMiddleContainer(
|
||||
*curBlock, *firstNode, *lastNode);
|
||||
MOZ_KnownLive(HTMLEditorRef())
|
||||
.SplitRangeOffFromBlockAndRemoveMiddleContainer(
|
||||
*curBlock, *firstNode, *lastNode);
|
||||
if (NS_WARN_IF(removeMiddleContainerResult.Failed())) {
|
||||
return removeMiddleContainerResult.Rv();
|
||||
}
|
||||
@ -8821,8 +8820,9 @@ nsresult HTMLEditRules::RemoveBlockStyle(
|
||||
// Process any partial progress saved
|
||||
if (curBlock) {
|
||||
SplitRangeOffFromNodeResult removeMiddleContainerResult =
|
||||
SplitRangeOffFromBlockAndRemoveMiddleContainer(
|
||||
*curBlock, *firstNode, *lastNode);
|
||||
MOZ_KnownLive(HTMLEditorRef())
|
||||
.SplitRangeOffFromBlockAndRemoveMiddleContainer(
|
||||
*curBlock, *firstNode, *lastNode);
|
||||
if (NS_WARN_IF(removeMiddleContainerResult.Failed())) {
|
||||
return removeMiddleContainerResult.Rv();
|
||||
}
|
||||
@ -8853,8 +8853,9 @@ nsresult HTMLEditRules::RemoveBlockStyle(
|
||||
// handle it now. We need to remove the portion of curBlock that
|
||||
// contains [firstNode - lastNode].
|
||||
SplitRangeOffFromNodeResult removeMiddleContainerResult =
|
||||
SplitRangeOffFromBlockAndRemoveMiddleContainer(
|
||||
*curBlock, *firstNode, *lastNode);
|
||||
MOZ_KnownLive(HTMLEditorRef())
|
||||
.SplitRangeOffFromBlockAndRemoveMiddleContainer(
|
||||
*curBlock, *firstNode, *lastNode);
|
||||
if (NS_WARN_IF(removeMiddleContainerResult.Failed())) {
|
||||
return removeMiddleContainerResult.Rv();
|
||||
}
|
||||
@ -8876,8 +8877,9 @@ nsresult HTMLEditRules::RemoveBlockStyle(
|
||||
// Some node that is already sans block style. Skip over it and process
|
||||
// any partial progress saved.
|
||||
SplitRangeOffFromNodeResult removeMiddleContainerResult =
|
||||
SplitRangeOffFromBlockAndRemoveMiddleContainer(*curBlock, *firstNode,
|
||||
*lastNode);
|
||||
MOZ_KnownLive(HTMLEditorRef())
|
||||
.SplitRangeOffFromBlockAndRemoveMiddleContainer(
|
||||
*curBlock, *firstNode, *lastNode);
|
||||
if (NS_WARN_IF(removeMiddleContainerResult.Failed())) {
|
||||
return removeMiddleContainerResult.Rv();
|
||||
}
|
||||
@ -8888,8 +8890,9 @@ nsresult HTMLEditRules::RemoveBlockStyle(
|
||||
// Process any partial progress saved
|
||||
if (curBlock) {
|
||||
SplitRangeOffFromNodeResult removeMiddleContainerResult =
|
||||
SplitRangeOffFromBlockAndRemoveMiddleContainer(*curBlock, *firstNode,
|
||||
*lastNode);
|
||||
MOZ_KnownLive(HTMLEditorRef())
|
||||
.SplitRangeOffFromBlockAndRemoveMiddleContainer(
|
||||
*curBlock, *firstNode, *lastNode);
|
||||
if (NS_WARN_IF(removeMiddleContainerResult.Failed())) {
|
||||
return removeMiddleContainerResult.Rv();
|
||||
}
|
||||
|
@ -635,29 +635,6 @@ class HTMLEditRules : public TextEditRules {
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
MOZ_MUST_USE SplitRangeOffFromNodeResult OutdentAroundSelection();
|
||||
|
||||
/**
|
||||
* SplitRangeOffFromBlockAndRemoveMiddleContainer() splits the nodes
|
||||
* between aStartOfRange and aEndOfRange, then, removes the middle element
|
||||
* and moves its content to where the middle element was.
|
||||
*
|
||||
* @param aBlockElement The node which will be split.
|
||||
* @param aStartOfRange The first node which will be unwrapped
|
||||
* from aBlockElement.
|
||||
* @param aEndOfRange The last node which will be unwrapped from
|
||||
* aBlockElement.
|
||||
* @return The left content is new created left
|
||||
* element of aBlockElement.
|
||||
* The right content is split element,
|
||||
* i.e., must be aBlockElement.
|
||||
* The middle content is nullptr since
|
||||
* removing it is the job of this method.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
MOZ_MUST_USE SplitRangeOffFromNodeResult
|
||||
SplitRangeOffFromBlockAndRemoveMiddleContainer(Element& aBlockElement,
|
||||
nsIContent& aStartOfRange,
|
||||
nsIContent& aEndOfRange);
|
||||
|
||||
/**
|
||||
* OutdentPartOfBlock() outdents the nodes between aStartOfOutdent and
|
||||
* aEndOfOutdent. This splits the range off from aBlockElement first.
|
||||
|
@ -1631,6 +1631,28 @@ class HTMLEditor final : public TextEditor,
|
||||
nsIContent& aStartOfMiddleElement,
|
||||
nsIContent& aEndOfMiddleElement);
|
||||
|
||||
/**
|
||||
* SplitRangeOffFromBlockAndRemoveMiddleContainer() splits the nodes
|
||||
* between aStartOfRange and aEndOfRange, then, removes the middle element
|
||||
* and moves its content to where the middle element was.
|
||||
*
|
||||
* @param aBlockElement The node which will be split.
|
||||
* @param aStartOfRange The first node which will be unwrapped
|
||||
* from aBlockElement.
|
||||
* @param aEndOfRange The last node which will be unwrapped from
|
||||
* aBlockElement.
|
||||
* @return The left content is new created left
|
||||
* element of aBlockElement.
|
||||
* The right content is split element,
|
||||
* i.e., must be aBlockElement.
|
||||
* The middle content is nullptr since
|
||||
* removing it is the job of this method.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT MOZ_MUST_USE SplitRangeOffFromNodeResult
|
||||
SplitRangeOffFromBlockAndRemoveMiddleContainer(Element& aBlockElement,
|
||||
nsIContent& aStartOfRange,
|
||||
nsIContent& aEndOfRange);
|
||||
|
||||
/**
|
||||
* MoveNodesIntoNewBlockquoteElement() inserts at least one <blockquote>
|
||||
* element and moves nodes in aNodeArray into new <blockquote> elements.
|
||||
|
Loading…
Reference in New Issue
Block a user