2001-09-26 02:53:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
1999-03-29 10:21:01 +04:00
|
|
|
|
2016-07-07 13:05:51 +03:00
|
|
|
#ifndef HTMLEditRules_h
|
|
|
|
#define HTMLEditRules_h
|
1999-03-29 10:21:01 +04:00
|
|
|
|
2003-06-03 02:21:06 +04:00
|
|
|
#include "TypeInState.h"
|
2017-11-01 08:41:03 +03:00
|
|
|
#include "mozilla/EditorDOMPoint.h" // for EditorDOMPoint
|
2016-07-09 05:34:41 +03:00
|
|
|
#include "mozilla/SelectionState.h"
|
|
|
|
#include "mozilla/TextEditRules.h"
|
2012-07-13 10:33:42 +04:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsIEditor.h"
|
|
|
|
#include "nsIHTMLEditor.h"
|
|
|
|
#include "nsISupportsImpl.h"
|
2009-04-22 12:43:15 +04:00
|
|
|
#include "nsTArray.h"
|
2012-07-13 10:33:42 +04:00
|
|
|
#include "nscore.h"
|
1999-03-29 10:21:01 +04:00
|
|
|
|
2017-10-03 01:05:19 +03:00
|
|
|
class nsAtom;
|
2012-07-13 10:33:42 +04:00
|
|
|
class nsIDOMCharacterData;
|
|
|
|
class nsIDOMDocument;
|
1999-11-25 03:19:45 +03:00
|
|
|
class nsIDOMElement;
|
2012-07-13 10:33:42 +04:00
|
|
|
class nsIDOMNode;
|
2000-05-04 12:33:48 +04:00
|
|
|
class nsIEditor;
|
2012-07-13 10:33:42 +04:00
|
|
|
class nsINode;
|
|
|
|
class nsRange;
|
2016-07-07 13:05:51 +03:00
|
|
|
|
2012-07-13 10:33:42 +04:00
|
|
|
namespace mozilla {
|
2016-07-07 13:05:51 +03:00
|
|
|
|
2016-11-18 11:59:23 +03:00
|
|
|
class EditActionResult;
|
2016-07-09 05:42:33 +03:00
|
|
|
class HTMLEditor;
|
2016-07-07 13:33:32 +03:00
|
|
|
class RulesInfo;
|
2017-11-17 10:03:11 +03:00
|
|
|
class SplitNodeResult;
|
2016-07-09 05:54:50 +03:00
|
|
|
class TextEditor;
|
2018-01-12 13:01:04 +03:00
|
|
|
enum class EditAction : int32_t;
|
|
|
|
|
2012-07-13 10:33:42 +04:00
|
|
|
namespace dom {
|
|
|
|
class Element;
|
2014-04-10 20:09:40 +04:00
|
|
|
class Selection;
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace dom
|
1999-06-16 09:02:43 +04:00
|
|
|
|
2016-07-07 13:05:51 +03:00
|
|
|
struct StyleCache final : public PropItem
|
2003-06-03 02:21:06 +04:00
|
|
|
{
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mPresent;
|
2015-05-28 18:58:42 +03:00
|
|
|
|
2016-07-07 13:05:51 +03:00
|
|
|
StyleCache()
|
|
|
|
: PropItem()
|
|
|
|
, mPresent(false)
|
|
|
|
{
|
2007-12-12 06:23:34 +03:00
|
|
|
MOZ_COUNT_CTOR(StyleCache);
|
|
|
|
}
|
|
|
|
|
2017-10-03 01:05:19 +03:00
|
|
|
StyleCache(nsAtom* aTag,
|
2017-12-26 06:25:45 +03:00
|
|
|
nsAtom* aAttr,
|
2016-07-07 13:05:51 +03:00
|
|
|
const nsAString& aValue)
|
|
|
|
: PropItem(aTag, aAttr, aValue)
|
|
|
|
, mPresent(false)
|
|
|
|
{
|
2007-12-12 06:23:34 +03:00
|
|
|
MOZ_COUNT_CTOR(StyleCache);
|
|
|
|
}
|
|
|
|
|
2017-10-03 01:05:19 +03:00
|
|
|
StyleCache(nsAtom* aTag,
|
2017-12-26 06:25:45 +03:00
|
|
|
nsAtom* aAttr)
|
2017-01-06 16:35:48 +03:00
|
|
|
: PropItem(aTag, aAttr, EmptyString())
|
|
|
|
, mPresent(false)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(StyleCache);
|
|
|
|
}
|
|
|
|
|
2016-07-07 13:05:51 +03:00
|
|
|
~StyleCache()
|
|
|
|
{
|
2007-12-12 06:23:34 +03:00
|
|
|
MOZ_COUNT_DTOR(StyleCache);
|
|
|
|
}
|
2003-06-03 02:21:06 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#define SIZE_STYLE_TABLE 19
|
|
|
|
|
2016-07-09 05:34:41 +03:00
|
|
|
class HTMLEditRules : public TextEditRules
|
1999-03-29 10:21:01 +04:00
|
|
|
{
|
|
|
|
public:
|
2000-03-24 03:26:47 +03:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2016-07-09 05:34:41 +03:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLEditRules, TextEditRules)
|
1999-03-29 10:21:01 +04:00
|
|
|
|
2016-07-07 13:05:51 +03:00
|
|
|
HTMLEditRules();
|
2000-03-24 03:26:47 +03:00
|
|
|
|
2017-12-21 08:52:32 +03:00
|
|
|
// TextEditRules methods
|
|
|
|
virtual nsresult Init(TextEditor* aTextEditor) override;
|
|
|
|
virtual nsresult DetachEditor() override;
|
|
|
|
virtual nsresult BeforeEdit(EditAction aAction,
|
|
|
|
nsIEditor::EDirection aDirection) override;
|
|
|
|
virtual nsresult AfterEdit(EditAction aAction,
|
|
|
|
nsIEditor::EDirection aDirection) override;
|
|
|
|
virtual nsresult WillDoAction(Selection* aSelection,
|
|
|
|
RulesInfo* aInfo,
|
|
|
|
bool* aCancel,
|
|
|
|
bool* aHandled) override;
|
|
|
|
virtual nsresult DidDoAction(Selection* aSelection,
|
|
|
|
RulesInfo* aInfo,
|
|
|
|
nsresult aResult) override;
|
|
|
|
virtual bool DocumentIsEmpty() override;
|
|
|
|
virtual nsresult DocumentModified() override;
|
1999-04-05 21:21:59 +04:00
|
|
|
|
2016-07-07 13:05:51 +03:00
|
|
|
nsresult GetListState(bool* aMixed, bool* aOL, bool* aUL, bool* aDL);
|
|
|
|
nsresult GetListItemState(bool* aMixed, bool* aLI, bool* aDT, bool* aDD);
|
|
|
|
nsresult GetIndentState(bool* aCanIndent, bool* aCanOutdent);
|
|
|
|
nsresult GetAlignment(bool* aMixed, nsIHTMLEditor::EAlignment* aAlign);
|
|
|
|
nsresult GetParagraphState(bool* aMixed, nsAString& outFormat);
|
2017-03-03 07:13:21 +03:00
|
|
|
nsresult MakeSureElemStartsOrEndsOnCR(nsINode& aNode);
|
2000-05-03 04:14:28 +04:00
|
|
|
|
2018-01-12 18:21:17 +03:00
|
|
|
void DidCreateNode(Element* aNewElement);
|
|
|
|
void DidInsertNode(nsIContent& aNode);
|
|
|
|
void WillDeleteNode(nsINode* aChild);
|
|
|
|
void DidSplitNode(nsINode* aExistingRightNode,
|
|
|
|
nsINode* aNewLeftNode);
|
|
|
|
void WillJoinNodes(nsINode& aLeftNode, nsINode& aRightNode);
|
|
|
|
void DidJoinNodes(nsINode& aLeftNode, nsINode& aRightNode);
|
|
|
|
void DidInsertText(nsINode* aTextNode, int32_t aOffset,
|
|
|
|
const nsAString& aString);
|
|
|
|
void DidDeleteText(nsINode* aTextNode, int32_t aOffset, int32_t aLength);
|
|
|
|
void WillDeleteSelection(Selection* aSelection);
|
|
|
|
|
2016-04-20 21:19:20 +03:00
|
|
|
void DeleteNodeIfCollapsedText(nsINode& aNode);
|
2000-03-24 03:26:47 +03:00
|
|
|
|
2018-01-12 18:21:17 +03:00
|
|
|
void StartToListenToEditActions() { mListenerEnabled = true; }
|
|
|
|
void EndListeningToEditActions() { mListenerEnabled = false; }
|
|
|
|
|
1999-04-05 21:21:59 +04:00
|
|
|
protected:
|
2016-07-07 13:05:51 +03:00
|
|
|
virtual ~HTMLEditRules();
|
1999-04-05 21:21:59 +04:00
|
|
|
|
1999-06-16 09:02:43 +04:00
|
|
|
enum RulesEndpoint
|
|
|
|
{
|
|
|
|
kStart,
|
|
|
|
kEnd
|
|
|
|
};
|
|
|
|
|
2014-05-10 01:02:29 +04:00
|
|
|
void InitFields();
|
|
|
|
|
2016-05-01 16:15:14 +03:00
|
|
|
void WillInsert(Selection& aSelection, bool* aCancel);
|
2016-07-07 13:05:51 +03:00
|
|
|
nsresult WillInsertText(EditAction aAction,
|
|
|
|
Selection* aSelection,
|
|
|
|
bool* aCancel,
|
|
|
|
bool* aHandled,
|
|
|
|
const nsAString* inString,
|
|
|
|
nsAString* outString,
|
|
|
|
int32_t aMaxLength);
|
2016-05-01 16:15:14 +03:00
|
|
|
nsresult WillLoadHTML(Selection* aSelection, bool* aCancel);
|
|
|
|
nsresult WillInsertBreak(Selection& aSelection, bool* aCancel,
|
|
|
|
bool* aHandled);
|
2017-12-11 12:28:46 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* InsertBRElement() inserts a <br> element into aInsertToBreak.
|
|
|
|
*
|
|
|
|
* @param aSelection The selection.
|
|
|
|
* @param aInsertToBreak The point where new <br> element will be
|
|
|
|
* inserted before.
|
|
|
|
*/
|
|
|
|
nsresult InsertBRElement(Selection& aSelection,
|
|
|
|
const EditorDOMPoint& aInsertToBreak);
|
|
|
|
|
2016-05-01 16:15:14 +03:00
|
|
|
nsresult DidInsertBreak(Selection* aSelection, nsresult aResult);
|
|
|
|
nsresult SplitMailCites(Selection* aSelection, bool* aHandled);
|
|
|
|
nsresult WillDeleteSelection(Selection* aSelection,
|
2012-05-10 18:54:33 +04:00
|
|
|
nsIEditor::EDirection aAction,
|
|
|
|
nsIEditor::EStripWrappers aStripWrappers,
|
|
|
|
bool* aCancel, bool* aHandled);
|
2016-05-01 16:15:14 +03:00
|
|
|
nsresult DidDeleteSelection(Selection* aSelection,
|
2015-05-28 18:58:42 +03:00
|
|
|
nsIEditor::EDirection aDir,
|
2003-03-23 22:51:03 +03:00
|
|
|
nsresult aResult);
|
2016-05-01 16:15:14 +03:00
|
|
|
nsresult InsertBRIfNeeded(Selection* aSelection);
|
2017-08-01 16:38:50 +03:00
|
|
|
|
2017-10-26 19:27:44 +03:00
|
|
|
/**
|
|
|
|
* CanContainParagraph() returns true if aElement can have a <p> element as
|
|
|
|
* its child or its descendant.
|
|
|
|
*/
|
|
|
|
bool CanContainParagraph(Element& aElement) const;
|
|
|
|
|
2017-08-01 16:38:50 +03:00
|
|
|
/**
|
|
|
|
* Insert a normal <br> element or a moz-<br> element to aNode when
|
|
|
|
* aNode is a block and it has no children.
|
|
|
|
*
|
|
|
|
* @param aNode Reference to a block parent.
|
|
|
|
* @param aInsertMozBR true if this should insert a moz-<br> element.
|
|
|
|
* Otherwise, i.e., this should insert a normal <br>
|
|
|
|
* element, false.
|
|
|
|
*/
|
|
|
|
nsresult InsertBRIfNeededInternal(nsINode& aNode, bool aInsertMozBR);
|
|
|
|
|
2017-11-01 08:41:03 +03:00
|
|
|
EditorDOMPoint GetGoodSelPointForNode(nsINode& aNode,
|
|
|
|
nsIEditor::EDirection aAction);
|
Bug 1316302 part.1 Helper methods for HTMLEditRules::WillDeleteSelection() should have an out argument to indicates if it actually handles the action r=smaug
When HTMLEditRules::WillDeleteSelection() tries to remove something from the end/start of a block to its last/first text node but it's contained by block elements, it tries to join the container and the block. However, JoinBlocks() always fails to join them since it's impossible operation. In this case, HTMLEditRules::WillDeleteSelection() should retry to remove something in the leaf, however, it's impossible for now because JoinBlocks() and its helper methods don't return if it handles the action actually.
This patch renames |JoinBlocks()| to |TryToJoinBlocks()| for representing what it is. And this patch adds |bool* aHandled| to the helper methods. Then, *aHandled and *aCancel are now always returns the result of each method. Therefore, for merging the result of multiple helper methods, callers need to receive the result with temporary variables and merge them by themselves.
Note that when they modify DOM node actually or the action should do nothing (for example, selection is across tables), aHandled is set to true.
MozReview-Commit-ID: 7ApUOgtLUog
--HG--
extra : rebase_source : 4abc1ec208107b782a719df058623fd7f92d180c
2016-11-18 11:54:31 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* TryToJoinBlocks() tries to join two block elements. The right element is
|
|
|
|
* always joined to the left element. If the elements are the same type and
|
|
|
|
* not nested within each other, JoinNodesSmart() is called (example, joining
|
|
|
|
* two list items together into one). If the elements are not the same type,
|
|
|
|
* or one is a descendant of the other, we instead destroy the right block
|
|
|
|
* placing its children into leftblock. DTD containment rules are followed
|
|
|
|
* throughout.
|
|
|
|
*
|
2016-11-18 11:59:23 +03:00
|
|
|
* @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
|
Bug 1316302 part.1 Helper methods for HTMLEditRules::WillDeleteSelection() should have an out argument to indicates if it actually handles the action r=smaug
When HTMLEditRules::WillDeleteSelection() tries to remove something from the end/start of a block to its last/first text node but it's contained by block elements, it tries to join the container and the block. However, JoinBlocks() always fails to join them since it's impossible operation. In this case, HTMLEditRules::WillDeleteSelection() should retry to remove something in the leaf, however, it's impossible for now because JoinBlocks() and its helper methods don't return if it handles the action actually.
This patch renames |JoinBlocks()| to |TryToJoinBlocks()| for representing what it is. And this patch adds |bool* aHandled| to the helper methods. Then, *aHandled and *aCancel are now always returns the result of each method. Therefore, for merging the result of multiple helper methods, callers need to receive the result with temporary variables and merge them by themselves.
Note that when they modify DOM node actually or the action should do nothing (for example, selection is across tables), aHandled is set to true.
MozReview-Commit-ID: 7ApUOgtLUog
--HG--
extra : rebase_source : 4abc1ec208107b782a719df058623fd7f92d180c
2016-11-18 11:54:31 +03:00
|
|
|
* unexpected case, this returns true with this.
|
|
|
|
*/
|
2016-11-18 11:59:23 +03:00
|
|
|
EditActionResult TryToJoinBlocks(nsIContent& aLeftNode,
|
|
|
|
nsIContent& aRightNode);
|
Bug 1316302 part.1 Helper methods for HTMLEditRules::WillDeleteSelection() should have an out argument to indicates if it actually handles the action r=smaug
When HTMLEditRules::WillDeleteSelection() tries to remove something from the end/start of a block to its last/first text node but it's contained by block elements, it tries to join the container and the block. However, JoinBlocks() always fails to join them since it's impossible operation. In this case, HTMLEditRules::WillDeleteSelection() should retry to remove something in the leaf, however, it's impossible for now because JoinBlocks() and its helper methods don't return if it handles the action actually.
This patch renames |JoinBlocks()| to |TryToJoinBlocks()| for representing what it is. And this patch adds |bool* aHandled| to the helper methods. Then, *aHandled and *aCancel are now always returns the result of each method. Therefore, for merging the result of multiple helper methods, callers need to receive the result with temporary variables and merge them by themselves.
Note that when they modify DOM node actually or the action should do nothing (for example, selection is across tables), aHandled is set to true.
MozReview-Commit-ID: 7ApUOgtLUog
--HG--
extra : rebase_source : 4abc1ec208107b782a719df058623fd7f92d180c
2016-11-18 11:54:31 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* MoveBlock() moves the content from aRightBlock starting from aRightOffset
|
|
|
|
* into aLeftBlock at aLeftOffset. Note that the "block" can be inline nodes
|
|
|
|
* between <br>s, or between blocks, etc. DTD containment rules are followed
|
|
|
|
* throughout.
|
|
|
|
*
|
2016-11-18 11:59:23 +03:00
|
|
|
* @return Sets handled to true if this actually joins the nodes.
|
|
|
|
* canceled is always false.
|
Bug 1316302 part.1 Helper methods for HTMLEditRules::WillDeleteSelection() should have an out argument to indicates if it actually handles the action r=smaug
When HTMLEditRules::WillDeleteSelection() tries to remove something from the end/start of a block to its last/first text node but it's contained by block elements, it tries to join the container and the block. However, JoinBlocks() always fails to join them since it's impossible operation. In this case, HTMLEditRules::WillDeleteSelection() should retry to remove something in the leaf, however, it's impossible for now because JoinBlocks() and its helper methods don't return if it handles the action actually.
This patch renames |JoinBlocks()| to |TryToJoinBlocks()| for representing what it is. And this patch adds |bool* aHandled| to the helper methods. Then, *aHandled and *aCancel are now always returns the result of each method. Therefore, for merging the result of multiple helper methods, callers need to receive the result with temporary variables and merge them by themselves.
Note that when they modify DOM node actually or the action should do nothing (for example, selection is across tables), aHandled is set to true.
MozReview-Commit-ID: 7ApUOgtLUog
--HG--
extra : rebase_source : 4abc1ec208107b782a719df058623fd7f92d180c
2016-11-18 11:54:31 +03:00
|
|
|
*/
|
2016-11-18 11:59:23 +03:00
|
|
|
EditActionResult MoveBlock(Element& aLeftBlock, Element& aRightBlock,
|
|
|
|
int32_t aLeftOffset, int32_t aRightOffset);
|
Bug 1316302 part.1 Helper methods for HTMLEditRules::WillDeleteSelection() should have an out argument to indicates if it actually handles the action r=smaug
When HTMLEditRules::WillDeleteSelection() tries to remove something from the end/start of a block to its last/first text node but it's contained by block elements, it tries to join the container and the block. However, JoinBlocks() always fails to join them since it's impossible operation. In this case, HTMLEditRules::WillDeleteSelection() should retry to remove something in the leaf, however, it's impossible for now because JoinBlocks() and its helper methods don't return if it handles the action actually.
This patch renames |JoinBlocks()| to |TryToJoinBlocks()| for representing what it is. And this patch adds |bool* aHandled| to the helper methods. Then, *aHandled and *aCancel are now always returns the result of each method. Therefore, for merging the result of multiple helper methods, callers need to receive the result with temporary variables and merge them by themselves.
Note that when they modify DOM node actually or the action should do nothing (for example, selection is across tables), aHandled is set to true.
MozReview-Commit-ID: 7ApUOgtLUog
--HG--
extra : rebase_source : 4abc1ec208107b782a719df058623fd7f92d180c
2016-11-18 11:54:31 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* MoveNodeSmart() moves aNode to (aDestElement, aInOutDestOffset).
|
|
|
|
* DTD containment rules are followed throughout.
|
|
|
|
*
|
|
|
|
* @param aOffset returns the point after inserted content.
|
2016-11-18 11:59:23 +03:00
|
|
|
* @return Sets true to handled if this actually moves
|
|
|
|
* the nodes.
|
|
|
|
* canceled is always false.
|
Bug 1316302 part.1 Helper methods for HTMLEditRules::WillDeleteSelection() should have an out argument to indicates if it actually handles the action r=smaug
When HTMLEditRules::WillDeleteSelection() tries to remove something from the end/start of a block to its last/first text node but it's contained by block elements, it tries to join the container and the block. However, JoinBlocks() always fails to join them since it's impossible operation. In this case, HTMLEditRules::WillDeleteSelection() should retry to remove something in the leaf, however, it's impossible for now because JoinBlocks() and its helper methods don't return if it handles the action actually.
This patch renames |JoinBlocks()| to |TryToJoinBlocks()| for representing what it is. And this patch adds |bool* aHandled| to the helper methods. Then, *aHandled and *aCancel are now always returns the result of each method. Therefore, for merging the result of multiple helper methods, callers need to receive the result with temporary variables and merge them by themselves.
Note that when they modify DOM node actually or the action should do nothing (for example, selection is across tables), aHandled is set to true.
MozReview-Commit-ID: 7ApUOgtLUog
--HG--
extra : rebase_source : 4abc1ec208107b782a719df058623fd7f92d180c
2016-11-18 11:54:31 +03:00
|
|
|
*/
|
2016-11-18 11:59:23 +03:00
|
|
|
EditActionResult MoveNodeSmart(nsIContent& aNode, Element& aDestElement,
|
|
|
|
int32_t* aInOutDestOffset);
|
Bug 1316302 part.1 Helper methods for HTMLEditRules::WillDeleteSelection() should have an out argument to indicates if it actually handles the action r=smaug
When HTMLEditRules::WillDeleteSelection() tries to remove something from the end/start of a block to its last/first text node but it's contained by block elements, it tries to join the container and the block. However, JoinBlocks() always fails to join them since it's impossible operation. In this case, HTMLEditRules::WillDeleteSelection() should retry to remove something in the leaf, however, it's impossible for now because JoinBlocks() and its helper methods don't return if it handles the action actually.
This patch renames |JoinBlocks()| to |TryToJoinBlocks()| for representing what it is. And this patch adds |bool* aHandled| to the helper methods. Then, *aHandled and *aCancel are now always returns the result of each method. Therefore, for merging the result of multiple helper methods, callers need to receive the result with temporary variables and merge them by themselves.
Note that when they modify DOM node actually or the action should do nothing (for example, selection is across tables), aHandled is set to true.
MozReview-Commit-ID: 7ApUOgtLUog
--HG--
extra : rebase_source : 4abc1ec208107b782a719df058623fd7f92d180c
2016-11-18 11:54:31 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* MoveContents() moves the contents of aElement to (aDestElement,
|
|
|
|
* aInOutDestOffset). DTD containment rules are followed throughout.
|
|
|
|
*
|
|
|
|
* @param aInOutDestOffset updated to point after inserted content.
|
2016-11-18 11:59:23 +03:00
|
|
|
* @return Sets true to handled if this actually moves
|
|
|
|
* the nodes.
|
|
|
|
* canceled is always false.
|
Bug 1316302 part.1 Helper methods for HTMLEditRules::WillDeleteSelection() should have an out argument to indicates if it actually handles the action r=smaug
When HTMLEditRules::WillDeleteSelection() tries to remove something from the end/start of a block to its last/first text node but it's contained by block elements, it tries to join the container and the block. However, JoinBlocks() always fails to join them since it's impossible operation. In this case, HTMLEditRules::WillDeleteSelection() should retry to remove something in the leaf, however, it's impossible for now because JoinBlocks() and its helper methods don't return if it handles the action actually.
This patch renames |JoinBlocks()| to |TryToJoinBlocks()| for representing what it is. And this patch adds |bool* aHandled| to the helper methods. Then, *aHandled and *aCancel are now always returns the result of each method. Therefore, for merging the result of multiple helper methods, callers need to receive the result with temporary variables and merge them by themselves.
Note that when they modify DOM node actually or the action should do nothing (for example, selection is across tables), aHandled is set to true.
MozReview-Commit-ID: 7ApUOgtLUog
--HG--
extra : rebase_source : 4abc1ec208107b782a719df058623fd7f92d180c
2016-11-18 11:54:31 +03:00
|
|
|
*/
|
2016-11-18 11:59:23 +03:00
|
|
|
EditActionResult MoveContents(Element& aElement, Element& aDestElement,
|
|
|
|
int32_t* aInOutDestOffset);
|
Bug 1316302 part.1 Helper methods for HTMLEditRules::WillDeleteSelection() should have an out argument to indicates if it actually handles the action r=smaug
When HTMLEditRules::WillDeleteSelection() tries to remove something from the end/start of a block to its last/first text node but it's contained by block elements, it tries to join the container and the block. However, JoinBlocks() always fails to join them since it's impossible operation. In this case, HTMLEditRules::WillDeleteSelection() should retry to remove something in the leaf, however, it's impossible for now because JoinBlocks() and its helper methods don't return if it handles the action actually.
This patch renames |JoinBlocks()| to |TryToJoinBlocks()| for representing what it is. And this patch adds |bool* aHandled| to the helper methods. Then, *aHandled and *aCancel are now always returns the result of each method. Therefore, for merging the result of multiple helper methods, callers need to receive the result with temporary variables and merge them by themselves.
Note that when they modify DOM node actually or the action should do nothing (for example, selection is across tables), aHandled is set to true.
MozReview-Commit-ID: 7ApUOgtLUog
--HG--
extra : rebase_source : 4abc1ec208107b782a719df058623fd7f92d180c
2016-11-18 11:54:31 +03:00
|
|
|
|
2012-05-18 12:29:39 +04:00
|
|
|
nsresult DeleteNonTableElements(nsINode* aNode);
|
2016-05-01 16:15:14 +03:00
|
|
|
nsresult WillMakeList(Selection* aSelection,
|
2012-07-23 14:27:22 +04:00
|
|
|
const nsAString* aListType,
|
|
|
|
bool aEntireList,
|
|
|
|
const nsAString* aBulletType,
|
|
|
|
bool* aCancel, bool* aHandled,
|
2012-07-30 18:20:58 +04:00
|
|
|
const nsAString* aItemType = nullptr);
|
2016-05-01 16:15:14 +03:00
|
|
|
nsresult WillRemoveList(Selection* aSelection, bool aOrdered, bool* aCancel,
|
|
|
|
bool* aHandled);
|
|
|
|
nsresult WillIndent(Selection* aSelection, bool* aCancel, bool* aHandled);
|
|
|
|
nsresult WillCSSIndent(Selection* aSelection, bool* aCancel, bool* aHandled);
|
|
|
|
nsresult WillHTMLIndent(Selection* aSelection, bool* aCancel,
|
|
|
|
bool* aHandled);
|
2016-05-01 16:15:51 +03:00
|
|
|
nsresult WillOutdent(Selection& aSelection, bool* aCancel, bool* aHandled);
|
2016-05-01 16:15:14 +03:00
|
|
|
nsresult WillAlign(Selection& aSelection, const nsAString& aAlignType,
|
2012-07-23 14:27:22 +04:00
|
|
|
bool* aCancel, bool* aHandled);
|
2016-05-01 17:58:41 +03:00
|
|
|
nsresult WillAbsolutePosition(Selection& aSelection, bool* aCancel,
|
2016-05-01 16:15:14 +03:00
|
|
|
bool* aHandled);
|
|
|
|
nsresult WillRemoveAbsolutePosition(Selection* aSelection, bool* aCancel,
|
|
|
|
bool* aHandled);
|
|
|
|
nsresult WillRelativeChangeZIndex(Selection* aSelection, int32_t aChange,
|
2012-07-23 14:27:22 +04:00
|
|
|
bool* aCancel, bool* aHandled);
|
2016-05-01 16:15:14 +03:00
|
|
|
nsresult WillMakeDefListItem(Selection* aSelection,
|
2012-07-23 14:27:22 +04:00
|
|
|
const nsAString* aBlockType, bool aEntireList,
|
|
|
|
bool* aCancel, bool* aHandled);
|
2016-05-01 17:58:17 +03:00
|
|
|
nsresult WillMakeBasicBlock(Selection& aSelection,
|
|
|
|
const nsAString& aBlockType,
|
2012-07-23 14:27:22 +04:00
|
|
|
bool* aCancel, bool* aHandled);
|
2017-10-03 01:05:19 +03:00
|
|
|
nsresult MakeBasicBlock(Selection& aSelection, nsAtom& aBlockType);
|
2016-07-07 13:33:32 +03:00
|
|
|
nsresult DidMakeBasicBlock(Selection* aSelection, RulesInfo* aInfo,
|
2016-05-01 16:15:14 +03:00
|
|
|
nsresult aResult);
|
2003-06-25 12:50:48 +04:00
|
|
|
nsresult DidAbsolutePosition();
|
2015-04-24 14:27:35 +03:00
|
|
|
nsresult AlignInnerBlocks(nsINode& aNode, const nsAString* alignType);
|
2016-07-07 13:05:51 +03:00
|
|
|
nsresult AlignBlockContents(nsIDOMNode* aNode, const nsAString* alignType);
|
2016-05-01 16:15:14 +03:00
|
|
|
nsresult AppendInnerFormatNodes(nsTArray<OwningNonNull<nsINode>>& aArray,
|
2012-05-18 12:29:39 +04:00
|
|
|
nsINode* aNode);
|
2016-07-07 13:05:51 +03:00
|
|
|
nsresult GetFormatString(nsIDOMNode* aNode, nsAString &outFormat);
|
2015-04-24 14:27:34 +03:00
|
|
|
enum class Lists { no, yes };
|
|
|
|
enum class Tables { no, yes };
|
|
|
|
void GetInnerContent(nsINode& aNode,
|
2016-05-01 16:15:14 +03:00
|
|
|
nsTArray<OwningNonNull<nsINode>>& aOutArrayOfNodes,
|
2015-04-24 14:27:34 +03:00
|
|
|
int32_t* aIndex, Lists aLists = Lists::yes,
|
|
|
|
Tables aTables = Tables::yes);
|
2016-05-01 16:15:14 +03:00
|
|
|
Element* IsInListItem(nsINode* aNode);
|
2017-10-03 01:05:19 +03:00
|
|
|
nsAtom& DefaultParagraphSeparator();
|
2016-05-01 16:15:14 +03:00
|
|
|
nsresult ReturnInHeader(Selection& aSelection, Element& aHeader,
|
|
|
|
nsINode& aNode, int32_t aOffset);
|
2017-11-10 08:58:53 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* ReturnInParagraph() does the right thing for Enter key press or
|
2017-11-10 10:51:24 +03:00
|
|
|
* 'insertParagraph' command in aParentDivOrP. aParentDivOrP will be
|
|
|
|
* split at start of first selection range.
|
2017-11-10 08:58:53 +03:00
|
|
|
*
|
2017-11-10 10:51:24 +03:00
|
|
|
* @param aSelection The selection. aParentDivOrP will be split at
|
|
|
|
* start of the first selection range.
|
2017-11-10 08:58:53 +03:00
|
|
|
* @param aParentDivOrP The parent block. This must be <p> or <div>
|
|
|
|
* element.
|
|
|
|
* @return Returns with NS_OK if this doesn't meat any
|
|
|
|
* unexpected situation. If this method tries to
|
|
|
|
* split the paragraph, marked as handled.
|
|
|
|
*/
|
|
|
|
EditActionResult ReturnInParagraph(Selection& aSelection,
|
2017-11-15 09:35:17 +03:00
|
|
|
Element& aParentDivOrP);
|
2017-11-10 08:43:13 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* SplitParagraph() splits the parent block, aPara, at aSelNode - aOffset.
|
|
|
|
*
|
2017-11-16 07:26:58 +03:00
|
|
|
* @param aSelection The selection.
|
|
|
|
* @param aParentDivOrP The parent block to be split. This must be <p>
|
|
|
|
* or <div> element.
|
|
|
|
* @param aStartOfRightNode The point to be start of right node after
|
|
|
|
* split. This must be descendant of
|
|
|
|
* aParentDivOrP.
|
|
|
|
* @param aNextBRNode Next <br> node if there is. Otherwise, nullptr.
|
|
|
|
* If this is not nullptr, the <br> node may be
|
|
|
|
* removed.
|
2017-11-10 08:43:13 +03:00
|
|
|
*/
|
2017-11-15 09:35:17 +03:00
|
|
|
nsresult SplitParagraph(Selection& aSelection,
|
2017-11-16 07:26:58 +03:00
|
|
|
Element& aParentDivOrP,
|
|
|
|
const EditorRawDOMPoint& aStartOfRightNode,
|
|
|
|
nsIContent* aBRNode);
|
2017-11-10 08:43:13 +03:00
|
|
|
|
2016-05-01 16:15:14 +03:00
|
|
|
nsresult ReturnInListItem(Selection& aSelection, Element& aHeader,
|
|
|
|
nsINode& aNode, int32_t aOffset);
|
2012-08-12 22:28:26 +04:00
|
|
|
nsresult AfterEditInner(EditAction action,
|
2012-05-05 22:52:29 +04:00
|
|
|
nsIEditor::EDirection aDirection);
|
2016-05-01 16:15:14 +03:00
|
|
|
nsresult RemovePartOfBlock(Element& aBlock, nsIContent& aStartChild,
|
2015-04-24 14:27:35 +03:00
|
|
|
nsIContent& aEndChild);
|
2016-07-07 13:05:51 +03:00
|
|
|
void SplitBlock(Element& aBlock,
|
|
|
|
nsIContent& aStartChild,
|
|
|
|
nsIContent& aEndChild,
|
|
|
|
nsIContent** aOutLeftNode = nullptr,
|
|
|
|
nsIContent** aOutRightNode = nullptr,
|
|
|
|
nsIContent** aOutMiddleNode = nullptr);
|
2016-05-01 16:16:03 +03:00
|
|
|
nsresult OutdentPartOfBlock(Element& aBlock,
|
|
|
|
nsIContent& aStartChild,
|
|
|
|
nsIContent& aEndChild,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aIsBlockIndentedWithCSS,
|
2016-05-01 16:16:03 +03:00
|
|
|
nsIContent** aOutLeftNode,
|
|
|
|
nsIContent** aOutRightNode);
|
2012-06-06 11:36:46 +04:00
|
|
|
|
2017-10-03 01:05:19 +03:00
|
|
|
already_AddRefed<Element> ConvertListType(Element* aList, nsAtom* aListType,
|
|
|
|
nsAtom* aItemType);
|
2012-06-06 11:36:46 +04:00
|
|
|
|
2016-05-01 16:15:14 +03:00
|
|
|
nsresult CreateStyleForInsertText(Selection& aSelection, nsIDocument& aDoc);
|
2017-12-20 16:25:12 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* IsEmptyBlockElement() returns true if aElement is a block level element
|
|
|
|
* and it doesn't have any visible content.
|
|
|
|
*/
|
|
|
|
enum class IgnoreSingleBR
|
|
|
|
{
|
|
|
|
eYes,
|
|
|
|
eNo
|
|
|
|
};
|
|
|
|
bool IsEmptyBlockElement(Element& aElement,
|
|
|
|
IgnoreSingleBR aIgnoreSingleBR);
|
|
|
|
|
2016-05-01 16:15:14 +03:00
|
|
|
nsresult CheckForEmptyBlock(nsINode* aStartNode, Element* aBodyNode,
|
|
|
|
Selection* aSelection,
|
|
|
|
nsIEditor::EDirection aAction, bool* aHandled);
|
2016-05-01 16:15:02 +03:00
|
|
|
enum class BRLocation { beforeBlock, blockEnd };
|
2016-05-01 16:15:14 +03:00
|
|
|
Element* CheckForInvisibleBR(Element& aBlock, BRLocation aWhere,
|
|
|
|
int32_t aOffset = 0);
|
|
|
|
nsresult ExpandSelectionForDeletion(Selection& aSelection);
|
2016-07-07 13:05:51 +03:00
|
|
|
bool IsFirstNode(nsIDOMNode* aNode);
|
|
|
|
bool IsLastNode(nsIDOMNode* aNode);
|
2016-05-01 16:15:14 +03:00
|
|
|
nsresult NormalizeSelection(Selection* aSelection);
|
2017-07-10 11:35:26 +03:00
|
|
|
EditorDOMPoint GetPromotedPoint(RulesEndpoint aWhere, nsINode& aNode,
|
|
|
|
int32_t aOffset, EditAction actionID);
|
2016-05-01 16:15:14 +03:00
|
|
|
void GetPromotedRanges(Selection& aSelection,
|
2015-10-18 08:24:48 +03:00
|
|
|
nsTArray<RefPtr<nsRange>>& outArrayOfRanges,
|
2015-04-24 14:27:34 +03:00
|
|
|
EditAction inOperationType);
|
2015-04-24 14:27:34 +03:00
|
|
|
void PromoteRange(nsRange& aRange, EditAction inOperationType);
|
2015-04-24 14:27:34 +03:00
|
|
|
enum class TouchContent { no, yes };
|
2016-07-07 13:05:51 +03:00
|
|
|
nsresult GetNodesForOperation(
|
|
|
|
nsTArray<RefPtr<nsRange>>& aArrayOfRanges,
|
|
|
|
nsTArray<OwningNonNull<nsINode>>& aOutArrayOfNodes,
|
|
|
|
EditAction aOperationType,
|
|
|
|
TouchContent aTouchContent = TouchContent::yes);
|
|
|
|
void GetChildNodesForOperation(
|
|
|
|
nsINode& aNode,
|
|
|
|
nsTArray<OwningNonNull<nsINode>>& outArrayOfNodes);
|
2017-11-01 08:41:03 +03:00
|
|
|
nsresult GetNodesFromPoint(const EditorDOMPoint& aPoint,
|
2015-04-24 14:27:35 +03:00
|
|
|
EditAction aOperation,
|
2016-05-01 16:15:14 +03:00
|
|
|
nsTArray<OwningNonNull<nsINode>>& outArrayOfNodes,
|
2015-04-24 14:27:35 +03:00
|
|
|
TouchContent aTouchContent);
|
2016-07-07 13:05:51 +03:00
|
|
|
nsresult GetNodesFromSelection(
|
|
|
|
Selection& aSelection,
|
|
|
|
EditAction aOperation,
|
|
|
|
nsTArray<OwningNonNull<nsINode>>& outArrayOfNodes,
|
|
|
|
TouchContent aTouchContent = TouchContent::yes);
|
2015-04-24 14:27:34 +03:00
|
|
|
enum class EntireList { no, yes };
|
2016-07-07 13:05:51 +03:00
|
|
|
nsresult GetListActionNodes(
|
|
|
|
nsTArray<OwningNonNull<nsINode>>& aOutArrayOfNodes,
|
|
|
|
EntireList aEntireList,
|
|
|
|
TouchContent aTouchContent = TouchContent::yes);
|
2016-05-01 16:15:14 +03:00
|
|
|
void GetDefinitionListItemTypes(Element* aElement, bool* aDT, bool* aDD);
|
2015-04-24 14:27:34 +03:00
|
|
|
nsresult GetParagraphFormatNodes(
|
2016-07-07 13:05:51 +03:00
|
|
|
nsTArray<OwningNonNull<nsINode>>& outArrayOfNodes,
|
|
|
|
TouchContent aTouchContent = TouchContent::yes);
|
2016-05-01 16:15:14 +03:00
|
|
|
void LookInsideDivBQandList(nsTArray<OwningNonNull<nsINode>>& aNodeArray);
|
2016-07-07 13:05:51 +03:00
|
|
|
nsresult BustUpInlinesAtRangeEndpoints(RangeItem& inRange);
|
|
|
|
nsresult BustUpInlinesAtBRs(
|
|
|
|
nsIContent& aNode,
|
|
|
|
nsTArray<OwningNonNull<nsINode>>& aOutArrayOfNodes);
|
Bug 1411345 - HTMLEditRules::GetHighestInlineParent() shouldn't return editing host even when it's the highest inline parent of aNode r=m_kato
HTMLEditRules::BustUpInlinesAtRangeEndpoints() tries to split all inline nodes
at range start and range end. It uses EditorBase::SplitNodeDeep() to split
the nodes and HTMLEditRules::GetHighestInlineParent() to retrieve the highest
inline parent of them.
Currently, HTMLEditRules::GetHighestInlineParent() may return editing host or
ancestor of it if active editing host is not block. Then, it may cause
splitting editing host or its parents and following methods of HTMLEditRules
will fail to modify the nodes created outside the editing host.
So, HTMLEditRules::GetHighestInlineParent() should return only one of the
descendants of active editing host.
Unfortunately, even if just adding the test case as a crash test, I cannot
reproduce the crash with automated tests. Therefore, this patch doesn't
include any automated tests.
And this patch changes a crash test, 1402196.html, which expects that an inline
editing host is split by execCommand("insertOrderedList"). However, this patch
fixes this wrong behavior. Therefore, this patch changes the event target of
event listener from <p> inside the editing host to the editing host itself.
MozReview-Commit-ID: 8i5ci1fcrDd
--HG--
extra : rebase_source : 572a7b22550a38ca71c954f62eefa695addd53c2
2017-10-30 19:14:58 +03:00
|
|
|
/**
|
|
|
|
* GetHiestInlineParent() returns the highest inline node parent between
|
|
|
|
* aNode and the editing host. Even if the editing host is an inline
|
|
|
|
* element, this method never returns the editing host as the result.
|
|
|
|
*/
|
2016-05-01 16:13:51 +03:00
|
|
|
nsIContent* GetHighestInlineParent(nsINode& aNode);
|
2016-05-01 16:15:14 +03:00
|
|
|
void MakeTransitionList(nsTArray<OwningNonNull<nsINode>>& aNodeArray,
|
2015-04-24 14:27:35 +03:00
|
|
|
nsTArray<bool>& aTransitionArray);
|
2016-05-01 16:15:14 +03:00
|
|
|
nsresult RemoveBlockStyle(nsTArray<OwningNonNull<nsINode>>& aNodeArray);
|
|
|
|
nsresult ApplyBlockStyle(nsTArray<OwningNonNull<nsINode>>& aNodeArray,
|
2017-10-03 01:05:19 +03:00
|
|
|
nsAtom& aBlockTag);
|
2016-05-01 16:15:14 +03:00
|
|
|
nsresult MakeBlockquote(nsTArray<OwningNonNull<nsINode>>& aNodeArray);
|
2017-11-17 10:03:11 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* MaybeSplitAncestorsForInsert() does nothing if container of
|
|
|
|
* aStartOfDeepestRightNode can have an element whose tag name is aTag.
|
|
|
|
* Otherwise, looks for an ancestor node which is or is in active editing
|
|
|
|
* host and can have an element whose name is aTag. If there is such
|
|
|
|
* ancestor, its descendants are split.
|
|
|
|
*
|
|
|
|
* Note that this may create empty elements while splitting ancestors.
|
|
|
|
*
|
|
|
|
* @param aTag The name of element to be inserted
|
|
|
|
* after calling this method.
|
|
|
|
* @param aStartOfDeepestRightNode The start point of deepest right node.
|
|
|
|
* This point must be descendant of
|
|
|
|
* active editing host.
|
|
|
|
* @return When succeeded, SplitPoint() returns
|
|
|
|
* the point to insert the element.
|
|
|
|
*/
|
|
|
|
SplitNodeResult MaybeSplitAncestorsForInsert(
|
|
|
|
nsAtom& aTag,
|
|
|
|
const EditorRawDOMPoint& aStartOfDeepestRightNode);
|
|
|
|
|
2000-04-24 15:51:12 +04:00
|
|
|
nsresult AddTerminatingBR(nsIDOMNode *aBlock);
|
2016-07-07 13:05:51 +03:00
|
|
|
EditorDOMPoint JoinNodesSmart(nsIContent& aNodeLeft,
|
|
|
|
nsIContent& aNodeRight);
|
2016-05-01 16:15:14 +03:00
|
|
|
Element* GetTopEnclosingMailCite(nsINode& aNode);
|
2017-01-11 13:07:33 +03:00
|
|
|
nsresult PopListItem(nsIContent& aListItem, bool* aOutOfList = nullptr);
|
2016-05-01 16:16:26 +03:00
|
|
|
nsresult RemoveListStructure(Element& aList);
|
2017-10-12 10:28:28 +03:00
|
|
|
nsresult CacheInlineStyles(nsINode* aNode);
|
2012-05-22 14:15:09 +04:00
|
|
|
nsresult ReapplyCachedStyles();
|
2013-02-07 12:08:57 +04:00
|
|
|
void ClearCachedStyles();
|
2015-04-24 14:27:35 +03:00
|
|
|
void AdjustSpecialBreaks();
|
2016-05-01 16:15:14 +03:00
|
|
|
nsresult AdjustWhitespace(Selection* aSelection);
|
|
|
|
nsresult PinSelectionToNewBlock(Selection* aSelection);
|
|
|
|
void CheckInterlinePosition(Selection& aSelection);
|
|
|
|
nsresult AdjustSelection(Selection* aSelection,
|
2014-11-02 15:04:13 +03:00
|
|
|
nsIEditor::EDirection aAction);
|
Bug 1415800 - part 5: Redesign HTMLEditRules::FindNearSelectableNode() r=m_kato
First, the method name is not correct. It tries to find an editable node near
the given DOM point. Therefore, it should be FindNearEditableNode().
Next, the implementation did something odd. E.g., in the first |if| block,
when |nearNode| is nullptr, it returns nullptr. However, following |if| block
does something only when |nearNode| is nullptr. So, we can get rid of the
second |if| block. Then, nobody will change aDirection. So, we can make it
not a reference now.
Similarly, in |while| block, if |nearNode| becomes nullptr, it returns error.
However, following block checks if |nearNode| is NOT nullptr. So, we can get
rid of this |if| statement and outdent its block.
Additionally, |curNode| isn't necessary. It only increments the refcount
redundantly. So, we can get rid of it.
Finally, FindNearEditableNode() can return found node directly instead of
error code because error code doesn't make sense. Not found an editable
node is not illegal. And also it can take EditorRawDOMPoint instead of
a set of container, child and offset of the child in the container.
MozReview-Commit-ID: CTI581PhJMd
--HG--
extra : rebase_source : 7e05998721ce96727d40dda1be5e7e36b090bcd3
2017-11-09 19:35:10 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* FindNearEditableNode() tries to find an editable node near aPoint.
|
|
|
|
*
|
|
|
|
* @param aPoint The DOM point where to start to search from.
|
|
|
|
* @param aDirection If nsIEditor::ePrevious is set, this searches an
|
|
|
|
* editable node from next nodes. Otherwise, from
|
|
|
|
* previous nodes.
|
|
|
|
* @return If found, returns non-nullptr. Otherwise, nullptr.
|
|
|
|
* Note that if found node is in different table element,
|
|
|
|
* this returns nullptr.
|
|
|
|
* And also if aDirection is not nsIEditor::ePrevious,
|
|
|
|
* the result may be the node pointed by aPoint.
|
|
|
|
*/
|
|
|
|
nsIContent* FindNearEditableNode(const EditorRawDOMPoint& aPoint,
|
|
|
|
nsIEditor::EDirection aDirection);
|
2012-07-27 18:03:28 +04:00
|
|
|
/**
|
|
|
|
* Returns true if aNode1 or aNode2 or both is the descendant of some type of
|
|
|
|
* table element, but their nearest table element ancestors differ. "Table
|
|
|
|
* element" here includes not just <table> but also <td>, <tbody>, <tr>, etc.
|
|
|
|
* The nodes count as being their own descendants for this purpose, so a
|
|
|
|
* table element is its own nearest table element ancestor.
|
|
|
|
*/
|
2016-07-07 13:05:51 +03:00
|
|
|
bool InDifferentTableElements(nsIDOMNode* aNode1, nsIDOMNode* aNode2);
|
|
|
|
bool InDifferentTableElements(nsINode* aNode1, nsINode* aNode2);
|
1999-11-25 03:19:45 +03:00
|
|
|
nsresult RemoveEmptyNodes();
|
2016-07-07 13:05:51 +03:00
|
|
|
nsresult SelectionEndpointInNode(nsINode* aNode, bool* aResult);
|
2014-11-02 15:04:13 +03:00
|
|
|
nsresult UpdateDocChangeRange(nsRange* aRange);
|
2000-01-10 13:13:58 +03:00
|
|
|
nsresult ConfirmSelectionInBody();
|
2017-08-01 16:38:50 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Insert normal <br> element into aNode when aNode is a block and it has
|
|
|
|
* no children.
|
|
|
|
*/
|
|
|
|
nsresult InsertBRIfNeeded(nsINode& aNode)
|
|
|
|
{
|
|
|
|
return InsertBRIfNeededInternal(aNode, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Insert moz-<br> element (<br type="_moz">) into aNode when aNode is a
|
|
|
|
* block and it has no children.
|
|
|
|
*/
|
|
|
|
nsresult InsertMozBRIfNeeded(nsINode& aNode)
|
|
|
|
{
|
|
|
|
return InsertBRIfNeededInternal(aNode, true);
|
|
|
|
}
|
|
|
|
|
2016-07-07 13:05:51 +03:00
|
|
|
bool IsEmptyInline(nsINode& aNode);
|
|
|
|
bool ListIsEmptyLine(nsTArray<OwningNonNull<nsINode>>& arrayOfNodes);
|
2017-03-03 07:13:21 +03:00
|
|
|
nsresult RemoveAlignment(nsINode& aNode, const nsAString& aAlignType,
|
2016-07-07 13:05:51 +03:00
|
|
|
bool aChildrenOnly);
|
2017-03-03 07:13:21 +03:00
|
|
|
nsresult MakeSureElemStartsOrEndsOnCR(nsINode& aNode, bool aStarts);
|
2016-05-01 16:14:27 +03:00
|
|
|
enum class ContentsOnly { no, yes };
|
2016-05-01 16:15:14 +03:00
|
|
|
nsresult AlignBlock(Element& aElement,
|
2016-05-01 16:14:27 +03:00
|
|
|
const nsAString& aAlignType, ContentsOnly aContentsOnly);
|
2016-05-01 16:17:15 +03:00
|
|
|
enum class Change { minus, plus };
|
|
|
|
nsresult ChangeIndentation(Element& aElement, Change aChange);
|
2010-11-12 00:40:52 +03:00
|
|
|
void DocumentModifiedWorker();
|
1999-11-25 03:19:45 +03:00
|
|
|
|
2017-01-06 16:35:48 +03:00
|
|
|
/**
|
|
|
|
* InitStyleCacheArray() initializes aStyleCache for usable with
|
|
|
|
* GetInlineStyles().
|
|
|
|
*/
|
|
|
|
void InitStyleCacheArray(StyleCache aStyleCache[SIZE_STYLE_TABLE]);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GetInlineStyles() retrieves the style of aNode and modifies each item of
|
|
|
|
* aStyleCache.
|
|
|
|
*/
|
2017-10-12 10:28:28 +03:00
|
|
|
nsresult GetInlineStyles(nsINode* aNode,
|
2017-01-06 16:35:48 +03:00
|
|
|
StyleCache aStyleCache[SIZE_STYLE_TABLE]);
|
|
|
|
|
1999-11-25 03:19:45 +03:00
|
|
|
protected:
|
2016-07-09 05:42:33 +03:00
|
|
|
HTMLEditor* mHTMLEditor;
|
2016-07-07 13:05:51 +03:00
|
|
|
RefPtr<nsRange> mDocChangeRange;
|
|
|
|
bool mListenerEnabled;
|
|
|
|
bool mReturnInEmptyLIKillsList;
|
|
|
|
bool mDidDeleteSelection;
|
|
|
|
bool mDidRangedDelete;
|
|
|
|
bool mRestoreContentEditableCount;
|
|
|
|
RefPtr<nsRange> mUtilRange;
|
|
|
|
// Need to remember an int across willJoin/didJoin...
|
|
|
|
uint32_t mJoinOffset;
|
|
|
|
nsCOMPtr<Element> mNewBlock;
|
|
|
|
RefPtr<RangeItem> mRangeItem;
|
2017-01-06 16:35:48 +03:00
|
|
|
|
|
|
|
// XXX In strict speaking, mCachedStyles isn't enough to cache inline styles
|
|
|
|
// because inline style can be specified with "style" attribute and/or
|
|
|
|
// CSS in <style> elements or CSS files. So, we need to look for better
|
|
|
|
// implementation about this.
|
2016-07-07 13:05:51 +03:00
|
|
|
StyleCache mCachedStyles[SIZE_STYLE_TABLE];
|
1999-11-25 03:19:45 +03:00
|
|
|
};
|
|
|
|
|
2016-07-07 13:05:51 +03:00
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // #ifndef HTMLEditRules_h
|
1999-03-29 10:21:01 +04:00
|
|
|
|