diff --git a/editor/libeditor/HTMLEditUtils.h b/editor/libeditor/HTMLEditUtils.h
index 574abb8e334e..059b2a752a62 100644
--- a/editor/libeditor/HTMLEditUtils.h
+++ b/editor/libeditor/HTMLEditUtils.h
@@ -31,8 +31,10 @@ namespace mozilla {
enum class EditAction;
class HTMLEditUtils final {
+ using AbstractRange = dom::AbstractRange;
using Element = dom::Element;
using Selection = dom::Selection;
+ using Text = dom::Text;
public:
static constexpr char16_t kNewLine = '\n';
@@ -153,7 +155,7 @@ class HTMLEditUtils final {
* element and can be removed or split to in order to modifying inline
* styles.
*/
- static bool IsRemovableInlineStyleElement(dom::Element& aElement);
+ static bool IsRemovableInlineStyleElement(Element& aElement);
static bool IsFormatNode(const nsINode* aNode);
static bool IsNodeThatCanOutdent(nsINode* aNode);
static bool IsHeader(nsINode& aNode);
@@ -296,7 +298,7 @@ class HTMLEditUtils final {
* But if you call this a lot, please specify proper editing host (or parent
* block) for the performance.
*/
- static bool IsVisibleTextNode(const dom::Text& aText,
+ static bool IsVisibleTextNode(const Text& aText,
const Element* aEditingHost = nullptr);
/**
@@ -304,7 +306,7 @@ class HTMLEditUtils final {
* text frames. Callers have to guarantee that there is no pending reflow.
*/
static bool IsInVisibleTextFrames(nsPresContext* aPresContext,
- const dom::Text& aText);
+ const Text& aText);
/**
* IsVisibleBRElement() and IsInvisibleBRElement() return true if aContent is
@@ -1288,8 +1290,7 @@ class HTMLEditUtils final {
* GetElementIfOnlyOneSelected() returns an element if aRange selects only
* the element node (and its descendants).
*/
- static Element* GetElementIfOnlyOneSelected(
- const dom::AbstractRange& aRange) {
+ static Element* GetElementIfOnlyOneSelected(const AbstractRange& aRange) {
if (!aRange.IsPositioned() || aRange.Collapsed()) {
return nullptr;
}
@@ -1317,7 +1318,7 @@ class HTMLEditUtils final {
}
static Element* GetTableCellElementIfOnlyOneSelected(
- const dom::AbstractRange& aRange) {
+ const AbstractRange& aRange) {
Element* element = HTMLEditUtils::GetElementIfOnlyOneSelected(aRange);
return element && HTMLEditUtils::IsTableCell(element) ? element : nullptr;
}
@@ -1405,7 +1406,7 @@ class HTMLEditUtils final {
*aPoint.ContainerAsText(), aPoint.Offset());
}
static Maybe GetPreviousCharOffsetExceptASCIIWhiteSpaces(
- const dom::Text& aTextNode, uint32_t aOffset) {
+ const Text& aTextNode, uint32_t aOffset) {
const nsTextFragment& textFragment = aTextNode.TextFragment();
MOZ_ASSERT(aOffset <= textFragment.GetLength());
for (uint32_t i = aOffset; i; i--) {
@@ -1427,7 +1428,7 @@ class HTMLEditUtils final {
aPoint.Offset());
}
static Maybe GetNextCharOffsetExceptASCIIWhiteSpaces(
- const dom::Text& aTextNode, uint32_t aOffset) {
+ const Text& aTextNode, uint32_t aOffset) {
const nsTextFragment& textFragment = aTextNode.TextFragment();
MOZ_ASSERT(aOffset <= textFragment.GetLength());
for (uint32_t i = aOffset + 1; i < textFragment.GetLength(); i++) {
@@ -1449,7 +1450,7 @@ class HTMLEditUtils final {
aPoint.Offset());
}
static Maybe GetPreviousCharOffsetExceptWhiteSpaces(
- const dom::Text& aTextNode, uint32_t aOffset) {
+ const Text& aTextNode, uint32_t aOffset) {
if (!aOffset) {
return Nothing();
}
@@ -1476,7 +1477,7 @@ class HTMLEditUtils final {
*aPoint.ContainerAsText(), aPoint.Offset());
}
static Maybe GetInclusiveNextCharOffsetExceptWhiteSpaces(
- const dom::Text& aTextNode, uint32_t aOffset) {
+ const Text& aTextNode, uint32_t aOffset) {
const nsTextFragment& textFragment = aTextNode.TextFragment();
MOZ_ASSERT(aOffset <= textFragment.GetLength());
for (uint32_t i = aOffset; i < textFragment.GetLength(); i++) {
@@ -1503,7 +1504,7 @@ class HTMLEditUtils final {
aPoint.Offset());
}
static uint32_t GetFirstASCIIWhiteSpaceOffsetCollapsedWith(
- const dom::Text& aTextNode, uint32_t aOffset) {
+ const Text& aTextNode, uint32_t aOffset) {
MOZ_ASSERT(aOffset < aTextNode.TextLength());
MOZ_ASSERT(nsCRT::IsAsciiSpace(aTextNode.TextFragment().CharAt(aOffset)));
if (!aOffset) {
@@ -1664,7 +1665,7 @@ class HTMLEditUtils final {
}
if (aOptions.contains(WalkTreeOption::IgnoreWhiteSpaceOnlyText) &&
aContent.IsText() &&
- const_cast(aContent.AsText())->TextIsOnlyWhitespace()) {
+ const_cast(aContent.AsText())->TextIsOnlyWhitespace()) {
return true;
}
return false;
@@ -1705,9 +1706,11 @@ class HTMLEditUtils final {
* Then, you can check whether `` and/or `` elements are in it.
*/
class MOZ_STACK_CLASS DefinitionListItemScanner final {
+ using Element = dom::Element;
+
public:
DefinitionListItemScanner() = delete;
- explicit DefinitionListItemScanner(dom::Element& aDLElement) {
+ explicit DefinitionListItemScanner(Element& aDLElement) {
MOZ_ASSERT(aDLElement.IsHTMLElement(nsGkAtoms::dl));
for (nsIContent* child = aDLElement.GetFirstChild(); child;
child = child->GetNextSibling()) {
@@ -1742,10 +1745,13 @@ class MOZ_STACK_CLASS DefinitionListItemScanner final {
* only one table cell element, the ranges are just ignored.
*/
class MOZ_STACK_CLASS SelectedTableCellScanner final {
+ using Element = dom::Element;
+ using Selection = dom::Selection;
+
public:
SelectedTableCellScanner() = delete;
- explicit SelectedTableCellScanner(const dom::Selection& aSelection) {
- dom::Element* firstSelectedCellElement =
+ explicit SelectedTableCellScanner(const Selection& aSelection) {
+ Element* firstSelectedCellElement =
HTMLEditUtils::GetFirstSelectedTableCellElement(aSelection);
if (!firstSelectedCellElement) {
return; // We're not in table cell selection mode.
@@ -1760,7 +1766,7 @@ class MOZ_STACK_CLASS SelectedTableCellScanner final {
// Just ignore selection ranges which do not select only one table
// cell element. This is possible case if web apps sets multiple
// selections and first range selects a table cell element.
- if (dom::Element* selectedCellElement =
+ if (Element* selectedCellElement =
HTMLEditUtils::GetTableCellElementIfOnlyOneSelected(*range)) {
mSelectedCellElements.AppendElement(*selectedCellElement);
}
@@ -1771,7 +1777,7 @@ class MOZ_STACK_CLASS SelectedTableCellScanner final {
if (aRanges.Ranges().IsEmpty()) {
return;
}
- dom::Element* firstSelectedCellElement =
+ Element* firstSelectedCellElement =
HTMLEditUtils::GetTableCellElementIfOnlyOneSelected(
aRanges.FirstRangeRef());
if (!firstSelectedCellElement) {
@@ -1787,7 +1793,7 @@ class MOZ_STACK_CLASS SelectedTableCellScanner final {
// Just ignore selection ranges which do not select only one table
// cell element. This is possible case if web apps sets multiple
// selections and first range selects a table cell element.
- if (dom::Element* selectedCellElement =
+ if (Element* selectedCellElement =
HTMLEditUtils::GetTableCellElementIfOnlyOneSelected(*range)) {
mSelectedCellElements.AppendElement(*selectedCellElement);
}
@@ -1798,7 +1804,7 @@ class MOZ_STACK_CLASS SelectedTableCellScanner final {
return !mSelectedCellElements.IsEmpty();
}
- const nsTArray>& ElementsRef() const {
+ const nsTArray>& ElementsRef() const {
return mSelectedCellElements;
}
@@ -1806,13 +1812,13 @@ class MOZ_STACK_CLASS SelectedTableCellScanner final {
* GetFirstElement() and GetNextElement() are stateful iterator methods.
* This is useful to port legacy code which used old `nsITableEditor` API.
*/
- dom::Element* GetFirstElement() const {
+ Element* GetFirstElement() const {
MOZ_ASSERT(!mSelectedCellElements.IsEmpty());
mIndex = 0;
return !mSelectedCellElements.IsEmpty() ? mSelectedCellElements[0].get()
: nullptr;
}
- dom::Element* GetNextElement() const {
+ Element* GetNextElement() const {
MOZ_ASSERT(mIndex < mSelectedCellElements.Length());
return ++mIndex < mSelectedCellElements.Length()
? mSelectedCellElements[mIndex].get()
@@ -1820,7 +1826,7 @@ class MOZ_STACK_CLASS SelectedTableCellScanner final {
}
private:
- AutoTArray, 16> mSelectedCellElements;
+ AutoTArray, 16> mSelectedCellElements;
mutable size_t mIndex = 0;
};