Bug 1260651 part.3 Rename DOMPoint to mozilla::EditorDOMPoint because same name class is used in other modules widely r=mccr8

MozReview-Commit-ID: 9ZyVTv7veuK
This commit is contained in:
Masayuki Nakano 2016-06-23 17:13:03 +09:00
Родитель c4605a4cb2
Коммит caafdafcc5
7 изменённых файлов: 58 добавлений и 48 удалений

Просмотреть файл

@ -235,21 +235,25 @@ class nsTrivialFunctor : public nsBoolDomIterFunctor
}
};
namespace mozilla {
/******************************************************************************
* general dom point utility struct
*****************************************************************************/
struct MOZ_STACK_CLASS DOMPoint
struct MOZ_STACK_CLASS EditorDOMPoint final
{
nsCOMPtr<nsINode> node;
int32_t offset;
DOMPoint() : node(nullptr), offset(-1) {}
DOMPoint(nsINode* aNode, int32_t aOffset)
EditorDOMPoint()
: node(nullptr)
, offset(-1)
{}
EditorDOMPoint(nsINode* aNode, int32_t aOffset)
: node(aNode)
, offset(aOffset)
{}
DOMPoint(nsIDOMNode* aNode, int32_t aOffset)
EditorDOMPoint(nsIDOMNode* aNode, int32_t aOffset)
: node(do_QueryInterface(aNode))
, offset(aOffset)
{}
@ -266,8 +270,6 @@ struct MOZ_STACK_CLASS DOMPoint
}
};
namespace mozilla {
class EditorUtils final
{
public:

Просмотреть файл

@ -3871,7 +3871,7 @@ nsEditor::SplitNodeDeep(nsIContent& aNode,
* This joins two like nodes "deeply", joining children as appropriate.
* Returns the point of the join, or (nullptr, -1) in case of error.
*/
::DOMPoint
EditorDOMPoint
nsEditor::JoinNodeDeep(nsIContent& aLeftNode, nsIContent& aRightNode)
{
// While the rightmost children and their descendants of the left node match
@ -3882,7 +3882,7 @@ nsEditor::JoinNodeDeep(nsIContent& aLeftNode, nsIContent& aRightNode)
nsCOMPtr<nsIContent> rightNodeToJoin = &aRightNode;
nsCOMPtr<nsINode> parentNode = aRightNode.GetParentNode();
::DOMPoint ret;
EditorDOMPoint ret;
while (leftNodeToJoin && rightNodeToJoin && parentNode &&
AreNodesSameType(leftNodeToJoin, rightNodeToJoin)) {
@ -3893,7 +3893,7 @@ nsEditor::JoinNodeDeep(nsIContent& aLeftNode, nsIContent& aRightNode)
// Do the join
nsresult res = JoinNodes(*leftNodeToJoin, *rightNodeToJoin);
NS_ENSURE_SUCCESS(res, ::DOMPoint());
NS_ENSURE_SUCCESS(res, EditorDOMPoint());
if (parentNode->GetAsText()) {
// We've joined all the way down to text nodes, we're done!

Просмотреть файл

@ -52,11 +52,11 @@ class nsIWidget;
class nsRange;
class nsString;
class nsTransactionManager;
struct DOMPoint;
namespace mozilla {
class ErrorResult;
class TextComposition;
struct EditorDOMPoint;
namespace dom {
class ChangeAttributeTxn;
@ -639,7 +639,8 @@ public:
EmptyContainers::yes,
nsIContent** outLeftNode = nullptr,
nsIContent** outRightNode = nullptr);
::DOMPoint JoinNodeDeep(nsIContent& aLeftNode, nsIContent& aRightNode);
mozilla::EditorDOMPoint JoinNodeDeep(nsIContent& aLeftNode,
nsIContent& aRightNode);
nsresult GetString(const nsAString& name, nsAString& value);

Просмотреть файл

@ -2093,7 +2093,7 @@ nsHTMLEditRules::WillDeleteSelection(Selection* aSelection,
// Are they both text nodes? If so, join them!
if (startNode == stepbrother && startNode->GetAsText() &&
sibling->GetAsText()) {
::DOMPoint pt = JoinNodesSmart(*sibling, *startNode->AsContent());
EditorDOMPoint pt = JoinNodesSmart(*sibling, *startNode->AsContent());
NS_ENSURE_STATE(pt.node);
// Fix up selection
res = aSelection->Collapse(pt.node, pt.offset);
@ -2161,7 +2161,7 @@ nsHTMLEditRules::WillDeleteSelection(Selection* aSelection,
if (bDeletedBR) {
// Put selection at edge of block and we are done.
NS_ENSURE_STATE(leafNode);
::DOMPoint newSel = GetGoodSelPointForNode(*leafNode, aAction);
EditorDOMPoint newSel = GetGoodSelPointForNode(*leafNode, aAction);
NS_ENSURE_STATE(newSel.node);
aSelection->Collapse(newSel.node, newSel.offset);
return NS_OK;
@ -2323,7 +2323,8 @@ nsHTMLEditRules::WillDeleteSelection(Selection* aSelection,
NS_ENSURE_SUCCESS(res, res);
// Then join paragraphs, insert break
NS_ENSURE_STATE(mHTMLEditor);
::DOMPoint pt = mHTMLEditor->JoinNodeDeep(*leftParent, *rightParent);
EditorDOMPoint pt =
mHTMLEditor->JoinNodeDeep(*leftParent, *rightParent);
NS_ENSURE_STATE(pt.node);
// Fix up selection
res = aSelection->Collapse(pt.node, pt.offset);
@ -2338,7 +2339,8 @@ nsHTMLEditRules::WillDeleteSelection(Selection* aSelection,
NS_ENSURE_SUCCESS(res, res);
// Join blocks
NS_ENSURE_STATE(mHTMLEditor);
::DOMPoint pt = mHTMLEditor->JoinNodeDeep(*leftParent, *rightParent);
EditorDOMPoint pt =
mHTMLEditor->JoinNodeDeep(*leftParent, *rightParent);
NS_ENSURE_STATE(pt.node);
// Fix up selection
res = aSelection->Collapse(pt.node, pt.offset);
@ -2520,20 +2522,20 @@ nsHTMLEditRules::InsertBRIfNeeded(Selection* aSelection)
* nsIEditor::EDirection aAction which edge to find: eNext indicates
* beginning, ePrevious ending
*/
::DOMPoint
EditorDOMPoint
nsHTMLEditRules::GetGoodSelPointForNode(nsINode& aNode,
nsIEditor::EDirection aAction)
{
NS_ENSURE_TRUE(mHTMLEditor, ::DOMPoint());
NS_ENSURE_TRUE(mHTMLEditor, EditorDOMPoint());
if (aNode.GetAsText() || mHTMLEditor->IsContainer(&aNode)) {
return ::DOMPoint(&aNode,
aAction == nsIEditor::ePrevious ? aNode.Length() : 0);
return EditorDOMPoint(&aNode,
aAction == nsIEditor::ePrevious ? aNode.Length() : 0);
}
::DOMPoint ret;
EditorDOMPoint ret;
ret.node = aNode.GetParentNode();
ret.offset = ret.node ? ret.node->IndexOf(&aNode) : -1;
NS_ENSURE_TRUE(mHTMLEditor, ::DOMPoint());
NS_ENSURE_TRUE(mHTMLEditor, EditorDOMPoint());
if ((!aNode.IsHTMLElement(nsGkAtoms::br) ||
mHTMLEditor->IsVisBreak(&aNode)) &&
aAction == nsIEditor::ePrevious) {
@ -2779,7 +2781,7 @@ nsHTMLEditRules::JoinBlocks(nsIContent& aLeftNode, nsIContent& aRightNode,
if (mergeLists || leftBlock->NodeInfo()->NameAtom() ==
rightBlock->NodeInfo()->NameAtom()) {
// Nodes are same type. merge them.
::DOMPoint pt = JoinNodesSmart(*leftBlock, *rightBlock);
EditorDOMPoint pt = JoinNodesSmart(*leftBlock, *rightBlock);
if (pt.node && mergeLists) {
nsCOMPtr<Element> newBlock;
res = ConvertListType(rightBlock, getter_AddRefs(newBlock),
@ -2811,7 +2813,7 @@ nsHTMLEditRules::MoveBlock(Element& aLeftBlock, Element& aRightBlock,
{
nsTArray<OwningNonNull<nsINode>> arrayOfNodes;
// GetNodesFromPoint is the workhorse that figures out what we wnat to move.
nsresult res = GetNodesFromPoint(::DOMPoint(&aRightBlock, aRightOffset),
nsresult res = GetNodesFromPoint(EditorDOMPoint(&aRightBlock, aRightOffset),
EditAction::makeList, arrayOfNodes,
TouchContent::yes);
NS_ENSURE_SUCCESS(res, res);
@ -6025,7 +6027,7 @@ nsHTMLEditRules::GetHighestInlineParent(nsINode& aNode)
// from a point that will be operated on.
//
nsresult
nsHTMLEditRules::GetNodesFromPoint(::DOMPoint aPoint,
nsHTMLEditRules::GetNodesFromPoint(EditorDOMPoint aPoint,
EditAction aOperation,
nsTArray<OwningNonNull<nsINode>>& outArrayOfNodes,
TouchContent aTouchContent)
@ -6910,12 +6912,12 @@ nsHTMLEditRules::SplitAsNeeded(nsIAtom& aTag,
*
* Returns the point where they're merged, or (nullptr, -1) on failure.
*/
::DOMPoint
EditorDOMPoint
nsHTMLEditRules::JoinNodesSmart(nsIContent& aNodeLeft, nsIContent& aNodeRight)
{
// Caller responsible for left and right node being the same type
nsCOMPtr<nsINode> parent = aNodeLeft.GetParentNode();
NS_ENSURE_TRUE(parent, ::DOMPoint());
NS_ENSURE_TRUE(parent, EditorDOMPoint());
int32_t parOffset = parent->IndexOf(&aNodeLeft);
nsCOMPtr<nsINode> rightParent = aNodeRight.GetParentNode();
@ -6923,34 +6925,34 @@ nsHTMLEditRules::JoinNodesSmart(nsIContent& aNodeLeft, nsIContent& aNodeRight)
// left one
nsresult res;
if (parent != rightParent) {
NS_ENSURE_TRUE(mHTMLEditor, ::DOMPoint());
NS_ENSURE_TRUE(mHTMLEditor, EditorDOMPoint());
res = mHTMLEditor->MoveNode(&aNodeRight, parent, parOffset);
NS_ENSURE_SUCCESS(res, ::DOMPoint());
NS_ENSURE_SUCCESS(res, EditorDOMPoint());
}
::DOMPoint ret(&aNodeRight, aNodeLeft.Length());
EditorDOMPoint ret(&aNodeRight, aNodeLeft.Length());
// Separate join rules for differing blocks
if (nsHTMLEditUtils::IsList(&aNodeLeft) || aNodeLeft.GetAsText()) {
// For lists, merge shallow (wouldn't want to combine list items)
res = mHTMLEditor->JoinNodes(aNodeLeft, aNodeRight);
NS_ENSURE_SUCCESS(res, ::DOMPoint());
NS_ENSURE_SUCCESS(res, EditorDOMPoint());
return ret;
}
// Remember the last left child, and first right child
NS_ENSURE_TRUE(mHTMLEditor, ::DOMPoint());
NS_ENSURE_TRUE(mHTMLEditor, EditorDOMPoint());
nsCOMPtr<nsIContent> lastLeft = mHTMLEditor->GetLastEditableChild(aNodeLeft);
NS_ENSURE_TRUE(lastLeft, ::DOMPoint());
NS_ENSURE_TRUE(lastLeft, EditorDOMPoint());
NS_ENSURE_TRUE(mHTMLEditor, ::DOMPoint());
NS_ENSURE_TRUE(mHTMLEditor, EditorDOMPoint());
nsCOMPtr<nsIContent> firstRight = mHTMLEditor->GetFirstEditableChild(aNodeRight);
NS_ENSURE_TRUE(firstRight, ::DOMPoint());
NS_ENSURE_TRUE(firstRight, EditorDOMPoint());
// For list items, divs, etc., merge smart
NS_ENSURE_TRUE(mHTMLEditor, ::DOMPoint());
NS_ENSURE_TRUE(mHTMLEditor, EditorDOMPoint());
res = mHTMLEditor->JoinNodes(aNodeLeft, aNodeRight);
NS_ENSURE_SUCCESS(res, ::DOMPoint());
NS_ENSURE_SUCCESS(res, EditorDOMPoint());
if (lastLeft && firstRight && mHTMLEditor &&
mHTMLEditor->AreNodesSameType(lastLeft, firstRight) &&
@ -6958,7 +6960,7 @@ nsHTMLEditRules::JoinNodesSmart(nsIContent& aNodeLeft, nsIContent& aNodeRight)
(lastLeft->IsElement() && firstRight->IsElement() &&
mHTMLEditor->mHTMLCSSUtils->ElementsSameStyle(lastLeft->AsElement(),
firstRight->AsElement())))) {
NS_ENSURE_TRUE(mHTMLEditor, ::DOMPoint());
NS_ENSURE_TRUE(mHTMLEditor, EditorDOMPoint());
return JoinNodesSmart(*lastLeft, *firstRight);
}
return ret;

Просмотреть файл

@ -30,12 +30,12 @@ class nsPlaintextEditor;
class nsRange;
class nsRulesInfo;
namespace mozilla {
struct EditorDOMPoint;
namespace dom {
class Element;
class Selection;
} // namespace dom
} // namespace mozilla
struct DOMPoint;
struct StyleCache : public PropItem
{
@ -142,8 +142,8 @@ protected:
nsIEditor::EDirection aDir,
nsresult aResult);
nsresult InsertBRIfNeeded(Selection* aSelection);
::DOMPoint GetGoodSelPointForNode(nsINode& aNode,
nsIEditor::EDirection aAction);
mozilla::EditorDOMPoint GetGoodSelPointForNode(nsINode& aNode,
nsIEditor::EDirection aAction);
nsresult JoinBlocks(nsIContent& aLeftNode, nsIContent& aRightNode,
bool* aCanceled);
nsresult MoveBlock(Element& aLeftBlock, Element& aRightBlock,
@ -255,7 +255,7 @@ protected:
TouchContent aTouchContent = TouchContent::yes);
void GetChildNodesForOperation(nsINode& aNode,
nsTArray<OwningNonNull<nsINode>>& outArrayOfNodes);
nsresult GetNodesFromPoint(::DOMPoint aPoint,
nsresult GetNodesFromPoint(mozilla::EditorDOMPoint aPoint,
EditAction aOperation,
nsTArray<OwningNonNull<nsINode>>& outArrayOfNodes,
TouchContent aTouchContent);
@ -287,7 +287,8 @@ protected:
nsresult SplitAsNeeded(nsIAtom& aTag, nsCOMPtr<nsINode>& inOutParent,
int32_t& inOutOffset);
nsresult AddTerminatingBR(nsIDOMNode *aBlock);
::DOMPoint JoinNodesSmart(nsIContent& aNodeLeft, nsIContent& aNodeRight);
mozilla::EditorDOMPoint JoinNodesSmart(nsIContent& aNodeLeft,
nsIContent& aNodeRight);
Element* GetTopEnclosingMailCite(nsINode& aNode);
nsresult PopListItem(nsIDOMNode *aListItem, bool *aOutOfList);
nsresult RemoveListStructure(Element& aList);

Просмотреть файл

@ -623,7 +623,7 @@ nsWSRunObject::GetWSNodes()
// collect up an array of nodes that are contiguous with the insertion point
// and which contain only whitespace. Stop if you reach non-ws text or a new
// block boundary.
::DOMPoint start(mNode, mOffset), end(mNode, mOffset);
EditorDOMPoint start(mNode, mOffset), end(mNode, mOffset);
nsCOMPtr<nsINode> wsBoundingParent = GetWSBoundingParent();
// first look backwards to find preceding ws nodes
@ -1044,7 +1044,7 @@ nsWSRunObject::GetPreviousWSNodeInner(nsINode* aStartNode,
}
nsIContent*
nsWSRunObject::GetPreviousWSNode(::DOMPoint aPoint,
nsWSRunObject::GetPreviousWSNode(EditorDOMPoint aPoint,
nsINode* aBlockParent)
{
// Can't really recycle various getnext/prior routines because we
@ -1128,7 +1128,7 @@ nsWSRunObject::GetNextWSNodeInner(nsINode* aStartNode,
}
nsIContent*
nsWSRunObject::GetNextWSNode(::DOMPoint aPoint, nsINode* aBlockParent)
nsWSRunObject::GetNextWSNode(EditorDOMPoint aPoint, nsINode* aBlockParent)
{
// Can't really recycle various getnext/prior routines because we have
// special needs here. Need to step into inline containers but not block

Просмотреть файл

@ -15,7 +15,9 @@
class nsHTMLEditor;
class nsIDOMNode;
struct DOMPoint;
namespace mozilla {
struct EditorDOMPoint;
} // namespace mozilla
// class nsWSRunObject represents the entire whitespace situation
// around a given point. It collects up a list of nodes that contain
@ -312,9 +314,11 @@ class MOZ_STACK_CLASS nsWSRunObject
void MakeSingleWSRun(WSType aType);
nsIContent* GetPreviousWSNodeInner(nsINode* aStartNode,
nsINode* aBlockParent);
nsIContent* GetPreviousWSNode(::DOMPoint aPoint, nsINode* aBlockParent);
nsIContent* GetPreviousWSNode(mozilla::EditorDOMPoint aPoint,
nsINode* aBlockParent);
nsIContent* GetNextWSNodeInner(nsINode* aStartNode, nsINode* aBlockParent);
nsIContent* GetNextWSNode(::DOMPoint aPoint, nsINode* aBlockParent);
nsIContent* GetNextWSNode(mozilla::EditorDOMPoint aPoint,
nsINode* aBlockParent);
nsresult PrepareToDeleteRangePriv(nsWSRunObject* aEndObject);
nsresult PrepareToSplitAcrossBlocksPriv();
nsresult DeleteChars(nsINode* aStartNode, int32_t aStartOffset,