зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
2937ae1381
Коммит
592ca1c3b6
|
@ -1286,7 +1286,7 @@ nsresult ParagraphStateAtSelection::CollectEditableFormatNodesInSelection(
|
||||||
// Scan for table elements. If we find table elements other than table,
|
// 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
|
// replace it with a list of any editable non-table content. Ditto for
|
||||||
// list elements.
|
// list elements.
|
||||||
if (HTMLEditUtils::IsTableElement(content) ||
|
if (HTMLEditUtils::IsAnyTableElement(content) ||
|
||||||
HTMLEditUtils::IsList(content) || HTMLEditUtils::IsListItem(content)) {
|
HTMLEditUtils::IsList(content) || HTMLEditUtils::IsListItem(content)) {
|
||||||
aArrayOfContents.RemoveElementAt(i);
|
aArrayOfContents.RemoveElementAt(i);
|
||||||
aHTMLEditor.CollectChildren(content, aArrayOfContents, 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
|
// Make sure it's not a table element. If so, cancel the operation
|
||||||
// (translation: users cannot backspace or delete across table cells)
|
// (translation: users cannot backspace or delete across table cells)
|
||||||
if (HTMLEditUtils::IsTableElement(&aOtherBlockElement)) {
|
if (HTMLEditUtils::IsAnyTableElement(&aOtherBlockElement)) {
|
||||||
return EditActionCanceled();
|
return EditActionCanceled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3105,7 +3105,7 @@ HTMLEditor::HandleDeleteCollapsedSelectionAtCurrentBlockBoundary(
|
||||||
|
|
||||||
// Make sure it's not a table element. If so, cancel the operation
|
// Make sure it's not a table element. If so, cancel the operation
|
||||||
// (translation: users cannot backspace or delete across table cells)
|
// (translation: users cannot backspace or delete across table cells)
|
||||||
if (HTMLEditUtils::IsTableElement(&aCurrentBlockElement)) {
|
if (HTMLEditUtils::IsAnyTableElement(&aCurrentBlockElement)) {
|
||||||
return EditActionCanceled();
|
return EditActionCanceled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4227,8 +4227,8 @@ EditActionResult HTMLEditor::TryToJoinBlocksWithTransaction(
|
||||||
return EditActionIgnored(NS_ERROR_UNEXPECTED);
|
return EditActionIgnored(NS_ERROR_UNEXPECTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (HTMLEditUtils::IsTableElement(leftBlockElement) ||
|
if (HTMLEditUtils::IsAnyTableElement(leftBlockElement) ||
|
||||||
HTMLEditUtils::IsTableElement(rightBlockElement)) {
|
HTMLEditUtils::IsAnyTableElement(rightBlockElement)) {
|
||||||
// Do not try to merge table elements
|
// Do not try to merge table elements
|
||||||
return EditActionCanceled();
|
return EditActionCanceled();
|
||||||
}
|
}
|
||||||
|
@ -6882,7 +6882,7 @@ SplitRangeOffFromNodeResult HTMLEditor::HandleOutdentAtSelectionInternal() {
|
||||||
parentContent && !parentContent->IsHTMLElement(nsGkAtoms::body) &&
|
parentContent && !parentContent->IsHTMLElement(nsGkAtoms::body) &&
|
||||||
parentContent != editingHost &&
|
parentContent != editingHost &&
|
||||||
(parentContent->IsHTMLElement(nsGkAtoms::table) ||
|
(parentContent->IsHTMLElement(nsGkAtoms::table) ||
|
||||||
!HTMLEditUtils::IsTableElement(parentContent));
|
!HTMLEditUtils::IsAnyTableElement(parentContent));
|
||||||
parentContent = parentContent->GetParent()) {
|
parentContent = parentContent->GetParent()) {
|
||||||
// If we reach a `<blockquote>` ancestor, it should be split at next
|
// If we reach a `<blockquote>` ancestor, it should be split at next
|
||||||
// time at least for outdenting current node.
|
// time at least for outdenting current node.
|
||||||
|
@ -7510,7 +7510,7 @@ nsresult HTMLEditor::AlignContentsAtSelection(const nsAString& aAlignType) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
nsINode* parent = atStartOfSelection.Container();
|
nsINode* parent = atStartOfSelection.Container();
|
||||||
createEmptyDivElement = !HTMLEditUtils::IsTableElement(parent) ||
|
createEmptyDivElement = !HTMLEditUtils::IsAnyTableElement(parent) ||
|
||||||
HTMLEditUtils::IsTableCellOrCaption(*parent);
|
HTMLEditUtils::IsTableCellOrCaption(*parent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7676,7 +7676,7 @@ nsresult HTMLEditor::AlignNodesAndDescendants(
|
||||||
// Skip insignificant formatting text nodes to prevent unnecessary
|
// Skip insignificant formatting text nodes to prevent unnecessary
|
||||||
// structure splitting!
|
// structure splitting!
|
||||||
if (content->IsText() &&
|
if (content->IsText() &&
|
||||||
((HTMLEditUtils::IsTableElement(atContent.GetContainer()) &&
|
((HTMLEditUtils::IsAnyTableElement(atContent.GetContainer()) &&
|
||||||
!HTMLEditUtils::IsTableCellOrCaption(*atContent.GetContainer())) ||
|
!HTMLEditUtils::IsTableCellOrCaption(*atContent.GetContainer())) ||
|
||||||
HTMLEditUtils::IsList(atContent.GetContainer()) ||
|
HTMLEditUtils::IsList(atContent.GetContainer()) ||
|
||||||
IsEmptyNode(*content))) {
|
IsEmptyNode(*content))) {
|
||||||
|
@ -7908,7 +7908,7 @@ EditActionResult HTMLEditor::MaybeDeleteTopMostEmptyAncestor(
|
||||||
HTMLEditUtils::GetInclusiveAncestorBlockElement(aStartContent);
|
HTMLEditUtils::GetInclusiveAncestorBlockElement(aStartContent);
|
||||||
RefPtr<Element> topMostEmptyBlockElement;
|
RefPtr<Element> topMostEmptyBlockElement;
|
||||||
while (blockElement && blockElement != &aEditingHostElement &&
|
while (blockElement && blockElement != &aEditingHostElement &&
|
||||||
!HTMLEditUtils::IsTableElement(blockElement) &&
|
!HTMLEditUtils::IsAnyTableElement(blockElement) &&
|
||||||
IsEmptyNode(*blockElement, true, false)) {
|
IsEmptyNode(*blockElement, true, false)) {
|
||||||
topMostEmptyBlockElement = blockElement;
|
topMostEmptyBlockElement = blockElement;
|
||||||
blockElement =
|
blockElement =
|
||||||
|
@ -8083,7 +8083,7 @@ size_t HTMLEditor::CollectChildren(
|
||||||
(HTMLEditUtils::IsList(content) ||
|
(HTMLEditUtils::IsList(content) ||
|
||||||
HTMLEditUtils::IsListItem(content))) ||
|
HTMLEditUtils::IsListItem(content))) ||
|
||||||
(aCollectTableChildren == CollectTableChildren::Yes &&
|
(aCollectTableChildren == CollectTableChildren::Yes &&
|
||||||
HTMLEditUtils::IsTableElement(content))) {
|
HTMLEditUtils::IsAnyTableElement(content))) {
|
||||||
numberOfFoundChildren += CollectChildren(
|
numberOfFoundChildren += CollectChildren(
|
||||||
*content, aOutArrayOfContents,
|
*content, aOutArrayOfContents,
|
||||||
aIndexToInsertChildren + numberOfFoundChildren, aCollectListChildren,
|
aIndexToInsertChildren + numberOfFoundChildren, aCollectListChildren,
|
||||||
|
@ -8139,7 +8139,7 @@ HTMLEditor::GetRangeExtendedToIncludeInvisibleNodes(
|
||||||
WSRunScanner(this, atStart).GetStartReasonContent());
|
WSRunScanner(this, atStart).GetStartReasonContent());
|
||||||
// We want to keep looking up. But stop if we are crossing table
|
// We want to keep looking up. But stop if we are crossing table
|
||||||
// element boundaries, or if we hit the root.
|
// element boundaries, or if we hit the root.
|
||||||
if (HTMLEditUtils::IsTableElement(
|
if (HTMLEditUtils::IsAnyTableElement(
|
||||||
backwardScanFromStartResult.GetContent()) ||
|
backwardScanFromStartResult.GetContent()) ||
|
||||||
backwardScanFromStartResult.GetContent() == commonAncestorBlock ||
|
backwardScanFromStartResult.GetContent() == commonAncestorBlock ||
|
||||||
backwardScanFromStartResult.GetContent() == editingHost) {
|
backwardScanFromStartResult.GetContent() == editingHost) {
|
||||||
|
@ -8185,7 +8185,7 @@ HTMLEditor::GetRangeExtendedToIncludeInvisibleNodes(
|
||||||
wsScannerAtEnd.GetEndReasonContent());
|
wsScannerAtEnd.GetEndReasonContent());
|
||||||
// We want to keep looking up. But stop if we are crossing table
|
// We want to keep looking up. But stop if we are crossing table
|
||||||
// element boundaries, or if we hit the root.
|
// element boundaries, or if we hit the root.
|
||||||
if (HTMLEditUtils::IsTableElement(
|
if (HTMLEditUtils::IsAnyTableElement(
|
||||||
forwardScanFromEndResult.GetContent()) ||
|
forwardScanFromEndResult.GetContent()) ||
|
||||||
forwardScanFromEndResult.GetContent() == commonAncestorBlock ||
|
forwardScanFromEndResult.GetContent() == commonAncestorBlock ||
|
||||||
forwardScanFromEndResult.GetContent() == editingHost) {
|
forwardScanFromEndResult.GetContent() == editingHost) {
|
||||||
|
@ -9284,7 +9284,7 @@ Element* HTMLEditor::GetNearestAncestorListItemElement(
|
||||||
// whether we reach it or not.
|
// whether we reach it or not.
|
||||||
for (Element* parentElement = aContent.GetParentElement();
|
for (Element* parentElement = aContent.GetParentElement();
|
||||||
parentElement && IsDescendantOfEditorRoot(parentElement) &&
|
parentElement && IsDescendantOfEditorRoot(parentElement) &&
|
||||||
!HTMLEditUtils::IsTableElement(parentElement);
|
!HTMLEditUtils::IsAnyTableElement(parentElement);
|
||||||
parentElement = parentElement->GetParentElement()) {
|
parentElement = parentElement->GetParentElement()) {
|
||||||
if (HTMLEditUtils::IsListItem(parentElement)) {
|
if (HTMLEditUtils::IsListItem(parentElement)) {
|
||||||
return parentElement;
|
return parentElement;
|
||||||
|
@ -11141,12 +11141,12 @@ bool HTMLEditor::NodesInDifferentTableElements(nsINode& aNode1,
|
||||||
nsINode& aNode2) {
|
nsINode& aNode2) {
|
||||||
nsINode* parentNode1;
|
nsINode* parentNode1;
|
||||||
for (parentNode1 = &aNode1;
|
for (parentNode1 = &aNode1;
|
||||||
parentNode1 && !HTMLEditUtils::IsTableElement(parentNode1);
|
parentNode1 && !HTMLEditUtils::IsAnyTableElement(parentNode1);
|
||||||
parentNode1 = parentNode1->GetParentNode()) {
|
parentNode1 = parentNode1->GetParentNode()) {
|
||||||
}
|
}
|
||||||
nsINode* parentNode2;
|
nsINode* parentNode2;
|
||||||
for (parentNode2 = &aNode2;
|
for (parentNode2 = &aNode2;
|
||||||
parentNode2 && !HTMLEditUtils::IsTableElement(parentNode2);
|
parentNode2 && !HTMLEditUtils::IsAnyTableElement(parentNode2);
|
||||||
parentNode2 = parentNode2->GetParentNode()) {
|
parentNode2 = parentNode2->GetParentNode()) {
|
||||||
}
|
}
|
||||||
// XXX Despite of the name, this returns true if only one node is in a
|
// 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);
|
MOZ_ASSERT(aNode);
|
||||||
return aNode->IsAnyOfHTMLElements(
|
return aNode->IsAnyOfHTMLElements(
|
||||||
nsGkAtoms::table, nsGkAtoms::tr, nsGkAtoms::td, nsGkAtoms::th,
|
nsGkAtoms::table, nsGkAtoms::tr, nsGkAtoms::td, nsGkAtoms::th,
|
||||||
|
|
|
@ -93,7 +93,7 @@ class HTMLEditUtils final {
|
||||||
static bool IsListItem(nsINode* aNode);
|
static bool IsListItem(nsINode* aNode);
|
||||||
static bool IsTable(nsINode* aNode);
|
static bool IsTable(nsINode* aNode);
|
||||||
static bool IsTableRow(nsINode* aNode);
|
static bool IsTableRow(nsINode* aNode);
|
||||||
static bool IsTableElement(nsINode* aNode);
|
static bool IsAnyTableElement(nsINode* aNode);
|
||||||
static bool IsTableElementButNotTable(nsINode* aNode);
|
static bool IsTableElementButNotTable(nsINode* aNode);
|
||||||
static bool IsTableCell(nsINode* node);
|
static bool IsTableCell(nsINode* node);
|
||||||
static bool IsTableCellOrCaption(nsINode& aNode);
|
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 selection is in a table element, we need special handling.
|
||||||
if (HTMLEditUtils::IsTableElement(blockParent)) {
|
if (HTMLEditUtils::IsAnyTableElement(blockParent)) {
|
||||||
EditActionResult result = HandleTabKeyPressInTable(aKeyboardEvent);
|
EditActionResult result = HandleTabKeyPressInTable(aKeyboardEvent);
|
||||||
if (result.Failed()) {
|
if (result.Failed()) {
|
||||||
NS_WARNING("HTMLEditor::HandleTabKeyPressInTable() failed");
|
NS_WARNING("HTMLEditor::HandleTabKeyPressInTable() failed");
|
||||||
|
@ -1786,7 +1786,7 @@ EditorDOMPoint HTMLEditor::InsertNodeIntoProperAncestorWithTransaction(
|
||||||
// If the current parent is a root (body or table element)
|
// If the current parent is a root (body or table element)
|
||||||
// then go no further - we can't insert.
|
// then go no further - we can't insert.
|
||||||
if (pointToInsert.IsContainerHTMLElement(nsGkAtoms::body) ||
|
if (pointToInsert.IsContainerHTMLElement(nsGkAtoms::body) ||
|
||||||
HTMLEditUtils::IsTableElement(pointToInsert.GetContainer())) {
|
HTMLEditUtils::IsAnyTableElement(pointToInsert.GetContainer())) {
|
||||||
return EditorDOMPoint();
|
return EditorDOMPoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3985,7 +3985,7 @@ bool HTMLEditor::SetCaretInTableCell(Element* aElement) {
|
||||||
MOZ_ASSERT(IsEditActionDataAvailable());
|
MOZ_ASSERT(IsEditActionDataAvailable());
|
||||||
|
|
||||||
if (!aElement || !aElement->IsHTMLElement() ||
|
if (!aElement || !aElement->IsHTMLElement() ||
|
||||||
!HTMLEditUtils::IsTableElement(aElement) ||
|
!HTMLEditUtils::IsAnyTableElement(aElement) ||
|
||||||
!IsDescendantOfEditorRoot(aElement)) {
|
!IsDescendantOfEditorRoot(aElement)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -304,7 +304,7 @@ nsresult HTMLEditor::DoInsertHTMLWithContext(
|
||||||
// but if not we want to delete _contents_ of cells and replace
|
// but if not we want to delete _contents_ of cells and replace
|
||||||
// with non-table elements. Use cellSelectionMode bool to
|
// with non-table elements. Use cellSelectionMode bool to
|
||||||
// indicate results.
|
// indicate results.
|
||||||
if (!HTMLEditUtils::IsTableElement(arrayOfTopMostChildContents[0])) {
|
if (!HTMLEditUtils::IsAnyTableElement(arrayOfTopMostChildContents[0])) {
|
||||||
cellSelectionMode = false;
|
cellSelectionMode = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3127,7 +3127,7 @@ HTMLEditor::AutoHTMLFragmentBoundariesFixer::GetMostAncestorListOrTableElement(
|
||||||
const {
|
const {
|
||||||
Element* lastFoundAncestorListOrTableElement = nullptr;
|
Element* lastFoundAncestorListOrTableElement = nullptr;
|
||||||
for (auto& content : aArrayOfTopMostChildContents) {
|
for (auto& content : aArrayOfTopMostChildContents) {
|
||||||
if (HTMLEditUtils::IsTableElement(content) &&
|
if (HTMLEditUtils::IsAnyTableElement(content) &&
|
||||||
!content->IsHTMLElement(nsGkAtoms::table)) {
|
!content->IsHTMLElement(nsGkAtoms::table)) {
|
||||||
Element* tableElement = nullptr;
|
Element* tableElement = nullptr;
|
||||||
for (Element* maybeTableElement = content->GetParentElement();
|
for (Element* maybeTableElement = content->GetParentElement();
|
||||||
|
@ -3214,7 +3214,7 @@ HTMLEditor::AutoHTMLFragmentBoundariesFixer::FindReplaceableTableElement(
|
||||||
for (Element* element =
|
for (Element* element =
|
||||||
aContentMaybeInTableElement.GetAsElementOrParentElement();
|
aContentMaybeInTableElement.GetAsElementOrParentElement();
|
||||||
element; element = element->GetParentElement()) {
|
element; element = element->GetParentElement()) {
|
||||||
if (!HTMLEditUtils::IsTableElement(element) ||
|
if (!HTMLEditUtils::IsAnyTableElement(element) ||
|
||||||
element->IsHTMLElement(nsGkAtoms::table)) {
|
element->IsHTMLElement(nsGkAtoms::table)) {
|
||||||
// XXX Perhaps, the original developer of this method assumed that
|
// XXX Perhaps, the original developer of this method assumed that
|
||||||
// aTableElement won't be skipped because if it's assumed, we can
|
// aTableElement won't be skipped because if it's assumed, we can
|
||||||
|
|
Загрузка…
Ссылка в новой задаче