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-08-09 05:34:04 +04:00
|
|
|
|
|
|
|
|
2016-07-08 08:03:31 +03:00
|
|
|
#ifndef mozilla_EditorUtils_h
|
|
|
|
#define mozilla_EditorUtils_h
|
1999-08-09 05:34:04 +04:00
|
|
|
|
2017-06-28 03:34:18 +03:00
|
|
|
#include "mozilla/dom/Selection.h"
|
2018-01-12 13:01:04 +03:00
|
|
|
#include "mozilla/EditAction.h"
|
2016-07-08 07:10:13 +03:00
|
|
|
#include "mozilla/EditorBase.h"
|
2017-11-06 11:01:33 +03:00
|
|
|
#include "mozilla/EditorDOMPoint.h"
|
2016-07-08 07:10:13 +03:00
|
|
|
#include "mozilla/GuardObjects.h"
|
1999-08-09 05:34:04 +04:00
|
|
|
#include "nsCOMPtr.h"
|
2012-07-13 10:33:42 +04:00
|
|
|
#include "nsDebug.h"
|
1999-08-09 05:34:04 +04:00
|
|
|
#include "nsIEditor.h"
|
2012-07-13 10:33:42 +04:00
|
|
|
#include "nscore.h"
|
1999-12-07 11:30:19 +03:00
|
|
|
|
2017-10-03 01:05:19 +03:00
|
|
|
class nsAtom;
|
2012-07-13 10:33:42 +04:00
|
|
|
class nsIContentIterator;
|
2016-06-23 10:59:15 +03:00
|
|
|
class nsISimpleEnumerator;
|
|
|
|
class nsITransferable;
|
2014-11-02 15:04:13 +03:00
|
|
|
class nsRange;
|
2016-06-23 12:51:19 +03:00
|
|
|
|
2014-11-02 15:04:13 +03:00
|
|
|
namespace mozilla {
|
2015-04-24 14:27:35 +03:00
|
|
|
template <class T> class OwningNonNull;
|
2016-06-23 12:51:19 +03:00
|
|
|
|
2018-05-11 09:52:24 +03:00
|
|
|
namespace dom {
|
|
|
|
class Element;
|
|
|
|
class Text;
|
|
|
|
} // namespace dom
|
|
|
|
|
2016-11-18 11:59:23 +03:00
|
|
|
/***************************************************************************
|
|
|
|
* EditActionResult is useful to return multiple results of an editor
|
|
|
|
* action handler without out params.
|
|
|
|
* Note that when you return an anonymous instance from a method, you should
|
|
|
|
* use EditActionIgnored(), EditActionHandled() or EditActionCanceled() for
|
|
|
|
* easier to read. In other words, EditActionResult should be used when
|
|
|
|
* declaring return type of a method, being an argument or defined as a local
|
|
|
|
* variable.
|
|
|
|
*/
|
|
|
|
class MOZ_STACK_CLASS EditActionResult final
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
bool Succeeded() const { return NS_SUCCEEDED(mRv); }
|
|
|
|
bool Failed() const { return NS_FAILED(mRv); }
|
|
|
|
nsresult Rv() const { return mRv; }
|
|
|
|
bool Canceled() const { return mCanceled; }
|
|
|
|
bool Handled() const { return mHandled; }
|
2018-04-24 09:23:01 +03:00
|
|
|
bool EditorDestroyed() const { return mRv == NS_ERROR_EDITOR_DESTROYED; }
|
2016-11-18 11:59:23 +03:00
|
|
|
|
|
|
|
EditActionResult SetResult(nsresult aRv)
|
|
|
|
{
|
|
|
|
mRv = aRv;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
EditActionResult MarkAsCanceled()
|
|
|
|
{
|
|
|
|
mCanceled = true;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
EditActionResult MarkAsHandled()
|
|
|
|
{
|
|
|
|
mHandled = true;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
explicit EditActionResult(nsresult aRv)
|
|
|
|
: mRv(aRv)
|
|
|
|
, mCanceled(false)
|
|
|
|
, mHandled(false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
EditActionResult& operator|=(const EditActionResult& aOther)
|
|
|
|
{
|
|
|
|
mCanceled |= aOther.mCanceled;
|
|
|
|
mHandled |= aOther.mHandled;
|
|
|
|
// When both result are same, keep the result.
|
|
|
|
if (mRv == aOther.mRv) {
|
|
|
|
return *this;
|
|
|
|
}
|
2018-04-24 09:23:01 +03:00
|
|
|
// If one of the result is NS_ERROR_EDITOR_DESTROYED, use it since it's
|
|
|
|
// the most important error code for editor.
|
|
|
|
if (EditorDestroyed() || aOther.EditorDestroyed()) {
|
|
|
|
mRv = NS_ERROR_EDITOR_DESTROYED;
|
|
|
|
}
|
2016-11-18 11:59:23 +03:00
|
|
|
// If one of the results is error, use NS_ERROR_FAILURE.
|
2018-04-24 09:23:01 +03:00
|
|
|
else if (Failed() || aOther.Failed()) {
|
2016-11-18 11:59:23 +03:00
|
|
|
mRv = NS_ERROR_FAILURE;
|
|
|
|
} else {
|
|
|
|
// Otherwise, use generic success code, NS_OK.
|
|
|
|
mRv = NS_OK;
|
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsresult mRv;
|
|
|
|
bool mCanceled;
|
|
|
|
bool mHandled;
|
|
|
|
|
|
|
|
EditActionResult(nsresult aRv, bool aCanceled, bool aHandled)
|
|
|
|
: mRv(aRv)
|
|
|
|
, mCanceled(aCanceled)
|
|
|
|
, mHandled(aHandled)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
EditActionResult()
|
|
|
|
: mRv(NS_ERROR_NOT_INITIALIZED)
|
|
|
|
, mCanceled(false)
|
|
|
|
, mHandled(false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
friend EditActionResult EditActionIgnored(nsresult aRv);
|
|
|
|
friend EditActionResult EditActionHandled(nsresult aRv);
|
|
|
|
friend EditActionResult EditActionCanceled(nsresult aRv);
|
|
|
|
};
|
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
* When an edit action handler (or its helper) does nothing,
|
|
|
|
* EditActionIgnored should be returned.
|
|
|
|
*/
|
|
|
|
inline EditActionResult
|
|
|
|
EditActionIgnored(nsresult aRv = NS_OK)
|
|
|
|
{
|
|
|
|
return EditActionResult(aRv, false, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
* When an edit action handler (or its helper) handled and not canceled,
|
|
|
|
* EditActionHandled should be returned.
|
|
|
|
*/
|
|
|
|
inline EditActionResult
|
|
|
|
EditActionHandled(nsresult aRv = NS_OK)
|
|
|
|
{
|
|
|
|
return EditActionResult(aRv, false, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
* When an edit action handler (or its helper) handled and canceled,
|
|
|
|
* EditActionHandled should be returned.
|
|
|
|
*/
|
|
|
|
inline EditActionResult
|
|
|
|
EditActionCanceled(nsresult aRv = NS_OK)
|
|
|
|
{
|
|
|
|
return EditActionResult(aRv, true, true);
|
|
|
|
}
|
|
|
|
|
2018-05-11 09:52:24 +03:00
|
|
|
/***************************************************************************
|
|
|
|
* CreateNodeResultBase is a simple class for CreateSomething() methods
|
|
|
|
* which want to return new node.
|
|
|
|
*/
|
|
|
|
template<typename NodeType>
|
|
|
|
class CreateNodeResultBase;
|
|
|
|
|
|
|
|
typedef CreateNodeResultBase<dom::Element> CreateElementResult;
|
|
|
|
|
|
|
|
template<typename NodeType>
|
|
|
|
class MOZ_STACK_CLASS CreateNodeResultBase final
|
|
|
|
{
|
|
|
|
typedef CreateNodeResultBase<NodeType> SelfType;
|
|
|
|
public:
|
|
|
|
bool Succeeded() const { return NS_SUCCEEDED(mRv); }
|
|
|
|
bool Failed() const { return NS_FAILED(mRv); }
|
|
|
|
nsresult Rv() const { return mRv; }
|
|
|
|
NodeType* GetNewNode() const { return mNode; }
|
|
|
|
|
|
|
|
CreateNodeResultBase() = delete;
|
|
|
|
|
|
|
|
explicit CreateNodeResultBase(nsresult aRv)
|
|
|
|
: mRv(aRv)
|
|
|
|
{
|
|
|
|
MOZ_DIAGNOSTIC_ASSERT(NS_FAILED(mRv));
|
|
|
|
}
|
|
|
|
|
|
|
|
explicit CreateNodeResultBase(NodeType* aNode)
|
|
|
|
: mNode(aNode)
|
|
|
|
, mRv(aNode ? NS_OK : NS_ERROR_FAILURE)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
explicit CreateNodeResultBase(already_AddRefed<NodeType>&& aNode)
|
|
|
|
: mNode(aNode)
|
|
|
|
, mRv(mNode.get() ? NS_OK : NS_ERROR_FAILURE)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
CreateNodeResultBase(const SelfType& aOther) = delete;
|
|
|
|
SelfType& operator=(const SelfType& aOther) = delete;
|
|
|
|
CreateNodeResultBase(SelfType&& aOther) = default;
|
|
|
|
SelfType& operator=(SelfType&& aOther) = default;
|
|
|
|
|
|
|
|
already_AddRefed<NodeType> forget()
|
|
|
|
{
|
|
|
|
mRv = NS_ERROR_NOT_INITIALIZED;
|
|
|
|
return mNode.forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
RefPtr<NodeType> mNode;
|
|
|
|
nsresult mRv;
|
|
|
|
};
|
|
|
|
|
2017-11-16 06:09:57 +03:00
|
|
|
/***************************************************************************
|
2018-04-09 20:16:49 +03:00
|
|
|
* SplitNodeResult is a simple class for
|
|
|
|
* EditorBase::SplitNodeDeepWithTransaction().
|
2017-11-16 06:09:57 +03:00
|
|
|
* This makes the callers' code easier to read.
|
|
|
|
*/
|
|
|
|
class MOZ_STACK_CLASS SplitNodeResult final
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
bool Succeeded() const { return NS_SUCCEEDED(mRv); }
|
|
|
|
bool Failed() const { return NS_FAILED(mRv); }
|
|
|
|
nsresult Rv() const { return mRv; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* DidSplit() returns true if a node was actually split.
|
|
|
|
*/
|
|
|
|
bool DidSplit() const
|
|
|
|
{
|
|
|
|
return mPreviousNode && mNextNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GetLeftNode() simply returns the left node which was created at splitting.
|
|
|
|
* This returns nullptr if the node wasn't split.
|
|
|
|
*/
|
|
|
|
nsIContent* GetLeftNode() const
|
|
|
|
{
|
|
|
|
return mPreviousNode && mNextNode ? mPreviousNode.get() : nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GetRightNode() simply returns the right node which was split.
|
|
|
|
* This won't return nullptr unless failed to split due to invalid arguments.
|
|
|
|
*/
|
|
|
|
nsIContent* GetRightNode() const
|
|
|
|
{
|
2017-11-19 05:05:26 +03:00
|
|
|
if (mGivenSplitPoint.IsSet()) {
|
2017-12-07 13:08:56 +03:00
|
|
|
return mGivenSplitPoint.GetChild();
|
2017-11-19 05:05:26 +03:00
|
|
|
}
|
2017-11-16 06:09:57 +03:00
|
|
|
return mPreviousNode && !mNextNode ? mPreviousNode : mNextNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GetPreviousNode() returns previous node at the split point.
|
|
|
|
*/
|
2017-11-19 05:05:26 +03:00
|
|
|
nsIContent* GetPreviousNode() const
|
|
|
|
{
|
|
|
|
if (mGivenSplitPoint.IsSet()) {
|
|
|
|
return mGivenSplitPoint.IsEndOfContainer() ?
|
2017-12-07 13:08:56 +03:00
|
|
|
mGivenSplitPoint.GetChild() : nullptr;
|
2017-11-19 05:05:26 +03:00
|
|
|
}
|
|
|
|
return mPreviousNode;
|
|
|
|
}
|
2017-11-16 06:09:57 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* GetNextNode() returns next node at the split point.
|
|
|
|
*/
|
2017-11-19 05:05:26 +03:00
|
|
|
nsIContent* GetNextNode() const
|
|
|
|
{
|
|
|
|
if (mGivenSplitPoint.IsSet()) {
|
|
|
|
return !mGivenSplitPoint.IsEndOfContainer() ?
|
2017-12-07 13:08:56 +03:00
|
|
|
mGivenSplitPoint.GetChild() : nullptr;
|
2017-11-19 05:05:26 +03:00
|
|
|
}
|
|
|
|
return mNextNode;
|
|
|
|
}
|
2017-11-16 06:09:57 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* SplitPoint() returns the split point in the container.
|
|
|
|
* This is useful when callers insert an element at split point with
|
2018-04-09 19:17:26 +03:00
|
|
|
* EditorBase::CreateNodeWithTransaction() or something similar methods.
|
2017-11-16 06:09:57 +03:00
|
|
|
*
|
|
|
|
* Note that the result is EditorRawDOMPoint but the nodes are grabbed
|
|
|
|
* by this instance. Therefore, the life time of both container node
|
|
|
|
* and child node are guaranteed while using the result temporarily.
|
|
|
|
*/
|
|
|
|
EditorRawDOMPoint SplitPoint() const
|
|
|
|
{
|
|
|
|
if (Failed()) {
|
|
|
|
return EditorRawDOMPoint();
|
|
|
|
}
|
2017-11-19 05:05:26 +03:00
|
|
|
if (mGivenSplitPoint.IsSet()) {
|
2018-03-20 08:05:47 +03:00
|
|
|
return EditorRawDOMPoint(mGivenSplitPoint);
|
2017-11-19 05:05:26 +03:00
|
|
|
}
|
2017-11-16 06:09:57 +03:00
|
|
|
if (!mPreviousNode) {
|
|
|
|
return EditorRawDOMPoint(mNextNode);
|
|
|
|
}
|
|
|
|
EditorRawDOMPoint point(mPreviousNode);
|
|
|
|
DebugOnly<bool> advanced = point.AdvanceOffset();
|
|
|
|
NS_WARNING_ASSERTION(advanced,
|
|
|
|
"Failed to advance offset to after previous node");
|
|
|
|
return point;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This constructor shouldn't be used by anybody except methods which
|
|
|
|
* use this as result when it succeeds.
|
|
|
|
*
|
|
|
|
* @param aPreviousNodeOfSplitPoint Previous node immediately before
|
|
|
|
* split point.
|
|
|
|
* @param aNextNodeOfSplitPoint Next node immediately after split
|
|
|
|
* point.
|
|
|
|
*/
|
|
|
|
SplitNodeResult(nsIContent* aPreviousNodeOfSplitPoint,
|
|
|
|
nsIContent* aNextNodeOfSplitPoint)
|
|
|
|
: mPreviousNode(aPreviousNodeOfSplitPoint)
|
|
|
|
, mNextNode(aNextNodeOfSplitPoint)
|
|
|
|
, mRv(NS_OK)
|
|
|
|
{
|
|
|
|
MOZ_DIAGNOSTIC_ASSERT(mPreviousNode || mNextNode);
|
|
|
|
}
|
|
|
|
|
2017-11-19 05:05:26 +03:00
|
|
|
/**
|
|
|
|
* This constructor should be used when the method didn't split any nodes
|
|
|
|
* but want to return given split point as right point.
|
|
|
|
*/
|
|
|
|
explicit SplitNodeResult(const EditorRawDOMPoint& aGivenSplitPoint)
|
|
|
|
: mGivenSplitPoint(aGivenSplitPoint)
|
|
|
|
, mRv(NS_OK)
|
|
|
|
{
|
|
|
|
MOZ_DIAGNOSTIC_ASSERT(mGivenSplitPoint.IsSet());
|
|
|
|
}
|
|
|
|
|
2017-11-16 06:09:57 +03:00
|
|
|
/**
|
|
|
|
* This constructor shouldn't be used by anybody except methods which
|
|
|
|
* use this as error result when it fails.
|
|
|
|
*/
|
|
|
|
explicit SplitNodeResult(nsresult aRv)
|
|
|
|
: mRv(aRv)
|
|
|
|
{
|
|
|
|
MOZ_DIAGNOSTIC_ASSERT(NS_FAILED(mRv));
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2017-11-19 05:05:26 +03:00
|
|
|
// When methods which return this class split some nodes actually, they
|
|
|
|
// need to set a set of left node and right node to this class. However,
|
|
|
|
// one or both of them may be moved or removed by mutation observer.
|
|
|
|
// In such case, we cannot represent the point with EditorDOMPoint since
|
|
|
|
// it requires current container node. Therefore, we need to use
|
|
|
|
// nsCOMPtr<nsIContent> here instead.
|
2017-11-16 06:09:57 +03:00
|
|
|
nsCOMPtr<nsIContent> mPreviousNode;
|
|
|
|
nsCOMPtr<nsIContent> mNextNode;
|
|
|
|
|
2017-11-19 05:05:26 +03:00
|
|
|
// Methods which return this class may not split any nodes actually. Then,
|
|
|
|
// they may want to return given split point as is since such behavior makes
|
|
|
|
// their callers simpler. In this case, the point may be in a text node
|
|
|
|
// which cannot be represented as a node. Therefore, we need EditorDOMPoint
|
|
|
|
// for representing the point.
|
|
|
|
EditorDOMPoint mGivenSplitPoint;
|
|
|
|
|
2017-11-16 06:09:57 +03:00
|
|
|
nsresult mRv;
|
|
|
|
|
|
|
|
SplitNodeResult() = delete;
|
|
|
|
};
|
|
|
|
|
2018-05-17 10:28:52 +03:00
|
|
|
/***************************************************************************
|
|
|
|
* SplitRangeOffFromNodeResult class is a simple class for methods which split a
|
|
|
|
* node at 2 points for making part of the node split off from the node.
|
|
|
|
*/
|
|
|
|
class MOZ_STACK_CLASS SplitRangeOffFromNodeResult final
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
bool Succeeded() const { return NS_SUCCEEDED(mRv); }
|
|
|
|
bool Failed() const { return NS_FAILED(mRv); }
|
|
|
|
nsresult Rv() const { return mRv; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GetLeftContent() returns new created node before the part of quarried out.
|
|
|
|
* This may return nullptr if the method didn't split at start edge of
|
|
|
|
* the node.
|
|
|
|
*/
|
|
|
|
nsIContent* GetLeftContent() const { return mLeftContent; }
|
|
|
|
dom::Element* GetLeftContentAsElement() const
|
|
|
|
{
|
2018-05-30 17:56:24 +03:00
|
|
|
return Element::FromNodeOrNull(mLeftContent);
|
2018-05-17 10:28:52 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GetMiddleContent() returns new created node between left node and right
|
|
|
|
* node. I.e., this is quarried out from the node. This may return nullptr
|
|
|
|
* if the method unwrapped the middle node.
|
|
|
|
*/
|
|
|
|
nsIContent* GetMiddleContent() const { return mMiddleContent; }
|
|
|
|
dom::Element* GetMiddleContentAsElement() const
|
|
|
|
{
|
2018-05-30 17:56:24 +03:00
|
|
|
return Element::FromNodeOrNull(mMiddleContent);
|
2018-05-17 10:28:52 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GetRightContent() returns the right node after the part of quarried out.
|
|
|
|
* This may return nullptr it the method didn't split at end edge of the
|
|
|
|
* node.
|
|
|
|
*/
|
|
|
|
nsIContent* GetRightContent() const { return mRightContent; }
|
|
|
|
dom::Element* GetRightContentAsElement() const
|
|
|
|
{
|
2018-05-30 17:56:24 +03:00
|
|
|
return Element::FromNodeOrNull(mRightContent);
|
2018-05-17 10:28:52 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
SplitRangeOffFromNodeResult(nsIContent* aLeftContent, nsIContent* aMiddleContent,
|
|
|
|
nsIContent* aRightContent)
|
|
|
|
: mLeftContent(aLeftContent)
|
|
|
|
, mMiddleContent(aMiddleContent)
|
|
|
|
, mRightContent(aRightContent)
|
|
|
|
, mRv(NS_OK)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
SplitRangeOffFromNodeResult(SplitNodeResult& aSplitResultAtLeftOfMiddleNode,
|
|
|
|
SplitNodeResult& aSplitResultAtRightOfMiddleNode)
|
|
|
|
: mRv(NS_OK)
|
|
|
|
{
|
|
|
|
if (aSplitResultAtLeftOfMiddleNode.Succeeded()) {
|
|
|
|
mLeftContent = aSplitResultAtLeftOfMiddleNode.GetPreviousNode();
|
|
|
|
}
|
|
|
|
if (aSplitResultAtRightOfMiddleNode.Succeeded()) {
|
|
|
|
mRightContent = aSplitResultAtRightOfMiddleNode.GetNextNode();
|
|
|
|
mMiddleContent = aSplitResultAtRightOfMiddleNode.GetPreviousNode();
|
|
|
|
}
|
|
|
|
if (!mMiddleContent && aSplitResultAtLeftOfMiddleNode.Succeeded()) {
|
|
|
|
mMiddleContent = aSplitResultAtLeftOfMiddleNode.GetNextNode();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
explicit SplitRangeOffFromNodeResult(nsresult aRv)
|
|
|
|
: mRv(aRv)
|
|
|
|
{
|
|
|
|
MOZ_DIAGNOSTIC_ASSERT(NS_FAILED(mRv));
|
|
|
|
}
|
|
|
|
|
|
|
|
SplitRangeOffFromNodeResult(
|
|
|
|
const SplitRangeOffFromNodeResult& aOther) = delete;
|
|
|
|
SplitRangeOffFromNodeResult&
|
|
|
|
operator=(const SplitRangeOffFromNodeResult& aOther) = delete;
|
|
|
|
SplitRangeOffFromNodeResult(SplitRangeOffFromNodeResult&& aOther) = default;
|
|
|
|
SplitRangeOffFromNodeResult&
|
|
|
|
operator=(SplitRangeOffFromNodeResult&& aOther) = default;
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsCOMPtr<nsIContent> mLeftContent;
|
|
|
|
nsCOMPtr<nsIContent> mMiddleContent;
|
|
|
|
nsCOMPtr<nsIContent> mRightContent;
|
|
|
|
|
|
|
|
nsresult mRv;
|
|
|
|
|
|
|
|
SplitRangeOffFromNodeResult() = delete;
|
|
|
|
};
|
|
|
|
|
2000-01-31 13:30:12 +03:00
|
|
|
/***************************************************************************
|
2017-06-22 09:02:59 +03:00
|
|
|
* stack based helper class for batching a collection of transactions inside a
|
|
|
|
* placeholder transaction.
|
2000-01-31 13:30:12 +03:00
|
|
|
*/
|
2017-08-14 08:56:39 +03:00
|
|
|
class MOZ_RAII AutoPlaceholderBatch final
|
1999-09-30 00:08:15 +04:00
|
|
|
{
|
2016-06-23 12:51:19 +03:00
|
|
|
private:
|
2017-08-14 08:56:39 +03:00
|
|
|
RefPtr<EditorBase> mEditorBase;
|
2016-06-23 12:51:19 +03:00
|
|
|
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
|
|
|
|
|
|
|
|
public:
|
2017-08-14 08:56:39 +03:00
|
|
|
explicit AutoPlaceholderBatch(EditorBase* aEditorBase
|
|
|
|
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
|
|
|
|
: mEditorBase(aEditorBase)
|
|
|
|
{
|
|
|
|
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
|
|
|
|
BeginPlaceholderTransaction(nullptr);
|
|
|
|
}
|
|
|
|
AutoPlaceholderBatch(EditorBase* aEditorBase,
|
2017-10-03 01:05:19 +03:00
|
|
|
nsAtom* aTransactionName
|
2016-06-23 12:51:19 +03:00
|
|
|
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
|
2017-08-14 08:56:39 +03:00
|
|
|
: mEditorBase(aEditorBase)
|
2016-06-23 12:51:19 +03:00
|
|
|
{
|
|
|
|
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
|
2017-08-14 08:56:39 +03:00
|
|
|
BeginPlaceholderTransaction(aTransactionName);
|
2016-06-23 12:51:19 +03:00
|
|
|
}
|
2017-08-14 08:56:39 +03:00
|
|
|
~AutoPlaceholderBatch()
|
2016-06-23 12:51:19 +03:00
|
|
|
{
|
2017-08-14 08:56:39 +03:00
|
|
|
if (mEditorBase) {
|
|
|
|
mEditorBase->EndPlaceholderTransaction();
|
2015-08-25 21:04:12 +03:00
|
|
|
}
|
2016-06-23 12:51:19 +03:00
|
|
|
}
|
1999-09-30 00:08:15 +04:00
|
|
|
|
2016-06-23 12:46:58 +03:00
|
|
|
private:
|
2017-10-03 01:05:19 +03:00
|
|
|
void BeginPlaceholderTransaction(nsAtom* aTransactionName)
|
2016-06-23 12:46:58 +03:00
|
|
|
{
|
2017-08-14 08:56:39 +03:00
|
|
|
if (mEditorBase) {
|
|
|
|
mEditorBase->BeginPlaceholderTransaction(aTransactionName);
|
|
|
|
}
|
2016-06-23 12:46:58 +03:00
|
|
|
}
|
|
|
|
};
|
2016-07-07 07:27:31 +03:00
|
|
|
|
2000-01-31 13:30:12 +03:00
|
|
|
/***************************************************************************
|
|
|
|
* stack based helper class for saving/restoring selection. Note that this
|
|
|
|
* assumes that the nodes involved are still around afterwards!
|
|
|
|
*/
|
2016-07-07 07:27:31 +03:00
|
|
|
class MOZ_RAII AutoSelectionRestorer final
|
1999-08-09 05:34:04 +04:00
|
|
|
{
|
2016-07-07 07:27:31 +03:00
|
|
|
private:
|
|
|
|
// Ref-counted reference to the selection that we are supposed to restore.
|
|
|
|
RefPtr<dom::Selection> mSelection;
|
2016-07-08 07:10:13 +03:00
|
|
|
EditorBase* mEditorBase; // Non-owning ref to EditorBase.
|
2016-07-07 07:27:31 +03:00
|
|
|
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
|
1999-08-09 05:34:04 +04:00
|
|
|
|
2016-07-07 07:27:31 +03:00
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Constructor responsible for remembering all state needed to restore
|
|
|
|
* aSelection.
|
|
|
|
*/
|
|
|
|
AutoSelectionRestorer(dom::Selection* aSelection,
|
2016-07-08 07:10:13 +03:00
|
|
|
EditorBase* aEditorBase
|
2016-07-07 07:27:31 +03:00
|
|
|
MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
|
2015-05-28 18:58:42 +03:00
|
|
|
|
2016-07-07 07:27:31 +03:00
|
|
|
/**
|
|
|
|
* Destructor restores mSelection to its former state
|
|
|
|
*/
|
|
|
|
~AutoSelectionRestorer();
|
2000-08-26 08:03:50 +04:00
|
|
|
|
2016-07-07 07:27:31 +03:00
|
|
|
/**
|
|
|
|
* Abort() cancels to restore the selection.
|
|
|
|
*/
|
|
|
|
void Abort();
|
1999-08-09 05:34:04 +04:00
|
|
|
};
|
|
|
|
|
1999-12-07 11:30:19 +03:00
|
|
|
/***************************************************************************
|
Bug 1463985 - part 1: Rename EditAction to EditSubAction and related stuff r=m_kato
When we implement InputEvent.inputType, we need to set a stack class to record
which edit action is currently handled. However, currently, we call smaller
jobs as edit action. For example, when user types a character at selecting
some characters, then, EditAction::deleteSelection is performed first, then,
EditAction::insertText is performed. However, for the InputEvent.inputType,
we need inserText information. So, for making new enum EditAction, we need
to rename current EditAction to EditSubAction.
And also this renames related stuff:
EditorBase::mIsInEditAction -> EditorBase::mIsInEditSubAction
EditorBase::IsInEditAction() -> EditorBase::IsInEditSubAction()
EditorBase::mAction -> EditorBase::mTopLevelEditSubAction
TextEditRules::mTheAction -> TextEditRules::mTopLevelEditSubAction
EditorBase::StartOperation() ->
EditorBase::OnStartToHandleTopLevelEditSubAction()
EditorBase::EndOperation() ->
EditorBase::OnEndHandlingTopLevelEditSubAction()
AutoRules -> AutoTopLevelEditSubActionNotifier
RulesInfo -> EditSubActionInfo
MozReview-Commit-ID: cvSkPUjFm1
--HG--
extra : rebase_source : baf527a3e353b7a8ebe9a46be2243b059c500234
2018-05-28 14:12:34 +03:00
|
|
|
* AutoTopLevelEditSubActionNotifier notifies editor of start to handle
|
|
|
|
* top level edit sub-action and end handling top level edit sub-action.
|
1999-12-07 11:30:19 +03:00
|
|
|
*/
|
Bug 1463985 - part 1: Rename EditAction to EditSubAction and related stuff r=m_kato
When we implement InputEvent.inputType, we need to set a stack class to record
which edit action is currently handled. However, currently, we call smaller
jobs as edit action. For example, when user types a character at selecting
some characters, then, EditAction::deleteSelection is performed first, then,
EditAction::insertText is performed. However, for the InputEvent.inputType,
we need inserText information. So, for making new enum EditAction, we need
to rename current EditAction to EditSubAction.
And also this renames related stuff:
EditorBase::mIsInEditAction -> EditorBase::mIsInEditSubAction
EditorBase::IsInEditAction() -> EditorBase::IsInEditSubAction()
EditorBase::mAction -> EditorBase::mTopLevelEditSubAction
TextEditRules::mTheAction -> TextEditRules::mTopLevelEditSubAction
EditorBase::StartOperation() ->
EditorBase::OnStartToHandleTopLevelEditSubAction()
EditorBase::EndOperation() ->
EditorBase::OnEndHandlingTopLevelEditSubAction()
AutoRules -> AutoTopLevelEditSubActionNotifier
RulesInfo -> EditSubActionInfo
MozReview-Commit-ID: cvSkPUjFm1
--HG--
extra : rebase_source : baf527a3e353b7a8ebe9a46be2243b059c500234
2018-05-28 14:12:34 +03:00
|
|
|
class MOZ_RAII AutoTopLevelEditSubActionNotifier final
|
1999-12-07 11:30:19 +03:00
|
|
|
{
|
2016-06-23 12:15:42 +03:00
|
|
|
public:
|
Bug 1463985 - part 1: Rename EditAction to EditSubAction and related stuff r=m_kato
When we implement InputEvent.inputType, we need to set a stack class to record
which edit action is currently handled. However, currently, we call smaller
jobs as edit action. For example, when user types a character at selecting
some characters, then, EditAction::deleteSelection is performed first, then,
EditAction::insertText is performed. However, for the InputEvent.inputType,
we need inserText information. So, for making new enum EditAction, we need
to rename current EditAction to EditSubAction.
And also this renames related stuff:
EditorBase::mIsInEditAction -> EditorBase::mIsInEditSubAction
EditorBase::IsInEditAction() -> EditorBase::IsInEditSubAction()
EditorBase::mAction -> EditorBase::mTopLevelEditSubAction
TextEditRules::mTheAction -> TextEditRules::mTopLevelEditSubAction
EditorBase::StartOperation() ->
EditorBase::OnStartToHandleTopLevelEditSubAction()
EditorBase::EndOperation() ->
EditorBase::OnEndHandlingTopLevelEditSubAction()
AutoRules -> AutoTopLevelEditSubActionNotifier
RulesInfo -> EditSubActionInfo
MozReview-Commit-ID: cvSkPUjFm1
--HG--
extra : rebase_source : baf527a3e353b7a8ebe9a46be2243b059c500234
2018-05-28 14:12:34 +03:00
|
|
|
AutoTopLevelEditSubActionNotifier(EditorBase& aEditorBase,
|
|
|
|
EditSubAction aEditSubAction,
|
|
|
|
nsIEditor::EDirection aDirection
|
|
|
|
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
|
2016-07-08 07:10:13 +03:00
|
|
|
: mEditorBase(aEditorBase)
|
2016-06-23 12:15:42 +03:00
|
|
|
, mDoNothing(false)
|
2015-05-28 18:58:42 +03:00
|
|
|
{
|
2015-08-25 21:04:12 +03:00
|
|
|
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
|
Bug 1463985 - part 1: Rename EditAction to EditSubAction and related stuff r=m_kato
When we implement InputEvent.inputType, we need to set a stack class to record
which edit action is currently handled. However, currently, we call smaller
jobs as edit action. For example, when user types a character at selecting
some characters, then, EditAction::deleteSelection is performed first, then,
EditAction::insertText is performed. However, for the InputEvent.inputType,
we need inserText information. So, for making new enum EditAction, we need
to rename current EditAction to EditSubAction.
And also this renames related stuff:
EditorBase::mIsInEditAction -> EditorBase::mIsInEditSubAction
EditorBase::IsInEditAction() -> EditorBase::IsInEditSubAction()
EditorBase::mAction -> EditorBase::mTopLevelEditSubAction
TextEditRules::mTheAction -> TextEditRules::mTopLevelEditSubAction
EditorBase::StartOperation() ->
EditorBase::OnStartToHandleTopLevelEditSubAction()
EditorBase::EndOperation() ->
EditorBase::OnEndHandlingTopLevelEditSubAction()
AutoRules -> AutoTopLevelEditSubActionNotifier
RulesInfo -> EditSubActionInfo
MozReview-Commit-ID: cvSkPUjFm1
--HG--
extra : rebase_source : baf527a3e353b7a8ebe9a46be2243b059c500234
2018-05-28 14:12:34 +03:00
|
|
|
// mTopLevelEditSubAction will already be set if this is nested call
|
|
|
|
// XXX Looks like that this is not aware of unexpected nested edit action
|
|
|
|
// handling via selectionchange event listener or mutation event
|
|
|
|
// listener.
|
|
|
|
if (!mEditorBase.mTopLevelEditSubAction) {
|
|
|
|
mEditorBase.OnStartToHandleTopLevelEditSubAction(aEditSubAction,
|
|
|
|
aDirection);
|
2016-06-23 12:15:42 +03:00
|
|
|
} else {
|
|
|
|
mDoNothing = true; // nested calls will end up here
|
2000-08-14 06:39:37 +04:00
|
|
|
}
|
|
|
|
}
|
2016-06-23 12:15:42 +03:00
|
|
|
|
Bug 1463985 - part 1: Rename EditAction to EditSubAction and related stuff r=m_kato
When we implement InputEvent.inputType, we need to set a stack class to record
which edit action is currently handled. However, currently, we call smaller
jobs as edit action. For example, when user types a character at selecting
some characters, then, EditAction::deleteSelection is performed first, then,
EditAction::insertText is performed. However, for the InputEvent.inputType,
we need inserText information. So, for making new enum EditAction, we need
to rename current EditAction to EditSubAction.
And also this renames related stuff:
EditorBase::mIsInEditAction -> EditorBase::mIsInEditSubAction
EditorBase::IsInEditAction() -> EditorBase::IsInEditSubAction()
EditorBase::mAction -> EditorBase::mTopLevelEditSubAction
TextEditRules::mTheAction -> TextEditRules::mTopLevelEditSubAction
EditorBase::StartOperation() ->
EditorBase::OnStartToHandleTopLevelEditSubAction()
EditorBase::EndOperation() ->
EditorBase::OnEndHandlingTopLevelEditSubAction()
AutoRules -> AutoTopLevelEditSubActionNotifier
RulesInfo -> EditSubActionInfo
MozReview-Commit-ID: cvSkPUjFm1
--HG--
extra : rebase_source : baf527a3e353b7a8ebe9a46be2243b059c500234
2018-05-28 14:12:34 +03:00
|
|
|
~AutoTopLevelEditSubActionNotifier()
|
2000-08-14 06:39:37 +04:00
|
|
|
{
|
Bug 1463985 - part 1: Rename EditAction to EditSubAction and related stuff r=m_kato
When we implement InputEvent.inputType, we need to set a stack class to record
which edit action is currently handled. However, currently, we call smaller
jobs as edit action. For example, when user types a character at selecting
some characters, then, EditAction::deleteSelection is performed first, then,
EditAction::insertText is performed. However, for the InputEvent.inputType,
we need inserText information. So, for making new enum EditAction, we need
to rename current EditAction to EditSubAction.
And also this renames related stuff:
EditorBase::mIsInEditAction -> EditorBase::mIsInEditSubAction
EditorBase::IsInEditAction() -> EditorBase::IsInEditSubAction()
EditorBase::mAction -> EditorBase::mTopLevelEditSubAction
TextEditRules::mTheAction -> TextEditRules::mTopLevelEditSubAction
EditorBase::StartOperation() ->
EditorBase::OnStartToHandleTopLevelEditSubAction()
EditorBase::EndOperation() ->
EditorBase::OnEndHandlingTopLevelEditSubAction()
AutoRules -> AutoTopLevelEditSubActionNotifier
RulesInfo -> EditSubActionInfo
MozReview-Commit-ID: cvSkPUjFm1
--HG--
extra : rebase_source : baf527a3e353b7a8ebe9a46be2243b059c500234
2018-05-28 14:12:34 +03:00
|
|
|
if (!mDoNothing) {
|
|
|
|
mEditorBase.OnEndHandlingTopLevelEditSubAction();
|
2000-08-14 06:39:37 +04:00
|
|
|
}
|
|
|
|
}
|
2015-05-28 18:58:42 +03:00
|
|
|
|
2016-06-23 12:15:42 +03:00
|
|
|
protected:
|
Bug 1463985 - part 1: Rename EditAction to EditSubAction and related stuff r=m_kato
When we implement InputEvent.inputType, we need to set a stack class to record
which edit action is currently handled. However, currently, we call smaller
jobs as edit action. For example, when user types a character at selecting
some characters, then, EditAction::deleteSelection is performed first, then,
EditAction::insertText is performed. However, for the InputEvent.inputType,
we need inserText information. So, for making new enum EditAction, we need
to rename current EditAction to EditSubAction.
And also this renames related stuff:
EditorBase::mIsInEditAction -> EditorBase::mIsInEditSubAction
EditorBase::IsInEditAction() -> EditorBase::IsInEditSubAction()
EditorBase::mAction -> EditorBase::mTopLevelEditSubAction
TextEditRules::mTheAction -> TextEditRules::mTopLevelEditSubAction
EditorBase::StartOperation() ->
EditorBase::OnStartToHandleTopLevelEditSubAction()
EditorBase::EndOperation() ->
EditorBase::OnEndHandlingTopLevelEditSubAction()
AutoRules -> AutoTopLevelEditSubActionNotifier
RulesInfo -> EditSubActionInfo
MozReview-Commit-ID: cvSkPUjFm1
--HG--
extra : rebase_source : baf527a3e353b7a8ebe9a46be2243b059c500234
2018-05-28 14:12:34 +03:00
|
|
|
EditorBase& mEditorBase;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mDoNothing;
|
2015-08-25 21:04:12 +03:00
|
|
|
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
|
1999-12-07 11:30:19 +03:00
|
|
|
};
|
|
|
|
|
2000-01-04 06:09:41 +03:00
|
|
|
/***************************************************************************
|
|
|
|
* stack based helper class for turning off active selection adjustment
|
|
|
|
* by low level transactions
|
|
|
|
*/
|
2016-06-23 12:01:23 +03:00
|
|
|
class MOZ_RAII AutoTransactionsConserveSelection final
|
2000-01-04 06:09:41 +03:00
|
|
|
{
|
2016-06-23 12:01:23 +03:00
|
|
|
public:
|
2016-07-08 07:10:13 +03:00
|
|
|
explicit AutoTransactionsConserveSelection(EditorBase* aEditorBase
|
2016-06-23 12:01:23 +03:00
|
|
|
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
|
2016-07-08 07:10:13 +03:00
|
|
|
: mEditorBase(aEditorBase)
|
2016-06-23 12:01:23 +03:00
|
|
|
, mOldState(true)
|
2000-01-04 06:09:41 +03:00
|
|
|
{
|
2015-08-25 21:04:12 +03:00
|
|
|
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
|
2016-07-08 07:10:13 +03:00
|
|
|
if (mEditorBase) {
|
|
|
|
mOldState = mEditorBase->GetShouldTxnSetSelection();
|
|
|
|
mEditorBase->SetShouldTxnSetSelection(false);
|
2000-01-04 06:09:41 +03:00
|
|
|
}
|
|
|
|
}
|
2015-05-28 18:58:42 +03:00
|
|
|
|
2016-06-23 12:01:23 +03:00
|
|
|
~AutoTransactionsConserveSelection()
|
2000-01-04 06:09:41 +03:00
|
|
|
{
|
2016-07-08 07:10:13 +03:00
|
|
|
if (mEditorBase) {
|
|
|
|
mEditorBase->SetShouldTxnSetSelection(mOldState);
|
2000-01-04 06:09:41 +03:00
|
|
|
}
|
|
|
|
}
|
2015-05-28 18:58:42 +03:00
|
|
|
|
2016-06-23 12:01:23 +03:00
|
|
|
protected:
|
2016-07-08 07:10:13 +03:00
|
|
|
EditorBase* mEditorBase;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mOldState;
|
2015-08-25 21:04:12 +03:00
|
|
|
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
|
2000-01-04 06:09:41 +03:00
|
|
|
};
|
|
|
|
|
2001-05-11 17:59:11 +04:00
|
|
|
/***************************************************************************
|
|
|
|
* stack based helper class for batching reflow and paint requests.
|
|
|
|
*/
|
2016-07-07 07:09:51 +03:00
|
|
|
class MOZ_RAII AutoUpdateViewBatch final
|
2001-05-11 17:59:11 +04:00
|
|
|
{
|
2016-07-07 07:09:51 +03:00
|
|
|
public:
|
2016-07-08 07:10:13 +03:00
|
|
|
explicit AutoUpdateViewBatch(EditorBase* aEditorBase
|
2016-07-07 07:09:51 +03:00
|
|
|
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
|
2016-07-08 07:10:13 +03:00
|
|
|
: mEditorBase(aEditorBase)
|
2001-05-11 17:59:11 +04:00
|
|
|
{
|
2015-08-25 21:04:12 +03:00
|
|
|
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
|
2016-07-08 07:10:13 +03:00
|
|
|
NS_ASSERTION(mEditorBase, "null mEditorBase pointer!");
|
2001-05-11 17:59:11 +04:00
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
if (mEditorBase) {
|
|
|
|
mEditorBase->BeginUpdateViewBatch();
|
2016-07-07 07:09:51 +03:00
|
|
|
}
|
2001-05-11 17:59:11 +04:00
|
|
|
}
|
2015-05-28 18:58:42 +03:00
|
|
|
|
2016-07-07 07:09:51 +03:00
|
|
|
~AutoUpdateViewBatch()
|
2001-05-11 17:59:11 +04:00
|
|
|
{
|
2016-07-08 07:10:13 +03:00
|
|
|
if (mEditorBase) {
|
|
|
|
mEditorBase->EndUpdateViewBatch();
|
2016-07-07 07:09:51 +03:00
|
|
|
}
|
2001-05-11 17:59:11 +04:00
|
|
|
}
|
2015-05-28 18:58:42 +03:00
|
|
|
|
2016-07-07 07:09:51 +03:00
|
|
|
protected:
|
2016-07-08 07:10:13 +03:00
|
|
|
EditorBase* mEditorBase;
|
2015-08-25 21:04:12 +03:00
|
|
|
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
|
2001-05-11 17:59:11 +04:00
|
|
|
};
|
|
|
|
|
2017-06-28 03:34:18 +03:00
|
|
|
class MOZ_STACK_CLASS AutoRangeArray final
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit AutoRangeArray(dom::Selection* aSelection)
|
|
|
|
{
|
|
|
|
if (!aSelection) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
uint32_t rangeCount = aSelection->RangeCount();
|
|
|
|
for (uint32_t i = 0; i < rangeCount; i++) {
|
|
|
|
mRanges.AppendElement(*aSelection->GetRangeAt(i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
AutoTArray<mozilla::OwningNonNull<nsRange>, 8> mRanges;
|
|
|
|
};
|
|
|
|
|
2000-08-26 08:03:50 +04:00
|
|
|
/******************************************************************************
|
|
|
|
* some helper classes for iterating the dom tree
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2016-06-23 11:39:47 +03:00
|
|
|
class BoolDomIterFunctor
|
2000-08-26 08:03:50 +04:00
|
|
|
{
|
2016-06-23 11:39:47 +03:00
|
|
|
public:
|
|
|
|
virtual bool operator()(nsINode* aNode) const = 0;
|
2000-08-26 08:03:50 +04:00
|
|
|
};
|
|
|
|
|
2016-06-23 11:30:39 +03:00
|
|
|
class MOZ_RAII DOMIterator
|
2000-08-26 08:03:50 +04:00
|
|
|
{
|
2016-06-23 11:30:39 +03:00
|
|
|
public:
|
|
|
|
explicit DOMIterator(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM);
|
2015-05-22 16:58:30 +03:00
|
|
|
|
2016-06-23 11:30:39 +03:00
|
|
|
explicit DOMIterator(nsINode& aNode MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
|
|
|
|
virtual ~DOMIterator();
|
2015-04-24 14:27:34 +03:00
|
|
|
|
2016-06-23 11:30:39 +03:00
|
|
|
nsresult Init(nsRange& aRange);
|
2015-05-22 16:58:30 +03:00
|
|
|
|
2016-06-23 11:30:39 +03:00
|
|
|
void AppendList(
|
2016-06-23 11:39:47 +03:00
|
|
|
const BoolDomIterFunctor& functor,
|
2016-06-23 11:30:39 +03:00
|
|
|
nsTArray<mozilla::OwningNonNull<nsINode>>& arrayOfNodes) const;
|
2000-08-26 08:03:50 +04:00
|
|
|
|
2016-06-23 11:30:39 +03:00
|
|
|
protected:
|
|
|
|
nsCOMPtr<nsIContentIterator> mIter;
|
|
|
|
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
|
|
|
|
};
|
2016-06-23 11:25:03 +03:00
|
|
|
|
2016-06-23 11:30:39 +03:00
|
|
|
class MOZ_RAII DOMSubtreeIterator final : public DOMIterator
|
2000-08-26 08:03:50 +04:00
|
|
|
{
|
2016-06-23 11:25:03 +03:00
|
|
|
public:
|
|
|
|
explicit DOMSubtreeIterator(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM);
|
|
|
|
virtual ~DOMSubtreeIterator();
|
2015-05-22 16:58:30 +03:00
|
|
|
|
2016-06-23 11:25:03 +03:00
|
|
|
nsresult Init(nsRange& aRange);
|
2000-08-26 08:03:50 +04:00
|
|
|
};
|
2000-01-04 06:09:41 +03:00
|
|
|
|
2016-06-23 11:39:47 +03:00
|
|
|
class TrivialFunctor final : public BoolDomIterFunctor
|
Checking in for bug 50742, this change removes the use of XIF in mozilla and replaces the XIF converter with a HTML (and XML) serializer.
Contextual information added to HTML copy and intelligence added to HTML paste in the editor (fixes bugs 47014, 50568 and 46554, and partly (at least) fixes bug 53188).
Code written by vidur, jfrancis, jst, akkana. Tested by jfrancis, akkana, vidur, jst, kin. Reviwed (and super reviewed) by waterson, vidur, kin, jfrancis, jst
2000-10-07 14:57:30 +04:00
|
|
|
{
|
2016-06-23 11:19:35 +03:00
|
|
|
public:
|
|
|
|
// Used to build list of all nodes iterator covers
|
2017-11-06 06:37:28 +03:00
|
|
|
virtual bool operator()(nsINode* aNode) const override
|
2016-06-23 11:19:35 +03:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
Checking in for bug 50742, this change removes the use of XIF in mozilla and replaces the XIF converter with a HTML (and XML) serializer.
Contextual information added to HTML copy and intelligence added to HTML paste in the editor (fixes bugs 47014, 50568 and 46554, and partly (at least) fixes bug 53188).
Code written by vidur, jfrancis, jst, akkana. Tested by jfrancis, akkana, vidur, jst, kin. Reviwed (and super reviewed) by waterson, vidur, kin, jfrancis, jst
2000-10-07 14:57:30 +04:00
|
|
|
};
|
|
|
|
|
2016-07-07 05:49:42 +03:00
|
|
|
class EditorUtils final
|
2002-12-22 04:51:14 +03:00
|
|
|
{
|
2016-07-07 05:49:42 +03:00
|
|
|
public:
|
2017-11-06 11:01:33 +03:00
|
|
|
/**
|
|
|
|
* IsDescendantOf() checks if aNode is a child or a descendant of aParent.
|
|
|
|
* aOutPoint is set to the child of aParent.
|
|
|
|
*
|
|
|
|
* @return true if aNode is a child or a descendant of aParent.
|
|
|
|
*/
|
|
|
|
static bool IsDescendantOf(const nsINode& aNode,
|
|
|
|
const nsINode& aParent,
|
|
|
|
EditorRawDOMPoint* aOutPoint = nullptr);
|
|
|
|
static bool IsDescendantOf(const nsINode& aNode,
|
|
|
|
const nsINode& aParent,
|
|
|
|
EditorDOMPoint* aOutPoint);
|
2002-12-22 04:51:14 +03:00
|
|
|
};
|
|
|
|
|
2016-06-23 10:59:15 +03:00
|
|
|
} // namespace mozilla
|
|
|
|
|
2016-07-08 08:03:31 +03:00
|
|
|
#endif // #ifndef mozilla_EditorUtils_h
|