Skip to content

Commit

Permalink
Bug 1655391 - Make new stack only class handle deletion at current bl…
Browse files Browse the repository at this point in the history
…ock boundary r=m_kato

This patch creates new stack only class, `HTMLEditor::AutoBlockElementsJoiner`
and splits `HTMLEditor::HandleDeleteCollapsedSelectionAtCurrentBlockBoundary()`
to considering the content nodes to be joined part and doing join the nodes
part.

Differential Revision: https://phabricator.services.mozilla.com/D85567

UltraBlame original commit: f3411b0d664666e80a9bfac96ee2d7b4ef9fba68
  • Loading branch information
marco-c committed Aug 6, 2020
1 parent 734da30 commit 11969a2
Show file tree
Hide file tree
Showing 2 changed files with 259 additions and 97 deletions.
191 changes: 108 additions & 83 deletions editor/libeditor/HTMLEditSubActionHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12736,21 +12736,44 @@ NS_ERROR_FAILURE
)
;
}
EditActionResult
result
=
HandleDeleteCollapsedSelectionAtCurrentBlockBoundary
AutoBlockElementsJoiner
joiner
;
if
(
aDirectionAndAmount
MOZ_KnownLive
!
joiner
.
PrepareToDeleteCollapsedSelectionAtCurrentBlockBoundary
(
*
this
aDirectionAndAmount
*
scanFromStartPointResult
.
ElementPtr
(
)
startPoint
)
)
{
return
EditActionCanceled
(
)
;
}
EditActionResult
result
=
joiner
.
Run
(
*
this
startPoint
)
;
Expand All @@ -12765,12 +12788,20 @@ Succeeded
HTMLEditor
:
:
HandleDeleteCollapsedSelectionAtCurrentBlockBoundary
AutoBlockElementsJoiner
:
:
Run
(
)
failed
"
"
failed
(
current
block
boundary
)
"
)
;
Expand Down Expand Up @@ -15547,12 +15578,19 @@ return
result
;
}
EditActionResult
bool
HTMLEditor
:
:
HandleDeleteCollapsedSelectionAtCurrentBlockBoundary
AutoBlockElementsJoiner
:
:
PrepareToDeleteCollapsedSelectionAtCurrentBlockBoundary
(
const
HTMLEditor
&
aHTMLEditor
nsIEditor
:
:
Expand All @@ -15569,11 +15607,20 @@ aCaretPoint
{
MOZ_ASSERT
(
aHTMLEditor
.
IsEditActionDataAvailable
(
)
)
;
mMode
=
Mode
:
:
JoinCurrentBlock
;
if
(
HTMLEditUtils
Expand All @@ -15587,18 +15634,9 @@ aCurrentBlockElement
)
{
return
EditActionCanceled
(
)
false
;
}
nsCOMPtr
<
nsINode
>
leftNode
rightNode
;
if
(
aDirectionAndAmount
Expand All @@ -15610,76 +15648,100 @@ nsIEditor
ePrevious
)
{
leftNode
mLeftContent
=
aHTMLEditor
.
GetPreviousEditableHTMLNode
(
aCurrentBlockElement
)
;
rightNode
mRightContent
=
aCaretPoint
.
GetContainer
GetContainerAsContent
(
)
;
}
else
{
rightNode
mRightContent
=
aHTMLEditor
.
GetNextEditableHTMLNode
(
aCurrentBlockElement
)
;
leftNode
mLeftContent
=
aCaretPoint
.
GetContainer
GetContainerAsContent
(
)
;
}
if
(
!
leftNode
mLeftContent
|
|
!
rightNode
mRightContent
)
{
return
EditActionCanceled
(
)
false
;
}
if
(
return
!
HTMLEditor
:
:
NodesInDifferentTableElements
(
*
leftNode
mLeftContent
*
rightNode
mRightContent
)
;
}
EditActionResult
HTMLEditor
:
:
AutoBlockElementsJoiner
:
:
HandleDeleteCollapsedSelectionAtCurrentBlockBoundary
(
HTMLEditor
&
aHTMLEditor
const
EditorDOMPoint
&
aCaretPoint
)
{
return
EditActionCanceled
MOZ_ASSERT
(
mLeftContent
)
;
MOZ_ASSERT
(
mRightContent
)
;
}
EditActionResult
result
(
Expand All @@ -15696,70 +15758,31 @@ aCaretPoint
AutoTrackDOMPoint
tracker
(
aHTMLEditor
.
RangeUpdaterRef
(
)
&
pointToPutCaret
)
;
if
(
NS_WARN_IF
(
!
leftNode
-
>
IsContent
(
)
)
|
|
NS_WARN_IF
(
!
rightNode
-
>
IsContent
(
)
)
)
{
return
EditActionResult
(
NS_ERROR_FAILURE
)
;
}
result
|
=
aHTMLEditor
.
TryToJoinBlocksWithTransaction
(
MOZ_KnownLive
(
*
leftNode
-
>
AsContent
(
)
mLeftContent
)
MOZ_KnownLive
(
*
rightNode
-
>
AsContent
(
)
mRightContent
)
)
;
Expand Down Expand Up @@ -15799,6 +15822,8 @@ result
nsresult
rv
=
aHTMLEditor
.
CollapseSelectionTo
(
pointToPutCaret
Expand Down
Loading

0 comments on commit 11969a2

Please sign in to comment.