From c97adaf6707c60245c41c8f83e6d380662c37345 Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Wed, 16 May 2018 14:54:33 +0900 Subject: [PATCH] Bug 1460509 - part 57: Mark HTMLEditRules::AlignInnerBlocks() as MOZ_MUST_USE since it may cause destroying the editor r=m_kato MozReview-Commit-ID: 8hBJPn1shZu --HG-- extra : rebase_source : 2df70cd07015fa0895a5d7540c1179107088a8e2 --- editor/libeditor/HTMLEditRules.cpp | 15 ++++++++------- editor/libeditor/HTMLEditRules.h | 11 ++++++++++- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/editor/libeditor/HTMLEditRules.cpp b/editor/libeditor/HTMLEditRules.cpp index b73731fc90ff..1cab0e1a0f8e 100644 --- a/editor/libeditor/HTMLEditRules.cpp +++ b/editor/libeditor/HTMLEditRules.cpp @@ -5872,10 +5872,15 @@ HTMLEditRules::WillAlign(const nsAString& aAlignType, continue; } if (HTMLEditUtils::IsList(atCurNode.GetContainer())) { - // If we don't use CSS, add a contraint to list element: they have to - // be inside another list, i.e., >= second level of nesting + // If we don't use CSS, add a content to list element: they have to + // be inside another list, i.e., >= second level of nesting. + // XXX AlignInnerBlocks() handles list item elements and table cells. + // Is it intentional to change alignment of nested other type + // descendants too? rv = AlignInnerBlocks(*curNode, aAlignType); - NS_ENSURE_SUCCESS(rv, rv); + if (NS_WARN_IF(NS_FAILED(rv))) { + return rv; + } curDiv = nullptr; continue; } @@ -5924,10 +5929,6 @@ HTMLEditRules::WillAlign(const nsAString& aAlignType, return NS_OK; } - -/** - * AlignInnerBlocks() aligns inside table cells or list items. - */ nsresult HTMLEditRules::AlignInnerBlocks(nsINode& aNode, const nsAString& aAlignType) diff --git a/editor/libeditor/HTMLEditRules.h b/editor/libeditor/HTMLEditRules.h index 512976182405..4871d36909a6 100644 --- a/editor/libeditor/HTMLEditRules.h +++ b/editor/libeditor/HTMLEditRules.h @@ -401,7 +401,16 @@ protected: */ MOZ_MUST_USE nsresult DidAbsolutePosition(); - nsresult AlignInnerBlocks(nsINode& aNode, const nsAString& aAlignType); + /** + * AlignInnerBlocks() calls AlignBlockContents() for every list item element + * and table cell element in aNode. + * + * @param aNode The node whose descendants should be aligned + * to aAlignType. + * @param aAlignType New value of align attribute of
. + */ + MOZ_MUST_USE nsresult + AlignInnerBlocks(nsINode& aNode, const nsAString& aAlignType); /** * AlignBlockContents() sets align attribute of
element which is