NS_IMETHODIMP HTMLEditor::DoInlineTableEditingAction(nsIDOMElement* aElement) { NS_ENSURE_ARG_POINTER(aElement); bool anonElement = false; if (aElement && NS_SUCCEEDED(aElement->HasAttribute(NS_LITERAL_STRING("_moz_anonclass"), &anonElement)) && anonElement) { nsAutoString anonclass; nsresult rv = aElement->GetAttribute(NS_LITERAL_STRING("_moz_anonclass"), anonclass); NS_ENSURE_SUCCESS(rv, rv); if (!StringBeginsWith(anonclass, NS_LITERAL_STRING("mozTable"))) return NS_OK; nsCOMPtr<nsIDOMNode> tableNode = GetEnclosingTable(mInlineEditedCell); nsCOMPtr<nsIDOMElement> tableElement = do_QueryInterface(tableNode); int32_t rowCount, colCount; rv = GetTableSize(tableElement, &rowCount, &colCount); NS_ENSURE_SUCCESS(rv, rv); bool hideUI = false; bool hideResizersWithInlineTableUI = (GetAsDOMNode(mResizedObject) == tableElement); if (anonclass.EqualsLiteral("mozTableAddColumnBefore")) InsertTableColumn(1, false); else if (anonclass.EqualsLiteral("mozTableAddColumnAfter")) InsertTableColumn(1, true); else if (anonclass.EqualsLiteral("mozTableAddRowBefore")) InsertTableRow(1, false); else if (anonclass.EqualsLiteral("mozTableAddRowAfter")) InsertTableRow(1, true); else if (anonclass.EqualsLiteral("mozTableRemoveColumn")) { DeleteTableColumn(1); #ifndef DISABLE_TABLE_DELETION hideUI = (colCount == 1); #endif } else if (anonclass.EqualsLiteral("mozTableRemoveRow")) { DeleteTableRow(1); #ifndef DISABLE_TABLE_DELETION hideUI = (rowCount == 1); #endif } else return NS_OK; if (hideUI) { HideInlineTableEditingUI(); if (hideResizersWithInlineTableUI) HideResizers(); } } return NS_OK; }
nsresult HTMLEditor::DoInlineTableEditingAction(const Element& aElement) { nsAutoString anonclass; aElement.GetAttr(kNameSpaceID_None, nsGkAtoms::_moz_anonclass, anonclass); if (!StringBeginsWith(anonclass, NS_LITERAL_STRING("mozTable"))) { return NS_OK; } RefPtr<Element> tableElement = GetEnclosingTable(mInlineEditedCell); int32_t rowCount, colCount; nsresult rv = GetTableSize(tableElement, &rowCount, &colCount); NS_ENSURE_SUCCESS(rv, rv); bool hideUI = false; bool hideResizersWithInlineTableUI = (mResizedObject == tableElement); if (anonclass.EqualsLiteral("mozTableAddColumnBefore")) { InsertTableColumn(1, false); } else if (anonclass.EqualsLiteral("mozTableAddColumnAfter")) { InsertTableColumn(1, true); } else if (anonclass.EqualsLiteral("mozTableAddRowBefore")) { InsertTableRow(1, false); } else if (anonclass.EqualsLiteral("mozTableAddRowAfter")) { InsertTableRow(1, true); } else if (anonclass.EqualsLiteral("mozTableRemoveColumn")) { DeleteTableColumn(1); #ifndef DISABLE_TABLE_DELETION hideUI = (colCount == 1); #endif } else if (anonclass.EqualsLiteral("mozTableRemoveRow")) { DeleteTableRow(1); #ifndef DISABLE_TABLE_DELETION hideUI = (rowCount == 1); #endif } else { return NS_OK; } // InsertTableRow might causes reframe if (Destroyed()) { return NS_OK; } if (hideUI) { HideInlineTableEditingUI(); if (hideResizersWithInlineTableUI) { HideResizers(); } } return NS_OK; }