зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1549319 - Make template methods marked as MOZ_CAN_RUN_SCRIPT take only EditorDOMPoint (i.e., not allow EditorRawDOMPoint) r=m_kato
It'd be better to change copy constructor of `EditorDOMPointBase` to explicit, but it'd require too many changes in editor code. So, this patch just changes each method callers only. Differential Revision: https://phabricator.services.mozilla.com/D30054 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
8eddd573c6
Коммит
4579004eac
|
@ -123,30 +123,6 @@ using namespace widget;
|
||||||
* mozilla::EditorBase
|
* mozilla::EditorBase
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
template already_AddRefed<Element> EditorBase::CreateNodeWithTransaction(
|
|
||||||
nsAtom& aTag, const EditorDOMPoint& aPointToInsert);
|
|
||||||
template already_AddRefed<Element> EditorBase::CreateNodeWithTransaction(
|
|
||||||
nsAtom& aTag, const EditorRawDOMPoint& aPointToInsert);
|
|
||||||
template nsresult EditorBase::InsertNodeWithTransaction(
|
|
||||||
nsIContent& aContentToInsert, const EditorDOMPoint& aPointToInsert);
|
|
||||||
template nsresult EditorBase::InsertNodeWithTransaction(
|
|
||||||
nsIContent& aContentToInsert, const EditorRawDOMPoint& aPointToInsert);
|
|
||||||
template already_AddRefed<nsIContent> EditorBase::SplitNodeWithTransaction(
|
|
||||||
const EditorDOMPoint& aStartOfRightNode, ErrorResult& aError);
|
|
||||||
template already_AddRefed<nsIContent> EditorBase::SplitNodeWithTransaction(
|
|
||||||
const EditorRawDOMPoint& aStartOfRightNode, ErrorResult& aError);
|
|
||||||
template SplitNodeResult EditorBase::SplitNodeDeepWithTransaction(
|
|
||||||
nsIContent& aMostAncestorToSplit,
|
|
||||||
const EditorDOMPoint& aStartOfDeepestRightNode, SplitAtEdges aSplitAtEdges);
|
|
||||||
template SplitNodeResult EditorBase::SplitNodeDeepWithTransaction(
|
|
||||||
nsIContent& aMostAncestorToSplit,
|
|
||||||
const EditorRawDOMPoint& aStartOfDeepestRightNode,
|
|
||||||
SplitAtEdges aSplitAtEdges);
|
|
||||||
template nsresult EditorBase::MoveNodeWithTransaction(
|
|
||||||
nsIContent& aContent, const EditorDOMPoint& aPointToInsert);
|
|
||||||
template nsresult EditorBase::MoveNodeWithTransaction(
|
|
||||||
nsIContent& aContent, const EditorRawDOMPoint& aPointToInsert);
|
|
||||||
|
|
||||||
EditorBase::EditorBase()
|
EditorBase::EditorBase()
|
||||||
: mEditActionData(nullptr),
|
: mEditActionData(nullptr),
|
||||||
mPlaceholderName(nullptr),
|
mPlaceholderName(nullptr),
|
||||||
|
@ -1342,9 +1318,8 @@ EditorBase::SetSpellcheckUserOverride(bool enable) {
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename PT, typename CT>
|
|
||||||
already_AddRefed<Element> EditorBase::CreateNodeWithTransaction(
|
already_AddRefed<Element> EditorBase::CreateNodeWithTransaction(
|
||||||
nsAtom& aTagName, const EditorDOMPointBase<PT, CT>& aPointToInsert) {
|
nsAtom& aTagName, const EditorDOMPoint& aPointToInsert) {
|
||||||
MOZ_ASSERT(IsEditActionDataAvailable());
|
MOZ_ASSERT(IsEditActionDataAvailable());
|
||||||
|
|
||||||
MOZ_ASSERT(aPointToInsert.IsSetAndValid());
|
MOZ_ASSERT(aPointToInsert.IsSetAndValid());
|
||||||
|
@ -1414,18 +1389,16 @@ EditorBase::InsertNode(nsINode* aNodeToInsert, nsINode* aContainer,
|
||||||
aOffset < 0
|
aOffset < 0
|
||||||
? static_cast<int32_t>(aContainer->Length())
|
? static_cast<int32_t>(aContainer->Length())
|
||||||
: std::min(aOffset, static_cast<int32_t>(aContainer->Length()));
|
: std::min(aOffset, static_cast<int32_t>(aContainer->Length()));
|
||||||
nsresult rv = InsertNodeWithTransaction(
|
nsresult rv = InsertNodeWithTransaction(*contentToInsert,
|
||||||
*contentToInsert, EditorRawDOMPoint(aContainer, offset));
|
EditorDOMPoint(aContainer, offset));
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
return EditorBase::ToGenericNSResult(rv);
|
return EditorBase::ToGenericNSResult(rv);
|
||||||
}
|
}
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename PT, typename CT>
|
|
||||||
nsresult EditorBase::InsertNodeWithTransaction(
|
nsresult EditorBase::InsertNodeWithTransaction(
|
||||||
nsIContent& aContentToInsert,
|
nsIContent& aContentToInsert, const EditorDOMPoint& aPointToInsert) {
|
||||||
const EditorDOMPointBase<PT, CT>& aPointToInsert) {
|
|
||||||
MOZ_ASSERT(IsEditActionDataAvailable());
|
MOZ_ASSERT(IsEditActionDataAvailable());
|
||||||
|
|
||||||
if (NS_WARN_IF(!aPointToInsert.IsSet())) {
|
if (NS_WARN_IF(!aPointToInsert.IsSet())) {
|
||||||
|
@ -1472,7 +1445,7 @@ EditorBase::SplitNode(nsINode* aNode, int32_t aOffset, nsINode** aNewLeftNode) {
|
||||||
std::min(std::max(aOffset, 0), static_cast<int32_t>(aNode->Length()));
|
std::min(std::max(aOffset, 0), static_cast<int32_t>(aNode->Length()));
|
||||||
ErrorResult error;
|
ErrorResult error;
|
||||||
nsCOMPtr<nsIContent> newNode =
|
nsCOMPtr<nsIContent> newNode =
|
||||||
SplitNodeWithTransaction(EditorRawDOMPoint(aNode, offset), error);
|
SplitNodeWithTransaction(EditorDOMPoint(aNode, offset), error);
|
||||||
newNode.forget(aNewLeftNode);
|
newNode.forget(aNewLeftNode);
|
||||||
if (NS_WARN_IF(error.Failed())) {
|
if (NS_WARN_IF(error.Failed())) {
|
||||||
return EditorBase::ToGenericNSResult(error.StealNSResult());
|
return EditorBase::ToGenericNSResult(error.StealNSResult());
|
||||||
|
@ -1480,9 +1453,8 @@ EditorBase::SplitNode(nsINode* aNode, int32_t aOffset, nsINode** aNewLeftNode) {
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename PT, typename CT>
|
|
||||||
already_AddRefed<nsIContent> EditorBase::SplitNodeWithTransaction(
|
already_AddRefed<nsIContent> EditorBase::SplitNodeWithTransaction(
|
||||||
const EditorDOMPointBase<PT, CT>& aStartOfRightNode, ErrorResult& aError) {
|
const EditorDOMPoint& aStartOfRightNode, ErrorResult& aError) {
|
||||||
MOZ_ASSERT(IsEditActionDataAvailable());
|
MOZ_ASSERT(IsEditActionDataAvailable());
|
||||||
|
|
||||||
if (NS_WARN_IF(!aStartOfRightNode.IsSet()) ||
|
if (NS_WARN_IF(!aStartOfRightNode.IsSet()) ||
|
||||||
|
@ -1712,7 +1684,7 @@ already_AddRefed<Element> EditorBase::ReplaceContainerWithTransactionInternal(
|
||||||
}
|
}
|
||||||
|
|
||||||
rv = InsertNodeWithTransaction(
|
rv = InsertNodeWithTransaction(
|
||||||
*child, EditorRawDOMPoint(newContainer, newContainer->Length()));
|
*child, EditorDOMPoint(newContainer, newContainer->Length()));
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -1764,8 +1736,8 @@ nsresult EditorBase::RemoveContainerWithTransaction(Element& aElement) {
|
||||||
// use offset here because previous child might have been moved to
|
// use offset here because previous child might have been moved to
|
||||||
// container.
|
// container.
|
||||||
rv = InsertNodeWithTransaction(
|
rv = InsertNodeWithTransaction(
|
||||||
*child, EditorRawDOMPoint(pointToInsertChildren.GetContainer(),
|
*child, EditorDOMPoint(pointToInsertChildren.GetContainer(),
|
||||||
pointToInsertChildren.Offset()));
|
pointToInsertChildren.Offset()));
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
@ -1820,8 +1792,7 @@ already_AddRefed<Element> EditorBase::InsertContainerWithTransactionInternal(
|
||||||
|
|
||||||
{
|
{
|
||||||
AutoTransactionsConserveSelection conserveSelection(*this);
|
AutoTransactionsConserveSelection conserveSelection(*this);
|
||||||
rv =
|
rv = InsertNodeWithTransaction(aContent, EditorDOMPoint(newContainer, 0));
|
||||||
InsertNodeWithTransaction(aContent, EditorRawDOMPoint(newContainer, 0));
|
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -1836,9 +1807,8 @@ already_AddRefed<Element> EditorBase::InsertContainerWithTransactionInternal(
|
||||||
return newContainer.forget();
|
return newContainer.forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename PT, typename CT>
|
|
||||||
nsresult EditorBase::MoveNodeWithTransaction(
|
nsresult EditorBase::MoveNodeWithTransaction(
|
||||||
nsIContent& aContent, const EditorDOMPointBase<PT, CT>& aPointToInsert) {
|
nsIContent& aContent, const EditorDOMPoint& aPointToInsert) {
|
||||||
MOZ_ASSERT(aPointToInsert.IsSetAndValid());
|
MOZ_ASSERT(aPointToInsert.IsSetAndValid());
|
||||||
|
|
||||||
EditorDOMPoint oldPoint(&aContent);
|
EditorDOMPoint oldPoint(&aContent);
|
||||||
|
@ -1852,8 +1822,7 @@ nsresult EditorBase::MoveNodeWithTransaction(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Notify our internal selection state listener
|
// Notify our internal selection state listener
|
||||||
EditorDOMPoint newPoint(aPointToInsert);
|
AutoMoveNodeSelNotify selNotify(RangeUpdaterRef(), oldPoint, aPointToInsert);
|
||||||
AutoMoveNodeSelNotify selNotify(RangeUpdaterRef(), oldPoint, newPoint);
|
|
||||||
|
|
||||||
// Hold a reference so aNode doesn't go away when we remove it (bug 772282)
|
// Hold a reference so aNode doesn't go away when we remove it (bug 772282)
|
||||||
nsresult rv = DeleteNodeWithTransaction(aContent);
|
nsresult rv = DeleteNodeWithTransaction(aContent);
|
||||||
|
@ -1862,7 +1831,7 @@ nsresult EditorBase::MoveNodeWithTransaction(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mutation event listener could break insertion point. Let's check it.
|
// Mutation event listener could break insertion point. Let's check it.
|
||||||
EditorRawDOMPoint pointToInsert(selNotify.ComputeInsertionPoint());
|
EditorDOMPoint pointToInsert(selNotify.ComputeInsertionPoint());
|
||||||
if (NS_WARN_IF(!pointToInsert.IsSet())) {
|
if (NS_WARN_IF(!pointToInsert.IsSet())) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
@ -3728,10 +3697,9 @@ bool EditorBase::IsPreformatted(nsINode* aNode) {
|
||||||
return styleText->WhiteSpaceIsSignificant();
|
return styleText->WhiteSpaceIsSignificant();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename PT, typename CT>
|
|
||||||
SplitNodeResult EditorBase::SplitNodeDeepWithTransaction(
|
SplitNodeResult EditorBase::SplitNodeDeepWithTransaction(
|
||||||
nsIContent& aMostAncestorToSplit,
|
nsIContent& aMostAncestorToSplit,
|
||||||
const EditorDOMPointBase<PT, CT>& aStartOfDeepestRightNode,
|
const EditorDOMPoint& aStartOfDeepestRightNode,
|
||||||
SplitAtEdges aSplitAtEdges) {
|
SplitAtEdges aSplitAtEdges) {
|
||||||
MOZ_ASSERT(aStartOfDeepestRightNode.IsSetAndValid());
|
MOZ_ASSERT(aStartOfDeepestRightNode.IsSetAndValid());
|
||||||
MOZ_ASSERT(
|
MOZ_ASSERT(
|
||||||
|
|
|
@ -936,10 +936,8 @@ class EditorBase : public nsIEditor,
|
||||||
* container. Otherwise, will insert the node
|
* container. Otherwise, will insert the node
|
||||||
* before child node referred by this.
|
* before child node referred by this.
|
||||||
*/
|
*/
|
||||||
template <typename PT, typename CT>
|
MOZ_CAN_RUN_SCRIPT nsresult InsertNodeWithTransaction(
|
||||||
MOZ_CAN_RUN_SCRIPT nsresult
|
nsIContent& aContentToInsert, const EditorDOMPoint& aPointToInsert);
|
||||||
InsertNodeWithTransaction(nsIContent& aContentToInsert,
|
|
||||||
const EditorDOMPointBase<PT, CT>& aPointToInsert);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ReplaceContainerWithTransaction() creates new element whose name is
|
* ReplaceContainerWithTransaction() creates new element whose name is
|
||||||
|
@ -1071,10 +1069,8 @@ class EditorBase : public nsIEditor,
|
||||||
* @param aError If succeed, returns no error. Otherwise, an
|
* @param aError If succeed, returns no error. Otherwise, an
|
||||||
* error.
|
* error.
|
||||||
*/
|
*/
|
||||||
template <typename PT, typename CT>
|
|
||||||
MOZ_CAN_RUN_SCRIPT already_AddRefed<nsIContent> SplitNodeWithTransaction(
|
MOZ_CAN_RUN_SCRIPT already_AddRefed<nsIContent> SplitNodeWithTransaction(
|
||||||
const EditorDOMPointBase<PT, CT>& aStartOfRightNode,
|
const EditorDOMPoint& aStartOfRightNode, ErrorResult& aResult);
|
||||||
ErrorResult& aResult);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* JoinNodesWithTransaction() joins aLeftNode and aRightNode. Content of
|
* JoinNodesWithTransaction() joins aLeftNode and aRightNode. Content of
|
||||||
|
@ -1093,9 +1089,8 @@ class EditorBase : public nsIEditor,
|
||||||
*
|
*
|
||||||
* @param aContent The node to be moved.
|
* @param aContent The node to be moved.
|
||||||
*/
|
*/
|
||||||
template <typename PT, typename CT>
|
|
||||||
MOZ_CAN_RUN_SCRIPT nsresult MoveNodeWithTransaction(
|
MOZ_CAN_RUN_SCRIPT nsresult MoveNodeWithTransaction(
|
||||||
nsIContent& aContent, const EditorDOMPointBase<PT, CT>& aPointToInsert);
|
nsIContent& aContent, const EditorDOMPoint& aPointToInsert);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MoveNodeToEndWithTransaction() moves aContent to end of aNewContainer.
|
* MoveNodeToEndWithTransaction() moves aContent to end of aNewContainer.
|
||||||
|
@ -1107,7 +1102,7 @@ class EditorBase : public nsIEditor,
|
||||||
MOZ_CAN_RUN_SCRIPT
|
MOZ_CAN_RUN_SCRIPT
|
||||||
nsresult MoveNodeToEndWithTransaction(nsIContent& aContent,
|
nsresult MoveNodeToEndWithTransaction(nsIContent& aContent,
|
||||||
nsINode& aNewContainer) {
|
nsINode& aNewContainer) {
|
||||||
EditorRawDOMPoint pointToInsert;
|
EditorDOMPoint pointToInsert;
|
||||||
pointToInsert.SetToEndOf(&aNewContainer);
|
pointToInsert.SetToEndOf(&aNewContainer);
|
||||||
return MoveNodeWithTransaction(aContent, pointToInsert);
|
return MoveNodeWithTransaction(aContent, pointToInsert);
|
||||||
}
|
}
|
||||||
|
@ -1243,9 +1238,8 @@ class EditorBase : public nsIEditor,
|
||||||
* child node referred by this.
|
* child node referred by this.
|
||||||
* @return The created new element node.
|
* @return The created new element node.
|
||||||
*/
|
*/
|
||||||
template <typename PT, typename CT>
|
|
||||||
MOZ_CAN_RUN_SCRIPT already_AddRefed<Element> CreateNodeWithTransaction(
|
MOZ_CAN_RUN_SCRIPT already_AddRefed<Element> CreateNodeWithTransaction(
|
||||||
nsAtom& aTag, const EditorDOMPointBase<PT, CT>& aPointToInsert);
|
nsAtom& aTag, const EditorDOMPoint& aPointToInsert);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an aggregate transaction for delete selection. The result may
|
* Create an aggregate transaction for delete selection. The result may
|
||||||
|
@ -1390,11 +1384,10 @@ class EditorBase : public nsIEditor,
|
||||||
* be good to insert something if the
|
* be good to insert something if the
|
||||||
* caller want to do it.
|
* caller want to do it.
|
||||||
*/
|
*/
|
||||||
template <typename PT, typename CT>
|
MOZ_CAN_RUN_SCRIPT SplitNodeResult
|
||||||
MOZ_CAN_RUN_SCRIPT SplitNodeResult SplitNodeDeepWithTransaction(
|
SplitNodeDeepWithTransaction(nsIContent& aMostAncestorToSplit,
|
||||||
nsIContent& aMostAncestorToSplit,
|
const EditorDOMPoint& aDeepestStartOfRightNode,
|
||||||
const EditorDOMPointBase<PT, CT>& aDeepestStartOfRightNode,
|
SplitAtEdges aSplitAtEdges);
|
||||||
SplitAtEdges aSplitAtEdges);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* JoinNodesDeepWithTransaction() joins aLeftNode and aRightNode "deeply".
|
* JoinNodesDeepWithTransaction() joins aLeftNode and aRightNode "deeply".
|
||||||
|
|
|
@ -240,17 +240,17 @@ class MOZ_STACK_CLASS SplitNodeResult final {
|
||||||
* by this instance. Therefore, the life time of both container node
|
* by this instance. Therefore, the life time of both container node
|
||||||
* and child node are guaranteed while using the result temporarily.
|
* and child node are guaranteed while using the result temporarily.
|
||||||
*/
|
*/
|
||||||
EditorRawDOMPoint SplitPoint() const {
|
EditorDOMPoint SplitPoint() const {
|
||||||
if (Failed()) {
|
if (Failed()) {
|
||||||
return EditorRawDOMPoint();
|
return EditorDOMPoint();
|
||||||
}
|
}
|
||||||
if (mGivenSplitPoint.IsSet()) {
|
if (mGivenSplitPoint.IsSet()) {
|
||||||
return EditorRawDOMPoint(mGivenSplitPoint);
|
return EditorDOMPoint(mGivenSplitPoint);
|
||||||
}
|
}
|
||||||
if (!mPreviousNode) {
|
if (!mPreviousNode) {
|
||||||
return EditorRawDOMPoint(mNextNode);
|
return EditorDOMPoint(mNextNode);
|
||||||
}
|
}
|
||||||
EditorRawDOMPoint point(mPreviousNode);
|
EditorDOMPoint point(mPreviousNode);
|
||||||
DebugOnly<bool> advanced = point.AdvanceOffset();
|
DebugOnly<bool> advanced = point.AdvanceOffset();
|
||||||
NS_WARNING_ASSERTION(advanced,
|
NS_WARNING_ASSERTION(advanced,
|
||||||
"Failed to advance offset to after previous node");
|
"Failed to advance offset to after previous node");
|
||||||
|
|
|
@ -519,7 +519,7 @@ nsresult HTMLEditor::SetPositionToAbsolute(Element& aElement) {
|
||||||
nsINode* parentNode = aElement.GetParentNode();
|
nsINode* parentNode = aElement.GetParentNode();
|
||||||
if (parentNode->GetChildCount() == 1) {
|
if (parentNode->GetChildCount() == 1) {
|
||||||
RefPtr<Element> newBrElement =
|
RefPtr<Element> newBrElement =
|
||||||
InsertBrElementWithTransaction(EditorRawDOMPoint(parentNode, 0));
|
InsertBrElementWithTransaction(EditorDOMPoint(parentNode, 0));
|
||||||
if (NS_WARN_IF(!newBrElement)) {
|
if (NS_WARN_IF(!newBrElement)) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1833,7 +1833,7 @@ EditActionResult HTMLEditRules::WillInsertParagraphSeparator() {
|
||||||
// make block have a line. Then code further below will put in a second br.)
|
// make block have a line. Then code further below will put in a second br.)
|
||||||
if (IsEmptyBlockElement(*blockParent, IgnoreSingleBR::eNo)) {
|
if (IsEmptyBlockElement(*blockParent, IgnoreSingleBR::eNo)) {
|
||||||
AutoEditorDOMPointChildInvalidator lockOffset(atStartOfSelection);
|
AutoEditorDOMPointChildInvalidator lockOffset(atStartOfSelection);
|
||||||
EditorRawDOMPoint endOfBlockParent;
|
EditorDOMPoint endOfBlockParent;
|
||||||
endOfBlockParent.SetToEndOf(blockParent);
|
endOfBlockParent.SetToEndOf(blockParent);
|
||||||
RefPtr<Element> brElement =
|
RefPtr<Element> brElement =
|
||||||
MOZ_KnownLive(HTMLEditorRef())
|
MOZ_KnownLive(HTMLEditorRef())
|
||||||
|
@ -2060,7 +2060,7 @@ nsresult HTMLEditRules::InsertBRElement(const EditorDOMPoint& aPointToBreak) {
|
||||||
EditActionResult HTMLEditRules::SplitMailCites() {
|
EditActionResult HTMLEditRules::SplitMailCites() {
|
||||||
MOZ_ASSERT(IsEditorDataAvailable());
|
MOZ_ASSERT(IsEditorDataAvailable());
|
||||||
|
|
||||||
EditorRawDOMPoint pointToSplit(EditorBase::GetStartPoint(*SelectionRefPtr()));
|
EditorDOMPoint pointToSplit(EditorBase::GetStartPoint(*SelectionRefPtr()));
|
||||||
if (NS_WARN_IF(!pointToSplit.IsSet())) {
|
if (NS_WARN_IF(!pointToSplit.IsSet())) {
|
||||||
return EditActionIgnored(NS_ERROR_FAILURE);
|
return EditActionIgnored(NS_ERROR_FAILURE);
|
||||||
}
|
}
|
||||||
|
@ -2128,7 +2128,7 @@ EditActionResult HTMLEditRules::SplitMailCites() {
|
||||||
nsCOMPtr<nsINode> lastChild = previousNodeOfSplitPoint->GetLastChild();
|
nsCOMPtr<nsINode> lastChild = previousNodeOfSplitPoint->GetLastChild();
|
||||||
if (lastChild && !lastChild->IsHTMLElement(nsGkAtoms::br)) {
|
if (lastChild && !lastChild->IsHTMLElement(nsGkAtoms::br)) {
|
||||||
// We ignore the result here.
|
// We ignore the result here.
|
||||||
EditorRawDOMPoint endOfPreviousNodeOfSplitPoint;
|
EditorDOMPoint endOfPreviousNodeOfSplitPoint;
|
||||||
endOfPreviousNodeOfSplitPoint.SetToEndOf(previousNodeOfSplitPoint);
|
endOfPreviousNodeOfSplitPoint.SetToEndOf(previousNodeOfSplitPoint);
|
||||||
RefPtr<Element> invisibleBrElement =
|
RefPtr<Element> invisibleBrElement =
|
||||||
MOZ_KnownLive(HTMLEditorRef())
|
MOZ_KnownLive(HTMLEditorRef())
|
||||||
|
@ -2144,7 +2144,7 @@ EditActionResult HTMLEditRules::SplitMailCites() {
|
||||||
// In most cases, <br> should be inserted after current cite. However, if
|
// In most cases, <br> should be inserted after current cite. However, if
|
||||||
// left cite hasn't been created because the split point was start of the
|
// left cite hasn't been created because the split point was start of the
|
||||||
// cite node, <br> should be inserted before the current cite.
|
// cite node, <br> should be inserted before the current cite.
|
||||||
EditorRawDOMPoint pointToInsertBrNode(splitCiteNodeResult.SplitPoint());
|
EditorDOMPoint pointToInsertBrNode(splitCiteNodeResult.SplitPoint());
|
||||||
RefPtr<Element> brElement =
|
RefPtr<Element> brElement =
|
||||||
MOZ_KnownLive(HTMLEditorRef())
|
MOZ_KnownLive(HTMLEditorRef())
|
||||||
.InsertBrElementWithTransaction(pointToInsertBrNode);
|
.InsertBrElementWithTransaction(pointToInsertBrNode);
|
||||||
|
@ -2179,8 +2179,8 @@ EditActionResult HTMLEditRules::SplitMailCites() {
|
||||||
// then we will need a 2nd br added to achieve blank line that user expects.
|
// then we will need a 2nd br added to achieve blank line that user expects.
|
||||||
if (IsInlineNode(*citeNode)) {
|
if (IsInlineNode(*citeNode)) {
|
||||||
// Use DOM point which we tried to collapse to.
|
// Use DOM point which we tried to collapse to.
|
||||||
EditorRawDOMPoint pointToCreateNewBrNode(atBrNode.GetContainer(),
|
EditorDOMPoint pointToCreateNewBrNode(atBrNode.GetContainer(),
|
||||||
atBrNode.Offset());
|
atBrNode.Offset());
|
||||||
|
|
||||||
WSRunObject wsObj(&HTMLEditorRef(), pointToCreateNewBrNode);
|
WSRunObject wsObj(&HTMLEditorRef(), pointToCreateNewBrNode);
|
||||||
WSType wsType;
|
WSType wsType;
|
||||||
|
@ -3168,7 +3168,7 @@ nsresult HTMLEditRules::DeleteNodeIfCollapsedText(nsINode& aNode) {
|
||||||
nsresult HTMLEditRules::InsertBRIfNeeded() {
|
nsresult HTMLEditRules::InsertBRIfNeeded() {
|
||||||
MOZ_ASSERT(IsEditorDataAvailable());
|
MOZ_ASSERT(IsEditorDataAvailable());
|
||||||
|
|
||||||
EditorRawDOMPoint atStartOfSelection(
|
EditorDOMPoint atStartOfSelection(
|
||||||
EditorBase::GetStartPoint(*SelectionRefPtr()));
|
EditorBase::GetStartPoint(*SelectionRefPtr()));
|
||||||
if (NS_WARN_IF(!atStartOfSelection.IsSet())) {
|
if (NS_WARN_IF(!atStartOfSelection.IsSet())) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
|
@ -3687,7 +3687,7 @@ EditActionResult HTMLEditRules::MoveNodeSmart(nsIContent& aNode,
|
||||||
return EditActionIgnored(rv);
|
return EditActionIgnored(rv);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
EditorRawDOMPoint pointToInsert(&aDestElement, *aInOutDestOffset);
|
EditorDOMPoint pointToInsert(&aDestElement, *aInOutDestOffset);
|
||||||
nsresult rv = MOZ_KnownLive(HTMLEditorRef())
|
nsresult rv = MOZ_KnownLive(HTMLEditorRef())
|
||||||
.MoveNodeWithTransaction(aNode, pointToInsert);
|
.MoveNodeWithTransaction(aNode, pointToInsert);
|
||||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||||
|
@ -3972,11 +3972,9 @@ nsresult HTMLEditRules::MakeList(nsAtom& aListType, bool aEntireList,
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorRawDOMPoint atFirstListItemToInsertBefore(theList, 0);
|
|
||||||
RefPtr<Element> theListItem =
|
RefPtr<Element> theListItem =
|
||||||
MOZ_KnownLive(HTMLEditorRef())
|
MOZ_KnownLive(HTMLEditorRef())
|
||||||
.CreateNodeWithTransaction(aItemType,
|
.CreateNodeWithTransaction(aItemType, EditorDOMPoint(theList, 0));
|
||||||
atFirstListItemToInsertBefore);
|
|
||||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||||
return NS_ERROR_EDITOR_DESTROYED;
|
return NS_ERROR_EDITOR_DESTROYED;
|
||||||
}
|
}
|
||||||
|
@ -4086,7 +4084,7 @@ nsresult HTMLEditRules::MakeList(nsAtom& aListType, bool aEntireList,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorRawDOMPoint atCurNode(curNode);
|
EditorDOMPoint atCurNode(curNode);
|
||||||
if (NS_WARN_IF(!atCurNode.IsSet())) {
|
if (NS_WARN_IF(!atCurNode.IsSet())) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
@ -4111,10 +4109,10 @@ nsresult HTMLEditRules::MakeList(nsAtom& aListType, bool aEntireList,
|
||||||
return error.StealNSResult();
|
return error.StealNSResult();
|
||||||
}
|
}
|
||||||
newBlock = newLeftNode ? newLeftNode->AsElement() : nullptr;
|
newBlock = newLeftNode ? newLeftNode->AsElement() : nullptr;
|
||||||
EditorRawDOMPoint atParentOfCurNode(atCurNode.GetContainer());
|
|
||||||
curList =
|
curList =
|
||||||
MOZ_KnownLive(HTMLEditorRef())
|
MOZ_KnownLive(HTMLEditorRef())
|
||||||
.CreateNodeWithTransaction(aListType, atParentOfCurNode);
|
.CreateNodeWithTransaction(
|
||||||
|
aListType, EditorDOMPoint(atCurNode.GetContainer()));
|
||||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||||
return NS_ERROR_EDITOR_DESTROYED;
|
return NS_ERROR_EDITOR_DESTROYED;
|
||||||
}
|
}
|
||||||
|
@ -4476,7 +4474,7 @@ nsresult HTMLEditRules::MakeBasicBlock(nsAtom& blockType) {
|
||||||
if (NS_WARN_IF(splitNodeResult.Failed())) {
|
if (NS_WARN_IF(splitNodeResult.Failed())) {
|
||||||
return splitNodeResult.Rv();
|
return splitNodeResult.Rv();
|
||||||
}
|
}
|
||||||
EditorRawDOMPoint pointToInsertBrNode(splitNodeResult.SplitPoint());
|
EditorDOMPoint pointToInsertBrNode(splitNodeResult.SplitPoint());
|
||||||
// Put a <br> element at the split point
|
// Put a <br> element at the split point
|
||||||
brContent = MOZ_KnownLive(HTMLEditorRef())
|
brContent = MOZ_KnownLive(HTMLEditorRef())
|
||||||
.InsertBrElementWithTransaction(pointToInsertBrNode);
|
.InsertBrElementWithTransaction(pointToInsertBrNode);
|
||||||
|
@ -4791,7 +4789,7 @@ nsresult HTMLEditRules::IndentAroundSelectionWithCSS() {
|
||||||
nsresult rv =
|
nsresult rv =
|
||||||
MOZ_KnownLive(HTMLEditorRef())
|
MOZ_KnownLive(HTMLEditorRef())
|
||||||
.MoveNodeWithTransaction(MOZ_KnownLive(*curNode->AsContent()),
|
.MoveNodeWithTransaction(MOZ_KnownLive(*curNode->AsContent()),
|
||||||
EditorRawDOMPoint(sibling, 0));
|
EditorDOMPoint(sibling, 0));
|
||||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||||
return NS_ERROR_EDITOR_DESTROYED;
|
return NS_ERROR_EDITOR_DESTROYED;
|
||||||
}
|
}
|
||||||
|
@ -5067,7 +5065,7 @@ nsresult HTMLEditRules::IndentAroundSelectionWithHTML() {
|
||||||
sibling->NodeInfo()->NamespaceID()) {
|
sibling->NodeInfo()->NamespaceID()) {
|
||||||
rv = MOZ_KnownLive(HTMLEditorRef())
|
rv = MOZ_KnownLive(HTMLEditorRef())
|
||||||
.MoveNodeWithTransaction(MOZ_KnownLive(*curNode->AsContent()),
|
.MoveNodeWithTransaction(MOZ_KnownLive(*curNode->AsContent()),
|
||||||
EditorRawDOMPoint(sibling, 0));
|
EditorDOMPoint(sibling, 0));
|
||||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||||
return NS_ERROR_EDITOR_DESTROYED;
|
return NS_ERROR_EDITOR_DESTROYED;
|
||||||
}
|
}
|
||||||
|
@ -5566,7 +5564,7 @@ SplitRangeOffFromNodeResult HTMLEditRules::OutdentAroundSelection() {
|
||||||
// We have an embedded list, so move it out from under the parent
|
// We have an embedded list, so move it out from under the parent
|
||||||
// list. Be sure to put it after the parent list because this
|
// list. Be sure to put it after the parent list because this
|
||||||
// loop iterates backwards through the parent's list of children.
|
// loop iterates backwards through the parent's list of children.
|
||||||
EditorRawDOMPoint afterCurrentList(curParent, offset + 1);
|
EditorDOMPoint afterCurrentList(curParent, offset + 1);
|
||||||
rv = MOZ_KnownLive(HTMLEditorRef())
|
rv = MOZ_KnownLive(HTMLEditorRef())
|
||||||
.MoveNodeWithTransaction(*child, afterCurrentList);
|
.MoveNodeWithTransaction(*child, afterCurrentList);
|
||||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||||
|
@ -5675,7 +5673,7 @@ SplitRangeOffFromNodeResult HTMLEditRules::SplitRangeOffFromBlock(
|
||||||
SplitNodeResult splitAtStartResult =
|
SplitNodeResult splitAtStartResult =
|
||||||
MOZ_KnownLive(HTMLEditorRef())
|
MOZ_KnownLive(HTMLEditorRef())
|
||||||
.SplitNodeDeepWithTransaction(
|
.SplitNodeDeepWithTransaction(
|
||||||
aBlockElement, EditorRawDOMPoint(&aStartOfMiddleElement),
|
aBlockElement, EditorDOMPoint(&aStartOfMiddleElement),
|
||||||
SplitAtEdges::eDoNotCreateEmptyContainer);
|
SplitAtEdges::eDoNotCreateEmptyContainer);
|
||||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||||
return SplitRangeOffFromNodeResult(NS_ERROR_EDITOR_DESTROYED);
|
return SplitRangeOffFromNodeResult(NS_ERROR_EDITOR_DESTROYED);
|
||||||
|
@ -5684,7 +5682,7 @@ SplitRangeOffFromNodeResult HTMLEditRules::SplitRangeOffFromBlock(
|
||||||
"Failed to split aBlockElement at start");
|
"Failed to split aBlockElement at start");
|
||||||
|
|
||||||
// Split at after the end
|
// Split at after the end
|
||||||
EditorRawDOMPoint atAfterEnd(&aEndOfMiddleElement);
|
EditorDOMPoint atAfterEnd(&aEndOfMiddleElement);
|
||||||
DebugOnly<bool> advanced = atAfterEnd.AdvanceOffset();
|
DebugOnly<bool> advanced = atAfterEnd.AdvanceOffset();
|
||||||
NS_WARNING_ASSERTION(advanced, "Failed to advance offset after the end node");
|
NS_WARNING_ASSERTION(advanced, "Failed to advance offset after the end node");
|
||||||
SplitNodeResult splitAtEndResult =
|
SplitNodeResult splitAtEndResult =
|
||||||
|
@ -5845,7 +5843,7 @@ nsresult HTMLEditRules::CreateStyleForInsertText(Document& aDocument) {
|
||||||
SplitNodeResult splitTextNodeResult =
|
SplitNodeResult splitTextNodeResult =
|
||||||
MOZ_KnownLive(HTMLEditorRef())
|
MOZ_KnownLive(HTMLEditorRef())
|
||||||
.SplitNodeDeepWithTransaction(
|
.SplitNodeDeepWithTransaction(
|
||||||
*text, EditorRawDOMPoint(text, offset),
|
*text, EditorDOMPoint(text, offset),
|
||||||
SplitAtEdges::eAllowToCreateEmptyContainer);
|
SplitAtEdges::eAllowToCreateEmptyContainer);
|
||||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||||
return NS_ERROR_EDITOR_DESTROYED;
|
return NS_ERROR_EDITOR_DESTROYED;
|
||||||
|
@ -5862,9 +5860,9 @@ nsresult HTMLEditRules::CreateStyleForInsertText(Document& aDocument) {
|
||||||
}
|
}
|
||||||
OwningNonNull<Text> newNode =
|
OwningNonNull<Text> newNode =
|
||||||
EditorBase::CreateTextNode(aDocument, EmptyString());
|
EditorBase::CreateTextNode(aDocument, EmptyString());
|
||||||
nsresult rv = MOZ_KnownLive(HTMLEditorRef())
|
nsresult rv =
|
||||||
.InsertNodeWithTransaction(
|
MOZ_KnownLive(HTMLEditorRef())
|
||||||
*newNode, EditorRawDOMPoint(node, offset));
|
.InsertNodeWithTransaction(*newNode, EditorDOMPoint(node, offset));
|
||||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||||
return NS_ERROR_EDITOR_DESTROYED;
|
return NS_ERROR_EDITOR_DESTROYED;
|
||||||
}
|
}
|
||||||
|
@ -6090,8 +6088,7 @@ nsresult HTMLEditRules::AlignContentsAtSelection(const nsAString& aAlignType) {
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
// Put in a moz-br so that it won't get deleted
|
// Put in a moz-br so that it won't get deleted
|
||||||
CreateElementResult createMozBrResult =
|
CreateElementResult createMozBrResult = CreateMozBR(EditorDOMPoint(div, 0));
|
||||||
CreateMozBR(EditorRawDOMPoint(div, 0));
|
|
||||||
if (NS_WARN_IF(createMozBrResult.Failed())) {
|
if (NS_WARN_IF(createMozBrResult.Failed())) {
|
||||||
return createMozBrResult.Rv();
|
return createMozBrResult.Rv();
|
||||||
}
|
}
|
||||||
|
@ -6298,10 +6295,9 @@ nsresult HTMLEditRules::AlignBlockContents(nsINode& aNode,
|
||||||
|
|
||||||
// else we need to put in a div, set the alignment, and toss in all the
|
// else we need to put in a div, set the alignment, and toss in all the
|
||||||
// children
|
// children
|
||||||
EditorRawDOMPoint atStartOfNode(&aNode, 0);
|
RefPtr<Element> divElem = MOZ_KnownLive(HTMLEditorRef())
|
||||||
RefPtr<Element> divElem =
|
.CreateNodeWithTransaction(
|
||||||
MOZ_KnownLive(HTMLEditorRef())
|
*nsGkAtoms::div, EditorDOMPoint(&aNode, 0));
|
||||||
.CreateNodeWithTransaction(*nsGkAtoms::div, atStartOfNode);
|
|
||||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||||
return NS_ERROR_EDITOR_DESTROYED;
|
return NS_ERROR_EDITOR_DESTROYED;
|
||||||
}
|
}
|
||||||
|
@ -6322,7 +6318,7 @@ nsresult HTMLEditRules::AlignBlockContents(nsINode& aNode,
|
||||||
while (lastChild && (lastChild != divElem)) {
|
while (lastChild && (lastChild != divElem)) {
|
||||||
nsresult rv =
|
nsresult rv =
|
||||||
MOZ_KnownLive(HTMLEditorRef())
|
MOZ_KnownLive(HTMLEditorRef())
|
||||||
.MoveNodeWithTransaction(*lastChild, EditorRawDOMPoint(divElem, 0));
|
.MoveNodeWithTransaction(*lastChild, EditorDOMPoint(divElem, 0));
|
||||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||||
return NS_ERROR_EDITOR_DESTROYED;
|
return NS_ERROR_EDITOR_DESTROYED;
|
||||||
}
|
}
|
||||||
|
@ -7493,8 +7489,7 @@ nsresult HTMLEditRules::BustUpInlinesAtRangeEndpoints(RangeItem& aRangeItem) {
|
||||||
MOZ_KnownLive(HTMLEditorRef())
|
MOZ_KnownLive(HTMLEditorRef())
|
||||||
.SplitNodeDeepWithTransaction(
|
.SplitNodeDeepWithTransaction(
|
||||||
*endInline,
|
*endInline,
|
||||||
EditorRawDOMPoint(aRangeItem.mEndContainer,
|
EditorDOMPoint(aRangeItem.mEndContainer, aRangeItem.mEndOffset),
|
||||||
aRangeItem.mEndOffset),
|
|
||||||
SplitAtEdges::eDoNotCreateEmptyContainer);
|
SplitAtEdges::eDoNotCreateEmptyContainer);
|
||||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||||
return NS_ERROR_EDITOR_DESTROYED;
|
return NS_ERROR_EDITOR_DESTROYED;
|
||||||
|
@ -7518,8 +7513,8 @@ nsresult HTMLEditRules::BustUpInlinesAtRangeEndpoints(RangeItem& aRangeItem) {
|
||||||
MOZ_KnownLive(HTMLEditorRef())
|
MOZ_KnownLive(HTMLEditorRef())
|
||||||
.SplitNodeDeepWithTransaction(
|
.SplitNodeDeepWithTransaction(
|
||||||
*startInline,
|
*startInline,
|
||||||
EditorRawDOMPoint(aRangeItem.mStartContainer,
|
EditorDOMPoint(aRangeItem.mStartContainer,
|
||||||
aRangeItem.mStartOffset),
|
aRangeItem.mStartOffset),
|
||||||
SplitAtEdges::eDoNotCreateEmptyContainer);
|
SplitAtEdges::eDoNotCreateEmptyContainer);
|
||||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||||
return NS_ERROR_EDITOR_DESTROYED;
|
return NS_ERROR_EDITOR_DESTROYED;
|
||||||
|
@ -7560,7 +7555,7 @@ nsresult HTMLEditRules::BustUpInlinesAtBRs(
|
||||||
// Else we need to bust up aNode along all the breaks
|
// Else we need to bust up aNode along all the breaks
|
||||||
nsCOMPtr<nsIContent> nextNode = &aNode;
|
nsCOMPtr<nsIContent> nextNode = &aNode;
|
||||||
for (OwningNonNull<nsINode>& brNode : arrayOfBreaks) {
|
for (OwningNonNull<nsINode>& brNode : arrayOfBreaks) {
|
||||||
EditorRawDOMPoint atBrNode(brNode);
|
EditorDOMPoint atBrNode(brNode);
|
||||||
if (NS_WARN_IF(!atBrNode.IsSet())) {
|
if (NS_WARN_IF(!atBrNode.IsSet())) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
@ -7585,7 +7580,7 @@ nsresult HTMLEditRules::BustUpInlinesAtBRs(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move break outside of container and also put in node list
|
// Move break outside of container and also put in node list
|
||||||
EditorRawDOMPoint atNextNode(splitNodeResult.GetNextNode());
|
EditorDOMPoint atNextNode(splitNodeResult.GetNextNode());
|
||||||
nsresult rv = MOZ_KnownLive(HTMLEditorRef())
|
nsresult rv = MOZ_KnownLive(HTMLEditorRef())
|
||||||
.MoveNodeWithTransaction(
|
.MoveNodeWithTransaction(
|
||||||
MOZ_KnownLive(*brNode->AsContent()), atNextNode);
|
MOZ_KnownLive(*brNode->AsContent()), atNextNode);
|
||||||
|
@ -7763,7 +7758,7 @@ nsresult HTMLEditRules::ReturnInHeader(Element& aHeader, nsINode& aNode,
|
||||||
SplitNodeResult splitHeaderResult =
|
SplitNodeResult splitHeaderResult =
|
||||||
MOZ_KnownLive(HTMLEditorRef())
|
MOZ_KnownLive(HTMLEditorRef())
|
||||||
.SplitNodeDeepWithTransaction(
|
.SplitNodeDeepWithTransaction(
|
||||||
aHeader, EditorRawDOMPoint(node, aOffset),
|
aHeader, EditorDOMPoint(node, aOffset),
|
||||||
SplitAtEdges::eAllowToCreateEmptyContainer);
|
SplitAtEdges::eAllowToCreateEmptyContainer);
|
||||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||||
return NS_ERROR_EDITOR_DESTROYED;
|
return NS_ERROR_EDITOR_DESTROYED;
|
||||||
|
@ -7782,7 +7777,7 @@ nsresult HTMLEditRules::ReturnInHeader(Element& aHeader, nsINode& aNode,
|
||||||
}
|
}
|
||||||
if (isEmptyNode) {
|
if (isEmptyNode) {
|
||||||
CreateElementResult createMozBrResult =
|
CreateElementResult createMozBrResult =
|
||||||
CreateMozBR(EditorRawDOMPoint(prevItem, 0));
|
CreateMozBR(EditorDOMPoint(prevItem, 0));
|
||||||
if (NS_WARN_IF(createMozBrResult.Failed())) {
|
if (NS_WARN_IF(createMozBrResult.Failed())) {
|
||||||
return createMozBrResult.Rv();
|
return createMozBrResult.Rv();
|
||||||
}
|
}
|
||||||
|
@ -7811,7 +7806,7 @@ nsresult HTMLEditRules::ReturnInHeader(Element& aHeader, nsINode& aNode,
|
||||||
// Create a paragraph
|
// Create a paragraph
|
||||||
nsAtom& paraAtom = DefaultParagraphSeparator();
|
nsAtom& paraAtom = DefaultParagraphSeparator();
|
||||||
// We want a wrapper element even if we separate with <br>
|
// We want a wrapper element even if we separate with <br>
|
||||||
EditorRawDOMPoint nextToHeader(headerParent, offset + 1);
|
EditorDOMPoint nextToHeader(headerParent, offset + 1);
|
||||||
RefPtr<Element> pNode =
|
RefPtr<Element> pNode =
|
||||||
MOZ_KnownLive(HTMLEditorRef())
|
MOZ_KnownLive(HTMLEditorRef())
|
||||||
.CreateNodeWithTransaction(¶Atom == nsGkAtoms::br
|
.CreateNodeWithTransaction(¶Atom == nsGkAtoms::br
|
||||||
|
@ -7828,7 +7823,7 @@ nsresult HTMLEditRules::ReturnInHeader(Element& aHeader, nsINode& aNode,
|
||||||
// Append a <br> to it
|
// Append a <br> to it
|
||||||
RefPtr<Element> brElement =
|
RefPtr<Element> brElement =
|
||||||
MOZ_KnownLive(HTMLEditorRef())
|
MOZ_KnownLive(HTMLEditorRef())
|
||||||
.InsertBrElementWithTransaction(EditorRawDOMPoint(pNode, 0));
|
.InsertBrElementWithTransaction(EditorDOMPoint(pNode, 0));
|
||||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||||
return NS_ERROR_EDITOR_DESTROYED;
|
return NS_ERROR_EDITOR_DESTROYED;
|
||||||
}
|
}
|
||||||
|
@ -7964,7 +7959,7 @@ EditActionResult HTMLEditRules::ReturnInParagraph(Element& aParentDivOrP) {
|
||||||
|
|
||||||
EditorDOMPoint pointToSplitParentDivOrP(atStartOfSelection);
|
EditorDOMPoint pointToSplitParentDivOrP(atStartOfSelection);
|
||||||
|
|
||||||
EditorRawDOMPoint pointToInsertBR;
|
EditorDOMPoint pointToInsertBR;
|
||||||
if (doesCRCreateNewP && atStartOfSelection.GetContainer() == &aParentDivOrP) {
|
if (doesCRCreateNewP && atStartOfSelection.GetContainer() == &aParentDivOrP) {
|
||||||
// We are at the edges of the block, so, we don't need to create new <br>.
|
// We are at the edges of the block, so, we don't need to create new <br>.
|
||||||
brContent = nullptr;
|
brContent = nullptr;
|
||||||
|
@ -8091,7 +8086,7 @@ nsresult HTMLEditRules::SplitParagraph(
|
||||||
SplitNodeResult splitDivOrPResult =
|
SplitNodeResult splitDivOrPResult =
|
||||||
MOZ_KnownLive(HTMLEditorRef())
|
MOZ_KnownLive(HTMLEditorRef())
|
||||||
.SplitNodeDeepWithTransaction(
|
.SplitNodeDeepWithTransaction(
|
||||||
aParentDivOrP, EditorRawDOMPoint(selNode, selOffset),
|
aParentDivOrP, EditorDOMPoint(selNode, selOffset),
|
||||||
SplitAtEdges::eAllowToCreateEmptyContainer);
|
SplitAtEdges::eAllowToCreateEmptyContainer);
|
||||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||||
return NS_ERROR_EDITOR_DESTROYED;
|
return NS_ERROR_EDITOR_DESTROYED;
|
||||||
|
@ -8183,7 +8178,7 @@ nsresult HTMLEditRules::ReturnInListItem(Element& aListItem, nsINode& aNode,
|
||||||
// Are we the last list item in the list?
|
// Are we the last list item in the list?
|
||||||
if (!HTMLEditorRef().IsLastEditableChild(&aListItem)) {
|
if (!HTMLEditorRef().IsLastEditableChild(&aListItem)) {
|
||||||
// We need to split the list!
|
// We need to split the list!
|
||||||
EditorRawDOMPoint atListItem(&aListItem);
|
EditorDOMPoint atListItem(&aListItem);
|
||||||
ErrorResult error;
|
ErrorResult error;
|
||||||
leftListNode = MOZ_KnownLive(HTMLEditorRef())
|
leftListNode = MOZ_KnownLive(HTMLEditorRef())
|
||||||
.SplitNodeWithTransaction(atListItem, error);
|
.SplitNodeWithTransaction(atListItem, error);
|
||||||
|
@ -8197,7 +8192,7 @@ nsresult HTMLEditRules::ReturnInListItem(Element& aListItem, nsINode& aNode,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Are we in a sublist?
|
// Are we in a sublist?
|
||||||
EditorRawDOMPoint atNextSiblingOfLeftList(leftListNode);
|
EditorDOMPoint atNextSiblingOfLeftList(leftListNode);
|
||||||
DebugOnly<bool> advanced = atNextSiblingOfLeftList.AdvanceOffset();
|
DebugOnly<bool> advanced = atNextSiblingOfLeftList.AdvanceOffset();
|
||||||
NS_WARNING_ASSERTION(advanced,
|
NS_WARNING_ASSERTION(advanced,
|
||||||
"Failed to advance offset after the right list node");
|
"Failed to advance offset after the right list node");
|
||||||
|
@ -8251,7 +8246,7 @@ nsresult HTMLEditRules::ReturnInListItem(Element& aListItem, nsINode& aNode,
|
||||||
// Append a <br> to it
|
// Append a <br> to it
|
||||||
RefPtr<Element> brElement =
|
RefPtr<Element> brElement =
|
||||||
MOZ_KnownLive(HTMLEditorRef())
|
MOZ_KnownLive(HTMLEditorRef())
|
||||||
.InsertBrElementWithTransaction(EditorRawDOMPoint(pNode, 0));
|
.InsertBrElementWithTransaction(EditorDOMPoint(pNode, 0));
|
||||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||||
return NS_ERROR_EDITOR_DESTROYED;
|
return NS_ERROR_EDITOR_DESTROYED;
|
||||||
}
|
}
|
||||||
|
@ -8292,7 +8287,7 @@ nsresult HTMLEditRules::ReturnInListItem(Element& aListItem, nsINode& aNode,
|
||||||
SplitNodeResult splitListItemResult =
|
SplitNodeResult splitListItemResult =
|
||||||
MOZ_KnownLive(HTMLEditorRef())
|
MOZ_KnownLive(HTMLEditorRef())
|
||||||
.SplitNodeDeepWithTransaction(
|
.SplitNodeDeepWithTransaction(
|
||||||
aListItem, EditorRawDOMPoint(selNode, aOffset),
|
aListItem, EditorDOMPoint(selNode, aOffset),
|
||||||
SplitAtEdges::eAllowToCreateEmptyContainer);
|
SplitAtEdges::eAllowToCreateEmptyContainer);
|
||||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||||
return NS_ERROR_EDITOR_DESTROYED;
|
return NS_ERROR_EDITOR_DESTROYED;
|
||||||
|
@ -8313,7 +8308,7 @@ nsresult HTMLEditRules::ReturnInListItem(Element& aListItem, nsINode& aNode,
|
||||||
}
|
}
|
||||||
if (isEmptyNode) {
|
if (isEmptyNode) {
|
||||||
CreateElementResult createMozBrResult =
|
CreateElementResult createMozBrResult =
|
||||||
CreateMozBR(EditorRawDOMPoint(prevItem, 0));
|
CreateMozBR(EditorDOMPoint(prevItem, 0));
|
||||||
if (NS_WARN_IF(createMozBrResult.Failed())) {
|
if (NS_WARN_IF(createMozBrResult.Failed())) {
|
||||||
return createMozBrResult.Rv();
|
return createMozBrResult.Rv();
|
||||||
}
|
}
|
||||||
|
@ -8331,8 +8326,8 @@ nsresult HTMLEditRules::ReturnInListItem(Element& aListItem, nsINode& aNode,
|
||||||
nsAtom* listAtom =
|
nsAtom* listAtom =
|
||||||
nodeAtom == nsGkAtoms::dt ? nsGkAtoms::dd : nsGkAtoms::dt;
|
nodeAtom == nsGkAtoms::dt ? nsGkAtoms::dd : nsGkAtoms::dt;
|
||||||
MOZ_DIAGNOSTIC_ASSERT(itemOffset != -1);
|
MOZ_DIAGNOSTIC_ASSERT(itemOffset != -1);
|
||||||
EditorRawDOMPoint atNextListItem(list, aListItem.GetNextSibling(),
|
EditorDOMPoint atNextListItem(list, aListItem.GetNextSibling(),
|
||||||
itemOffset + 1);
|
itemOffset + 1);
|
||||||
RefPtr<Element> newListItem =
|
RefPtr<Element> newListItem =
|
||||||
MOZ_KnownLive(HTMLEditorRef())
|
MOZ_KnownLive(HTMLEditorRef())
|
||||||
.CreateNodeWithTransaction(MOZ_KnownLive(*listAtom),
|
.CreateNodeWithTransaction(MOZ_KnownLive(*listAtom),
|
||||||
|
@ -8484,10 +8479,9 @@ nsresult HTMLEditRules::MakeBlockquote(
|
||||||
|
|
||||||
// If no curBlock, make one
|
// If no curBlock, make one
|
||||||
if (!curBlock) {
|
if (!curBlock) {
|
||||||
EditorDOMPoint atCurNode(curNode);
|
|
||||||
SplitNodeResult splitNodeResult =
|
SplitNodeResult splitNodeResult =
|
||||||
MaybeSplitAncestorsForInsertWithTransaction(*nsGkAtoms::blockquote,
|
MaybeSplitAncestorsForInsertWithTransaction(*nsGkAtoms::blockquote,
|
||||||
atCurNode);
|
EditorDOMPoint(curNode));
|
||||||
if (NS_WARN_IF(splitNodeResult.Failed())) {
|
if (NS_WARN_IF(splitNodeResult.Failed())) {
|
||||||
return splitNodeResult.Rv();
|
return splitNodeResult.Rv();
|
||||||
}
|
}
|
||||||
|
@ -8828,9 +8822,8 @@ nsresult HTMLEditRules::ApplyBlockStyle(
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename PT, typename CT>
|
|
||||||
SplitNodeResult HTMLEditRules::MaybeSplitAncestorsForInsertWithTransaction(
|
SplitNodeResult HTMLEditRules::MaybeSplitAncestorsForInsertWithTransaction(
|
||||||
nsAtom& aTag, const EditorDOMPointBase<PT, CT>& aStartOfDeepestRightNode) {
|
nsAtom& aTag, const EditorDOMPoint& aStartOfDeepestRightNode) {
|
||||||
MOZ_ASSERT(IsEditorDataAvailable());
|
MOZ_ASSERT(IsEditorDataAvailable());
|
||||||
|
|
||||||
if (NS_WARN_IF(!aStartOfDeepestRightNode.IsSet())) {
|
if (NS_WARN_IF(!aStartOfDeepestRightNode.IsSet())) {
|
||||||
|
@ -8908,7 +8901,7 @@ nsresult HTMLEditRules::JoinNearestEditableNodesWithTransaction(
|
||||||
int32_t parOffset = parent->ComputeIndexOf(&aNodeLeft);
|
int32_t parOffset = parent->ComputeIndexOf(&aNodeLeft);
|
||||||
nsresult rv = MOZ_KnownLive(HTMLEditorRef())
|
nsresult rv = MOZ_KnownLive(HTMLEditorRef())
|
||||||
.MoveNodeWithTransaction(
|
.MoveNodeWithTransaction(
|
||||||
aNodeRight, EditorRawDOMPoint(parent, parOffset));
|
aNodeRight, EditorDOMPoint(parent, parOffset));
|
||||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||||
return NS_ERROR_EDITOR_DESTROYED;
|
return NS_ERROR_EDITOR_DESTROYED;
|
||||||
}
|
}
|
||||||
|
@ -9145,7 +9138,7 @@ HTMLEditRules::InsertBRElementToEmptyListItemsAndTableCellsInChangedRange() {
|
||||||
// still pass the "IsEmptyNode" test, and we want the br's to be after
|
// still pass the "IsEmptyNode" test, and we want the br's to be after
|
||||||
// them. Also, we want the br to be after the selection if the selection
|
// them. Also, we want the br to be after the selection if the selection
|
||||||
// is in this node.
|
// is in this node.
|
||||||
EditorRawDOMPoint endOfNode;
|
EditorDOMPoint endOfNode;
|
||||||
endOfNode.SetToEndOf(node);
|
endOfNode.SetToEndOf(node);
|
||||||
// XXX This method should return nsreuslt due to may be destroyed by this
|
// XXX This method should return nsreuslt due to may be destroyed by this
|
||||||
// CreateMozBr() call.
|
// CreateMozBr() call.
|
||||||
|
@ -9663,7 +9656,7 @@ nsresult HTMLEditRules::RemoveEmptyNodesInChangedRange() {
|
||||||
// but preserve br.
|
// but preserve br.
|
||||||
RefPtr<Element> brElement =
|
RefPtr<Element> brElement =
|
||||||
MOZ_KnownLive(HTMLEditorRef())
|
MOZ_KnownLive(HTMLEditorRef())
|
||||||
.InsertBrElementWithTransaction(EditorRawDOMPoint(delNode));
|
.InsertBrElementWithTransaction(EditorDOMPoint(delNode));
|
||||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||||
return NS_ERROR_EDITOR_DESTROYED;
|
return NS_ERROR_EDITOR_DESTROYED;
|
||||||
}
|
}
|
||||||
|
@ -10064,8 +10057,8 @@ nsresult HTMLEditRules::InsertBRIfNeededInternal(nsINode& aNode,
|
||||||
}
|
}
|
||||||
|
|
||||||
CreateElementResult createBrResult =
|
CreateElementResult createBrResult =
|
||||||
!aInsertMozBR ? CreateBR(EditorRawDOMPoint(&aNode, 0))
|
!aInsertMozBR ? CreateBR(EditorDOMPoint(&aNode, 0))
|
||||||
: CreateMozBR(EditorRawDOMPoint(&aNode, 0));
|
: CreateMozBR(EditorDOMPoint(&aNode, 0));
|
||||||
if (NS_WARN_IF(createBrResult.Failed())) {
|
if (NS_WARN_IF(createBrResult.Failed())) {
|
||||||
return createBrResult.Rv();
|
return createBrResult.Rv();
|
||||||
}
|
}
|
||||||
|
@ -10380,7 +10373,7 @@ nsresult HTMLEditRules::MakeSureElemStartsOrEndsOnCR(nsINode& aNode,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!foundCR) {
|
if (!foundCR) {
|
||||||
EditorRawDOMPoint pointToInsert;
|
EditorDOMPoint pointToInsert;
|
||||||
if (!aStarts) {
|
if (!aStarts) {
|
||||||
pointToInsert.SetToEndOf(&aNode);
|
pointToInsert.SetToEndOf(&aNode);
|
||||||
} else {
|
} else {
|
||||||
|
@ -10714,7 +10707,7 @@ nsresult HTMLEditRules::PrepareToMakeElementAbsolutePosition(
|
||||||
"Failed to create current positioned div element");
|
"Failed to create current positioned div element");
|
||||||
*aTargetElement = curPositionedDiv;
|
*aTargetElement = curPositionedDiv;
|
||||||
}
|
}
|
||||||
EditorRawDOMPoint atEndOfCurPositionedDiv;
|
EditorDOMPoint atEndOfCurPositionedDiv;
|
||||||
atEndOfCurPositionedDiv.SetToEndOf(curPositionedDiv);
|
atEndOfCurPositionedDiv.SetToEndOf(curPositionedDiv);
|
||||||
curList = MOZ_KnownLive(HTMLEditorRef())
|
curList = MOZ_KnownLive(HTMLEditorRef())
|
||||||
.CreateNodeWithTransaction(MOZ_KnownLive(*containerName),
|
.CreateNodeWithTransaction(MOZ_KnownLive(*containerName),
|
||||||
|
@ -10774,10 +10767,10 @@ nsresult HTMLEditRules::PrepareToMakeElementAbsolutePosition(
|
||||||
return splitNodeResult.Rv();
|
return splitNodeResult.Rv();
|
||||||
}
|
}
|
||||||
if (!curPositionedDiv) {
|
if (!curPositionedDiv) {
|
||||||
EditorRawDOMPoint atListItemParent(atListItem.GetContainer());
|
curPositionedDiv = MOZ_KnownLive(HTMLEditorRef())
|
||||||
curPositionedDiv =
|
.CreateNodeWithTransaction(
|
||||||
MOZ_KnownLive(HTMLEditorRef())
|
*nsGkAtoms::div,
|
||||||
.CreateNodeWithTransaction(*nsGkAtoms::div, atListItemParent);
|
EditorDOMPoint(atListItem.GetContainer()));
|
||||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||||
return NS_ERROR_EDITOR_DESTROYED;
|
return NS_ERROR_EDITOR_DESTROYED;
|
||||||
}
|
}
|
||||||
|
@ -10786,7 +10779,7 @@ nsresult HTMLEditRules::PrepareToMakeElementAbsolutePosition(
|
||||||
"Failed to create current positioned div element");
|
"Failed to create current positioned div element");
|
||||||
*aTargetElement = curPositionedDiv;
|
*aTargetElement = curPositionedDiv;
|
||||||
}
|
}
|
||||||
EditorRawDOMPoint atEndOfCurPositionedDiv;
|
EditorDOMPoint atEndOfCurPositionedDiv;
|
||||||
atEndOfCurPositionedDiv.SetToEndOf(curPositionedDiv);
|
atEndOfCurPositionedDiv.SetToEndOf(curPositionedDiv);
|
||||||
curList = MOZ_KnownLive(HTMLEditorRef())
|
curList = MOZ_KnownLive(HTMLEditorRef())
|
||||||
.CreateNodeWithTransaction(MOZ_KnownLive(*containerName),
|
.CreateNodeWithTransaction(MOZ_KnownLive(*containerName),
|
||||||
|
|
|
@ -1087,10 +1087,9 @@ class HTMLEditRules : public TextEditRules {
|
||||||
* @return When succeeded, SplitPoint() returns
|
* @return When succeeded, SplitPoint() returns
|
||||||
* the point to insert the element.
|
* the point to insert the element.
|
||||||
*/
|
*/
|
||||||
template <typename PT, typename CT>
|
|
||||||
MOZ_CAN_RUN_SCRIPT MOZ_MUST_USE SplitNodeResult
|
MOZ_CAN_RUN_SCRIPT MOZ_MUST_USE SplitNodeResult
|
||||||
MaybeSplitAncestorsForInsertWithTransaction(
|
MaybeSplitAncestorsForInsertWithTransaction(
|
||||||
nsAtom& aTag, const EditorDOMPointBase<PT, CT>& aStartOfDeepestRightNode);
|
nsAtom& aTag, const EditorDOMPoint& aStartOfDeepestRightNode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* JoinNearestEditableNodesWithTransaction() joins two editable nodes which
|
* JoinNearestEditableNodesWithTransaction() joins two editable nodes which
|
||||||
|
|
|
@ -133,13 +133,6 @@ bool HTMLEditorPrefs::sUserWantsToEnableResizingUIByDefault = false;
|
||||||
bool HTMLEditorPrefs::sUserWantsToEnableInlineTableEditingUIByDefault = false;
|
bool HTMLEditorPrefs::sUserWantsToEnableInlineTableEditingUIByDefault = false;
|
||||||
bool HTMLEditorPrefs::sUserWantsToEnableAbsolutePositioningUIByDefault = false;
|
bool HTMLEditorPrefs::sUserWantsToEnableAbsolutePositioningUIByDefault = false;
|
||||||
|
|
||||||
template EditorDOMPoint HTMLEditor::InsertNodeIntoProperAncestorWithTransaction(
|
|
||||||
nsIContent& aNode, const EditorDOMPoint& aPointToInsert,
|
|
||||||
SplitAtEdges aSplitAtEdges);
|
|
||||||
template EditorDOMPoint HTMLEditor::InsertNodeIntoProperAncestorWithTransaction(
|
|
||||||
nsIContent& aNode, const EditorRawDOMPoint& aPointToInsert,
|
|
||||||
SplitAtEdges aSplitAtEdges);
|
|
||||||
|
|
||||||
HTMLEditor::HTMLEditor()
|
HTMLEditor::HTMLEditor()
|
||||||
: mCRInParagraphCreatesParagraph(false),
|
: mCRInParagraphCreatesParagraph(false),
|
||||||
mCSSAware(false),
|
mCSSAware(false),
|
||||||
|
@ -1184,7 +1177,7 @@ nsresult HTMLEditor::InsertBrElementAtSelectionWithTransaction() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorRawDOMPoint atStartOfSelection(
|
EditorDOMPoint atStartOfSelection(
|
||||||
EditorBase::GetStartPoint(*SelectionRefPtr()));
|
EditorBase::GetStartPoint(*SelectionRefPtr()));
|
||||||
if (NS_WARN_IF(!atStartOfSelection.IsSet())) {
|
if (NS_WARN_IF(!atStartOfSelection.IsSet())) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
|
@ -1298,7 +1291,7 @@ nsresult HTMLEditor::ReplaceHeadContentsWithSourceWithTransaction(
|
||||||
// Loop over the contents of the fragment and move into the document
|
// Loop over the contents of the fragment and move into the document
|
||||||
while (nsCOMPtr<nsIContent> child = documentFragment->GetFirstChild()) {
|
while (nsCOMPtr<nsIContent> child = documentFragment->GetFirstChild()) {
|
||||||
nsresult rv = InsertNodeWithTransaction(
|
nsresult rv = InsertNodeWithTransaction(
|
||||||
*child, EditorRawDOMPoint(headNode, offsetOfNewNode++));
|
*child, EditorDOMPoint(headNode, offsetOfNewNode++));
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
@ -1611,7 +1604,7 @@ HTMLEditor::InsertElementAtSelection(Element* aElement, bool aDeleteSelection) {
|
||||||
if (SelectionRefPtr()->GetAnchorNode()) {
|
if (SelectionRefPtr()->GetAnchorNode()) {
|
||||||
EditorRawDOMPoint atAnchor(SelectionRefPtr()->AnchorRef());
|
EditorRawDOMPoint atAnchor(SelectionRefPtr()->AnchorRef());
|
||||||
// Adjust position based on the node we are going to insert.
|
// Adjust position based on the node we are going to insert.
|
||||||
EditorRawDOMPoint pointToInsert =
|
EditorDOMPoint pointToInsert =
|
||||||
GetBetterInsertionPointFor(*aElement, atAnchor);
|
GetBetterInsertionPointFor(*aElement, atAnchor);
|
||||||
if (NS_WARN_IF(!pointToInsert.IsSet())) {
|
if (NS_WARN_IF(!pointToInsert.IsSet())) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
|
@ -1654,9 +1647,8 @@ HTMLEditor::InsertElementAtSelection(Element* aElement, bool aDeleteSelection) {
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename PT, typename CT>
|
|
||||||
EditorDOMPoint HTMLEditor::InsertNodeIntoProperAncestorWithTransaction(
|
EditorDOMPoint HTMLEditor::InsertNodeIntoProperAncestorWithTransaction(
|
||||||
nsIContent& aNode, const EditorDOMPointBase<PT, CT>& aPointToInsert,
|
nsIContent& aNode, const EditorDOMPoint& aPointToInsert,
|
||||||
SplitAtEdges aSplitAtEdges) {
|
SplitAtEdges aSplitAtEdges) {
|
||||||
if (NS_WARN_IF(!aPointToInsert.IsSet())) {
|
if (NS_WARN_IF(!aPointToInsert.IsSet())) {
|
||||||
return EditorDOMPoint();
|
return EditorDOMPoint();
|
||||||
|
@ -2120,7 +2112,7 @@ HTMLEditor::MakeOrChangeList(const nsAString& aListType, bool entireList,
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorRawDOMPoint atStartOfSelection(firstRange->StartRef());
|
EditorDOMPoint atStartOfSelection(firstRange->StartRef());
|
||||||
if (NS_WARN_IF(!atStartOfSelection.IsSet()) ||
|
if (NS_WARN_IF(!atStartOfSelection.IsSet()) ||
|
||||||
NS_WARN_IF(!atStartOfSelection.GetContainerAsContent())) {
|
NS_WARN_IF(!atStartOfSelection.GetContainerAsContent())) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
|
@ -2160,9 +2152,8 @@ HTMLEditor::MakeOrChangeList(const nsAString& aListType, bool entireList,
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
// make a list item
|
// make a list item
|
||||||
EditorRawDOMPoint atStartOfNewList(newList, 0);
|
|
||||||
RefPtr<Element> newItem =
|
RefPtr<Element> newItem =
|
||||||
CreateNodeWithTransaction(*nsGkAtoms::li, atStartOfNewList);
|
CreateNodeWithTransaction(*nsGkAtoms::li, EditorDOMPoint(newList, 0));
|
||||||
if (NS_WARN_IF(!newItem)) {
|
if (NS_WARN_IF(!newItem)) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
@ -2296,7 +2287,7 @@ nsresult HTMLEditor::InsertBasicBlockWithTransaction(nsAtom& aTagName) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorRawDOMPoint atStartOfSelection(firstRange->StartRef());
|
EditorDOMPoint atStartOfSelection(firstRange->StartRef());
|
||||||
if (NS_WARN_IF(!atStartOfSelection.IsSet()) ||
|
if (NS_WARN_IF(!atStartOfSelection.IsSet()) ||
|
||||||
NS_WARN_IF(!atStartOfSelection.GetContainerAsContent())) {
|
NS_WARN_IF(!atStartOfSelection.GetContainerAsContent())) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
|
@ -2436,7 +2427,7 @@ nsresult HTMLEditor::IndentOrOutdentAsSubAction(
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorRawDOMPoint atStartOfSelection(firstRange->StartRef());
|
EditorDOMPoint atStartOfSelection(firstRange->StartRef());
|
||||||
if (NS_WARN_IF(!atStartOfSelection.IsSet()) ||
|
if (NS_WARN_IF(!atStartOfSelection.IsSet()) ||
|
||||||
NS_WARN_IF(!atStartOfSelection.GetContainerAsContent())) {
|
NS_WARN_IF(!atStartOfSelection.GetContainerAsContent())) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
|
@ -3834,7 +3825,7 @@ nsresult HTMLEditor::RemoveBlockContainerWithTransaction(Element& aElement) {
|
||||||
!sibling->IsHTMLElement(nsGkAtoms::br) && !IsBlockNode(child)) {
|
!sibling->IsHTMLElement(nsGkAtoms::br) && !IsBlockNode(child)) {
|
||||||
// Insert br node
|
// Insert br node
|
||||||
RefPtr<Element> brElement =
|
RefPtr<Element> brElement =
|
||||||
InsertBrElementWithTransaction(EditorRawDOMPoint(&aElement, 0));
|
InsertBrElementWithTransaction(EditorDOMPoint(&aElement, 0));
|
||||||
if (NS_WARN_IF(!brElement)) {
|
if (NS_WARN_IF(!brElement)) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
@ -3852,7 +3843,7 @@ nsresult HTMLEditor::RemoveBlockContainerWithTransaction(Element& aElement) {
|
||||||
MOZ_ASSERT(child, "aNode has first editable child but not last?");
|
MOZ_ASSERT(child, "aNode has first editable child but not last?");
|
||||||
if (!IsBlockNode(child) && !child->IsHTMLElement(nsGkAtoms::br)) {
|
if (!IsBlockNode(child) && !child->IsHTMLElement(nsGkAtoms::br)) {
|
||||||
// Insert br node
|
// Insert br node
|
||||||
EditorRawDOMPoint endOfNode;
|
EditorDOMPoint endOfNode;
|
||||||
endOfNode.SetToEndOf(&aElement);
|
endOfNode.SetToEndOf(&aElement);
|
||||||
RefPtr<Element> brElement = InsertBrElementWithTransaction(endOfNode);
|
RefPtr<Element> brElement = InsertBrElementWithTransaction(endOfNode);
|
||||||
if (NS_WARN_IF(!brElement)) {
|
if (NS_WARN_IF(!brElement)) {
|
||||||
|
@ -3875,7 +3866,7 @@ nsresult HTMLEditor::RemoveBlockContainerWithTransaction(Element& aElement) {
|
||||||
!sibling->IsHTMLElement(nsGkAtoms::br)) {
|
!sibling->IsHTMLElement(nsGkAtoms::br)) {
|
||||||
// Insert br node
|
// Insert br node
|
||||||
RefPtr<Element> brElement =
|
RefPtr<Element> brElement =
|
||||||
InsertBrElementWithTransaction(EditorRawDOMPoint(&aElement, 0));
|
InsertBrElementWithTransaction(EditorDOMPoint(&aElement, 0));
|
||||||
if (NS_WARN_IF(!brElement)) {
|
if (NS_WARN_IF(!brElement)) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
@ -4562,9 +4553,8 @@ nsresult HTMLEditor::CopyLastEditableChildStylesWithTransaction(
|
||||||
nsAtom* tagName = elementInPreviousBlock->NodeInfo()->NameAtom();
|
nsAtom* tagName = elementInPreviousBlock->NodeInfo()->NameAtom();
|
||||||
// At first time, just create the most descendant inline container element.
|
// At first time, just create the most descendant inline container element.
|
||||||
if (!firstClonsedElement) {
|
if (!firstClonsedElement) {
|
||||||
EditorRawDOMPoint atStartOfNewBlock(newBlock, 0);
|
firstClonsedElement = lastClonedElement = CreateNodeWithTransaction(
|
||||||
firstClonsedElement = lastClonedElement =
|
MOZ_KnownLive(*tagName), EditorDOMPoint(newBlock, 0));
|
||||||
CreateNodeWithTransaction(MOZ_KnownLive(*tagName), atStartOfNewBlock);
|
|
||||||
if (NS_WARN_IF(!firstClonsedElement)) {
|
if (NS_WARN_IF(!firstClonsedElement)) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
@ -4591,7 +4581,7 @@ nsresult HTMLEditor::CopyLastEditableChildStylesWithTransaction(
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<Element> brElement =
|
RefPtr<Element> brElement =
|
||||||
InsertBrElementWithTransaction(EditorRawDOMPoint(firstClonsedElement, 0));
|
InsertBrElementWithTransaction(EditorDOMPoint(firstClonsedElement, 0));
|
||||||
if (NS_WARN_IF(!brElement)) {
|
if (NS_WARN_IF(!brElement)) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1479,9 +1479,8 @@ class HTMLEditor final : public TextEditor,
|
||||||
* @return Returns inserted point if succeeded.
|
* @return Returns inserted point if succeeded.
|
||||||
* Otherwise, the result is not set.
|
* Otherwise, the result is not set.
|
||||||
*/
|
*/
|
||||||
template <typename PT, typename CT>
|
|
||||||
MOZ_CAN_RUN_SCRIPT EditorDOMPoint InsertNodeIntoProperAncestorWithTransaction(
|
MOZ_CAN_RUN_SCRIPT EditorDOMPoint InsertNodeIntoProperAncestorWithTransaction(
|
||||||
nsIContent& aNode, const EditorDOMPointBase<PT, CT>& aPointToInsert,
|
nsIContent& aNode, const EditorDOMPoint& aPointToInsert,
|
||||||
SplitAtEdges aSplitAtEdges);
|
SplitAtEdges aSplitAtEdges);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -646,7 +646,7 @@ nsresult HTMLEditor::DoInsertHTMLWithContext(
|
||||||
// in a BR that is not visible. If so, the code above just placed
|
// in a BR that is not visible. If so, the code above just placed
|
||||||
// selection inside that. So I split it instead.
|
// selection inside that. So I split it instead.
|
||||||
SplitNodeResult splitLinkResult = SplitNodeDeepWithTransaction(
|
SplitNodeResult splitLinkResult = SplitNodeDeepWithTransaction(
|
||||||
*linkContent, EditorRawDOMPoint(selNode, selOffset),
|
*linkContent, EditorDOMPoint(selNode, selOffset),
|
||||||
SplitAtEdges::eDoNotCreateEmptyContainer);
|
SplitAtEdges::eDoNotCreateEmptyContainer);
|
||||||
NS_WARNING_ASSERTION(splitLinkResult.Succeeded(),
|
NS_WARNING_ASSERTION(splitLinkResult.Succeeded(),
|
||||||
"Failed to split the link");
|
"Failed to split the link");
|
||||||
|
|
|
@ -364,7 +364,7 @@ nsresult HTMLEditor::SetInlinePropertyOnTextNode(
|
||||||
nsCOMPtr<nsIContent> textNodeForTheRange = &aText;
|
nsCOMPtr<nsIContent> textNodeForTheRange = &aText;
|
||||||
|
|
||||||
// Split at the end of the range.
|
// Split at the end of the range.
|
||||||
EditorRawDOMPoint atEnd(textNodeForTheRange, aEndOffset);
|
EditorDOMPoint atEnd(textNodeForTheRange, aEndOffset);
|
||||||
if (!atEnd.IsEndOfContainer()) {
|
if (!atEnd.IsEndOfContainer()) {
|
||||||
// We need to split off back of text node
|
// We need to split off back of text node
|
||||||
ErrorResult error;
|
ErrorResult error;
|
||||||
|
@ -375,7 +375,7 @@ nsresult HTMLEditor::SetInlinePropertyOnTextNode(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Split at the start of the range.
|
// Split at the start of the range.
|
||||||
EditorRawDOMPoint atStart(textNodeForTheRange, aStartOffset);
|
EditorDOMPoint atStart(textNodeForTheRange, aStartOffset);
|
||||||
if (!atStart.IsStartOfContainer()) {
|
if (!atStart.IsStartOfContainer()) {
|
||||||
// We need to split off front of text node
|
// We need to split off front of text node
|
||||||
ErrorResult error;
|
ErrorResult error;
|
||||||
|
@ -397,7 +397,7 @@ nsresult HTMLEditor::SetInlinePropertyOnTextNode(
|
||||||
if (IsSimpleModifiableNode(sibling, &aProperty, aAttribute, &aValue)) {
|
if (IsSimpleModifiableNode(sibling, &aProperty, aAttribute, &aValue)) {
|
||||||
// Following sib is already right kind of inline node; slide this over
|
// Following sib is already right kind of inline node; slide this over
|
||||||
return MoveNodeWithTransaction(*textNodeForTheRange,
|
return MoveNodeWithTransaction(*textNodeForTheRange,
|
||||||
EditorRawDOMPoint(sibling, 0));
|
EditorDOMPoint(sibling, 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -453,7 +453,7 @@ nsresult HTMLEditor::SetInlinePropertyOnNodeImpl(nsIContent& aNode,
|
||||||
}
|
}
|
||||||
if (IsSimpleModifiableNode(nextSibling, &aProperty, aAttribute, &aValue)) {
|
if (IsSimpleModifiableNode(nextSibling, &aProperty, aAttribute, &aValue)) {
|
||||||
nsresult rv =
|
nsresult rv =
|
||||||
MoveNodeWithTransaction(aNode, EditorRawDOMPoint(nextSibling, 0));
|
MoveNodeWithTransaction(aNode, EditorDOMPoint(nextSibling, 0));
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
@ -641,7 +641,7 @@ nsresult HTMLEditor::SplitStyleAbovePoint(
|
||||||
isSet) {
|
isSet) {
|
||||||
// Found a style node we need to split
|
// Found a style node we need to split
|
||||||
SplitNodeResult splitNodeResult = SplitNodeDeepWithTransaction(
|
SplitNodeResult splitNodeResult = SplitNodeDeepWithTransaction(
|
||||||
*node, EditorRawDOMPoint(*aNode, *aOffset),
|
*node, EditorDOMPoint(*aNode, *aOffset),
|
||||||
SplitAtEdges::eAllowToCreateEmptyContainer);
|
SplitAtEdges::eAllowToCreateEmptyContainer);
|
||||||
NS_WARNING_ASSERTION(splitNodeResult.Succeeded(),
|
NS_WARNING_ASSERTION(splitNodeResult.Succeeded(),
|
||||||
"Failed to split the node");
|
"Failed to split the node");
|
||||||
|
@ -732,8 +732,7 @@ nsresult HTMLEditor::ClearStyle(nsCOMPtr<nsINode>* aNode, int32_t* aOffset,
|
||||||
// leftNode. This is so we you don't revert back to the previous style
|
// leftNode. This is so we you don't revert back to the previous style
|
||||||
// if you happen to click at the end of a line.
|
// if you happen to click at the end of a line.
|
||||||
if (savedBR) {
|
if (savedBR) {
|
||||||
rv =
|
rv = MoveNodeWithTransaction(*savedBR, EditorDOMPoint(newSelParent, 0));
|
||||||
MoveNodeWithTransaction(*savedBR, EditorRawDOMPoint(newSelParent, 0));
|
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
@ -1641,7 +1640,7 @@ nsresult HTMLEditor::RelativeFontChangeOnTextNode(FontSize aDir,
|
||||||
nsCOMPtr<nsIContent> textNodeForTheRange = &aTextNode;
|
nsCOMPtr<nsIContent> textNodeForTheRange = &aTextNode;
|
||||||
|
|
||||||
// Split at the end of the range.
|
// Split at the end of the range.
|
||||||
EditorRawDOMPoint atEnd(textNodeForTheRange, aEndOffset);
|
EditorDOMPoint atEnd(textNodeForTheRange, aEndOffset);
|
||||||
if (!atEnd.IsEndOfContainer()) {
|
if (!atEnd.IsEndOfContainer()) {
|
||||||
// We need to split off back of text node
|
// We need to split off back of text node
|
||||||
ErrorResult error;
|
ErrorResult error;
|
||||||
|
@ -1652,7 +1651,7 @@ nsresult HTMLEditor::RelativeFontChangeOnTextNode(FontSize aDir,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Split at the start of the range.
|
// Split at the start of the range.
|
||||||
EditorRawDOMPoint atStart(textNodeForTheRange, aStartOffset);
|
EditorDOMPoint atStart(textNodeForTheRange, aStartOffset);
|
||||||
if (!atStart.IsStartOfContainer()) {
|
if (!atStart.IsStartOfContainer()) {
|
||||||
// We need to split off front of text node
|
// We need to split off front of text node
|
||||||
ErrorResult error;
|
ErrorResult error;
|
||||||
|
@ -1678,7 +1677,7 @@ nsresult HTMLEditor::RelativeFontChangeOnTextNode(FontSize aDir,
|
||||||
if (sibling && sibling->IsHTMLElement(nodeType)) {
|
if (sibling && sibling->IsHTMLElement(nodeType)) {
|
||||||
// Following sib is already right kind of inline node; slide this over
|
// Following sib is already right kind of inline node; slide this over
|
||||||
nsresult rv = MoveNodeWithTransaction(*textNodeForTheRange,
|
nsresult rv = MoveNodeWithTransaction(*textNodeForTheRange,
|
||||||
EditorRawDOMPoint(sibling, 0));
|
EditorDOMPoint(sibling, 0));
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
@ -1789,7 +1788,7 @@ nsresult HTMLEditor::RelativeFontChangeOnNode(int32_t aSizeChange,
|
||||||
if (sibling && sibling->IsHTMLElement(atom)) {
|
if (sibling && sibling->IsHTMLElement(atom)) {
|
||||||
// following sib is already right kind of inline node; slide this over
|
// following sib is already right kind of inline node; slide this over
|
||||||
// into it
|
// into it
|
||||||
return MoveNodeWithTransaction(*aNode, EditorRawDOMPoint(sibling, 0));
|
return MoveNodeWithTransaction(*aNode, EditorDOMPoint(sibling, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
// else insert it above aNode
|
// else insert it above aNode
|
||||||
|
|
|
@ -2799,8 +2799,8 @@ nsresult HTMLEditor::MergeCells(RefPtr<Element> aTargetCell,
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
rv = InsertNodeWithTransaction(
|
rv = InsertNodeWithTransaction(*cellChild,
|
||||||
*cellChild, EditorRawDOMPoint(aTargetCell, insertIndex));
|
EditorDOMPoint(aTargetCell, insertIndex));
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,11 +44,6 @@ namespace mozilla {
|
||||||
|
|
||||||
using namespace dom;
|
using namespace dom;
|
||||||
|
|
||||||
template CreateElementResult TextEditRules::CreateBRInternal(
|
|
||||||
const EditorDOMPoint& aPointToInsert, bool aCreateMozBR);
|
|
||||||
template CreateElementResult TextEditRules::CreateBRInternal(
|
|
||||||
const EditorRawDOMPoint& aPointToInsert, bool aCreateMozBR);
|
|
||||||
|
|
||||||
#define CANCEL_OPERATION_IF_READONLY_OR_DISABLED \
|
#define CANCEL_OPERATION_IF_READONLY_OR_DISABLED \
|
||||||
if (IsReadonly() || IsDisabled()) { \
|
if (IsReadonly() || IsDisabled()) { \
|
||||||
*aCancel = true; \
|
*aCancel = true; \
|
||||||
|
@ -982,7 +977,7 @@ nsresult TextEditRules::WillSetText(bool* aCancel, bool* aHandled,
|
||||||
}
|
}
|
||||||
nsresult rv = MOZ_KnownLive(TextEditorRef())
|
nsresult rv = MOZ_KnownLive(TextEditorRef())
|
||||||
.InsertNodeWithTransaction(
|
.InsertNodeWithTransaction(
|
||||||
*newNode, EditorRawDOMPoint(rootElement, 0));
|
*newNode, EditorDOMPoint(rootElement, 0));
|
||||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||||
return NS_ERROR_EDITOR_DESTROYED;
|
return NS_ERROR_EDITOR_DESTROYED;
|
||||||
}
|
}
|
||||||
|
@ -1473,7 +1468,7 @@ nsresult TextEditRules::CreateTrailingBRIfNeeded() {
|
||||||
|
|
||||||
if (!lastChild->IsHTMLElement(nsGkAtoms::br)) {
|
if (!lastChild->IsHTMLElement(nsGkAtoms::br)) {
|
||||||
AutoTransactionsConserveSelection dontChangeMySelection(TextEditorRef());
|
AutoTransactionsConserveSelection dontChangeMySelection(TextEditorRef());
|
||||||
EditorRawDOMPoint endOfRoot;
|
EditorDOMPoint endOfRoot;
|
||||||
endOfRoot.SetToEndOf(rootElement);
|
endOfRoot.SetToEndOf(rootElement);
|
||||||
CreateElementResult createMozBrResult = CreateMozBR(endOfRoot);
|
CreateElementResult createMozBrResult = CreateMozBR(endOfRoot);
|
||||||
if (NS_WARN_IF(createMozBrResult.Failed())) {
|
if (NS_WARN_IF(createMozBrResult.Failed())) {
|
||||||
|
@ -1558,8 +1553,8 @@ nsresult TextEditRules::CreateBogusNodeIfNeeded() {
|
||||||
|
|
||||||
// Put the node in the document.
|
// Put the node in the document.
|
||||||
nsresult rv = MOZ_KnownLive(TextEditorRef())
|
nsresult rv = MOZ_KnownLive(TextEditorRef())
|
||||||
.InsertNodeWithTransaction(
|
.InsertNodeWithTransaction(*newBrElement,
|
||||||
*newBrElement, EditorRawDOMPoint(rootElement, 0));
|
EditorDOMPoint(rootElement, 0));
|
||||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||||
return NS_ERROR_EDITOR_DESTROYED;
|
return NS_ERROR_EDITOR_DESTROYED;
|
||||||
}
|
}
|
||||||
|
@ -1770,9 +1765,8 @@ void TextEditRules::FillBufWithPWChars(nsAString* aOutString, int32_t aLength) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename PT, typename CT>
|
|
||||||
CreateElementResult TextEditRules::CreateBRInternal(
|
CreateElementResult TextEditRules::CreateBRInternal(
|
||||||
const EditorDOMPointBase<PT, CT>& aPointToInsert, bool aCreateMozBR) {
|
const EditorDOMPoint& aPointToInsert, bool aCreateMozBR) {
|
||||||
MOZ_ASSERT(IsEditorDataAvailable());
|
MOZ_ASSERT(IsEditorDataAvailable());
|
||||||
|
|
||||||
if (NS_WARN_IF(!aPointToInsert.IsSet())) {
|
if (NS_WARN_IF(!aPointToInsert.IsSet())) {
|
||||||
|
|
|
@ -312,9 +312,8 @@ class TextEditRules : public nsITimerCallback, public nsINamed {
|
||||||
* @return Returns created <br> element or an error code
|
* @return Returns created <br> element or an error code
|
||||||
* if couldn't create new <br> element.
|
* if couldn't create new <br> element.
|
||||||
*/
|
*/
|
||||||
template <typename PT, typename CT>
|
|
||||||
MOZ_CAN_RUN_SCRIPT CreateElementResult
|
MOZ_CAN_RUN_SCRIPT CreateElementResult
|
||||||
CreateBR(const EditorDOMPointBase<PT, CT>& aPointToInsert) {
|
CreateBR(const EditorDOMPoint& aPointToInsert) {
|
||||||
CreateElementResult ret = CreateBRInternal(aPointToInsert, false);
|
CreateElementResult ret = CreateBRInternal(aPointToInsert, false);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
// If editor is destroyed, it must return NS_ERROR_EDITOR_DESTROYED.
|
// If editor is destroyed, it must return NS_ERROR_EDITOR_DESTROYED.
|
||||||
|
@ -333,9 +332,8 @@ class TextEditRules : public nsITimerCallback, public nsINamed {
|
||||||
* @return Returns created <br> element or an error code
|
* @return Returns created <br> element or an error code
|
||||||
* if couldn't create new <br> element.
|
* if couldn't create new <br> element.
|
||||||
*/
|
*/
|
||||||
template <typename PT, typename CT>
|
|
||||||
MOZ_CAN_RUN_SCRIPT CreateElementResult
|
MOZ_CAN_RUN_SCRIPT CreateElementResult
|
||||||
CreateMozBR(const EditorDOMPointBase<PT, CT>& aPointToInsert) {
|
CreateMozBR(const EditorDOMPoint& aPointToInsert) {
|
||||||
CreateElementResult ret = CreateBRInternal(aPointToInsert, true);
|
CreateElementResult ret = CreateBRInternal(aPointToInsert, true);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
// If editor is destroyed, it must return NS_ERROR_EDITOR_DESTROYED.
|
// If editor is destroyed, it must return NS_ERROR_EDITOR_DESTROYED.
|
||||||
|
@ -391,9 +389,8 @@ class TextEditRules : public nsITimerCallback, public nsINamed {
|
||||||
* @return Returns created <br> element and error code.
|
* @return Returns created <br> element and error code.
|
||||||
* If it succeeded, never returns nullptr.
|
* If it succeeded, never returns nullptr.
|
||||||
*/
|
*/
|
||||||
template <typename PT, typename CT>
|
MOZ_CAN_RUN_SCRIPT CreateElementResult
|
||||||
MOZ_CAN_RUN_SCRIPT CreateElementResult CreateBRInternal(
|
CreateBRInternal(const EditorDOMPoint& aPointToInsert, bool aCreateMozBR);
|
||||||
const EditorDOMPointBase<PT, CT>& aPointToInsert, bool aCreateMozBR);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -64,11 +64,6 @@ namespace mozilla {
|
||||||
|
|
||||||
using namespace dom;
|
using namespace dom;
|
||||||
|
|
||||||
template already_AddRefed<Element> TextEditor::InsertBrElementWithTransaction(
|
|
||||||
const EditorDOMPoint& aPointToInsert, EDirection aSelect);
|
|
||||||
template already_AddRefed<Element> TextEditor::InsertBrElementWithTransaction(
|
|
||||||
const EditorRawDOMPoint& aPointToInsert, EDirection aSelect);
|
|
||||||
|
|
||||||
TextEditor::TextEditor()
|
TextEditor::TextEditor()
|
||||||
: mWrapColumn(0),
|
: mWrapColumn(0),
|
||||||
mMaxTextLength(-1),
|
mMaxTextLength(-1),
|
||||||
|
@ -242,9 +237,8 @@ TextEditor::SetDocumentCharacterSet(const nsACString& characterSet) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a new meta charset tag
|
// Create a new meta charset tag
|
||||||
EditorRawDOMPoint atStartOfHeadNode(headNode, 0);
|
|
||||||
RefPtr<Element> metaElement =
|
RefPtr<Element> metaElement =
|
||||||
CreateNodeWithTransaction(*nsGkAtoms::meta, atStartOfHeadNode);
|
CreateNodeWithTransaction(*nsGkAtoms::meta, EditorDOMPoint(headNode, 0));
|
||||||
if (NS_WARN_IF(!metaElement)) {
|
if (NS_WARN_IF(!metaElement)) {
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -436,10 +430,8 @@ nsresult TextEditor::InsertLineBreakAsAction() {
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename PT, typename CT>
|
|
||||||
already_AddRefed<Element> TextEditor::InsertBrElementWithTransaction(
|
already_AddRefed<Element> TextEditor::InsertBrElementWithTransaction(
|
||||||
const EditorDOMPointBase<PT, CT>& aPointToInsert,
|
const EditorDOMPoint& aPointToInsert, EDirection aSelect /* = eNone */) {
|
||||||
EDirection aSelect /* = eNone */) {
|
|
||||||
MOZ_ASSERT(IsEditActionDataAvailable());
|
MOZ_ASSERT(IsEditActionDataAvailable());
|
||||||
|
|
||||||
if (NS_WARN_IF(!aPointToInsert.IsSet())) {
|
if (NS_WARN_IF(!aPointToInsert.IsSet())) {
|
||||||
|
@ -869,7 +861,7 @@ already_AddRefed<Element> TextEditor::DeleteSelectionAndCreateElement(
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorRawDOMPoint pointToInsert(SelectionRefPtr()->AnchorRef());
|
EditorDOMPoint pointToInsert(SelectionRefPtr()->AnchorRef());
|
||||||
if (!pointToInsert.IsSet()) {
|
if (!pointToInsert.IsSet()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -354,10 +354,8 @@ class TextEditor : public EditorBase, public nsIPlaintextEditor {
|
||||||
* @return The new <br> node. If failed to create new
|
* @return The new <br> node. If failed to create new
|
||||||
* <br> node, returns nullptr.
|
* <br> node, returns nullptr.
|
||||||
*/
|
*/
|
||||||
template <typename PT, typename CT>
|
|
||||||
MOZ_CAN_RUN_SCRIPT already_AddRefed<Element> InsertBrElementWithTransaction(
|
MOZ_CAN_RUN_SCRIPT already_AddRefed<Element> InsertBrElementWithTransaction(
|
||||||
const EditorDOMPointBase<PT, CT>& aPointToInsert,
|
const EditorDOMPoint& aPointToInsert, EDirection aSelect = eNone);
|
||||||
EDirection aSelect = eNone);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extends the selection for given deletion operation
|
* Extends the selection for given deletion operation
|
||||||
|
|
|
@ -55,12 +55,6 @@ template void WSRunObject::NextVisibleNode(const EditorRawDOMPoint& aPoint,
|
||||||
nsCOMPtr<nsINode>* outVisNode,
|
nsCOMPtr<nsINode>* outVisNode,
|
||||||
int32_t* outVisOffset,
|
int32_t* outVisOffset,
|
||||||
WSType* outType) const;
|
WSType* outType) const;
|
||||||
template already_AddRefed<Element> WSRunObject::InsertBreak(
|
|
||||||
Selection& aSelection, const EditorDOMPoint& aPointToInsert,
|
|
||||||
nsIEditor::EDirection aSelect);
|
|
||||||
template already_AddRefed<Element> WSRunObject::InsertBreak(
|
|
||||||
Selection& aSelection, const EditorRawDOMPoint& aPointToInsert,
|
|
||||||
nsIEditor::EDirection aSelect);
|
|
||||||
template void WSRunObject::GetASCIIWhitespacesBounds(
|
template void WSRunObject::GetASCIIWhitespacesBounds(
|
||||||
int16_t aDir, const EditorDOMPoint& aPoint, dom::Text** outStartNode,
|
int16_t aDir, const EditorDOMPoint& aPoint, dom::Text** outStartNode,
|
||||||
int32_t* outStartOffset, dom::Text** outEndNode, int32_t* outEndOffset);
|
int32_t* outStartOffset, dom::Text** outEndNode, int32_t* outEndOffset);
|
||||||
|
@ -171,9 +165,8 @@ nsresult WSRunObject::PrepareToSplitAcrossBlocks(HTMLEditor* aHTMLEditor,
|
||||||
return wsObj.PrepareToSplitAcrossBlocksPriv();
|
return wsObj.PrepareToSplitAcrossBlocksPriv();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename PT, typename CT>
|
|
||||||
already_AddRefed<Element> WSRunObject::InsertBreak(
|
already_AddRefed<Element> WSRunObject::InsertBreak(
|
||||||
Selection& aSelection, const EditorDOMPointBase<PT, CT>& aPointToInsert,
|
Selection& aSelection, const EditorDOMPoint& aPointToInsert,
|
||||||
nsIEditor::EDirection aSelect) {
|
nsIEditor::EDirection aSelect) {
|
||||||
if (NS_WARN_IF(!aPointToInsert.IsSet())) {
|
if (NS_WARN_IF(!aPointToInsert.IsSet())) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -393,8 +386,8 @@ nsresult WSRunObject::DeleteWSBackward() {
|
||||||
// Easy case, preformatted ws.
|
// Easy case, preformatted ws.
|
||||||
if (mPRE && (nsCRT::IsAsciiSpace(point.mChar) || point.mChar == kNBSP)) {
|
if (mPRE && (nsCRT::IsAsciiSpace(point.mChar) || point.mChar == kNBSP)) {
|
||||||
nsresult rv =
|
nsresult rv =
|
||||||
DeleteRange(EditorRawDOMPoint(point.mTextNode, point.mOffset),
|
DeleteRange(EditorDOMPoint(point.mTextNode, point.mOffset),
|
||||||
EditorRawDOMPoint(point.mTextNode, point.mOffset + 1));
|
EditorDOMPoint(point.mTextNode, point.mOffset + 1));
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
@ -420,8 +413,8 @@ nsresult WSRunObject::DeleteWSBackward() {
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// finally, delete that ws
|
// finally, delete that ws
|
||||||
rv = DeleteRange(EditorRawDOMPoint(startNode, startOffset),
|
rv = DeleteRange(EditorDOMPoint(startNode, startOffset),
|
||||||
EditorRawDOMPoint(endNode, endOffset));
|
EditorDOMPoint(endNode, endOffset));
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
@ -439,8 +432,8 @@ nsresult WSRunObject::DeleteWSBackward() {
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// finally, delete that ws
|
// finally, delete that ws
|
||||||
rv = DeleteRange(EditorRawDOMPoint(node, startOffset),
|
rv = DeleteRange(EditorDOMPoint(node, startOffset),
|
||||||
EditorRawDOMPoint(node, endOffset));
|
EditorDOMPoint(node, endOffset));
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
@ -457,8 +450,8 @@ nsresult WSRunObject::DeleteWSForward() {
|
||||||
// Easy case, preformatted ws.
|
// Easy case, preformatted ws.
|
||||||
if (mPRE && (nsCRT::IsAsciiSpace(point.mChar) || point.mChar == kNBSP)) {
|
if (mPRE && (nsCRT::IsAsciiSpace(point.mChar) || point.mChar == kNBSP)) {
|
||||||
nsresult rv =
|
nsresult rv =
|
||||||
DeleteRange(EditorRawDOMPoint(point.mTextNode, point.mOffset),
|
DeleteRange(EditorDOMPoint(point.mTextNode, point.mOffset),
|
||||||
EditorRawDOMPoint(point.mTextNode, point.mOffset + 1));
|
EditorDOMPoint(point.mTextNode, point.mOffset + 1));
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
@ -483,8 +476,8 @@ nsresult WSRunObject::DeleteWSForward() {
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// Finally, delete that ws
|
// Finally, delete that ws
|
||||||
rv = DeleteRange(EditorRawDOMPoint(startNode, startOffset),
|
rv = DeleteRange(EditorDOMPoint(startNode, startOffset),
|
||||||
EditorRawDOMPoint(endNode, endOffset));
|
EditorDOMPoint(endNode, endOffset));
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
@ -502,8 +495,8 @@ nsresult WSRunObject::DeleteWSForward() {
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// Finally, delete that ws
|
// Finally, delete that ws
|
||||||
rv = DeleteRange(EditorRawDOMPoint(node, startOffset),
|
rv = DeleteRange(EditorDOMPoint(node, startOffset),
|
||||||
EditorRawDOMPoint(node, endOffset));
|
EditorDOMPoint(node, endOffset));
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
@ -1302,10 +1295,8 @@ nsresult WSRunObject::PrepareToSplitAcrossBlocksPriv() {
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename PT1, typename CT1, typename PT2, typename CT2>
|
nsresult WSRunObject::DeleteRange(const EditorDOMPoint& aStartPoint,
|
||||||
nsresult WSRunObject::DeleteRange(
|
const EditorDOMPoint& aEndPoint) {
|
||||||
const EditorDOMPointBase<PT1, CT1>& aStartPoint,
|
|
||||||
const EditorDOMPointBase<PT2, CT2>& aEndPoint) {
|
|
||||||
if (NS_WARN_IF(!aStartPoint.IsSet()) || NS_WARN_IF(!aEndPoint.IsSet())) {
|
if (NS_WARN_IF(!aStartPoint.IsSet()) || NS_WARN_IF(!aEndPoint.IsSet())) {
|
||||||
return NS_ERROR_INVALID_ARG;
|
return NS_ERROR_INVALID_ARG;
|
||||||
}
|
}
|
||||||
|
@ -1884,9 +1875,8 @@ nsresult WSRunObject::CheckTrailingNBSPOfRun(WSFragment* aRun) {
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename PT, typename CT>
|
|
||||||
nsresult WSRunObject::ReplacePreviousNBSPIfUnncessary(
|
nsresult WSRunObject::ReplacePreviousNBSPIfUnncessary(
|
||||||
WSFragment* aRun, const EditorDOMPointBase<PT, CT>& aPoint) {
|
WSFragment* aRun, const EditorDOMPoint& aPoint) {
|
||||||
if (NS_WARN_IF(!aRun) || NS_WARN_IF(!aPoint.IsSet())) {
|
if (NS_WARN_IF(!aRun) || NS_WARN_IF(!aPoint.IsSet())) {
|
||||||
return NS_ERROR_INVALID_ARG;
|
return NS_ERROR_INVALID_ARG;
|
||||||
}
|
}
|
||||||
|
|
|
@ -240,9 +240,8 @@ class MOZ_STACK_CLASS WSRunObject final {
|
||||||
* @return The new <br> node. If failed to create new <br>
|
* @return The new <br> node. If failed to create new <br>
|
||||||
* node, returns nullptr.
|
* node, returns nullptr.
|
||||||
*/
|
*/
|
||||||
template <typename PT, typename CT>
|
|
||||||
MOZ_CAN_RUN_SCRIPT already_AddRefed<dom::Element> InsertBreak(
|
MOZ_CAN_RUN_SCRIPT already_AddRefed<dom::Element> InsertBreak(
|
||||||
Selection& aSelection, const EditorDOMPointBase<PT, CT>& aPointToInsert,
|
Selection& aSelection, const EditorDOMPoint& aPointToInsert,
|
||||||
nsIEditor::EDirection aSelect);
|
nsIEditor::EDirection aSelect);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -387,10 +386,8 @@ class MOZ_STACK_CLASS WSRunObject final {
|
||||||
* When aEndPoint is in a text node, removes the text data before the point.
|
* When aEndPoint is in a text node, removes the text data before the point.
|
||||||
* Removes any nodes between them.
|
* Removes any nodes between them.
|
||||||
*/
|
*/
|
||||||
template <typename PT1, typename CT1, typename PT2, typename CT2>
|
MOZ_CAN_RUN_SCRIPT nsresult DeleteRange(const EditorDOMPoint& aStartPoint,
|
||||||
MOZ_CAN_RUN_SCRIPT nsresult
|
const EditorDOMPoint& aEndPoint);
|
||||||
DeleteRange(const EditorDOMPointBase<PT1, CT1>& aStartPoint,
|
|
||||||
const EditorDOMPointBase<PT2, CT2>& aEndPoint);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GetNextCharPoint() returns next character's point of aPoint. If there is
|
* GetNextCharPoint() returns next character's point of aPoint. If there is
|
||||||
|
@ -492,9 +489,8 @@ class MOZ_STACK_CLASS WSRunObject final {
|
||||||
* @param aPoint Current insertion point. Its previous character is
|
* @param aPoint Current insertion point. Its previous character is
|
||||||
* unnecessary NBSP will be checked.
|
* unnecessary NBSP will be checked.
|
||||||
*/
|
*/
|
||||||
template <typename PT, typename CT>
|
|
||||||
MOZ_CAN_RUN_SCRIPT nsresult ReplacePreviousNBSPIfUnncessary(
|
MOZ_CAN_RUN_SCRIPT nsresult ReplacePreviousNBSPIfUnncessary(
|
||||||
WSFragment* aRun, const EditorDOMPointBase<PT, CT>& aPoint);
|
WSFragment* aRun, const EditorDOMPoint& aPoint);
|
||||||
|
|
||||||
MOZ_CAN_RUN_SCRIPT
|
MOZ_CAN_RUN_SCRIPT
|
||||||
nsresult CheckLeadingNBSP(WSFragment* aRun, nsINode* aNode, int32_t aOffset);
|
nsresult CheckLeadingNBSP(WSFragment* aRun, nsINode* aNode, int32_t aOffset);
|
||||||
|
@ -502,11 +498,11 @@ class MOZ_STACK_CLASS WSRunObject final {
|
||||||
MOZ_CAN_RUN_SCRIPT nsresult Scrub();
|
MOZ_CAN_RUN_SCRIPT nsresult Scrub();
|
||||||
bool IsBlockNode(nsINode* aNode);
|
bool IsBlockNode(nsINode* aNode);
|
||||||
|
|
||||||
EditorRawDOMPoint StartPoint() const {
|
EditorDOMPoint StartPoint() const {
|
||||||
return EditorRawDOMPoint(mStartNode, mStartOffset);
|
return EditorDOMPoint(mStartNode, mStartOffset);
|
||||||
}
|
}
|
||||||
EditorRawDOMPoint EndPoint() const {
|
EditorDOMPoint EndPoint() const {
|
||||||
return EditorRawDOMPoint(mEndNode, mEndOffset);
|
return EditorDOMPoint(mEndNode, mEndOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The node passed to our constructor.
|
// The node passed to our constructor.
|
||||||
|
|
Загрузка…
Ссылка в новой задаче