Bug 1649121: part 4) Rename `HTMLEditUtils::IsTableElement` to `HTMLEditUtils::IsAnyTableElement`. r=masayuki

The old name was misleading.

Differential Revision: https://phabricator.services.mozilla.com/D81542
This commit is contained in:
Mirko Brodesser 2020-06-30 13:12:39 +00:00
Родитель 2937ae1381
Коммит 592ca1c3b6
5 изменённых файлов: 24 добавлений и 24 удалений

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

@ -1286,7 +1286,7 @@ nsresult ParagraphStateAtSelection::CollectEditableFormatNodesInSelection(
// Scan for table elements. If we find table elements other than table,
// replace it with a list of any editable non-table content. Ditto for
// list elements.
if (HTMLEditUtils::IsTableElement(content) ||
if (HTMLEditUtils::IsAnyTableElement(content) ||
HTMLEditUtils::IsList(content) || HTMLEditUtils::IsListItem(content)) {
aArrayOfContents.RemoveElementAt(i);
aHTMLEditor.CollectChildren(content, aArrayOfContents, i,
@ -2971,7 +2971,7 @@ EditActionResult HTMLEditor::HandleDeleteCollapsedSelectionAtOtherBlockBoundary(
// Make sure it's not a table element. If so, cancel the operation
// (translation: users cannot backspace or delete across table cells)
if (HTMLEditUtils::IsTableElement(&aOtherBlockElement)) {
if (HTMLEditUtils::IsAnyTableElement(&aOtherBlockElement)) {
return EditActionCanceled();
}
@ -3105,7 +3105,7 @@ HTMLEditor::HandleDeleteCollapsedSelectionAtCurrentBlockBoundary(
// Make sure it's not a table element. If so, cancel the operation
// (translation: users cannot backspace or delete across table cells)
if (HTMLEditUtils::IsTableElement(&aCurrentBlockElement)) {
if (HTMLEditUtils::IsAnyTableElement(&aCurrentBlockElement)) {
return EditActionCanceled();
}
@ -4227,8 +4227,8 @@ EditActionResult HTMLEditor::TryToJoinBlocksWithTransaction(
return EditActionIgnored(NS_ERROR_UNEXPECTED);
}
if (HTMLEditUtils::IsTableElement(leftBlockElement) ||
HTMLEditUtils::IsTableElement(rightBlockElement)) {
if (HTMLEditUtils::IsAnyTableElement(leftBlockElement) ||
HTMLEditUtils::IsAnyTableElement(rightBlockElement)) {
// Do not try to merge table elements
return EditActionCanceled();
}
@ -6882,7 +6882,7 @@ SplitRangeOffFromNodeResult HTMLEditor::HandleOutdentAtSelectionInternal() {
parentContent && !parentContent->IsHTMLElement(nsGkAtoms::body) &&
parentContent != editingHost &&
(parentContent->IsHTMLElement(nsGkAtoms::table) ||
!HTMLEditUtils::IsTableElement(parentContent));
!HTMLEditUtils::IsAnyTableElement(parentContent));
parentContent = parentContent->GetParent()) {
// If we reach a `<blockquote>` ancestor, it should be split at next
// time at least for outdenting current node.
@ -7510,7 +7510,7 @@ nsresult HTMLEditor::AlignContentsAtSelection(const nsAString& aAlignType) {
return NS_ERROR_FAILURE;
}
nsINode* parent = atStartOfSelection.Container();
createEmptyDivElement = !HTMLEditUtils::IsTableElement(parent) ||
createEmptyDivElement = !HTMLEditUtils::IsAnyTableElement(parent) ||
HTMLEditUtils::IsTableCellOrCaption(*parent);
}
}
@ -7676,7 +7676,7 @@ nsresult HTMLEditor::AlignNodesAndDescendants(
// Skip insignificant formatting text nodes to prevent unnecessary
// structure splitting!
if (content->IsText() &&
((HTMLEditUtils::IsTableElement(atContent.GetContainer()) &&
((HTMLEditUtils::IsAnyTableElement(atContent.GetContainer()) &&
!HTMLEditUtils::IsTableCellOrCaption(*atContent.GetContainer())) ||
HTMLEditUtils::IsList(atContent.GetContainer()) ||
IsEmptyNode(*content))) {
@ -7908,7 +7908,7 @@ EditActionResult HTMLEditor::MaybeDeleteTopMostEmptyAncestor(
HTMLEditUtils::GetInclusiveAncestorBlockElement(aStartContent);
RefPtr<Element> topMostEmptyBlockElement;
while (blockElement && blockElement != &aEditingHostElement &&
!HTMLEditUtils::IsTableElement(blockElement) &&
!HTMLEditUtils::IsAnyTableElement(blockElement) &&
IsEmptyNode(*blockElement, true, false)) {
topMostEmptyBlockElement = blockElement;
blockElement =
@ -8083,7 +8083,7 @@ size_t HTMLEditor::CollectChildren(
(HTMLEditUtils::IsList(content) ||
HTMLEditUtils::IsListItem(content))) ||
(aCollectTableChildren == CollectTableChildren::Yes &&
HTMLEditUtils::IsTableElement(content))) {
HTMLEditUtils::IsAnyTableElement(content))) {
numberOfFoundChildren += CollectChildren(
*content, aOutArrayOfContents,
aIndexToInsertChildren + numberOfFoundChildren, aCollectListChildren,
@ -8139,7 +8139,7 @@ HTMLEditor::GetRangeExtendedToIncludeInvisibleNodes(
WSRunScanner(this, atStart).GetStartReasonContent());
// We want to keep looking up. But stop if we are crossing table
// element boundaries, or if we hit the root.
if (HTMLEditUtils::IsTableElement(
if (HTMLEditUtils::IsAnyTableElement(
backwardScanFromStartResult.GetContent()) ||
backwardScanFromStartResult.GetContent() == commonAncestorBlock ||
backwardScanFromStartResult.GetContent() == editingHost) {
@ -8185,7 +8185,7 @@ HTMLEditor::GetRangeExtendedToIncludeInvisibleNodes(
wsScannerAtEnd.GetEndReasonContent());
// We want to keep looking up. But stop if we are crossing table
// element boundaries, or if we hit the root.
if (HTMLEditUtils::IsTableElement(
if (HTMLEditUtils::IsAnyTableElement(
forwardScanFromEndResult.GetContent()) ||
forwardScanFromEndResult.GetContent() == commonAncestorBlock ||
forwardScanFromEndResult.GetContent() == editingHost) {
@ -9284,7 +9284,7 @@ Element* HTMLEditor::GetNearestAncestorListItemElement(
// whether we reach it or not.
for (Element* parentElement = aContent.GetParentElement();
parentElement && IsDescendantOfEditorRoot(parentElement) &&
!HTMLEditUtils::IsTableElement(parentElement);
!HTMLEditUtils::IsAnyTableElement(parentElement);
parentElement = parentElement->GetParentElement()) {
if (HTMLEditUtils::IsListItem(parentElement)) {
return parentElement;
@ -11141,12 +11141,12 @@ bool HTMLEditor::NodesInDifferentTableElements(nsINode& aNode1,
nsINode& aNode2) {
nsINode* parentNode1;
for (parentNode1 = &aNode1;
parentNode1 && !HTMLEditUtils::IsTableElement(parentNode1);
parentNode1 && !HTMLEditUtils::IsAnyTableElement(parentNode1);
parentNode1 = parentNode1->GetParentNode()) {
}
nsINode* parentNode2;
for (parentNode2 = &aNode2;
parentNode2 && !HTMLEditUtils::IsTableElement(parentNode2);
parentNode2 && !HTMLEditUtils::IsAnyTableElement(parentNode2);
parentNode2 = parentNode2->GetParentNode()) {
}
// XXX Despite of the name, this returns true if only one node is in a

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

@ -146,9 +146,9 @@ bool HTMLEditUtils::IsListItem(nsINode* aNode) {
}
/**
* IsTableElement() returns true if aNode is an html table, td, tr, ...
* IsAnyTableElement() returns true if aNode is an html table, td, tr, ...
*/
bool HTMLEditUtils::IsTableElement(nsINode* aNode) {
bool HTMLEditUtils::IsAnyTableElement(nsINode* aNode) {
MOZ_ASSERT(aNode);
return aNode->IsAnyOfHTMLElements(
nsGkAtoms::table, nsGkAtoms::tr, nsGkAtoms::td, nsGkAtoms::th,

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

@ -93,7 +93,7 @@ class HTMLEditUtils final {
static bool IsListItem(nsINode* aNode);
static bool IsTable(nsINode* aNode);
static bool IsTableRow(nsINode* aNode);
static bool IsTableElement(nsINode* aNode);
static bool IsAnyTableElement(nsINode* aNode);
static bool IsTableElementButNotTable(nsINode* aNode);
static bool IsTableCell(nsINode* node);
static bool IsTableCellOrCaption(nsINode& aNode);

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

@ -729,7 +729,7 @@ nsresult HTMLEditor::HandleKeyPressEvent(WidgetKeyboardEvent* aKeyboardEvent) {
}
// If selection is in a table element, we need special handling.
if (HTMLEditUtils::IsTableElement(blockParent)) {
if (HTMLEditUtils::IsAnyTableElement(blockParent)) {
EditActionResult result = HandleTabKeyPressInTable(aKeyboardEvent);
if (result.Failed()) {
NS_WARNING("HTMLEditor::HandleTabKeyPressInTable() failed");
@ -1786,7 +1786,7 @@ EditorDOMPoint HTMLEditor::InsertNodeIntoProperAncestorWithTransaction(
// If the current parent is a root (body or table element)
// then go no further - we can't insert.
if (pointToInsert.IsContainerHTMLElement(nsGkAtoms::body) ||
HTMLEditUtils::IsTableElement(pointToInsert.GetContainer())) {
HTMLEditUtils::IsAnyTableElement(pointToInsert.GetContainer())) {
return EditorDOMPoint();
}
@ -3985,7 +3985,7 @@ bool HTMLEditor::SetCaretInTableCell(Element* aElement) {
MOZ_ASSERT(IsEditActionDataAvailable());
if (!aElement || !aElement->IsHTMLElement() ||
!HTMLEditUtils::IsTableElement(aElement) ||
!HTMLEditUtils::IsAnyTableElement(aElement) ||
!IsDescendantOfEditorRoot(aElement)) {
return false;
}

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

@ -304,7 +304,7 @@ nsresult HTMLEditor::DoInsertHTMLWithContext(
// but if not we want to delete _contents_ of cells and replace
// with non-table elements. Use cellSelectionMode bool to
// indicate results.
if (!HTMLEditUtils::IsTableElement(arrayOfTopMostChildContents[0])) {
if (!HTMLEditUtils::IsAnyTableElement(arrayOfTopMostChildContents[0])) {
cellSelectionMode = false;
}
}
@ -3127,7 +3127,7 @@ HTMLEditor::AutoHTMLFragmentBoundariesFixer::GetMostAncestorListOrTableElement(
const {
Element* lastFoundAncestorListOrTableElement = nullptr;
for (auto& content : aArrayOfTopMostChildContents) {
if (HTMLEditUtils::IsTableElement(content) &&
if (HTMLEditUtils::IsAnyTableElement(content) &&
!content->IsHTMLElement(nsGkAtoms::table)) {
Element* tableElement = nullptr;
for (Element* maybeTableElement = content->GetParentElement();
@ -3214,7 +3214,7 @@ HTMLEditor::AutoHTMLFragmentBoundariesFixer::FindReplaceableTableElement(
for (Element* element =
aContentMaybeInTableElement.GetAsElementOrParentElement();
element; element = element->GetParentElement()) {
if (!HTMLEditUtils::IsTableElement(element) ||
if (!HTMLEditUtils::IsAnyTableElement(element) ||
element->IsHTMLElement(nsGkAtoms::table)) {
// XXX Perhaps, the original developer of this method assumed that
// aTableElement won't be skipped because if it's assumed, we can