зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
627c9ff582
Коммит
72ea02b6a7
|
@ -5822,22 +5822,20 @@ SplitRangeOffFromNodeResult HTMLEditRules::OutdentAroundSelection() {
|
||||||
}
|
}
|
||||||
|
|
||||||
SplitRangeOffFromNodeResult
|
SplitRangeOffFromNodeResult
|
||||||
HTMLEditRules::SplitRangeOffFromBlockAndRemoveMiddleContainer(
|
HTMLEditor::SplitRangeOffFromBlockAndRemoveMiddleContainer(
|
||||||
Element& aBlockElement, nsIContent& aStartOfRange,
|
Element& aBlockElement, nsIContent& aStartOfRange,
|
||||||
nsIContent& aEndOfRange) {
|
nsIContent& aEndOfRange) {
|
||||||
MOZ_ASSERT(IsEditorDataAvailable());
|
MOZ_ASSERT(IsEditActionDataAvailable());
|
||||||
|
|
||||||
SplitRangeOffFromNodeResult splitResult =
|
SplitRangeOffFromNodeResult splitResult =
|
||||||
MOZ_KnownLive(HTMLEditorRef())
|
SplitRangeOffFromBlock(aBlockElement, aStartOfRange, aEndOfRange);
|
||||||
.SplitRangeOffFromBlock(aBlockElement, aStartOfRange, aEndOfRange);
|
|
||||||
if (NS_WARN_IF(splitResult.Rv() == NS_ERROR_EDITOR_DESTROYED)) {
|
if (NS_WARN_IF(splitResult.Rv() == NS_ERROR_EDITOR_DESTROYED)) {
|
||||||
return splitResult;
|
return splitResult;
|
||||||
}
|
}
|
||||||
NS_WARNING_ASSERTION(splitResult.Succeeded(),
|
NS_WARNING_ASSERTION(splitResult.Succeeded(),
|
||||||
"Failed to split the range off from the block element");
|
"Failed to split the range off from the block element");
|
||||||
nsresult rv = MOZ_KnownLive(HTMLEditorRef())
|
nsresult rv = RemoveBlockContainerWithTransaction(aBlockElement);
|
||||||
.RemoveBlockContainerWithTransaction(aBlockElement);
|
if (NS_WARN_IF(Destroyed())) {
|
||||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
|
||||||
return SplitRangeOffFromNodeResult(NS_ERROR_EDITOR_DESTROYED);
|
return SplitRangeOffFromNodeResult(NS_ERROR_EDITOR_DESTROYED);
|
||||||
}
|
}
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
|
@ -8790,8 +8788,9 @@ nsresult HTMLEditRules::RemoveBlockStyle(
|
||||||
// Process any partial progress saved
|
// Process any partial progress saved
|
||||||
if (curBlock) {
|
if (curBlock) {
|
||||||
SplitRangeOffFromNodeResult removeMiddleContainerResult =
|
SplitRangeOffFromNodeResult removeMiddleContainerResult =
|
||||||
SplitRangeOffFromBlockAndRemoveMiddleContainer(
|
MOZ_KnownLive(HTMLEditorRef())
|
||||||
*curBlock, *firstNode, *lastNode);
|
.SplitRangeOffFromBlockAndRemoveMiddleContainer(
|
||||||
|
*curBlock, *firstNode, *lastNode);
|
||||||
if (NS_WARN_IF(removeMiddleContainerResult.Failed())) {
|
if (NS_WARN_IF(removeMiddleContainerResult.Failed())) {
|
||||||
return removeMiddleContainerResult.Rv();
|
return removeMiddleContainerResult.Rv();
|
||||||
}
|
}
|
||||||
|
@ -8821,8 +8820,9 @@ nsresult HTMLEditRules::RemoveBlockStyle(
|
||||||
// Process any partial progress saved
|
// Process any partial progress saved
|
||||||
if (curBlock) {
|
if (curBlock) {
|
||||||
SplitRangeOffFromNodeResult removeMiddleContainerResult =
|
SplitRangeOffFromNodeResult removeMiddleContainerResult =
|
||||||
SplitRangeOffFromBlockAndRemoveMiddleContainer(
|
MOZ_KnownLive(HTMLEditorRef())
|
||||||
*curBlock, *firstNode, *lastNode);
|
.SplitRangeOffFromBlockAndRemoveMiddleContainer(
|
||||||
|
*curBlock, *firstNode, *lastNode);
|
||||||
if (NS_WARN_IF(removeMiddleContainerResult.Failed())) {
|
if (NS_WARN_IF(removeMiddleContainerResult.Failed())) {
|
||||||
return removeMiddleContainerResult.Rv();
|
return removeMiddleContainerResult.Rv();
|
||||||
}
|
}
|
||||||
|
@ -8853,8 +8853,9 @@ nsresult HTMLEditRules::RemoveBlockStyle(
|
||||||
// handle it now. We need to remove the portion of curBlock that
|
// handle it now. We need to remove the portion of curBlock that
|
||||||
// contains [firstNode - lastNode].
|
// contains [firstNode - lastNode].
|
||||||
SplitRangeOffFromNodeResult removeMiddleContainerResult =
|
SplitRangeOffFromNodeResult removeMiddleContainerResult =
|
||||||
SplitRangeOffFromBlockAndRemoveMiddleContainer(
|
MOZ_KnownLive(HTMLEditorRef())
|
||||||
*curBlock, *firstNode, *lastNode);
|
.SplitRangeOffFromBlockAndRemoveMiddleContainer(
|
||||||
|
*curBlock, *firstNode, *lastNode);
|
||||||
if (NS_WARN_IF(removeMiddleContainerResult.Failed())) {
|
if (NS_WARN_IF(removeMiddleContainerResult.Failed())) {
|
||||||
return removeMiddleContainerResult.Rv();
|
return removeMiddleContainerResult.Rv();
|
||||||
}
|
}
|
||||||
|
@ -8876,8 +8877,9 @@ nsresult HTMLEditRules::RemoveBlockStyle(
|
||||||
// Some node that is already sans block style. Skip over it and process
|
// Some node that is already sans block style. Skip over it and process
|
||||||
// any partial progress saved.
|
// any partial progress saved.
|
||||||
SplitRangeOffFromNodeResult removeMiddleContainerResult =
|
SplitRangeOffFromNodeResult removeMiddleContainerResult =
|
||||||
SplitRangeOffFromBlockAndRemoveMiddleContainer(*curBlock, *firstNode,
|
MOZ_KnownLive(HTMLEditorRef())
|
||||||
*lastNode);
|
.SplitRangeOffFromBlockAndRemoveMiddleContainer(
|
||||||
|
*curBlock, *firstNode, *lastNode);
|
||||||
if (NS_WARN_IF(removeMiddleContainerResult.Failed())) {
|
if (NS_WARN_IF(removeMiddleContainerResult.Failed())) {
|
||||||
return removeMiddleContainerResult.Rv();
|
return removeMiddleContainerResult.Rv();
|
||||||
}
|
}
|
||||||
|
@ -8888,8 +8890,9 @@ nsresult HTMLEditRules::RemoveBlockStyle(
|
||||||
// Process any partial progress saved
|
// Process any partial progress saved
|
||||||
if (curBlock) {
|
if (curBlock) {
|
||||||
SplitRangeOffFromNodeResult removeMiddleContainerResult =
|
SplitRangeOffFromNodeResult removeMiddleContainerResult =
|
||||||
SplitRangeOffFromBlockAndRemoveMiddleContainer(*curBlock, *firstNode,
|
MOZ_KnownLive(HTMLEditorRef())
|
||||||
*lastNode);
|
.SplitRangeOffFromBlockAndRemoveMiddleContainer(
|
||||||
|
*curBlock, *firstNode, *lastNode);
|
||||||
if (NS_WARN_IF(removeMiddleContainerResult.Failed())) {
|
if (NS_WARN_IF(removeMiddleContainerResult.Failed())) {
|
||||||
return removeMiddleContainerResult.Rv();
|
return removeMiddleContainerResult.Rv();
|
||||||
}
|
}
|
||||||
|
|
|
@ -635,29 +635,6 @@ class HTMLEditRules : public TextEditRules {
|
||||||
MOZ_CAN_RUN_SCRIPT
|
MOZ_CAN_RUN_SCRIPT
|
||||||
MOZ_MUST_USE SplitRangeOffFromNodeResult OutdentAroundSelection();
|
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
|
* OutdentPartOfBlock() outdents the nodes between aStartOfOutdent and
|
||||||
* aEndOfOutdent. This splits the range off from aBlockElement first.
|
* aEndOfOutdent. This splits the range off from aBlockElement first.
|
||||||
|
|
|
@ -1631,6 +1631,28 @@ class HTMLEditor final : public TextEditor,
|
||||||
nsIContent& aStartOfMiddleElement,
|
nsIContent& aStartOfMiddleElement,
|
||||||
nsIContent& aEndOfMiddleElement);
|
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>
|
* MoveNodesIntoNewBlockquoteElement() inserts at least one <blockquote>
|
||||||
* element and moves nodes in aNodeArray into new <blockquote> elements.
|
* element and moves nodes in aNodeArray into new <blockquote> elements.
|
||||||
|
|
Загрузка…
Ссылка в новой задаче