summaryrefslogtreecommitdiffstats
path: root/editor/libeditor/HTMLEditRules.h
diff options
context:
space:
mode:
authorGaming4JC <g4jc@hyperbola.info>2020-05-22 11:48:40 -0400
committerwolfbeast <mcwerewolf@wolfbeast.com>2020-06-27 02:20:28 +0200
commitd4cd571021b3651f4f2c6f3a2846e48ad726bcae (patch)
treeda7e203bfcd3b8d1060f1b177b2ec4d966bd7b1a /editor/libeditor/HTMLEditRules.h
parent016c55f4094d99cc4aaa2f8ac0f2c22adbf96a5b (diff)
downloadUXP-d4cd571021b3651f4f2c6f3a2846e48ad726bcae.tar
UXP-d4cd571021b3651f4f2c6f3a2846e48ad726bcae.tar.gz
UXP-d4cd571021b3651f4f2c6f3a2846e48ad726bcae.tar.lz
UXP-d4cd571021b3651f4f2c6f3a2846e48ad726bcae.tar.xz
UXP-d4cd571021b3651f4f2c6f3a2846e48ad726bcae.zip
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
Diffstat (limited to 'editor/libeditor/HTMLEditRules.h')
-rw-r--r--editor/libeditor/HTMLEditRules.h54
1 files changed, 24 insertions, 30 deletions
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 <br>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,