@@ -5686,7 +5686,8 @@ SplitRangeOffFromNodeResult HTMLEditRules::OutdentAroundSelection() {
56865686 nsCOMPtr<nsIContent> rightContentOfLastOutdented;
56875687 nsCOMPtr<Element> curBlockQuote;
56885688 nsCOMPtr<nsIContent> firstBQChild, lastBQChild;
5689- bool curBlockQuoteIsIndentedWithCSS = false ;
5689+ HTMLEditor::BlockIndentedWith curBlockIndentedWith =
5690+ HTMLEditor::BlockIndentedWith::HTML ;
56905691 for (uint32_t i = 0 ; i < arrayOfNodes.Length (); i++) {
56915692 if (!arrayOfNodes[i]->IsContent ()) {
56925693 continue ;
@@ -5706,8 +5707,9 @@ SplitRangeOffFromNodeResult HTMLEditRules::OutdentAroundSelection() {
57065707 // with any curBlockQuote first.
57075708 if (curBlockQuote) {
57085709 SplitRangeOffFromNodeResult outdentResult =
5709- OutdentPartOfBlock (*curBlockQuote, *firstBQChild, *lastBQChild,
5710- curBlockQuoteIsIndentedWithCSS);
5710+ MOZ_KnownLive (HTMLEditorRef ())
5711+ .OutdentPartOfBlock (*curBlockQuote, *firstBQChild, *lastBQChild,
5712+ curBlockIndentedWith);
57115713 if (NS_WARN_IF (outdentResult.Failed ())) {
57125714 return outdentResult;
57135715 }
@@ -5717,7 +5719,7 @@ SplitRangeOffFromNodeResult HTMLEditRules::OutdentAroundSelection() {
57175719 curBlockQuote = nullptr ;
57185720 firstBQChild = nullptr ;
57195721 lastBQChild = nullptr ;
5720- curBlockQuoteIsIndentedWithCSS = false ;
5722+ curBlockIndentedWith = HTMLEditor::BlockIndentedWith:: HTML ;
57215723 }
57225724 rv = MOZ_KnownLive (HTMLEditorRef ())
57235725 .RemoveBlockContainerWithTransaction (
@@ -5763,8 +5765,9 @@ SplitRangeOffFromNodeResult HTMLEditRules::OutdentAroundSelection() {
57635765 // this list item.
57645766 if (curBlockQuote) {
57655767 SplitRangeOffFromNodeResult outdentResult =
5766- OutdentPartOfBlock (*curBlockQuote, *firstBQChild, *lastBQChild,
5767- curBlockQuoteIsIndentedWithCSS);
5768+ MOZ_KnownLive (HTMLEditorRef ())
5769+ .OutdentPartOfBlock (*curBlockQuote, *firstBQChild, *lastBQChild,
5770+ curBlockIndentedWith);
57685771 if (NS_WARN_IF (outdentResult.Failed ())) {
57695772 return outdentResult;
57705773 }
@@ -5774,7 +5777,7 @@ SplitRangeOffFromNodeResult HTMLEditRules::OutdentAroundSelection() {
57745777 curBlockQuote = nullptr ;
57755778 firstBQChild = nullptr ;
57765779 lastBQChild = nullptr ;
5777- curBlockQuoteIsIndentedWithCSS = false ;
5780+ curBlockIndentedWith = HTMLEditor::BlockIndentedWith:: HTML ;
57785781 }
57795782 // XXX `curNode` could become different element since
57805783 // `OutdentPartOfBlock()` may run mutaiton event listeners.
@@ -5800,8 +5803,9 @@ SplitRangeOffFromNodeResult HTMLEditRules::OutdentAroundSelection() {
58005803 // let's handle it now. We need to remove the portion of
58015804 // curBlockQuote that contains [firstBQChild - lastBQChild].
58025805 SplitRangeOffFromNodeResult outdentResult =
5803- OutdentPartOfBlock (*curBlockQuote, *firstBQChild, *lastBQChild,
5804- curBlockQuoteIsIndentedWithCSS);
5806+ MOZ_KnownLive (HTMLEditorRef ())
5807+ .OutdentPartOfBlock (*curBlockQuote, *firstBQChild, *lastBQChild,
5808+ curBlockIndentedWith);
58055809 if (NS_WARN_IF (outdentResult.Failed ())) {
58065810 return outdentResult;
58075811 }
@@ -5811,13 +5815,13 @@ SplitRangeOffFromNodeResult HTMLEditRules::OutdentAroundSelection() {
58115815 curBlockQuote = nullptr ;
58125816 firstBQChild = nullptr ;
58135817 lastBQChild = nullptr ;
5814- curBlockQuoteIsIndentedWithCSS = false ;
5818+ // curBlockIndentedWith = HTMLEditor::BlockIndentedWith::HTML ;
58155819 // Fall out and handle curNode
58165820 }
58175821
58185822 // Are we inside a blockquote?
58195823 OwningNonNull<nsINode> n = curNode;
5820- curBlockQuoteIsIndentedWithCSS = false ;
5824+ curBlockIndentedWith = HTMLEditor::BlockIndentedWith:: HTML ;
58215825 // Keep looking up the hierarchy as long as we don't hit the body or the
58225826 // active editing host or a table element (other than an entire table)
58235827 while (!n->IsHTMLElement (nsGkAtoms::body) &&
@@ -5854,7 +5858,7 @@ SplitRangeOffFromNodeResult HTMLEditRules::OutdentAroundSelection() {
58545858 curBlockQuote = n->AsElement ();
58555859 firstBQChild = curNode;
58565860 lastBQChild = curNode;
5857- curBlockQuoteIsIndentedWithCSS = true ;
5861+ curBlockIndentedWith = HTMLEditor::BlockIndentedWith:: CSS ;
58585862 break ;
58595863 }
58605864 }
@@ -5961,8 +5965,9 @@ SplitRangeOffFromNodeResult HTMLEditRules::OutdentAroundSelection() {
59615965
59625966 // We have a <blockquote> we haven't finished handling.
59635967 SplitRangeOffFromNodeResult outdentResult =
5964- OutdentPartOfBlock (*curBlockQuote, *firstBQChild, *lastBQChild,
5965- curBlockQuoteIsIndentedWithCSS);
5968+ MOZ_KnownLive (HTMLEditorRef ())
5969+ .OutdentPartOfBlock (*curBlockQuote, *firstBQChild, *lastBQChild,
5970+ curBlockIndentedWith);
59665971 if (NS_WARN_IF (outdentResult.Failed ())) {
59675972 return outdentResult;
59685973 }
@@ -6028,28 +6033,25 @@ SplitRangeOffFromNodeResult HTMLEditor::SplitRangeOffFromBlock(
60286033 return SplitRangeOffFromNodeResult (splitAtStartResult, splitAtEndResult);
60296034}
60306035
6031- SplitRangeOffFromNodeResult HTMLEditRules ::OutdentPartOfBlock (
6036+ SplitRangeOffFromNodeResult HTMLEditor ::OutdentPartOfBlock (
60326037 Element& aBlockElement, nsIContent& aStartOfOutdent,
6033- nsIContent& aEndOfOutdent, bool aIsBlockIndentedWithCSS ) {
6034- MOZ_ASSERT (IsEditorDataAvailable ());
6038+ nsIContent& aEndOfOutdent, BlockIndentedWith aBlockIndentedWith ) {
6039+ MOZ_ASSERT (IsEditActionDataAvailable ());
60356040
60366041 SplitRangeOffFromNodeResult splitResult =
6037- MOZ_KnownLive (HTMLEditorRef ())
6038- .SplitRangeOffFromBlock (aBlockElement, aStartOfOutdent,
6039- aEndOfOutdent);
6040- if (NS_WARN_IF (splitResult.Rv () == NS_ERROR_EDITOR_DESTROYED )) {
6042+ SplitRangeOffFromBlock (aBlockElement, aStartOfOutdent, aEndOfOutdent);
6043+ if (NS_WARN_IF (splitResult.EditorDestroyed ())) {
60416044 return SplitRangeOffFromNodeResult (NS_ERROR_EDITOR_DESTROYED );
60426045 }
60436046
60446047 if (NS_WARN_IF (!splitResult.GetMiddleContentAsElement ())) {
60456048 return SplitRangeOffFromNodeResult (NS_ERROR_FAILURE );
60466049 }
60476050
6048- if (!aIsBlockIndentedWithCSS) {
6049- nsresult rv = MOZ_KnownLive (HTMLEditorRef ())
6050- .RemoveBlockContainerWithTransaction (MOZ_KnownLive (
6051- *splitResult.GetMiddleContentAsElement ()));
6052- if (NS_WARN_IF (!CanHandleEditAction ())) {
6051+ if (aBlockIndentedWith == BlockIndentedWith::HTML ) {
6052+ nsresult rv = RemoveBlockContainerWithTransaction (
6053+ MOZ_KnownLive (*splitResult.GetMiddleContentAsElement ()));
6054+ if (NS_WARN_IF (Destroyed ())) {
60536055 return SplitRangeOffFromNodeResult (NS_ERROR_EDITOR_DESTROYED );
60546056 }
60556057 if (NS_WARN_IF (NS_FAILED (rv))) {
@@ -6060,11 +6062,9 @@ SplitRangeOffFromNodeResult HTMLEditRules::OutdentPartOfBlock(
60606062 }
60616063
60626064 if (splitResult.GetMiddleContentAsElement ()) {
6063- nsresult rv =
6064- MOZ_KnownLive (HTMLEditorRef ())
6065- .ChangeMarginStart (
6066- MOZ_KnownLive (*splitResult.GetMiddleContentAsElement ()),
6067- HTMLEditor::ChangeMargin::Decrease);
6065+ nsresult rv = ChangeMarginStart (
6066+ MOZ_KnownLive (*splitResult.GetMiddleContentAsElement ()),
6067+ ChangeMargin::Decrease);
60686068 if (NS_WARN_IF (NS_FAILED (rv))) {
60696069 return SplitRangeOffFromNodeResult (rv);
60706070 }
0 commit comments