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;
|
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);
|
2018-05-12 05:25:23 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* MakeSureElemStartsAndEndsOnCR() inserts <br> element at start (and/or end)
|
|
|
|
* of aNode if neither:
|
|
|
|
* - first (last) editable child of aNode is a block or a <br>,
|
|
|
|
* - previous (next) sibling of aNode is block or a <br>
|
|
|
|
* - nor no previous (next) sibling of aNode.
|
|
|
|
*
|
|
|
|
* @param aNode The node which may be inserted <br> elements.
|
|
|
|
*/
|
|
|
|
MOZ_MUST_USE nsresult MakeSureElemStartsAndEndsOnCR(nsINode& aNode);
|
2000-05-03 04:14:28 +04:00
|
|
|
|
2018-04-26 17:27:50 +03:00
|
|
|
void DidCreateNode(Selection& aSelection, Element& aNewElement);
|
|
|
|
void DidInsertNode(Selection& aSelection, nsIContent& aNode);
|
|
|
|
void WillDeleteNode(Selection& aSelection, nsINode& aChild);
|
|
|
|
void DidSplitNode(Selection& aSelection,
|
|
|
|
nsINode& aExistingRightNode,
|
|
|
|
nsINode& aNewLeftNode);
|
2018-01-12 18:21:17 +03:00
|
|
|
void WillJoinNodes(nsINode& aLeftNode, nsINode& aRightNode);
|
2018-04-26 17:27:50 +03:00
|
|
|
void DidJoinNodes(Selection& aSelection,
|
|
|
|
nsINode& aLeftNode, nsINode& aRightNode);
|
|
|
|
void DidInsertText(Selection& aSelection,
|
|
|
|
nsINode& aTextNode, int32_t aOffset,
|
2018-01-12 18:21:17 +03:00
|
|
|
const nsAString& aString);
|
2018-04-26 17:27:50 +03:00
|
|
|
void DidDeleteText(Selection& aSelection,
|
|
|
|
nsINode& aTextNode, int32_t aOffset, int32_t aLength);
|
|
|
|
void WillDeleteSelection(Selection& aSelection);
|
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
|
|
|
|
2018-04-26 16:41:34 +03:00
|
|
|
HTMLEditor& HTMLEditorRef() const
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mData);
|
|
|
|
return mData->HTMLEditorRef();
|
|
|
|
}
|
|
|
|
|
1999-06-16 09:02:43 +04:00
|
|
|
enum RulesEndpoint
|
|
|
|
{
|
|
|
|
kStart,
|
|
|
|
kEnd
|
|
|
|
};
|
|
|
|
|
2014-05-10 01:02:29 +04:00
|
|
|
void InitFields();
|
|
|
|
|
2018-05-10 09:03:21 +03:00
|
|
|
void WillInsert(bool* aCancel);
|
2016-07-07 13:05:51 +03:00
|
|
|
nsresult WillInsertText(EditAction aAction,
|
|
|
|
bool* aCancel,
|
|
|
|
bool* aHandled,
|
|
|
|
const nsAString* inString,
|
|
|
|
nsAString* outString,
|
|
|
|
int32_t aMaxLength);
|
2018-05-10 09:03:21 +03:00
|
|
|
nsresult WillLoadHTML(bool* aCancel);
|
|
|
|
nsresult WillInsertBreak(bool* aCancel, bool* aHandled);
|
2017-12-11 12:28:46 +03:00
|
|
|
|
2018-04-26 16:41:34 +03:00
|
|
|
void DeleteNodeIfCollapsedText(nsINode& aNode);
|
|
|
|
|
2017-12-11 12:28:46 +03:00
|
|
|
/**
|
|
|
|
* InsertBRElement() inserts a <br> element into aInsertToBreak.
|
|
|
|
*
|
|
|
|
* @param aInsertToBreak The point where new <br> element will be
|
|
|
|
* inserted before.
|
|
|
|
*/
|
2018-05-10 09:03:21 +03:00
|
|
|
nsresult InsertBRElement(const EditorDOMPoint& aInsertToBreak);
|
2017-12-11 12:28:46 +03:00
|
|
|
|
2018-05-10 09:03:21 +03:00
|
|
|
nsresult SplitMailCites(bool* aHandled);
|
|
|
|
nsresult WillDeleteSelection(nsIEditor::EDirection aAction,
|
2012-05-10 18:54:33 +04:00
|
|
|
nsIEditor::EStripWrappers aStripWrappers,
|
|
|
|
bool* aCancel, bool* aHandled);
|
2018-05-10 09:03:21 +03:00
|
|
|
nsresult DidDeleteSelection(nsIEditor::EDirection aDir,
|
2003-03-23 22:51:03 +03:00
|
|
|
nsresult aResult);
|
2018-05-10 09:03:21 +03:00
|
|
|
nsresult InsertBRIfNeeded();
|
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;
|
|
|
|
|
2018-05-12 05:56:56 +03:00
|
|
|
/**
|
|
|
|
* Insert normal <br> element into aNode when aNode is a block and it has
|
|
|
|
* no children.
|
|
|
|
*/
|
|
|
|
MOZ_MUST_USE 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.
|
|
|
|
*/
|
|
|
|
MOZ_MUST_USE nsresult InsertMozBRIfNeeded(nsINode& aNode)
|
|
|
|
{
|
|
|
|
return InsertBRIfNeededInternal(aNode, true);
|
|
|
|
}
|
|
|
|
|
2017-08-01 16:38:50 +03:00
|
|
|
/**
|
|
|
|
* Insert a normal <br> element or a moz-<br> element to aNode when
|
2018-05-12 05:56:56 +03:00
|
|
|
* aNode is a block and it has no children. Use InsertBRIfNeeded() or
|
|
|
|
* InsertMozBRIfNeeded() instead.
|
2017-08-01 16:38:50 +03:00
|
|
|
*
|
|
|
|
* @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.
|
|
|
|
*/
|
2018-05-12 05:56:56 +03:00
|
|
|
MOZ_MUST_USE nsresult
|
|
|
|
InsertBRIfNeededInternal(nsINode& aNode, bool aInsertMozBR);
|
2017-08-01 16:38:50 +03:00
|
|
|
|
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
|
|
|
|
|
|
|
/**
|
2018-04-09 21:46:44 +03:00
|
|
|
* TryToJoinBlocksWithTransaction() 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,
|
|
|
|
* JoinEditableNodesWithTransaction() 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
|
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
|
|
|
* 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.
|
|
|
|
*/
|
2018-04-09 21:46:44 +03:00
|
|
|
EditActionResult TryToJoinBlocksWithTransaction(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);
|
2018-05-10 09:03:21 +03:00
|
|
|
nsresult WillMakeList(const nsAString* aListType,
|
2012-07-23 14:27:22 +04:00
|
|
|
bool aEntireList,
|
|
|
|
const nsAString* aBulletType,
|
|
|
|
bool* aCancel, bool* aHandled,
|
2012-07-30 18:20:58 +04:00
|
|
|
const nsAString* aItemType = nullptr);
|
2018-05-10 09:03:21 +03:00
|
|
|
nsresult WillRemoveList(bool aOrdered, bool* aCancel, bool* aHandled);
|
|
|
|
nsresult WillIndent(bool* aCancel, bool* aHandled);
|
|
|
|
nsresult WillCSSIndent(bool* aCancel, bool* aHandled);
|
|
|
|
nsresult WillHTMLIndent(bool* aCancel, bool* aHandled);
|
|
|
|
nsresult WillOutdent(bool* aCancel, bool* aHandled);
|
|
|
|
nsresult WillAlign(const nsAString& aAlignType,
|
2012-07-23 14:27:22 +04:00
|
|
|
bool* aCancel, bool* aHandled);
|
2018-05-11 13:32:00 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called before changing absolute positioned element to static positioned.
|
|
|
|
* This method actually changes the position property of nearest absolute
|
|
|
|
* positioned element. Therefore, this might cause destroying the HTML
|
|
|
|
* editor.
|
|
|
|
*
|
|
|
|
* @param aCancel Returns true if the operation is canceled.
|
|
|
|
* @param aHandled Returns true if the edit action is handled.
|
|
|
|
*/
|
|
|
|
MOZ_MUST_USE nsresult
|
|
|
|
WillRemoveAbsolutePosition(bool* aCancel, bool* aHandled);
|
2018-05-11 13:24:35 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called before changing z-index.
|
|
|
|
* This method actually changes z-index of nearest absolute positioned
|
|
|
|
* element relatively. Therefore, this might cause destroying the HTML
|
|
|
|
* editor.
|
|
|
|
*
|
|
|
|
* @param aChange Amount to change z-index.
|
|
|
|
* @param aCancel Returns true if the operation is canceled.
|
|
|
|
* @param aHandled Returns true if the edit action is handled.
|
|
|
|
*/
|
|
|
|
MOZ_MUST_USE nsresult
|
|
|
|
WillRelativeChangeZIndex(int32_t aChange, bool* aCancel, bool* aHandled);
|
|
|
|
|
2018-05-10 09:03:21 +03:00
|
|
|
nsresult WillMakeDefListItem(const nsAString* aBlockType, bool aEntireList,
|
2012-07-23 14:27:22 +04:00
|
|
|
bool* aCancel, bool* aHandled);
|
2018-05-10 09:03:21 +03:00
|
|
|
nsresult WillMakeBasicBlock(const nsAString& aBlockType,
|
2012-07-23 14:27:22 +04:00
|
|
|
bool* aCancel, bool* aHandled);
|
2018-05-10 09:03:21 +03:00
|
|
|
nsresult MakeBasicBlock(nsAtom& aBlockType);
|
|
|
|
nsresult DidMakeBasicBlock(RulesInfo* aInfo, nsresult aResult);
|
2018-05-11 13:39:26 +03:00
|
|
|
|
2018-05-11 14:25:01 +03:00
|
|
|
/**
|
|
|
|
* Called before changing an element to absolute positioned.
|
|
|
|
* This method only prepares the operation since DidAbsolutePosition() will
|
|
|
|
* change it actually later. mNewBlock is set to the target element and
|
|
|
|
* if necessary, some ancestor nodes of selection may be split.
|
|
|
|
*
|
|
|
|
* @param aCancel Returns true if the operation is canceled.
|
|
|
|
* @param aHandled Returns true if the edit action is handled.
|
|
|
|
*/
|
|
|
|
MOZ_MUST_USE nsresult WillAbsolutePosition(bool* aCancel, bool* aHandled);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* PrepareToMakeElementAbsolutePosition() is helper method of
|
|
|
|
* WillAbsolutePosition() since in some cases, needs to restore selection
|
|
|
|
* with AutoSelectionRestorer. So, all callers have to check if
|
|
|
|
* CanHandleEditAction() still returns true after a call of this method.
|
|
|
|
* XXX Should be documented outline of this method.
|
|
|
|
*
|
|
|
|
* @param aHandled Returns true if the edit action is handled.
|
|
|
|
* @param aTargetElement Returns target element which should be
|
|
|
|
* changed to absolute positioned.
|
|
|
|
*/
|
|
|
|
MOZ_MUST_USE nsresult
|
|
|
|
PrepareToMakeElementAbsolutePosition(bool* aHandled,
|
|
|
|
RefPtr<Element>* aTargetElement);
|
|
|
|
|
2018-05-11 13:39:26 +03:00
|
|
|
/**
|
|
|
|
* Called if nobody handles the edit action to make an element absolute
|
|
|
|
* positioned.
|
|
|
|
* This method actually changes the element which is computed by
|
|
|
|
* WillAbsolutePosition() to absolute positioned.
|
|
|
|
* Therefore, this might cause destroying the HTML editor.
|
|
|
|
*/
|
|
|
|
MOZ_MUST_USE nsresult DidAbsolutePosition();
|
|
|
|
|
2018-03-27 14:19:35 +03:00
|
|
|
nsresult AlignInnerBlocks(nsINode& aNode, const nsAString& aAlignType);
|
|
|
|
nsresult AlignBlockContents(nsINode& aNode, const nsAString& aAlignType);
|
2016-05-01 16:15:14 +03:00
|
|
|
nsresult AppendInnerFormatNodes(nsTArray<OwningNonNull<nsINode>>& aArray,
|
2012-05-18 12:29:39 +04:00
|
|
|
nsINode* aNode);
|
2018-01-30 07:10:52 +03:00
|
|
|
nsresult GetFormatString(nsINode* 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();
|
2018-05-10 09:03:21 +03:00
|
|
|
nsresult ReturnInHeader(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
|
|
|
*
|
|
|
|
* @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.
|
|
|
|
*/
|
2018-05-15 10:22:59 +03:00
|
|
|
MOZ_MUST_USE EditActionResult ReturnInParagraph(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 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
|
|
|
*/
|
2018-03-20 08:05:47 +03:00
|
|
|
template<typename PT, typename CT>
|
2018-05-15 10:15:35 +03:00
|
|
|
MOZ_MUST_USE nsresult
|
|
|
|
SplitParagraph(Element& aParentDivOrP,
|
|
|
|
const EditorDOMPointBase<PT, CT>& aStartOfRightNode,
|
|
|
|
nsIContent* aBRNode);
|
2017-11-10 08:43:13 +03:00
|
|
|
|
2018-05-15 09:32:11 +03:00
|
|
|
/**
|
|
|
|
* ReturnInListItem() handles insertParagraph command (i.e., handling
|
|
|
|
* Enter key press) in a list item element.
|
|
|
|
*
|
|
|
|
* @param aListItem The list item which has the following point.
|
|
|
|
* @param aNode Typically, Selection start container, where to
|
|
|
|
* insert a break.
|
|
|
|
* @param aOffset Typically, Selection start offset in the
|
|
|
|
* start container, where to insert a break.
|
|
|
|
*/
|
|
|
|
MOZ_MUST_USE nsresult
|
|
|
|
ReturnInListItem(Element& aListItem, 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
|
|
|
|
2018-05-10 09:03:21 +03:00
|
|
|
nsresult CreateStyleForInsertText(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,
|
|
|
|
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);
|
2018-05-10 09:03:21 +03:00
|
|
|
nsresult ExpandSelectionForDeletion();
|
|
|
|
nsresult NormalizeSelection();
|
2017-07-10 11:35:26 +03:00
|
|
|
EditorDOMPoint GetPromotedPoint(RulesEndpoint aWhere, nsINode& aNode,
|
|
|
|
int32_t aOffset, EditAction actionID);
|
2018-05-10 09:03:21 +03:00
|
|
|
void GetPromotedRanges(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(
|
|
|
|
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);
|
2018-05-14 18:43:07 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* RemoveBlockStyle() removes all format blocks, table related element,
|
|
|
|
* etc in aNodeArray.
|
|
|
|
* If aNodeArray has a format node, it will be removed and its contents
|
|
|
|
* will be moved to where it was.
|
|
|
|
* If aNodeArray has a table related element, <li>, <blockquote> or <div>,
|
|
|
|
* it will removed and its contents will be moved to where it was.
|
|
|
|
*/
|
2016-05-01 16:15:14 +03:00
|
|
|
nsresult RemoveBlockStyle(nsTArray<OwningNonNull<nsINode>>& aNodeArray);
|
Bug 1406726 - HTMLEditRules::WillInsertBreak() should reset mNewNode with caret position r=m_kato
HTMLEditRules::WillInsertBreak() started to use HTMLEditRules::MakeBasicBlock()
to wrap existing inline elements with default paragraph separator if inline
elements are children of editing host. However,
HTMLEditRules::ApplyBlockStyle() called by HTMLEditRules::MakeBasicBlock() sets
mNewNode to last new block node. So, if it wraps inline elements after caret
position, mNewNode becomes after expected caret position and
HTMLEditRules::AfterEditInner() will move caret into it.
This patch make HTMLEditRules::WillInsertBreak() reset mNewNode with
caret position after calling HTMLEditRules::MakeBasicBlock().
Additionally, this patch fixes a bug of HTMLEditor::IsVisibleBRElement().
That is, it uses only editable nodes to check if given <br> element is
visible. However, editable state is not related to this check. If <br>
element is followed by non-editable inline node (except invisible data
nodes), it always visible. This bug caused getting wrong nodes with
HTMLEditRules::GetNodesFromSelection() which is used by
HTMLEditRules::MakeBasicBlock(). Therefore, this patch also adds lots of
EditorBase::Get(Next|Previous)ElementOrText*() and
HTMLEditor::Get(Next|Previous)HTMLElementOrText*() to ignore only invisible
data nodes.
Note that even with this fix, the range of nodes computed by
HTMLEditRules::GetNodesFromSelection() is still odd if only non-editable
elements follow a <br> node which is first <br> element after the caret
position. However, what is expected by the execCommand spec is unclear.
So, automated test added by this patch checks current inconsistent behavior
for now.
MozReview-Commit-ID: 2m52StwoEEH
--HG--
extra : rebase_source : 6b9b2338e35c4d2e89a405fd8e1ffc7b0873ca1e
2018-02-13 13:01:42 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* ApplyBlockStyle() formats all nodes in aNodeArray with block elements
|
|
|
|
* whose name is aBlockTag.
|
|
|
|
* If aNodeArray has an inline element, a block element is created and the
|
|
|
|
* inline element and following inline elements are moved into the new block
|
|
|
|
* element.
|
|
|
|
* If aNodeArray has <br> elements, they'll be removed from the DOM tree and
|
|
|
|
* new block element will be created when there are some remaining inline
|
|
|
|
* elements.
|
|
|
|
* If aNodeArray has a block element, this calls itself with children of
|
|
|
|
* the block element. Then, new block element will be created when there
|
|
|
|
* are some remaining inline elements.
|
|
|
|
*
|
|
|
|
* @param aNodeArray Must be descendants of a node.
|
|
|
|
* @param aBlockTag The element name of new block elements.
|
|
|
|
*/
|
2018-05-14 18:08:46 +03:00
|
|
|
MOZ_MUST_USE nsresult
|
|
|
|
ApplyBlockStyle(nsTArray<OwningNonNull<nsINode>>& aNodeArray,
|
|
|
|
nsAtom& aBlockTag);
|
Bug 1406726 - HTMLEditRules::WillInsertBreak() should reset mNewNode with caret position r=m_kato
HTMLEditRules::WillInsertBreak() started to use HTMLEditRules::MakeBasicBlock()
to wrap existing inline elements with default paragraph separator if inline
elements are children of editing host. However,
HTMLEditRules::ApplyBlockStyle() called by HTMLEditRules::MakeBasicBlock() sets
mNewNode to last new block node. So, if it wraps inline elements after caret
position, mNewNode becomes after expected caret position and
HTMLEditRules::AfterEditInner() will move caret into it.
This patch make HTMLEditRules::WillInsertBreak() reset mNewNode with
caret position after calling HTMLEditRules::MakeBasicBlock().
Additionally, this patch fixes a bug of HTMLEditor::IsVisibleBRElement().
That is, it uses only editable nodes to check if given <br> element is
visible. However, editable state is not related to this check. If <br>
element is followed by non-editable inline node (except invisible data
nodes), it always visible. This bug caused getting wrong nodes with
HTMLEditRules::GetNodesFromSelection() which is used by
HTMLEditRules::MakeBasicBlock(). Therefore, this patch also adds lots of
EditorBase::Get(Next|Previous)ElementOrText*() and
HTMLEditor::Get(Next|Previous)HTMLElementOrText*() to ignore only invisible
data nodes.
Note that even with this fix, the range of nodes computed by
HTMLEditRules::GetNodesFromSelection() is still odd if only non-editable
elements follow a <br> node which is first <br> element after the caret
position. However, what is expected by the execCommand spec is unclear.
So, automated test added by this patch checks current inconsistent behavior
for now.
MozReview-Commit-ID: 2m52StwoEEH
--HG--
extra : rebase_source : 6b9b2338e35c4d2e89a405fd8e1ffc7b0873ca1e
2018-02-13 13:01:42 +03:00
|
|
|
|
2018-05-15 09:09:13 +03:00
|
|
|
/**
|
|
|
|
* MakeBlockquote() inserts at least one <blockquote> element and moves
|
|
|
|
* nodes in aNodeArray into new <blockquote> elements. If aNodeArray
|
|
|
|
* includes a table related element except <table>, this calls itself
|
|
|
|
* recursively to insert <blockquote> into the cell.
|
|
|
|
*
|
|
|
|
* @param aNodeArray Nodes which will be moved into created
|
|
|
|
* <blockquote> elements.
|
|
|
|
*/
|
|
|
|
MOZ_MUST_USE nsresult
|
|
|
|
MakeBlockquote(nsTArray<OwningNonNull<nsINode>>& aNodeArray);
|
2017-11-17 10:03:11 +03:00
|
|
|
|
|
|
|
/**
|
2018-04-09 20:16:49 +03:00
|
|
|
* MaybeSplitAncestorsForInsertWithTransaction() does nothing if container of
|
2017-11-17 10:03:11 +03:00
|
|
|
* 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.
|
|
|
|
*/
|
2018-03-20 08:05:47 +03:00
|
|
|
template<typename PT, typename CT>
|
2018-05-14 17:55:53 +03:00
|
|
|
MOZ_MUST_USE SplitNodeResult
|
|
|
|
MaybeSplitAncestorsForInsertWithTransaction(
|
|
|
|
nsAtom& aTag, const EditorDOMPointBase<PT, CT>& aStartOfDeepestRightNode);
|
2017-11-17 10:03:11 +03:00
|
|
|
|
2018-04-09 21:46:44 +03:00
|
|
|
/**
|
|
|
|
* JoinNearestEditableNodesWithTransaction() joins two editable nodes which
|
|
|
|
* are themselves or the nearest editable node of aLeftNode and aRightNode.
|
|
|
|
* XXX This method's behavior is odd. For example, if user types Backspace
|
|
|
|
* key at the second editable paragraph in this case:
|
|
|
|
* <div contenteditable>
|
|
|
|
* <p>first editable paragraph</p>
|
|
|
|
* <p contenteditable="false">non-editable paragraph</p>
|
|
|
|
* <p>second editable paragraph</p>
|
|
|
|
* </div>
|
|
|
|
* The first editable paragraph's content will be moved into the second
|
|
|
|
* editable paragraph and the non-editable paragraph becomes the first
|
|
|
|
* paragraph of the editor. I don't think that it's expected behavior of
|
|
|
|
* any users...
|
|
|
|
*
|
|
|
|
* @param aLeftNode The node which will be removed.
|
|
|
|
* @param aRightNode The node which will be inserted the content of
|
|
|
|
* aLeftNode.
|
2018-05-14 17:51:23 +03:00
|
|
|
* @param aNewFirstChildOfRightNode
|
|
|
|
* The point at the first child of aRightNode.
|
2018-04-09 21:46:44 +03:00
|
|
|
*/
|
2018-05-14 17:51:23 +03:00
|
|
|
MOZ_MUST_USE nsresult
|
|
|
|
JoinNearestEditableNodesWithTransaction(
|
|
|
|
nsIContent& aLeftNode, nsIContent& aRightNode,
|
|
|
|
EditorDOMPoint* aNewFirstChildOfRightNode);
|
2018-04-09 21:46:44 +03:00
|
|
|
|
2016-05-01 16:15:14 +03:00
|
|
|
Element* GetTopEnclosingMailCite(nsINode& aNode);
|
2018-05-14 12:18:24 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* PopListItem() tries to move aListItem outside its parent. If it's
|
|
|
|
* in a middle of a list element, the parent list element is split before
|
|
|
|
* aListItem. Then, moves aListItem to before its parent list element.
|
|
|
|
* I.e., moves aListItem between the 2 list elements if original parent
|
|
|
|
* was split. Then, if new parent is not a list element, the list item
|
|
|
|
* element is removed and its contents are moved to where the list item
|
|
|
|
* element was.
|
|
|
|
*
|
|
|
|
* @param aListItem Should be a <li>, <dt> or <dd> element.
|
|
|
|
* If it's not so, returns NS_ERROR_FAILURE.
|
|
|
|
* @param aOutOfList Returns true if the list item element is
|
|
|
|
* removed (i.e., unwrapped contents of
|
|
|
|
* aListItem). Otherwise, false.
|
|
|
|
*/
|
|
|
|
MOZ_MUST_USE nsresult
|
|
|
|
PopListItem(nsIContent& aListItem, bool* aOutOfList = nullptr);
|
2018-05-14 11:47:21 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* RemoveListStructure() destroys the list structure of aListElement.
|
|
|
|
* If aListElement has <li>, <dl> or <dt> as a child, the element is removed
|
|
|
|
* but its descendants are moved to where the list item element was.
|
|
|
|
* If aListElement has another <ul>, <ol> or <dl> as a child, this method
|
|
|
|
* is called recursively.
|
|
|
|
* If aListElement has other nodes as its child, they are just removed.
|
|
|
|
* Finally, aListElement is removed. and its all children are moved to
|
|
|
|
* where the aListElement was.
|
|
|
|
*
|
|
|
|
* @param aListElement A <ul>, <ol> or <dl> element.
|
|
|
|
*/
|
|
|
|
MOZ_MUST_USE nsresult RemoveListStructure(Element& aListElement);
|
|
|
|
|
2018-05-14 17:24:40 +03:00
|
|
|
/**
|
|
|
|
* CacheInlineStyles() caches style of aNode into mCachedStyles.
|
|
|
|
* This may cause flushing layout at retrieving computed value of CSS
|
|
|
|
* properties.
|
|
|
|
*/
|
|
|
|
MOZ_MUST_USE nsresult CacheInlineStyles(nsINode* aNode);
|
2018-05-14 17:14:50 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* ReapplyCachedStyles() restores some styles which are disappeared during
|
|
|
|
* handling edit action and it should be restored. This may cause flushing
|
|
|
|
* layout at retrieving computed value of CSS properties.
|
|
|
|
*/
|
|
|
|
MOZ_MUST_USE nsresult ReapplyCachedStyles();
|
|
|
|
|
2013-02-07 12:08:57 +04:00
|
|
|
void ClearCachedStyles();
|
2018-05-14 16:56:06 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* InsertBRElementToEmptyListItemsAndTableCellsInChangedRange() inserts
|
|
|
|
* <br> element into empty list item or table cell elements.
|
|
|
|
*/
|
|
|
|
MOZ_MUST_USE nsresult
|
|
|
|
InsertBRElementToEmptyListItemsAndTableCellsInChangedRange();
|
2018-05-14 16:42:08 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* AdjustWhitespace() may replace whitespaces with NBSP or something.
|
|
|
|
* See WSRunObject::AdjustWhitespace() for the detail.
|
|
|
|
*/
|
|
|
|
MOZ_MUST_USE nsresult AdjustWhitespace();
|
2018-05-14 16:37:33 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* PinSelectionToNewBlock() may collapse Selection around mNewNode if it's
|
|
|
|
* necessary,
|
|
|
|
*/
|
|
|
|
MOZ_MUST_USE nsresult PinSelectionToNewBlock();
|
|
|
|
|
2018-05-10 09:03:21 +03:00
|
|
|
void CheckInterlinePosition();
|
2018-05-14 13:25:48 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* AdjustSelection() may adjust Selection range to nearest editable content.
|
|
|
|
* Despite of the name, this may change the DOM tree. If it needs to create
|
|
|
|
* a <br> to put caret, this tries to create a <br> element.
|
|
|
|
*
|
|
|
|
* @param aAction Maybe used to look for a good point to put caret.
|
|
|
|
*/
|
|
|
|
MOZ_MUST_USE nsresult AdjustSelection(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.
|
|
|
|
*/
|
2018-03-20 08:05:47 +03:00
|
|
|
template<typename PT, typename CT>
|
|
|
|
nsIContent* FindNearEditableNode(const EditorDOMPointBase<PT, CT>& aPoint,
|
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
|
|
|
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(nsINode* aNode1, nsINode* aNode2);
|
2018-05-14 13:07:59 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* RemoveEmptyNodesInChangedRange() removes all empty nodes in
|
|
|
|
* mDocChangeRange. However, if mail-cite node has only a <br> element,
|
|
|
|
* the node will be removed but <br> element is moved to where the
|
|
|
|
* mail-cite node was.
|
|
|
|
* XXX This method is expensive if mDocChangeRange is too wide and may
|
|
|
|
* remove unexpected empty element, e.g., it was created by JS, but
|
|
|
|
* we haven't touched it. Cannot we remove this method and make
|
|
|
|
* guarantee that empty nodes won't be created?
|
|
|
|
*/
|
|
|
|
MOZ_MUST_USE nsresult RemoveEmptyNodesInChangedRange();
|
|
|
|
|
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);
|
2018-05-14 11:47:21 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* ConfirmSelectionInBody() makes sure that Selection is in editor root
|
|
|
|
* element typically <body> element (see HTMLEditor::UpdateRootElement())
|
|
|
|
* and only one Selection range.
|
|
|
|
* XXX This method is not necessary because even if selection is outside the
|
|
|
|
* <body> element, elements outside the <body> element should be
|
|
|
|
* editable, e.g., any element can be inserted siblings as <body> element
|
|
|
|
* and other browsers allow to edit such elements.
|
|
|
|
*/
|
|
|
|
MOZ_MUST_USE nsresult ConfirmSelectionInBody();
|
2017-08-01 16:38:50 +03:00
|
|
|
|
2016-07-07 13:05:51 +03:00
|
|
|
bool IsEmptyInline(nsINode& aNode);
|
|
|
|
bool ListIsEmptyLine(nsTArray<OwningNonNull<nsINode>>& arrayOfNodes);
|
2018-05-12 05:39:01 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* RemoveAlignment() removes align attributes, text-align properties and
|
|
|
|
* <center> elements in aNode.
|
|
|
|
*
|
|
|
|
* @param aNode Alignment information of the node and/or its
|
|
|
|
* descendants will be removed.
|
|
|
|
* @param aAlignType New align value to be set only when it's in
|
|
|
|
* CSS mode and this method meets <table> or <hr>.
|
|
|
|
* XXX This is odd and not clear when you see
|
|
|
|
* caller of this method. Do you have better
|
|
|
|
* idea?
|
|
|
|
* @param aDescendantsOnly true if align information of aNode itself
|
|
|
|
* shouldn't be removed. Otherwise, false.
|
|
|
|
*/
|
|
|
|
MOZ_MUST_USE nsresult
|
|
|
|
RemoveAlignment(nsINode& aNode, const nsAString& aAlignType,
|
|
|
|
bool aDescendantsOnly);
|
2018-05-12 05:25:23 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* MakeSureElemStartsOrEndsOnCR() inserts <br> element at start (end) of
|
|
|
|
* aNode if neither:
|
|
|
|
* - first (last) editable child of aNode is a block or a <br>,
|
|
|
|
* - previous (next) sibling of aNode is block or a <br>
|
|
|
|
* - nor no previous (next) sibling of aNode.
|
|
|
|
*
|
|
|
|
* @param aNode The node which may be inserted <br> element.
|
|
|
|
* @param aStarts true for trying to insert <br> to the start.
|
|
|
|
* false for trying to insert <br> to the end.
|
|
|
|
*/
|
|
|
|
MOZ_MUST_USE nsresult
|
|
|
|
MakeSureElemStartsOrEndsOnCR(nsINode& aNode, bool aStarts);
|
2018-05-12 04:58:57 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* AlignBlock() resets align attribute, text-align property, etc first.
|
|
|
|
* Then, aligns contents of aElement on aAlignType.
|
|
|
|
*
|
|
|
|
* @param aElement The element whose contents will be aligned.
|
|
|
|
* @param aAlignType Boundary or "center" which contents should be
|
|
|
|
* aligned on.
|
|
|
|
* @param aResetAlignOf Resets align of whether element and its
|
|
|
|
* descendants or only descendants.
|
|
|
|
*/
|
|
|
|
enum class ResetAlignOf { ElementAndDescendants, OnlyDescendants };
|
|
|
|
MOZ_MUST_USE nsresult
|
|
|
|
AlignBlock(Element& aElement, const nsAString& aAlignType,
|
|
|
|
ResetAlignOf aResetAlignOf);
|
2018-05-12 04:29:41 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* IncreaseMarginToIndent() increases the margin of aElement. See the
|
|
|
|
* document of ChangeMarginStart() for the detail.
|
|
|
|
* XXX This is not aware of vertical writing-mode.
|
|
|
|
*
|
|
|
|
* @param aElement The element to be indented.
|
|
|
|
*/
|
|
|
|
MOZ_MUST_USE nsresult IncreaseMarginToIndent(Element& aElement)
|
|
|
|
{
|
|
|
|
return ChangeMarginStart(aElement, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* DecreaseMarginToOutdent() decreases the margin of aElement. See the
|
|
|
|
* document of ChangeMarginStart() for the detail.
|
|
|
|
* XXX This is not aware of vertical writing-mode.
|
|
|
|
*
|
|
|
|
* @param aElement The element to be outdented.
|
|
|
|
*/
|
|
|
|
MOZ_MUST_USE nsresult DecreaseMarginToOutdent(Element& aElement)
|
|
|
|
{
|
|
|
|
return ChangeMarginStart(aElement, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ChangeMarginStart() changes margin of aElement to indent or outdent.
|
|
|
|
* However, use IncreaseMarginToIndent() and DecreaseMarginToOutdent()
|
|
|
|
* instead. If it's rtl text, margin-right will be changed. Otherwise,
|
|
|
|
* margin-left.
|
|
|
|
* XXX This is not aware of vertical writing-mode.
|
|
|
|
*
|
|
|
|
* @param aElement The element to be indented or outdented.
|
|
|
|
* @param aIncrease true for indent, false for outdent.
|
|
|
|
*/
|
|
|
|
MOZ_MUST_USE nsresult ChangeMarginStart(Element& aElement, bool aIncrease);
|
|
|
|
|
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
|
2018-05-14 17:20:28 +03:00
|
|
|
* aStyleCache. This might cause flushing layout at retrieving computed
|
|
|
|
* values of CSS properties.
|
2017-01-06 16:35:48 +03:00
|
|
|
*/
|
2018-05-14 17:20:28 +03:00
|
|
|
MOZ_MUST_USE nsresult
|
|
|
|
GetInlineStyles(nsINode* aNode, StyleCache aStyleCache[SIZE_STYLE_TABLE]);
|
2017-01-06 16:35:48 +03:00
|
|
|
|
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;
|
2018-05-11 14:25:01 +03:00
|
|
|
RefPtr<Element> mNewBlock;
|
2016-07-07 13:05:51 +03:00
|
|
|
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
|
|
|
|