rename from editor/libeditor/nsEditorUtils.cpp
rename to editor/libeditor/EditorUtils.cpp
--- a/editor/libeditor/nsEditorUtils.cpp
+++ b/editor/libeditor/EditorUtils.cpp
@@ -1,14 +1,14 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */
-#include "nsEditorUtils.h"
+#include "EditorUtils.h"
#include "mozilla/OwningNonNull.h"
#include "mozilla/dom/Selection.h"
#include "nsComponentManagerUtils.h"
#include "nsError.h"
#include "nsIClipboardDragDropHookList.h"
// hooks
#include "nsIClipboardDragDropHooks.h"
@@ -121,18 +121,22 @@ nsDOMSubtreeIterator::Init(nsRange& aRan
nsDOMSubtreeIterator::~nsDOMSubtreeIterator()
{
}
/******************************************************************************
* some general purpose editor utils
*****************************************************************************/
+namespace mozilla {
+
bool
-nsEditorUtils::IsDescendantOf(nsINode* aNode, nsINode* aParent, int32_t* aOffset)
+EditorUtils::IsDescendantOf(nsINode* aNode,
+ nsINode* aParent,
+ int32_t* aOffset)
{
MOZ_ASSERT(aNode && aParent);
if (aNode == aParent) {
return false;
}
for (nsCOMPtr<nsINode> node = aNode; node; node = node->GetParentNode()) {
if (node->GetParentNode() == aParent) {
@@ -142,33 +146,37 @@ nsEditorUtils::IsDescendantOf(nsINode* a
return true;
}
}
return false;
}
bool
-nsEditorUtils::IsDescendantOf(nsIDOMNode* aNode, nsIDOMNode* aParent, int32_t* aOffset)
+EditorUtils::IsDescendantOf(nsIDOMNode* aNode,
+ nsIDOMNode* aParent,
+ int32_t* aOffset)
{
nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
nsCOMPtr<nsINode> parent = do_QueryInterface(aParent);
NS_ENSURE_TRUE(node && parent, false);
return IsDescendantOf(node, parent, aOffset);
}
bool
-nsEditorUtils::IsLeafNode(nsIDOMNode *aNode)
+EditorUtils::IsLeafNode(nsIDOMNode* aNode)
{
bool hasChildren = false;
if (aNode)
aNode->HasChildNodes(&hasChildren);
return !hasChildren;
}
+} // namespace mozilla
+
/******************************************************************************
* utility methods for drag/drop/copy/paste hooks
*****************************************************************************/
nsresult
nsEditorHookUtils::GetHookEnumeratorFromDocument(nsIDOMDocument *aDoc,
nsISimpleEnumerator **aResult)
{
rename from editor/libeditor/nsEditorUtils.h
rename to editor/libeditor/EditorUtils.h
--- a/editor/libeditor/nsEditorUtils.h
+++ b/editor/libeditor/EditorUtils.h
@@ -1,17 +1,16 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */
-#ifndef nsEditorUtils_h__
-#define nsEditorUtils_h__
-
+#ifndef EditorUtils_h
+#define EditorUtils_h
#include "nsCOMPtr.h"
#include "nsDebug.h"
#include "nsEditor.h"
#include "nsIDOMNode.h"
#include "nsIEditor.h"
#include "nscore.h"
#include "mozilla/GuardObjects.h"
@@ -259,33 +258,37 @@ struct MOZ_STACK_CLASS DOMPoint
}
void SetPoint(nsIDOMNode* aNode, int32_t aOffset)
{
node = do_QueryInterface(aNode);
offset = aOffset;
}
};
+namespace mozilla {
-class nsEditorUtils
+class EditorUtils final
{
- public:
- static bool IsDescendantOf(nsINode* aNode, nsINode* aParent, int32_t* aOffset = 0);
- static bool IsDescendantOf(nsIDOMNode *aNode, nsIDOMNode *aParent, int32_t *aOffset = 0);
- static bool IsLeafNode(nsIDOMNode *aNode);
+public:
+ static bool IsDescendantOf(nsINode* aNode, nsINode* aParent,
+ int32_t* aOffset = 0);
+ static bool IsDescendantOf(nsIDOMNode* aNode, nsIDOMNode* aParent,
+ int32_t* aOffset = 0);
+ static bool IsLeafNode(nsIDOMNode* aNode);
};
+} // namespace mozilla
class nsIDOMEvent;
class nsISimpleEnumerator;
class nsITransferable;
class nsEditorHookUtils
{
public:
static bool DoInsertionHook(nsIDOMDocument *aDoc, nsIDOMEvent *aEvent,
nsITransferable *aTrans);
private:
static nsresult GetHookEnumeratorFromDocument(nsIDOMDocument *aDoc,
nsISimpleEnumerator **aEnumerator);
};
-#endif // nsEditorUtils_h__
+#endif // #ifndef EditorUtils_h
--- a/editor/libeditor/PlaceholderTxn.h
+++ b/editor/libeditor/PlaceholderTxn.h
@@ -2,17 +2,17 @@
/* 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/. */
#ifndef AggregatePlaceholderTxn_h__
#define AggregatePlaceholderTxn_h__
#include "EditAggregateTxn.h"
-#include "nsEditorUtils.h"
+#include "EditorUtils.h"
#include "nsIAbsorbingTransaction.h"
#include "nsIDOMNode.h"
#include "nsCOMPtr.h"
#include "nsWeakPtr.h"
#include "nsWeakReference.h"
#include "nsAutoPtr.h"
namespace mozilla {
--- a/editor/libeditor/moz.build
+++ b/editor/libeditor/moz.build
@@ -16,26 +16,26 @@ BROWSER_CHROME_MANIFESTS += ['tests/brow
UNIFIED_SOURCES += [
'ChangeAttributeTxn.cpp',
'ChangeStyleTxn.cpp',
'CreateElementTxn.cpp',
'DeleteNodeTxn.cpp',
'DeleteRangeTxn.cpp',
'DeleteTextTxn.cpp',
'EditAggregateTxn.cpp',
+ 'EditorUtils.cpp',
'EditTxn.cpp',
'IMETextTxn.cpp',
'InsertNodeTxn.cpp',
'InsertTextTxn.cpp',
'JoinNodeTxn.cpp',
'nsEditor.cpp',
'nsEditorCommands.cpp',
'nsEditorController.cpp',
'nsEditorEventListener.cpp',
- 'nsEditorUtils.cpp',
'nsHTMLAbsPosition.cpp',
'nsHTMLAnonymousUtils.cpp',
'nsHTMLCSSUtils.cpp',
'nsHTMLDataTransfer.cpp',
'nsHTMLEditor.cpp',
'nsHTMLEditorEventListener.cpp',
'nsHTMLEditorStyle.cpp',
'nsHTMLEditRules.cpp',
--- a/editor/libeditor/nsEditor.cpp
+++ b/editor/libeditor/nsEditor.cpp
@@ -11,16 +11,17 @@
#include <string.h> // for strcmp
#include "ChangeAttributeTxn.h" // for ChangeAttributeTxn
#include "CreateElementTxn.h" // for CreateElementTxn
#include "DeleteNodeTxn.h" // for DeleteNodeTxn
#include "DeleteRangeTxn.h" // for DeleteRangeTxn
#include "DeleteTextTxn.h" // for DeleteTextTxn
#include "EditAggregateTxn.h" // for EditAggregateTxn
+#include "EditorUtils.h" // for nsAutoRules, etc
#include "EditTxn.h" // for EditTxn
#include "IMETextTxn.h" // for IMETextTxn
#include "InsertNodeTxn.h" // for InsertNodeTxn
#include "InsertTextTxn.h" // for InsertTextTxn
#include "JoinNodeTxn.h" // for JoinNodeTxn
#include "PlaceholderTxn.h" // for PlaceholderTxn
#include "SplitNodeTxn.h" // for SplitNodeTxn
#include "mozFlushType.h" // for mozFlushType::Flush_Frames
@@ -42,17 +43,16 @@
#include "nsCaseTreatment.h"
#include "nsCharTraits.h" // for NS_IS_HIGH_SURROGATE, etc
#include "nsComponentManagerUtils.h" // for do_CreateInstance
#include "nsComputedDOMStyle.h" // for nsComputedDOMStyle
#include "nsContentUtils.h" // for nsContentUtils
#include "nsDOMString.h" // for DOMStringIsNull
#include "nsDebug.h" // for NS_ENSURE_TRUE, etc
#include "nsEditorEventListener.h" // for nsEditorEventListener
-#include "nsEditorUtils.h" // for nsAutoRules, etc
#include "nsError.h" // for NS_OK, etc
#include "nsFocusManager.h" // for nsFocusManager
#include "nsFrameSelection.h" // for nsFrameSelection
#include "nsGkAtoms.h" // for nsGkAtoms, nsGkAtoms::dir
#include "nsIAbsorbingTransaction.h" // for nsIAbsorbingTransaction
#include "nsIAtom.h" // for nsIAtom
#include "nsIContent.h" // for nsIContent
#include "nsIDOMAttr.h" // for nsIDOMAttr
@@ -3806,17 +3806,17 @@ int32_t
nsEditor::SplitNodeDeep(nsIContent& aNode,
nsIContent& aSplitPointParent,
int32_t aSplitPointOffset,
EmptyContainers aEmptyContainers,
nsIContent** aOutLeftNode,
nsIContent** aOutRightNode)
{
MOZ_ASSERT(&aSplitPointParent == &aNode ||
- nsEditorUtils::IsDescendantOf(&aSplitPointParent, &aNode));
+ EditorUtils::IsDescendantOf(&aSplitPointParent, &aNode));
int32_t offset = aSplitPointOffset;
nsCOMPtr<nsIContent> leftNode, rightNode;
OwningNonNull<nsIContent> nodeToSplit = aSplitPointParent;
while (true) {
// Need to insert rules code call here to do things like not split a list
// if you are after the last <li> or before the first, etc. For now we
// just have some smarts about unneccessarily splitting text nodes, which
--- a/editor/libeditor/nsHTMLAbsPosition.cpp
+++ b/editor/libeditor/nsHTMLAbsPosition.cpp
@@ -1,26 +1,26 @@
/* 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/. */
#include <math.h>
+#include "EditorUtils.h"
#include "mozilla/Preferences.h"
#include "mozilla/dom/Selection.h"
#include "mozilla/dom/Element.h"
#include "mozilla/mozalloc.h"
#include "nsAString.h"
#include "nsAlgorithm.h"
#include "nsCOMPtr.h"
#include "nsComputedDOMStyle.h"
#include "nsDebug.h"
#include "nsEditRules.h"
#include "nsEditor.h"
-#include "nsEditorUtils.h"
#include "nsError.h"
#include "nsGkAtoms.h"
#include "nsHTMLCSSUtils.h"
#include "nsHTMLEditRules.h"
#include "nsHTMLEditUtils.h"
#include "nsHTMLEditor.h"
#include "nsHTMLObjectResizer.h"
#include "nsIContent.h"
--- a/editor/libeditor/nsHTMLDataTransfer.cpp
+++ b/editor/libeditor/nsHTMLDataTransfer.cpp
@@ -1,17 +1,20 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 sw=2 et tw=78: */
/* 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/. */
#include <string.h>
+#include "EditorUtils.h"
+#include "mozilla/dom/DataTransfer.h"
#include "mozilla/dom/DocumentFragment.h"
+#include "mozilla/dom/DOMStringList.h"
#include "mozilla/OwningNonNull.h"
#include "mozilla/ArrayUtils.h"
#include "mozilla/Base64.h"
#include "mozilla/BasicEvents.h"
#include "mozilla/Preferences.h"
#include "mozilla/dom/Selection.h"
#include "nsAString.h"
#include "nsCOMPtr.h"
@@ -19,27 +22,24 @@
#include "nsCRTGlue.h"
#include "nsComponentManagerUtils.h"
#include "nsIScriptError.h"
#include "nsContentUtils.h"
#include "nsDebug.h"
#include "nsDependentSubstring.h"
#include "nsEditRules.h"
#include "nsEditor.h"
-#include "nsEditorUtils.h"
#include "nsError.h"
#include "nsGkAtoms.h"
#include "nsHTMLEditUtils.h"
#include "nsHTMLEditor.h"
#include "nsIClipboard.h"
#include "nsIContent.h"
#include "nsIContentFilter.h"
#include "nsIDOMComment.h"
-#include "mozilla/dom/DOMStringList.h"
-#include "mozilla/dom/DataTransfer.h"
#include "nsIDOMDocument.h"
#include "nsIDOMDocumentFragment.h"
#include "nsIDOMElement.h"
#include "nsIDOMHTMLAnchorElement.h"
#include "nsIDOMHTMLEmbedElement.h"
#include "nsIDOMHTMLFrameElement.h"
#include "nsIDOMHTMLIFrameElement.h"
#include "nsIDOMHTMLImageElement.h"
@@ -471,18 +471,19 @@ nsHTMLEditor::DoInsertHTMLWithContext(co
NS_ENSURE_TRUE(curNode, NS_ERROR_FAILURE);
NS_ENSURE_TRUE(curNode != fragmentAsNode, NS_ERROR_FAILURE);
NS_ENSURE_TRUE(!nsTextEditUtils::IsBody(curNode), NS_ERROR_FAILURE);
if (insertedContextParent)
{
// if we had to insert something higher up in the paste hierarchy, we want to
// skip any further paste nodes that descend from that. Else we will paste twice.
- if (nsEditorUtils::IsDescendantOf(curNode, insertedContextParent))
+ if (EditorUtils::IsDescendantOf(curNode, insertedContextParent)) {
continue;
+ }
}
// give the user a hand on table element insertion. if they have
// a table or table row on the clipboard, and are trying to insert
// into a table or table row, insert the appropriate children instead.
if ( (nsHTMLEditUtils::IsTableRow(curNode) && nsHTMLEditUtils::IsTableRow(parentNode))
&& (nsHTMLEditUtils::IsTable(curNode) || nsHTMLEditUtils::IsTable(parentNode)) )
{
@@ -2375,17 +2376,17 @@ nsHTMLEditor::ReplaceOrphanedStructure(S
// If we found substructure, paste it instead of its descendants.
// Only replace with the substructure if all the nodes in the list are
// descendants.
bool shouldReplaceNodes = true;
for (uint32_t i = 0; i < aNodeArray.Length(); i++) {
uint32_t idx = aStartOrEnd == StartOrEnd::start ?
i : (aNodeArray.Length() - i - 1);
OwningNonNull<nsINode> endpoint = aNodeArray[idx];
- if (!nsEditorUtils::IsDescendantOf(endpoint, replaceNode)) {
+ if (!EditorUtils::IsDescendantOf(endpoint, replaceNode)) {
shouldReplaceNodes = false;
break;
}
}
if (shouldReplaceNodes) {
// Now replace the removed nodes with the structural parent
aNodeArray.Clear();
--- a/editor/libeditor/nsHTMLEditRules.cpp
+++ b/editor/libeditor/nsHTMLEditRules.cpp
@@ -3,33 +3,33 @@
/* 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/. */
#include "nsHTMLEditRules.h"
#include <stdlib.h>
+#include "EditorUtils.h"
#include "mozilla/Assertions.h"
#include "mozilla/MathAlgorithms.h"
#include "mozilla/Preferences.h"
#include "mozilla/dom/Selection.h"
#include "mozilla/dom/Element.h"
#include "mozilla/OwningNonNull.h"
#include "mozilla/mozalloc.h"
#include "nsAutoPtr.h"
#include "nsAString.h"
#include "nsAlgorithm.h"
#include "nsCRT.h"
#include "nsCRTGlue.h"
#include "nsComponentManagerUtils.h"
#include "nsContentUtils.h"
#include "nsDebug.h"
#include "nsEditor.h"
-#include "nsEditorUtils.h"
#include "nsError.h"
#include "nsGkAtoms.h"
#include "nsHTMLCSSUtils.h"
#include "nsHTMLEditUtils.h"
#include "nsHTMLEditor.h"
#include "nsIAtom.h"
#include "nsIContent.h"
#include "nsIContentIterator.h"
@@ -1543,17 +1543,17 @@ nsHTMLEditRules::WillInsertBreak(Selecti
// Identify the block
nsCOMPtr<Element> blockParent = mHTMLEditor->GetBlock(node);
NS_ENSURE_TRUE(blockParent, NS_ERROR_FAILURE);
// If the active editing host is an inline element, or if the active editing
// host is the block parent itself, just append a br.
nsCOMPtr<Element> host = mHTMLEditor->GetActiveEditingHost();
- if (!nsEditorUtils::IsDescendantOf(blockParent, host)) {
+ if (!EditorUtils::IsDescendantOf(blockParent, host)) {
res = StandardBreakImpl(node, offset, aSelection);
NS_ENSURE_SUCCESS(res, res);
*aHandled = true;
return NS_OK;
}
// If block is empty, populate with br. (For example, imagine a div that
// contains the word "text". The user selects "text" and types return.
@@ -2603,18 +2603,18 @@ nsHTMLEditRules::JoinBlocks(nsIContent&
nsIAtom* existingList = nsGkAtoms::_empty;
int32_t offset;
nsCOMPtr<Element> leftList, rightList;
if (nsHTMLEditUtils::IsListItem(leftBlock) &&
nsHTMLEditUtils::IsListItem(rightBlock)) {
leftList = leftBlock->GetParentElement();
rightList = rightBlock->GetParentElement();
if (leftList && rightList && leftList != rightList &&
- !nsEditorUtils::IsDescendantOf(leftList, rightBlock, &offset) &&
- !nsEditorUtils::IsDescendantOf(rightList, leftBlock, &offset)) {
+ !EditorUtils::IsDescendantOf(leftList, rightBlock, &offset) &&
+ !EditorUtils::IsDescendantOf(rightList, leftBlock, &offset)) {
// There are some special complications if the lists are descendants of
// the other lists' items. Note that it is okay for them to be
// descendants of the other lists themselves, which is the usual case for
// sublists in our implementation.
leftBlock = leftList;
rightBlock = rightList;
mergeLists = true;
existingList = leftList->NodeInfo()->NameAtom();
@@ -2624,17 +2624,17 @@ nsHTMLEditRules::JoinBlocks(nsIContent&
nsAutoTxnsConserveSelection dontSpazMySelection(mHTMLEditor);
nsresult res = NS_OK;
int32_t rightOffset = 0;
int32_t leftOffset = -1;
// offset below is where you find yourself in rightBlock when you traverse
// upwards from leftBlock
- if (nsEditorUtils::IsDescendantOf(leftBlock, rightBlock, &rightOffset)) {
+ if (EditorUtils::IsDescendantOf(leftBlock, rightBlock, &rightOffset)) {
// Tricky case. Left block is inside right block. Do ws adjustment. This
// just destroys non-visible ws at boundaries we will be joining.
rightOffset++;
res = nsWSRunObject::ScrubBlockBoundary(mHTMLEditor,
nsWSRunObject::kBlockEnd,
leftBlock);
NS_ENSURE_SUCCESS(res, res);
@@ -2669,18 +2669,17 @@ nsHTMLEditRules::JoinBlocks(nsIContent&
} else {
res = MoveBlock(*leftBlock, *rightBlock, leftOffset, rightOffset);
}
if (brNode) {
mHTMLEditor->DeleteNode(brNode);
}
// Offset below is where you find yourself in leftBlock when you traverse
// upwards from rightBlock
- } else if (nsEditorUtils::IsDescendantOf(rightBlock, leftBlock,
- &leftOffset)) {
+ } else if (EditorUtils::IsDescendantOf(rightBlock, leftBlock, &leftOffset)) {
// Tricky case. Right block is inside left block. Do ws adjustment. This
// just destroys non-visible ws at boundaries we will be joining.
res = nsWSRunObject::ScrubBlockBoundary(mHTMLEditor,
nsWSRunObject::kBlockStart,
rightBlock);
NS_ENSURE_SUCCESS(res, res);
{
// We can't just track leftBlock because it's an Element, so track
@@ -3097,17 +3096,17 @@ nsHTMLEditRules::WillMakeList(Selection*
NS_ENSURE_STATE(mHTMLEditor);
res = mHTMLEditor->DeleteNode(curNode);
NS_ENSURE_SUCCESS(res, res);
continue;
}
if (nsHTMLEditUtils::IsList(curNode)) {
// do we have a curList already?
- if (curList && !nsEditorUtils::IsDescendantOf(curNode, curList)) {
+ if (curList && !EditorUtils::IsDescendantOf(curNode, curList)) {
// move all of our children into curList. cheezy way to do it: move
// whole list and then RemoveContainer() on the list. ConvertListType
// first: that routine handles converting the list item types, if
// needed
NS_ENSURE_STATE(mHTMLEditor);
res = mHTMLEditor->MoveNode(curNode, curList, -1);
NS_ENSURE_SUCCESS(res, res);
res = ConvertListType(curNode->AsElement(), getter_AddRefs(newBlock),
@@ -3127,17 +3126,17 @@ nsHTMLEditRules::WillMakeList(Selection*
continue;
}
if (nsHTMLEditUtils::IsListItem(curNode)) {
NS_ENSURE_STATE(mHTMLEditor);
if (!curParent->IsHTMLElement(listType)) {
// list item is in wrong type of list. if we don't have a curList,
// split the old list and make a new list of correct type.
- if (!curList || nsEditorUtils::IsDescendantOf(curNode, curList)) {
+ if (!curList || EditorUtils::IsDescendantOf(curNode, curList)) {
NS_ENSURE_STATE(mHTMLEditor);
NS_ENSURE_STATE(curParent->IsContent());
ErrorResult rv;
nsCOMPtr<nsIContent> splitNode =
mHTMLEditor->SplitNode(*curParent->AsContent(), offset, rv);
NS_ENSURE_TRUE(!rv.Failed(), rv.StealNSResult());
newBlock = splitNode ? splitNode->AsElement() : nullptr;
int32_t offset;
@@ -4030,17 +4029,17 @@ nsHTMLEditRules::WillOutdent(Selection&
bool unused;
res = PopListItem(GetAsDOMNode(curNode), &unused);
NS_ENSURE_SUCCESS(res, res);
continue;
}
// Do we have a blockquote that we are already committed to removing?
if (curBlockQuote) {
// If so, is this node a descendant?
- if (nsEditorUtils::IsDescendantOf(curNode, curBlockQuote)) {
+ if (EditorUtils::IsDescendantOf(curNode, curBlockQuote)) {
lastBQChild = curNode;
// Then we don't need to do anything different for this node
continue;
} else {
// Otherwise, we have progressed beyond end of curBlockQuote, so
// let's handle it now. We need to remove the portion of
// curBlockQuote that contains [firstBQChild - lastBQChild].
res = OutdentPartOfBlock(*curBlockQuote, *firstBQChild,
@@ -4160,28 +4159,28 @@ nsHTMLEditRules::WillOutdent(Selection&
if (rememberedLeftBQ || rememberedRightBQ) {
if (aSelection.Collapsed()) {
// Push selection past end of rememberedLeftBQ
NS_ENSURE_TRUE(aSelection.GetRangeAt(0), NS_OK);
nsCOMPtr<nsINode> startNode = aSelection.GetRangeAt(0)->GetStartParent();
int32_t startOffset = aSelection.GetRangeAt(0)->StartOffset();
if (rememberedLeftBQ &&
(startNode == rememberedLeftBQ ||
- nsEditorUtils::IsDescendantOf(startNode, rememberedLeftBQ))) {
+ EditorUtils::IsDescendantOf(startNode, rememberedLeftBQ))) {
// Selection is inside rememberedLeftBQ - push it past it.
startNode = rememberedLeftBQ->GetParentNode();
startOffset = startNode ? 1 + startNode->IndexOf(rememberedLeftBQ) : 0;
aSelection.Collapse(startNode, startOffset);
}
// And pull selection before beginning of rememberedRightBQ
startNode = aSelection.GetRangeAt(0)->GetStartParent();
startOffset = aSelection.GetRangeAt(0)->StartOffset();
if (rememberedRightBQ &&
(startNode == rememberedRightBQ ||
- nsEditorUtils::IsDescendantOf(startNode, rememberedRightBQ))) {
+ EditorUtils::IsDescendantOf(startNode, rememberedRightBQ))) {
// Selection is inside rememberedRightBQ - push it before it.
startNode = rememberedRightBQ->GetParentNode();
startOffset = startNode ? startNode->IndexOf(rememberedRightBQ) : -1;
aSelection.Collapse(startNode, startOffset);
}
}
return NS_OK;
}
@@ -4211,18 +4210,18 @@ void
nsHTMLEditRules::SplitBlock(Element& aBlock,
nsIContent& aStartChild,
nsIContent& aEndChild,
nsIContent** aOutLeftNode,
nsIContent** aOutRightNode,
nsIContent** aOutMiddleNode)
{
// aStartChild and aEndChild must be exclusive descendants of aBlock
- MOZ_ASSERT(nsEditorUtils::IsDescendantOf(&aStartChild, &aBlock) &&
- nsEditorUtils::IsDescendantOf(&aEndChild, &aBlock));
+ MOZ_ASSERT(EditorUtils::IsDescendantOf(&aStartChild, &aBlock) &&
+ EditorUtils::IsDescendantOf(&aEndChild, &aBlock));
NS_ENSURE_TRUE_VOID(mHTMLEditor);
nsCOMPtr<nsIEditor> kungFuDeathGrip(mHTMLEditor);
// Get split point location
OwningNonNull<nsIContent> startParent = *aStartChild.GetParent();
int32_t startOffset = startParent->IndexOf(&aStartChild);
// Do the splits!
@@ -6665,17 +6664,17 @@ nsHTMLEditRules::RemoveBlockStyle(nsTArr
// Recursion time
nsTArray<OwningNonNull<nsINode>> childArray;
GetChildNodesForOperation(*curNode, childArray);
res = RemoveBlockStyle(childArray);
NS_ENSURE_SUCCESS(res, res);
} else if (IsInlineNode(curNode)) {
if (curBlock) {
// If so, is this node a descendant?
- if (nsEditorUtils::IsDescendantOf(curNode, curBlock)) {
+ if (EditorUtils::IsDescendantOf(curNode, curBlock)) {
// Then we don't need to do anything different for this node
lastNode = curNode->AsContent();
continue;
} else {
// Otherwise, we have progressed beyond end of curBlock, so let's
// handle it now. We need to remove the portion of curBlock that
// contains [firstNode - lastNode].
res = RemovePartOfBlock(*curBlock, *firstNode, *lastNode);
@@ -7665,30 +7664,30 @@ nsHTMLEditRules::SelectionEndpointInNode
nsCOMPtr<nsIDOMNode> startParent, endParent;
range->GetStartContainer(getter_AddRefs(startParent));
if (startParent)
{
if (node == startParent) {
*aResult = true;
return NS_OK;
}
- if (nsEditorUtils::IsDescendantOf(startParent, node)) {
+ if (EditorUtils::IsDescendantOf(startParent, node)) {
*aResult = true;
return NS_OK;
}
}
range->GetEndContainer(getter_AddRefs(endParent));
if (startParent == endParent) continue;
if (endParent)
{
if (node == endParent) {
*aResult = true;
return NS_OK;
}
- if (nsEditorUtils::IsDescendantOf(endParent, node)) {
+ if (EditorUtils::IsDescendantOf(endParent, node)) {
*aResult = true;
return NS_OK;
}
}
}
return NS_OK;
}
--- a/editor/libeditor/nsHTMLEditor.cpp
+++ b/editor/libeditor/nsHTMLEditor.cpp
@@ -54,18 +54,18 @@
// netwerk
#include "nsIURI.h"
#include "nsNetUtil.h"
// Transactionas
#include "nsStyleSheetTxns.h"
// Misc
+#include "EditorUtils.h"
#include "TextEditorTest.h"
-#include "nsEditorUtils.h"
#include "nsWSRunObject.h"
#include "nsGkAtoms.h"
#include "nsIWidget.h"
#include "nsIFrame.h"
#include "nsIParserService.h"
#include "mozilla/dom/Selection.h"
#include "mozilla/dom/DocumentFragment.h"
--- a/editor/libeditor/nsHTMLEditorStyle.cpp
+++ b/editor/libeditor/nsHTMLEditorStyle.cpp
@@ -1,26 +1,26 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */
+#include "EditorUtils.h"
#include "TypeInState.h"
#include "mozilla/Assertions.h"
#include "mozilla/dom/Selection.h"
#include "mozilla/dom/Element.h"
#include "mozilla/mozalloc.h"
#include "nsAString.h"
#include "nsAttrName.h"
#include "nsCOMPtr.h"
#include "nsCaseTreatment.h"
#include "nsComponentManagerUtils.h"
#include "nsDebug.h"
#include "nsEditRules.h"
#include "nsEditor.h"
-#include "nsEditorUtils.h"
#include "nsError.h"
#include "nsGkAtoms.h"
#include "nsHTMLCSSUtils.h"
#include "nsHTMLEditUtils.h"
#include "nsHTMLEditor.h"
#include "nsIAtom.h"
#include "nsIContent.h"
#include "nsIContentIterator.h"
--- a/editor/libeditor/nsHTMLObjectResizer.cpp
+++ b/editor/libeditor/nsHTMLObjectResizer.cpp
@@ -1,25 +1,25 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */
#include "nsHTMLObjectResizer.h"
+#include "EditorUtils.h"
#include "mozilla/DebugOnly.h"
#include "mozilla/LookAndFeel.h"
#include "mozilla/MathAlgorithms.h"
#include "mozilla/Preferences.h"
#include "mozilla/mozalloc.h"
#include "nsAString.h"
#include "nsAlgorithm.h"
#include "nsCOMPtr.h"
#include "nsDebug.h"
-#include "nsEditorUtils.h"
#include "nsError.h"
#include "nsGkAtoms.h"
#include "nsHTMLCSSUtils.h"
#include "nsHTMLEditUtils.h"
#include "nsHTMLEditor.h"
#include "nsIAtom.h"
#include "nsIContent.h"
#include "nsID.h"
--- a/editor/libeditor/nsPlaintextDataTransfer.cpp
+++ b/editor/libeditor/nsPlaintextDataTransfer.cpp
@@ -1,24 +1,24 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */
+#include "EditorUtils.h"
#include "mozilla/ArrayUtils.h"
#include "mozilla/MouseEvents.h"
#include "mozilla/dom/Selection.h"
#include "nsAString.h"
#include "nsCOMPtr.h"
#include "nsCRT.h"
#include "nsComponentManagerUtils.h"
#include "nsContentUtils.h"
#include "nsDebug.h"
#include "nsEditor.h"
-#include "nsEditorUtils.h"
#include "nsError.h"
#include "nsIClipboard.h"
#include "nsIContent.h"
#include "nsIDOMDataTransfer.h"
#include "nsIDOMDocument.h"
#include "nsIDOMDragEvent.h"
#include "nsIDOMEvent.h"
#include "nsIDOMNode.h"
--- a/editor/libeditor/nsPlaintextEditor.cpp
+++ b/editor/libeditor/nsPlaintextEditor.cpp
@@ -1,15 +1,16 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */
#include "nsPlaintextEditor.h"
+#include "EditorUtils.h" // nsAutoEditBatch, nsAutoRules
#include "gfxFontUtils.h"
#include "mozilla/Assertions.h"
#include "mozilla/Preferences.h"
#include "mozilla/dom/Selection.h"
#include "mozilla/dom/Event.h"
#include "mozilla/TextComposition.h"
#include "mozilla/TextEvents.h"
#include "mozilla/dom/Element.h"
@@ -19,17 +20,16 @@
#include "nsCaret.h"
#include "nsCharTraits.h"
#include "nsComponentManagerUtils.h"
#include "nsContentCID.h"
#include "nsCopySupport.h"
#include "nsDebug.h"
#include "nsDependentSubstring.h"
#include "nsEditRules.h"
-#include "nsEditorUtils.h" // nsAutoEditBatch, nsAutoRules
#include "nsError.h"
#include "nsGkAtoms.h"
#include "nsIClipboard.h"
#include "nsIContent.h"
#include "nsIContentIterator.h"
#include "nsIDOMCharacterData.h"
#include "nsIDOMDocument.h"
#include "nsIDOMElement.h"
--- a/editor/libeditor/nsSelectionState.cpp
+++ b/editor/libeditor/nsSelectionState.cpp
@@ -1,22 +1,22 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */
#include "nsSelectionState.h"
+#include "EditorUtils.h" // for EditorUtils
#include "mozilla/Assertions.h" // for MOZ_ASSERT, etc
#include "mozilla/dom/Selection.h" // for Selection
#include "nsAString.h" // for nsAString_internal::Length
#include "nsCycleCollectionParticipant.h"
#include "nsDebug.h" // for NS_ENSURE_TRUE, etc
#include "nsEditor.h" // for nsEditor
-#include "nsEditorUtils.h" // for nsEditorUtils
#include "nsError.h" // for NS_OK, etc
#include "nsIContent.h" // for nsIContent
#include "nsIDOMCharacterData.h" // for nsIDOMCharacterData
#include "nsIDOMNode.h" // for nsIDOMNode
#include "nsISupportsImpl.h" // for nsRange::Release
#include "nsRange.h" // for nsRange
using namespace mozilla;
@@ -273,24 +273,25 @@ nsRangeUpdater::SelAdjDeleteNode(nsINode
}
if (item->endNode == aNode) {
item->endNode = parent;
item->endOffset = offset;
}
// check for range endpoints that are in descendants of aNode
nsCOMPtr<nsINode> oldStart;
- if (nsEditorUtils::IsDescendantOf(item->startNode, aNode)) {
+ if (EditorUtils::IsDescendantOf(item->startNode, aNode)) {
oldStart = item->startNode; // save for efficiency hack below.
item->startNode = parent;
item->startOffset = offset;
}
// avoid having to call IsDescendantOf() for common case of range startnode == range endnode.
- if ((item->endNode == oldStart) || nsEditorUtils::IsDescendantOf(item->endNode, aNode))
+ if (item->endNode == oldStart ||
+ EditorUtils::IsDescendantOf(item->endNode, aNode))
{
item->endNode = parent;
item->endOffset = offset;
}
}
}
void
--- a/editor/libeditor/nsTableEditor.cpp
+++ b/editor/libeditor/nsTableEditor.cpp
@@ -1,24 +1,24 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */
#include <stdio.h>
+#include "EditorUtils.h"
#include "mozilla/Assertions.h"
#include "mozilla/dom/Selection.h"
#include "mozilla/dom/Element.h"
#include "nsAString.h"
#include "nsAlgorithm.h"
#include "nsCOMPtr.h"
#include "nsDebug.h"
#include "nsEditor.h"
-#include "nsEditorUtils.h"
#include "nsError.h"
#include "nsGkAtoms.h"
#include "nsHTMLEditUtils.h"
#include "nsHTMLEditor.h"
#include "nsIAtom.h"
#include "nsIContent.h"
#include "nsIDOMElement.h"
#include "nsIDOMNode.h"
--- a/editor/libeditor/nsTextEditRules.cpp
+++ b/editor/libeditor/nsTextEditRules.cpp
@@ -1,30 +1,30 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */
#include "nsTextEditRules.h"
+#include "EditorUtils.h"
#include "mozilla/Assertions.h"
#include "mozilla/LookAndFeel.h"
#include "mozilla/Preferences.h"
#include "mozilla/dom/Selection.h"
#include "mozilla/TextComposition.h"
#include "mozilla/dom/Element.h"
#include "nsAString.h"
#include "nsCOMPtr.h"
#include "nsCRT.h"
#include "nsCRTGlue.h"
#include "nsComponentManagerUtils.h"
#include "nsContentUtils.h"
#include "nsDebug.h"
#include "nsEditor.h"
-#include "nsEditorUtils.h"
#include "nsError.h"
#include "nsGkAtoms.h"
#include "nsIContent.h"
#include "nsIDOMCharacterData.h"
#include "nsIDOMDocument.h"
#include "nsIDOMElement.h"
#include "nsIDOMNode.h"
#include "nsIDOMNodeFilter.h"
--- a/editor/libeditor/nsWSRunObject.cpp
+++ b/editor/libeditor/nsWSRunObject.cpp
@@ -1,25 +1,26 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */
#include "nsWSRunObject.h"
+#include "EditorUtils.h"
+
#include "mozilla/OwningNonNull.h"
#include "mozilla/Assertions.h"
#include "mozilla/Casting.h"
#include "mozilla/mozalloc.h"
#include "nsAString.h"
#include "nsCRT.h"
#include "nsContentUtils.h"
#include "nsDebug.h"
-#include "nsEditorUtils.h"
#include "nsError.h"
#include "nsHTMLEditor.h"
#include "nsIContent.h"
#include "nsIDOMDocument.h"
#include "nsIDOMNode.h"
#include "nsISupportsImpl.h"
#include "nsRange.h"
#include "nsSelectionState.h"
--- a/extensions/spellcheck/src/mozInlineSpellChecker.cpp
+++ b/extensions/spellcheck/src/mozInlineSpellChecker.cpp
@@ -27,51 +27,51 @@
* true when we get any change, and false once there is no possibility
* something changed that we need to check on navigation. Navigation events
* tend to be a little tricky because we want to check the current word on
* exit if something has changed. If we navigate inside the word, we don't want
* to do anything. As a result, this flag is cleared in FinishNavigationEvent
* when we know that we are checking as a result of navigation.
*/
+#include "EditorUtils.h"
+#include "mozilla/Services.h"
+#include "mozilla/dom/Selection.h"
#include "mozInlineSpellChecker.h"
#include "mozInlineSpellWordUtil.h"
#include "mozISpellI18NManager.h"
#include "nsCOMPtr.h"
#include "nsCRT.h"
#include "nsIDOMNode.h"
#include "nsIDOMDocument.h"
#include "nsIDOMElement.h"
#include "nsIDOMHTMLElement.h"
#include "nsIDOMMouseEvent.h"
#include "nsIDOMKeyEvent.h"
#include "nsIDOMNode.h"
#include "nsIDOMNodeList.h"
#include "nsIDOMEvent.h"
#include "nsGenericHTMLElement.h"
#include "nsRange.h"
-#include "mozilla/dom/Selection.h"
#include "nsIPlaintextEditor.h"
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
#include "nsIRunnable.h"
#include "nsISelection.h"
#include "nsISelectionPrivate.h"
#include "nsISelectionController.h"
#include "nsIServiceManager.h"
#include "nsITextServicesFilter.h"
#include "nsString.h"
#include "nsThreadUtils.h"
#include "nsUnicharUtils.h"
#include "nsIContent.h"
#include "nsRange.h"
#include "nsContentUtils.h"
#include "nsEditor.h"
-#include "nsEditorUtils.h"
-#include "mozilla/Services.h"
#include "nsIObserverService.h"
#include "nsITextControlElement.h"
#include "prtime.h"
using namespace mozilla;
using namespace mozilla::dom;
// Set to spew messages to the console about what is happening.