From d4cd571021b3651f4f2c6f3a2846e48ad726bcae Mon Sep 17 00:00:00 2001 From: Gaming4JC Date: Fri, 22 May 2020 11:48:40 -0400 Subject: Bug 1316302 - Part 3: Create EditActionResult class for making the methods which return nsresult, handled and canceled with out params In a lot of places, edit action handlers and their helper methods return nsresult and aHandled and aCanceled with out params. However, the out params cause the code complicated since: * it's not unclear if the method will overwrite aHandled and aCanceled value. * callers need to create temporary variable event if some of them are not necessary. This patch rewrites the helper methods of HTMLEditRules::WillDeleteSelection() with it. Tag #1563 --- editor/libeditor/HTMLEditRules.h | 54 ++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 30 deletions(-) (limited to 'editor/libeditor/HTMLEditRules.h') diff --git a/editor/libeditor/HTMLEditRules.h b/editor/libeditor/HTMLEditRules.h index 6cdfa57cf..5525fdf24 100644 --- a/editor/libeditor/HTMLEditRules.h +++ b/editor/libeditor/HTMLEditRules.h @@ -28,6 +28,7 @@ class nsRange; namespace mozilla { +class EditActionResult; class HTMLEditor; class RulesInfo; class TextEditor; @@ -173,20 +174,16 @@ protected: * placing its children into leftblock. DTD containment rules are followed * throughout. * - * @param aCanceled returns true if the operation should do nothing anymore - * even if this doesn't join the blocks. - * NOTE: When this returns an error, nobody should refer - * the result of this. - * @param aHandled returns true if this actually handles the request. - * Note that this may return true even if this does not - * join the block. E.g., if the blocks shouldn't be - * joined or it's impossible to join them but it's not + * @return Sets canceled to true if the operation should do + * nothing anymore even if this doesn't join the blocks. + * Sets handled to true if this actually handles the + * request. Note that this may set it to true even if this + * does not join the block. E.g., if the blocks shouldn't + * be joined or it's impossible to join them but it's not * unexpected case, this returns true with this. - * NOTE: When this returns an error, nobody should refer - * the result of this. */ - nsresult TryToJoinBlocks(nsIContent& aLeftNode, nsIContent& aRightNode, - bool* aCanceled, bool* aHandled); + EditActionResult TryToJoinBlocks(nsIContent& aLeftNode, + nsIContent& aRightNode); /** * MoveBlock() moves the content from aRightBlock starting from aRightOffset @@ -194,39 +191,36 @@ protected: * between
s, or between blocks, etc. DTD containment rules are followed * throughout. * - * @param aHandled returns true if this actually joins the nodes. - * NOTE: When this returns an error, nobody should refer - * the result of this. + * @return Sets handled to true if this actually joins the nodes. + * canceled is always false. */ - nsresult MoveBlock(Element& aLeftBlock, Element& aRightBlock, - int32_t aLeftOffset, int32_t aRightOffset, - bool* aHandled); + EditActionResult MoveBlock(Element& aLeftBlock, Element& aRightBlock, + int32_t aLeftOffset, int32_t aRightOffset); /** * MoveNodeSmart() moves aNode to (aDestElement, aInOutDestOffset). * DTD containment rules are followed throughout. * * @param aOffset returns the point after inserted content. - * @param aHandled returns true if this actually moves the - * nodes. - * NOTE: When this returns an error, nobody - * should refer the result of this. + * @return Sets true to handled if this actually moves + * the nodes. + * canceled is always false. */ - nsresult MoveNodeSmart(nsIContent& aNode, Element& aDestElement, - int32_t* aInOutDestOffset, bool* aHandled); + EditActionResult MoveNodeSmart(nsIContent& aNode, Element& aDestElement, + int32_t* aInOutDestOffset); /** * MoveContents() moves the contents of aElement to (aDestElement, * aInOutDestOffset). DTD containment rules are followed throughout. * * @param aInOutDestOffset updated to point after inserted content. - * @param aHandled returns true if this actually moves the - * nodes. - * NOTE: When this returns an error, nobody - * should refer the result of this. + * @return Sets true to handled if this actually moves + * the nodes. + * canceled is always false. */ - nsresult MoveContents(Element& aElement, Element& aDestElement, - int32_t* aInOutDestOffset, bool* aHandled); + EditActionResult MoveContents(Element& aElement, Element& aDestElement, + int32_t* aInOutDestOffset); + nsresult DeleteNonTableElements(nsINode* aNode); nsresult WillMakeList(Selection* aSelection, const nsAString* aListType, -- cgit v1.2.3