Π·Π΅ΡΠΊΠ°Π»ΠΎ ΠΈΠ· https://github.com/mozilla/gecko-dev.git
Backed out 2 changesets (bug 1484092) for build bustages in builds/worker/workspace/build/src/editor/libeditor/HTMLEditor.cppπ―53 on a CLOSED TREE
Backed out changeset 10fdd041f1b5 (bug 1484092) Backed out changeset d0b14e8711df (bug 1484092)
This commit is contained in:
Π ΠΎΠ΄ΠΈΡΠ΅Π»Ρ
c6f79a6d0e
ΠΠΎΠΌΠΌΠΈΡ
79400be144
|
@ -289,9 +289,7 @@ HTMLEditor::DeleteRefToAnonymousNode(ManualNACPtr aContent,
|
|||
NS_IMETHODIMP
|
||||
HTMLEditor::CheckSelectionStateForAnonymousButtons(Selection* aSelection)
|
||||
{
|
||||
if (NS_WARN_IF(!aSelection)) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
NS_ENSURE_ARG_POINTER(aSelection);
|
||||
|
||||
// early way out if all contextual UI extensions are disabled
|
||||
NS_ENSURE_TRUE(mIsObjectResizingEnabled ||
|
||||
|
@ -328,8 +326,7 @@ HTMLEditor::CheckSelectionStateForAnonymousButtons(Selection* aSelection)
|
|||
if (mIsObjectResizingEnabled || mIsInlineTableEditingEnabled) {
|
||||
// Resizing or Inline Table Editing is enabled, we need to check if the
|
||||
// selection is contained in a table cell
|
||||
cellElement =
|
||||
GetElementOrParentByTagNameAtSelection(*aSelection, *nsGkAtoms::td);
|
||||
cellElement = GetElementOrParentByTagName(NS_LITERAL_STRING("td"), nullptr);
|
||||
}
|
||||
|
||||
if (mIsObjectResizingEnabled && cellElement) {
|
||||
|
|
|
@ -88,16 +88,29 @@ GetLowerCaseNameAtom(const nsAString& aTagName)
|
|||
}
|
||||
|
||||
// Some utilities to handle overloading of "A" tag for link and named anchor.
|
||||
static bool
|
||||
IsLinkTag(const nsString& s)
|
||||
{
|
||||
return s.EqualsIgnoreCase("href");
|
||||
}
|
||||
|
||||
static bool
|
||||
IsLinkTag(const nsAtom& aTagName)
|
||||
{
|
||||
return aTagName.Equals(NS_LITERAL_STRING("href"));
|
||||
}
|
||||
|
||||
static bool
|
||||
IsNamedAnchorTag(const nsString& s)
|
||||
{
|
||||
return s.EqualsIgnoreCase("anchor") || s.EqualsIgnoreCase("namedanchor");
|
||||
}
|
||||
|
||||
static bool
|
||||
IsNamedAnchorTag(const nsAtom& aTagName)
|
||||
{
|
||||
return aTagName.Equals(NS_LITERAL_STRING("anchor");
|
||||
return aTagName.Equals(NS_LITERAL_STRING("anchor")) ||
|
||||
aTagName.Equals(NS_LITERAL_STRING("namedanchor"));
|
||||
}
|
||||
|
||||
template EditorDOMPoint
|
||||
|
@ -1093,38 +1106,24 @@ HTMLEditor::TabInTable(bool inIsShift,
|
|||
NS_ENSURE_TRUE(outHandled, NS_ERROR_NULL_POINTER);
|
||||
*outHandled = false;
|
||||
|
||||
RefPtr<Selection> selection = GetSelection();
|
||||
if (NS_WARN_IF(!selection)) {
|
||||
// Do nothing if we didn't find a table cell.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Find enclosing table cell from selection (cell may be selected element)
|
||||
Element* cellElement =
|
||||
GetElementOrParentByTagNameAtSelection(*selection, *nsGkAtoms::td);
|
||||
if (NS_WARN_IF(!cellElement)) {
|
||||
// Do nothing if we didn't find a table cell.
|
||||
return NS_OK;
|
||||
}
|
||||
nsCOMPtr<Element> cellElement =
|
||||
GetElementOrParentByTagName(NS_LITERAL_STRING("td"), nullptr);
|
||||
// Do nothing -- we didn't find a table cell
|
||||
NS_ENSURE_TRUE(cellElement, NS_OK);
|
||||
|
||||
// find enclosing table
|
||||
RefPtr<Element> table = GetEnclosingTable(cellElement);
|
||||
if (NS_WARN_IF(!table)) {
|
||||
return NS_OK;
|
||||
}
|
||||
nsCOMPtr<Element> table = GetEnclosingTable(cellElement);
|
||||
NS_ENSURE_TRUE(table, NS_OK);
|
||||
|
||||
// advance to next cell
|
||||
// first create an iterator over the table
|
||||
nsCOMPtr<nsIContentIterator> iter = NS_NewContentIterator();
|
||||
nsresult rv = iter->Init(table);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
// position iter at block
|
||||
rv = iter->PositionAt(cellElement);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsINode> node;
|
||||
do {
|
||||
|
@ -2528,93 +2527,84 @@ HTMLEditor::Align(const nsAString& aAlignType)
|
|||
return rules->DidDoAction(selection, subActionInfo, rv);
|
||||
}
|
||||
|
||||
Element*
|
||||
HTMLEditor::GetElementOrParentByTagName(const nsAtom& aTagName,
|
||||
already_AddRefed<Element>
|
||||
HTMLEditor::GetElementOrParentByTagName(const nsAString& aTagName,
|
||||
nsINode* aNode)
|
||||
{
|
||||
MOZ_ASSERT(&aTagName != nsGkAtoms::_empty);
|
||||
MOZ_ASSERT(!aTagName.IsEmpty());
|
||||
|
||||
if (aNode) {
|
||||
return GetElementOrParentByTagNameInternal(aTagName, *aNode);
|
||||
}
|
||||
RefPtr<Selection> selection = GetSelection();
|
||||
if (NS_WARN_IF(!selection)) {
|
||||
return nullptr;
|
||||
}
|
||||
return GetElementOrParentByTagNameAtSelection(*selection, aTagName);
|
||||
}
|
||||
|
||||
Element*
|
||||
HTMLEditor::GetElementOrParentByTagNameAtSelection(Selection& aSelection,
|
||||
const nsAtom& aTagName)
|
||||
{
|
||||
MOZ_ASSERT(&aTagName != nsGkAtoms::_empty);
|
||||
|
||||
// If no node supplied, get it from anchor node of current selection
|
||||
const EditorRawDOMPoint atAnchor(aSelection.AnchorRef());
|
||||
if (NS_WARN_IF(!atAnchor.IsSet())) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Try to get the actual selected node
|
||||
nsCOMPtr<nsINode> node;
|
||||
if (atAnchor.GetContainer()->HasChildNodes() &&
|
||||
atAnchor.GetContainerAsContent()) {
|
||||
node = atAnchor.GetChild();
|
||||
}
|
||||
// Anchor node is probably a text node - just use that
|
||||
nsCOMPtr<nsINode> node = aNode;
|
||||
if (!node) {
|
||||
node = atAnchor.GetContainer();
|
||||
if (NS_WARN_IF(!node)) {
|
||||
// If no node supplied, get it from anchor node of current selection
|
||||
RefPtr<Selection> selection = GetSelection();
|
||||
if (NS_WARN_IF(!selection)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const EditorDOMPoint atAnchor(selection->AnchorRef());
|
||||
if (NS_WARN_IF(!atAnchor.IsSet())) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Try to get the actual selected node
|
||||
if (atAnchor.GetContainer()->HasChildNodes() &&
|
||||
atAnchor.GetContainerAsContent()) {
|
||||
node = atAnchor.GetChild();
|
||||
}
|
||||
// Anchor node is probably a text node - just use that
|
||||
if (!node) {
|
||||
node = atAnchor.GetContainer();
|
||||
}
|
||||
}
|
||||
return GetElementOrParentByTagNameInternal(aTagName, *node);
|
||||
}
|
||||
|
||||
Element*
|
||||
HTMLEditor::GetElementOrParentByTagNameInternal(const nsAtom& aTagName,
|
||||
nsINode& aNode)
|
||||
{
|
||||
MOZ_ASSERT(&aTagName != nsGkAtoms::_empty);
|
||||
|
||||
Element* currentElement =
|
||||
aNode.IsElement() ? aNode.AsElement() : aNode.GetParentElement();
|
||||
if (NS_WARN_IF(!currentElement)) {
|
||||
nsCOMPtr<Element> current;
|
||||
if (node->IsElement()) {
|
||||
current = node->AsElement();
|
||||
} else if (node->GetParentElement()) {
|
||||
current = node->GetParentElement();
|
||||
} else {
|
||||
// Neither aNode nor its parent is an element, so no ancestor is
|
||||
MOZ_ASSERT(!aNode.GetParentNode() ||
|
||||
!aNode.GetParentNode()->GetParentNode());
|
||||
MOZ_ASSERT(!node->GetParentNode() ||
|
||||
!node->GetParentNode()->GetParentNode());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool getLink = IsLinkTag(aTagName);
|
||||
bool getNamedAnchor = IsNamedAnchorTag(aTagName);
|
||||
const nsAtom& tagName = getLink || getNamedAnchor ? *nsGkAtoms::a : aTagName;
|
||||
for (; currentElement; currentElement = currentElement->GetParentElement()) {
|
||||
nsAutoString tagName(aTagName);
|
||||
ToLowerCase(tagName);
|
||||
bool getLink = IsLinkTag(tagName);
|
||||
bool getNamedAnchor = IsNamedAnchorTag(tagName);
|
||||
if (getLink || getNamedAnchor) {
|
||||
tagName.Assign('a');
|
||||
}
|
||||
bool findTableCell = tagName.EqualsLiteral("td");
|
||||
bool findList = tagName.EqualsLiteral("list");
|
||||
|
||||
for (; current; current = current->GetParentElement()) {
|
||||
// Test if we have a link (an anchor with href set)
|
||||
if ((getLink && HTMLEditUtils::IsLink(currentElement)) ||
|
||||
(getNamedAnchor && HTMLEditUtils::IsNamedAnchor(currentElement))) {
|
||||
return currentElement;
|
||||
if ((getLink && HTMLEditUtils::IsLink(current)) ||
|
||||
(getNamedAnchor && HTMLEditUtils::IsNamedAnchor(current))) {
|
||||
return current.forget();
|
||||
}
|
||||
if (&tagName == nsGkAtoms::list_) {
|
||||
if (findList) {
|
||||
// Match "ol", "ul", or "dl" for lists
|
||||
if (HTMLEditUtils::IsList(currentElement)) {
|
||||
return currentElement;
|
||||
if (HTMLEditUtils::IsList(current)) {
|
||||
return current.forget();
|
||||
}
|
||||
} else if (&tagName == nsGkAtoms::td) {
|
||||
} else if (findTableCell) {
|
||||
// Table cells are another special case: match either "td" or "th"
|
||||
if (HTMLEditUtils::IsTableCell(currentElement)) {
|
||||
return currentElement;
|
||||
if (HTMLEditUtils::IsTableCell(current)) {
|
||||
return current.forget();
|
||||
}
|
||||
} else if (&tagName == currentElement->NodeInfo()->NameAtom()) {
|
||||
return currentElement;
|
||||
} else if (current->NodeName().Equals(tagName,
|
||||
nsCaseInsensitiveStringComparator())) {
|
||||
return current.forget();
|
||||
}
|
||||
|
||||
// Stop searching if parent is a body tag. Note: Originally used IsRoot to
|
||||
// stop at table cells, but that's too messy when you are trying to find
|
||||
// the parent table
|
||||
if (currentElement->GetParentElement() &&
|
||||
currentElement->GetParentElement()->IsHTMLElement(nsGkAtoms::body)) {
|
||||
if (current->GetParentElement() &&
|
||||
current->GetParentElement()->IsHTMLElement(nsGkAtoms::body)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -2627,20 +2617,15 @@ HTMLEditor::GetElementOrParentByTagName(const nsAString& aTagName,
|
|||
nsINode* aNode,
|
||||
Element** aReturn)
|
||||
{
|
||||
if (NS_WARN_IF(aTagName.IsEmpty()) ||
|
||||
NS_WARN_IF(!aReturn)) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
NS_ENSURE_TRUE(!aTagName.IsEmpty(), NS_ERROR_NULL_POINTER);
|
||||
NS_ENSURE_TRUE(aReturn, NS_ERROR_NULL_POINTER);
|
||||
|
||||
RefPtr<nsAtom> tagName = GetLowerCaseNameAtom(aTagName);
|
||||
if (NS_WARN_IF(!tagName) || NS_WARN_IF(tagName == nsGkAtoms::_empty)) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
RefPtr<Element> parent = GetElementOrParentByTagName(aTagName, aNode);
|
||||
|
||||
RefPtr<Element> parent = GetElementOrParentByTagName(*tagName, aNode);
|
||||
if (!parent) {
|
||||
return NS_SUCCESS_EDITOR_ELEMENT_NOT_FOUND;
|
||||
}
|
||||
|
||||
parent.forget(aReturn);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -2722,22 +2707,22 @@ HTMLEditor::GetSelectedElement(Selection& aSelection,
|
|||
const RangeBoundary& focus = aSelection.FocusRef();
|
||||
// Link node must be the same for both ends of selection
|
||||
if (anchor.IsSet()) {
|
||||
Element* parentLinkOfAnchor =
|
||||
GetElementOrParentByTagNameInternal(*nsGkAtoms::href,
|
||||
*anchor.Container());
|
||||
RefPtr<Element> parentLinkOfAnchor =
|
||||
GetElementOrParentByTagName(NS_LITERAL_STRING("href"),
|
||||
anchor.Container());
|
||||
// XXX: ERROR_HANDLING can parentLinkOfAnchor be null?
|
||||
if (parentLinkOfAnchor) {
|
||||
if (aSelection.IsCollapsed()) {
|
||||
// We have just a caret in the link.
|
||||
return do_AddRef(parentLinkOfAnchor);
|
||||
return parentLinkOfAnchor.forget();
|
||||
}
|
||||
if (focus.IsSet()) {
|
||||
// Link node must be the same for both ends of selection.
|
||||
Element* parentLinkOfFocus =
|
||||
GetElementOrParentByTagNameInternal(*nsGkAtoms::href,
|
||||
*focus.Container());
|
||||
RefPtr<Element> parentLinkOfFocus =
|
||||
GetElementOrParentByTagName(NS_LITERAL_STRING("href"),
|
||||
focus.Container());
|
||||
if (parentLinkOfFocus == parentLinkOfAnchor) {
|
||||
return do_AddRef(parentLinkOfAnchor);
|
||||
return parentLinkOfAnchor.forget();
|
||||
}
|
||||
}
|
||||
} else if (anchor.GetChildAtOffset() && focus.GetChildAtOffset()) {
|
||||
|
|
|
@ -322,27 +322,8 @@ public:
|
|||
*/
|
||||
nsresult DoInlineTableEditingAction(const Element& aUIAnonymousElement);
|
||||
|
||||
/**
|
||||
* GetElementOrParentByTagName() looks for an element node whose name matches
|
||||
* aTagName from aNode or anchor node of Selection to <body> element.
|
||||
*
|
||||
* @param aTagName The tag name which you want to look for.
|
||||
* Must not be nsGkAtoms::_empty.
|
||||
* If nsGkAtoms::list, the result may be <ul>, <ol> or
|
||||
* <dl> element.
|
||||
* If nsGkAtoms::td, the result may be <td> or <th>.
|
||||
* If nsGkAtoms::href, the result may be <a> element
|
||||
* which has "href" attribute with non-empty value.
|
||||
* If nsGkAtoms::anchor, the result may be <a> which
|
||||
* has "name" attribute with non-empty value.
|
||||
* @param aNode If non-nullptr, this starts to look for the result
|
||||
* from it. Otherwise, i.e., nullptr, starts from
|
||||
* anchor node of Selection.
|
||||
* @return If an element which matches aTagName, returns
|
||||
* an Element. Otherwise, nullptr.
|
||||
*/
|
||||
Element*
|
||||
GetElementOrParentByTagName(const nsAtom& aTagName, nsINode* aNode);
|
||||
already_AddRefed<Element>
|
||||
GetElementOrParentByTagName(const nsAString& aTagName, nsINode* aNode);
|
||||
|
||||
/**
|
||||
* Get an active editor's editing host in DOM window. If this editor isn't
|
||||
|
@ -833,48 +814,6 @@ protected: // Shouldn't be used by friend classes
|
|||
nsresult CollapseSelectionAfter(Selection& aSelection,
|
||||
Element& aElement);
|
||||
|
||||
/**
|
||||
* GetElementOrParentByTagNameAtSelection() looks for an element node whose
|
||||
* name matches aTagName from anchor node of Selection to <body> element.
|
||||
*
|
||||
* @param aSelection The Selection for this editor.
|
||||
* @param aTagName The tag name which you want to look for.
|
||||
* Must not be nsGkAtoms::_empty.
|
||||
* If nsGkAtoms::list, the result may be <ul>, <ol> or
|
||||
* <dl> element.
|
||||
* If nsGkAtoms::td, the result may be <td> or <th>.
|
||||
* If nsGkAtoms::href, the result may be <a> element
|
||||
* which has "href" attribute with non-empty value.
|
||||
* If nsGkAtoms::anchor, the result may be <a> which
|
||||
* has "name" attribute with non-empty value.
|
||||
* @return If an element which matches aTagName, returns
|
||||
* an Element. Otherwise, nullptr.
|
||||
*/
|
||||
Element*
|
||||
GetElementOrParentByTagNameAtSelection(Selection& aSelection,
|
||||
const nsAtom& aTagName);
|
||||
|
||||
/**
|
||||
* GetElementOrParentByTagNameInternal() looks for an element node whose
|
||||
* name matches aTagName from aNode to <body> element.
|
||||
*
|
||||
* @param aTagName The tag name which you want to look for.
|
||||
* Must not be nsGkAtoms::_empty.
|
||||
* If nsGkAtoms::list, the result may be <ul>, <ol> or
|
||||
* <dl> element.
|
||||
* If nsGkAtoms::td, the result may be <td> or <th>.
|
||||
* If nsGkAtoms::href, the result may be <a> element
|
||||
* which has "href" attribute with non-empty value.
|
||||
* If nsGkAtoms::anchor, the result may be <a> which
|
||||
* has "name" attribute with non-empty value.
|
||||
* @param aNode Start node to look for the element.
|
||||
* @return If an element which matches aTagName, returns
|
||||
* an Element. Otherwise, nullptr.
|
||||
*/
|
||||
Element*
|
||||
GetElementOrParentByTagNameInternal(const nsAtom& aTagName,
|
||||
nsINode& aNode);
|
||||
|
||||
/**
|
||||
* GetSelectedElement() returns an element node which is in first range of
|
||||
* aSelection. The rule is a little bit complicated and the rules do not
|
||||
|
|
|
@ -142,8 +142,9 @@ HTMLEditorEventListener::MouseDown(MouseEvent* aMouseEvent)
|
|||
selection->Collapse(parent, offset);
|
||||
} else {
|
||||
// Get enclosing link if in text so we can select the link
|
||||
Element* linkElement =
|
||||
htmlEditor->GetElementOrParentByTagName(*nsGkAtoms::href, node);
|
||||
RefPtr<Element> linkElement =
|
||||
htmlEditor->GetElementOrParentByTagName(NS_LITERAL_STRING("href"),
|
||||
node);
|
||||
if (linkElement) {
|
||||
element = linkElement;
|
||||
}
|
||||
|
|
|
@ -224,17 +224,16 @@ NS_IMETHODIMP
|
|||
HTMLEditor::GetFirstRow(Element* aTableElement,
|
||||
nsINode** aRowNode)
|
||||
{
|
||||
if (NS_WARN_IF(!aTableElement) || NS_WARN_IF(!aRowNode)) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
NS_ENSURE_TRUE(aRowNode, NS_ERROR_NULL_POINTER);
|
||||
|
||||
*aRowNode = nullptr;
|
||||
|
||||
Element* tableElement =
|
||||
GetElementOrParentByTagNameInternal(*nsGkAtoms::table, *aTableElement);
|
||||
if (NS_WARN_IF(!tableElement)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
nsCOMPtr<nsINode> tableElement = aTableElement;
|
||||
NS_ENSURE_TRUE(tableElement, NS_ERROR_NULL_POINTER);
|
||||
|
||||
tableElement = GetElementOrParentByTagName(NS_LITERAL_STRING("table"),
|
||||
tableElement);
|
||||
NS_ENSURE_TRUE(tableElement, NS_ERROR_NULL_POINTER);
|
||||
|
||||
nsCOMPtr<nsIContent> tableChild = tableElement->GetFirstChild();
|
||||
while (tableChild) {
|
||||
|
@ -603,20 +602,19 @@ HTMLEditor::InsertTableRow(int32_t aNumber,
|
|||
}
|
||||
|
||||
if (cellsInRow > 0) {
|
||||
if (NS_WARN_IF(!cellForRowParent)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
Element* parentRow =
|
||||
GetElementOrParentByTagNameInternal(*nsGkAtoms::tr, *cellForRowParent);
|
||||
if (NS_WARN_IF(!parentRow)) {
|
||||
|
||||
NS_NAMED_LITERAL_STRING(trStr, "tr");
|
||||
if (!cellForRowParent) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsCOMPtr<Element> parentRow =
|
||||
GetElementOrParentByTagName(trStr, cellForRowParent);
|
||||
NS_ENSURE_TRUE(parentRow, NS_ERROR_NULL_POINTER);
|
||||
|
||||
// The row parent and offset where we will insert new row
|
||||
nsCOMPtr<nsINode> parentOfRow = parentRow->GetParentNode();
|
||||
if (NS_WARN_IF(!parentOfRow)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
NS_ENSURE_TRUE(parentOfRow, NS_ERROR_NULL_POINTER);
|
||||
int32_t newRowOffset = parentOfRow->ComputeIndexOf(parentRow);
|
||||
|
||||
// Adjust for when adding past the end
|
||||
|
@ -853,16 +851,12 @@ HTMLEditor::DeleteTableCell(int32_t aNumber)
|
|||
&startRowIndex, &startColIndex);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
// Don't fail if no cell found
|
||||
if (NS_WARN_IF(!cell)) {
|
||||
return NS_SUCCESS_EDITOR_ELEMENT_NOT_FOUND;
|
||||
}
|
||||
NS_ENSURE_TRUE(cell, NS_SUCCESS_EDITOR_ELEMENT_NOT_FOUND);
|
||||
|
||||
if (GetNumberOfCellsInRow(table, startRowIndex) == 1) {
|
||||
Element* parentRow =
|
||||
GetElementOrParentByTagNameInternal(*nsGkAtoms::tr, *cell);
|
||||
if (NS_WARN_IF(!parentRow)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
RefPtr<Element> parentRow =
|
||||
GetElementOrParentByTagName(NS_LITERAL_STRING("tr"), cell);
|
||||
NS_ENSURE_TRUE(parentRow, NS_ERROR_NULL_POINTER);
|
||||
|
||||
// We should delete the row instead,
|
||||
// but first check if its the only row left
|
||||
|
@ -1093,10 +1087,10 @@ HTMLEditor::DeleteColumn(Element* aTable,
|
|||
// Delete the cell
|
||||
if (GetNumberOfCellsInRow(aTable, rowIndex) == 1) {
|
||||
// Only 1 cell in row - delete the row
|
||||
Element* parentRow =
|
||||
GetElementOrParentByTagNameInternal(*nsGkAtoms::tr, *cell);
|
||||
if (NS_WARN_IF(!parentRow)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
RefPtr<Element> parentRow =
|
||||
GetElementOrParentByTagName(NS_LITERAL_STRING("tr"), cell);
|
||||
if (!parentRow) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
// But first check if its the only row left
|
||||
|
@ -1310,13 +1304,12 @@ HTMLEditor::DeleteRow(Element* aTable,
|
|||
} while (cell);
|
||||
|
||||
// Things are messed up if we didn't find a cell in the row!
|
||||
if (NS_WARN_IF(!cellInDeleteRow)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
NS_ENSURE_TRUE(cellInDeleteRow, NS_ERROR_FAILURE);
|
||||
|
||||
// Delete the entire row
|
||||
RefPtr<Element> parentRow =
|
||||
GetElementOrParentByTagNameInternal(*nsGkAtoms::tr, *cellInDeleteRow);
|
||||
GetElementOrParentByTagName(NS_LITERAL_STRING("tr"), cellInDeleteRow);
|
||||
|
||||
if (parentRow) {
|
||||
rv = DeleteNodeWithTransaction(*parentRow);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
|
@ -1339,15 +1332,10 @@ HTMLEditor::DeleteRow(Element* aTable,
|
|||
NS_IMETHODIMP
|
||||
HTMLEditor::SelectTable()
|
||||
{
|
||||
RefPtr<Selection> selection = GetSelection();
|
||||
if (NS_WARN_IF(!selection)) {
|
||||
return NS_OK; // Don't fail if we didn't find a table.
|
||||
}
|
||||
RefPtr<Element> table =
|
||||
GetElementOrParentByTagNameAtSelection(*selection, *nsGkAtoms::table);
|
||||
if (NS_WARN_IF(!table)) {
|
||||
return NS_OK; // Don't fail if we didn't find a table.
|
||||
}
|
||||
GetElementOrParentByTagName(NS_LITERAL_STRING("table"), nullptr);
|
||||
// Don't fail if we didn't find a table
|
||||
NS_ENSURE_TRUE(table, NS_OK);
|
||||
|
||||
nsresult rv = ClearSelection();
|
||||
if (NS_FAILED(rv)) {
|
||||
|
@ -1359,15 +1347,9 @@ HTMLEditor::SelectTable()
|
|||
NS_IMETHODIMP
|
||||
HTMLEditor::SelectTableCell()
|
||||
{
|
||||
RefPtr<Selection> selection = GetSelection();
|
||||
if (NS_WARN_IF(!selection)) {
|
||||
return NS_SUCCESS_EDITOR_ELEMENT_NOT_FOUND;
|
||||
}
|
||||
RefPtr<Element> cell =
|
||||
GetElementOrParentByTagNameAtSelection(*selection, *nsGkAtoms::td);
|
||||
if (NS_WARN_IF(!cell)) {
|
||||
return NS_SUCCESS_EDITOR_ELEMENT_NOT_FOUND;
|
||||
}
|
||||
GetElementOrParentByTagName(NS_LITERAL_STRING("td"), nullptr);
|
||||
NS_ENSURE_TRUE(cell, NS_SUCCESS_EDITOR_ELEMENT_NOT_FOUND);
|
||||
|
||||
nsresult rv = ClearSelection();
|
||||
if (NS_FAILED(rv)) {
|
||||
|
@ -1380,26 +1362,17 @@ NS_IMETHODIMP
|
|||
HTMLEditor::SelectBlockOfCells(Element* aStartCell,
|
||||
Element* aEndCell)
|
||||
{
|
||||
if (NS_WARN_IF(!aStartCell) || NS_WARN_IF(!aEndCell)) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
NS_ENSURE_TRUE(aStartCell && aEndCell, NS_ERROR_NULL_POINTER);
|
||||
|
||||
RefPtr<Selection> selection = GetSelection();
|
||||
if (NS_WARN_IF(!selection)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
NS_ENSURE_TRUE(selection, NS_ERROR_FAILURE);
|
||||
|
||||
RefPtr<Element> table =
|
||||
GetElementOrParentByTagNameInternal(*nsGkAtoms::table, *aStartCell);
|
||||
if (NS_WARN_IF(!table)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
NS_NAMED_LITERAL_STRING(tableStr, "table");
|
||||
RefPtr<Element> table = GetElementOrParentByTagName(tableStr, aStartCell);
|
||||
NS_ENSURE_TRUE(table, NS_ERROR_FAILURE);
|
||||
|
||||
RefPtr<Element> endTable =
|
||||
GetElementOrParentByTagNameInternal(*nsGkAtoms::table, *aEndCell);
|
||||
if (NS_WARN_IF(!endTable)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
RefPtr<Element> endTable = GetElementOrParentByTagName(tableStr, aEndCell);
|
||||
NS_ENSURE_TRUE(endTable, NS_ERROR_FAILURE);
|
||||
|
||||
// We can only select a block if within the same table,
|
||||
// so do nothing if not within one table
|
||||
|
@ -1484,30 +1457,28 @@ HTMLEditor::SelectBlockOfCells(Element* aStartCell,
|
|||
NS_IMETHODIMP
|
||||
HTMLEditor::SelectAllTableCells()
|
||||
{
|
||||
RefPtr<Selection> selection = GetSelection();
|
||||
if (NS_WARN_IF(!selection)) {
|
||||
return NS_SUCCESS_EDITOR_ELEMENT_NOT_FOUND;
|
||||
}
|
||||
RefPtr<Element> cell =
|
||||
GetElementOrParentByTagNameAtSelection(*selection, *nsGkAtoms::td);
|
||||
if (NS_WARN_IF(!cell)) {
|
||||
// Don't fail if we didn't find a cell.
|
||||
return NS_SUCCESS_EDITOR_ELEMENT_NOT_FOUND;
|
||||
}
|
||||
GetElementOrParentByTagName(NS_LITERAL_STRING("td"), nullptr);
|
||||
|
||||
// Don't fail if we didn't find a cell
|
||||
NS_ENSURE_TRUE(cell, NS_SUCCESS_EDITOR_ELEMENT_NOT_FOUND);
|
||||
|
||||
RefPtr<Element> startCell = cell;
|
||||
|
||||
// Get parent table
|
||||
RefPtr<Element> table =
|
||||
GetElementOrParentByTagNameInternal(*nsGkAtoms::table, *cell);
|
||||
if (NS_WARN_IF(!table)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
GetElementOrParentByTagName(NS_LITERAL_STRING("table"), cell);
|
||||
if (!table) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
int32_t rowCount, colCount;
|
||||
nsresult rv = GetTableSize(table, &rowCount, &colCount);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
RefPtr<Selection> selection = GetSelection();
|
||||
NS_ENSURE_TRUE(selection, NS_ERROR_FAILURE);
|
||||
|
||||
// Suppress nsISelectionListener notification
|
||||
// until all selection changes are finished
|
||||
SelectionBatcher selectionBatcher(selection);
|
||||
|
@ -1551,25 +1522,19 @@ HTMLEditor::SelectAllTableCells()
|
|||
NS_IMETHODIMP
|
||||
HTMLEditor::SelectTableRow()
|
||||
{
|
||||
RefPtr<Selection> selection = GetSelection();
|
||||
if (NS_WARN_IF(!selection)) {
|
||||
// Don't fail if we didn't find a cell.
|
||||
return NS_SUCCESS_EDITOR_ELEMENT_NOT_FOUND;
|
||||
}
|
||||
RefPtr<Element> cell =
|
||||
GetElementOrParentByTagNameAtSelection(*selection, *nsGkAtoms::td);
|
||||
if (NS_WARN_IF(!cell)) {
|
||||
// Don't fail if we didn't find a cell.
|
||||
return NS_SUCCESS_EDITOR_ELEMENT_NOT_FOUND;
|
||||
}
|
||||
GetElementOrParentByTagName(NS_LITERAL_STRING("td"), nullptr);
|
||||
|
||||
// Don't fail if we didn't find a cell
|
||||
NS_ENSURE_TRUE(cell, NS_SUCCESS_EDITOR_ELEMENT_NOT_FOUND);
|
||||
RefPtr<Element> startCell = cell;
|
||||
|
||||
// Get table and location of cell:
|
||||
RefPtr<Selection> selection;
|
||||
RefPtr<Element> table;
|
||||
int32_t startRowIndex, startColIndex;
|
||||
|
||||
nsresult rv = GetCellContext(nullptr,
|
||||
nsresult rv = GetCellContext(getter_AddRefs(selection),
|
||||
getter_AddRefs(table),
|
||||
getter_AddRefs(cell),
|
||||
nullptr, nullptr,
|
||||
|
@ -1625,25 +1590,20 @@ HTMLEditor::SelectTableRow()
|
|||
NS_IMETHODIMP
|
||||
HTMLEditor::SelectTableColumn()
|
||||
{
|
||||
RefPtr<Selection> selection = GetSelection();
|
||||
if (NS_WARN_IF(!selection)) {
|
||||
// Don't fail if we didn't find a cell.
|
||||
return NS_SUCCESS_EDITOR_ELEMENT_NOT_FOUND;
|
||||
}
|
||||
RefPtr<Element> cell =
|
||||
GetElementOrParentByTagNameAtSelection(*selection, *nsGkAtoms::td);
|
||||
if (NS_WARN_IF(!cell)) {
|
||||
// Don't fail if we didn't find a cell.
|
||||
return NS_SUCCESS_EDITOR_ELEMENT_NOT_FOUND;
|
||||
}
|
||||
GetElementOrParentByTagName(NS_LITERAL_STRING("td"), nullptr);
|
||||
|
||||
// Don't fail if we didn't find a cell
|
||||
NS_ENSURE_TRUE(cell, NS_SUCCESS_EDITOR_ELEMENT_NOT_FOUND);
|
||||
|
||||
RefPtr<Element> startCell = cell;
|
||||
|
||||
// Get location of cell:
|
||||
RefPtr<Selection> selection;
|
||||
RefPtr<Element> table;
|
||||
int32_t startRowIndex, startColIndex;
|
||||
|
||||
nsresult rv = GetCellContext(nullptr,
|
||||
nsresult rv = GetCellContext(getter_AddRefs(selection),
|
||||
getter_AddRefs(table),
|
||||
getter_AddRefs(cell),
|
||||
nullptr, nullptr,
|
||||
|
@ -2509,18 +2469,13 @@ NS_IMETHODIMP
|
|||
HTMLEditor::NormalizeTable(Element* aTable)
|
||||
{
|
||||
RefPtr<Selection> selection = GetSelection();
|
||||
if (NS_WARN_IF(!selection)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
NS_ENSURE_TRUE(selection, NS_ERROR_FAILURE);
|
||||
|
||||
RefPtr<Element> table =
|
||||
aTable ?
|
||||
GetElementOrParentByTagNameInternal(*nsGkAtoms::table, *aTable) :
|
||||
GetElementOrParentByTagNameAtSelection(*selection, *nsGkAtoms::table);
|
||||
if (NS_WARN_IF(!table)) {
|
||||
// Don't fail if we didn't find a table.
|
||||
return NS_OK;
|
||||
}
|
||||
GetElementOrParentByTagName(NS_LITERAL_STRING("table"),
|
||||
aTable);
|
||||
// Don't fail if we didn't find a table
|
||||
NS_ENSURE_TRUE(table, NS_OK);
|
||||
|
||||
int32_t rowCount, colCount, rowIndex, colIndex;
|
||||
nsresult rv = GetTableSize(table, &rowCount, &colCount);
|
||||
|
@ -2606,19 +2561,11 @@ HTMLEditor::GetCellIndexes(Element* aCell,
|
|||
*aColIndex=0; // initialize out params
|
||||
NS_ENSURE_ARG_POINTER(aColIndex);
|
||||
*aRowIndex=0;
|
||||
// Needs to stay alive while we're using aCell, since it may be keeping it
|
||||
// alive.
|
||||
// XXX Looks like it's safe to use raw pointer here. However, layout code
|
||||
// change won't be handled by editor developers so that it must be safe
|
||||
// to keep using RefPtr here.
|
||||
RefPtr<Element> cell;
|
||||
RefPtr<Element> cell; // Needs to stay alive while we're using
|
||||
// aCell, since it may be keeping it alive.
|
||||
if (!aCell) {
|
||||
RefPtr<Selection> selection = GetSelection();
|
||||
if (NS_WARN_IF(!selection)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
// Get the selected cell or the cell enclosing the selection anchor
|
||||
cell = GetElementOrParentByTagNameAtSelection(*selection, *nsGkAtoms::td);
|
||||
cell = GetElementOrParentByTagName(NS_LITERAL_STRING("td"), nullptr);
|
||||
if (!cell) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -2685,31 +2632,12 @@ HTMLEditor::GetTableSize(Element* aTable,
|
|||
*aRowCount = 0;
|
||||
*aColCount = 0;
|
||||
// Get the selected talbe or the table enclosing the selection anchor
|
||||
// XXX Looks like it's safe to use raw pointer here. However, layout code
|
||||
// change won't be handled by editor developers so that it must be safe
|
||||
// to keep using RefPtr here.
|
||||
RefPtr<Element> table;
|
||||
if (aTable) {
|
||||
table = GetElementOrParentByTagNameInternal(*nsGkAtoms::table, *aTable);
|
||||
if (NS_WARN_IF(!table)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
} else {
|
||||
RefPtr<Selection> selection = GetSelection();
|
||||
if (NS_WARN_IF(!selection)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
table =
|
||||
GetElementOrParentByTagNameAtSelection(*selection, *nsGkAtoms::table);
|
||||
if (NS_WARN_IF(!table)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
RefPtr<Element> table =
|
||||
GetElementOrParentByTagName(NS_LITERAL_STRING("table"), aTable);
|
||||
NS_ENSURE_TRUE(table, NS_ERROR_FAILURE);
|
||||
|
||||
nsTableWrapperFrame* tableFrame = do_QueryFrame(table->GetPrimaryFrame());
|
||||
if (NS_WARN_IF(!tableFrame)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
NS_ENSURE_TRUE(tableFrame, NS_ERROR_FAILURE);
|
||||
|
||||
*aRowCount = tableFrame->GetRowCount();
|
||||
*aColCount = tableFrame->GetColCount();
|
||||
|
@ -2749,19 +2677,10 @@ HTMLEditor::GetCellDataAt(Element* aTable,
|
|||
|
||||
*aCell = nullptr;
|
||||
|
||||
// needs to live while we use aTable
|
||||
// XXX Really? Looks like it's safe to use raw pointer here.
|
||||
// However, layout code change won't be handled by editor developers
|
||||
// so that it must be safe to keep using RefPtr here.
|
||||
RefPtr<Element> table;
|
||||
RefPtr<Element> table; // needs to live while we use aTable
|
||||
if (!aTable) {
|
||||
RefPtr<Selection> selection = GetSelection();
|
||||
if (NS_WARN_IF(!selection)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
// Get the selected table or the table enclosing the selection anchor.
|
||||
table =
|
||||
GetElementOrParentByTagNameAtSelection(*selection, *nsGkAtoms::table);
|
||||
// Get the selected table or the table enclosing the selection anchor
|
||||
table = GetElementOrParentByTagName(NS_LITERAL_STRING("table"), nullptr);
|
||||
if (!table) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -2800,22 +2719,11 @@ HTMLEditor::GetCellAt(Element* aTable,
|
|||
NS_ENSURE_ARG_POINTER(aCell);
|
||||
*aCell = nullptr;
|
||||
|
||||
// Needs to live as long as we use aTable
|
||||
// XXX Really? Looks like it's safe to use raw pointer here.
|
||||
// However, layout code change won't be handled by editor developers
|
||||
// so that it must be safe to keep using RefPtr here.
|
||||
RefPtr<Element> table;
|
||||
RefPtr<Element> table; // Needs to live as long as we use aTable
|
||||
if (!aTable) {
|
||||
RefPtr<Selection> selection = GetSelection();
|
||||
if (NS_WARN_IF(!selection)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
// Get the selected table or the table enclosing the selection anchor.
|
||||
table =
|
||||
GetElementOrParentByTagNameAtSelection(*selection, *nsGkAtoms::table);
|
||||
if (NS_WARN_IF(!table)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
// Get the selected table or the table enclosing the selection anchor
|
||||
table = GetElementOrParentByTagName(NS_LITERAL_STRING("table"), nullptr);
|
||||
NS_ENSURE_TRUE(table, NS_ERROR_FAILURE);
|
||||
aTable = table;
|
||||
}
|
||||
|
||||
|
@ -2883,9 +2791,7 @@ HTMLEditor::GetCellContext(Selection** aSelection,
|
|||
}
|
||||
|
||||
RefPtr<Selection> selection = GetSelection();
|
||||
if (NS_WARN_IF(!selection)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
NS_ENSURE_TRUE(selection, NS_ERROR_FAILURE);
|
||||
|
||||
if (aSelection) {
|
||||
*aSelection = selection.get();
|
||||
|
@ -2923,7 +2829,6 @@ HTMLEditor::GetCellContext(Selection** aSelection,
|
|||
}
|
||||
|
||||
// We found a cell
|
||||
MOZ_ASSERT(cellOrTableElement);
|
||||
cell = cellOrTableElement;
|
||||
}
|
||||
if (aCell) {
|
||||
|
@ -2932,11 +2837,9 @@ HTMLEditor::GetCellContext(Selection** aSelection,
|
|||
}
|
||||
|
||||
// Get containing table
|
||||
table = GetElementOrParentByTagNameInternal(*nsGkAtoms::table, *cell);
|
||||
if (NS_WARN_IF(!table)) {
|
||||
// Cell must be in a table, so fail if not found
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
table = GetElementOrParentByTagName(NS_LITERAL_STRING("table"), cell);
|
||||
// Cell must be in a table, so fail if not found
|
||||
NS_ENSURE_TRUE(table, NS_ERROR_FAILURE);
|
||||
if (aTable) {
|
||||
table.forget(aTable);
|
||||
}
|
||||
|
@ -3254,11 +3157,13 @@ HTMLEditor::GetSelectedOrParentTableElement(nsAString& aTagName,
|
|||
getter_AddRefs(tableOrCellElement));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
NS_NAMED_LITERAL_STRING(tdName, "td");
|
||||
|
||||
if (tableOrCellElement) {
|
||||
// Each cell is in its own selection range,
|
||||
// so count signals multiple-cell selection
|
||||
*aSelectedCount = selection->RangeCount();
|
||||
aTagName = NS_LITERAL_STRING("td");
|
||||
aTagName = tdName;
|
||||
} else {
|
||||
nsCOMPtr<nsINode> anchorNode = selection->GetAnchorNode();
|
||||
if (NS_WARN_IF(!anchorNode)) {
|
||||
|
@ -3271,7 +3176,7 @@ HTMLEditor::GetSelectedOrParentTableElement(nsAString& aTagName,
|
|||
if (selectedNode) {
|
||||
if (selectedNode->IsHTMLElement(nsGkAtoms::td)) {
|
||||
tableOrCellElement = selectedNode->AsElement();
|
||||
aTagName = NS_LITERAL_STRING("td");
|
||||
aTagName = tdName;
|
||||
// Each cell is in its own selection range,
|
||||
// so count signals multiple-cell selection
|
||||
*aSelectedCount = selection->RangeCount();
|
||||
|
@ -3288,10 +3193,9 @@ HTMLEditor::GetSelectedOrParentTableElement(nsAString& aTagName,
|
|||
}
|
||||
if (!tableOrCellElement) {
|
||||
// Didn't find a table element -- find a cell parent
|
||||
tableOrCellElement =
|
||||
GetElementOrParentByTagNameInternal(*nsGkAtoms::td, *anchorNode);
|
||||
tableOrCellElement = GetElementOrParentByTagName(tdName, anchorNode);
|
||||
if (tableOrCellElement) {
|
||||
aTagName = NS_LITERAL_STRING("td");
|
||||
aTagName = tdName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3310,20 +3214,8 @@ HTMLEditor::GetSelectedCellsType(Element* aElement,
|
|||
|
||||
// Be sure we have a table element
|
||||
// (if aElement is null, this uses selection's anchor node)
|
||||
RefPtr<Element> table;
|
||||
if (aElement) {
|
||||
table = GetElementOrParentByTagNameInternal(*nsGkAtoms::table, *aElement);
|
||||
} else {
|
||||
RefPtr<Selection> selection = GetSelection();
|
||||
if (NS_WARN_IF(!selection)) {
|
||||
// If there is no Selection, the following GetTableSize() will return
|
||||
// nullptr if we set first argument to nullptr. So, let's return error
|
||||
// in this case.
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
table =
|
||||
GetElementOrParentByTagNameAtSelection(*selection, *nsGkAtoms::table);
|
||||
}
|
||||
RefPtr<Element> table =
|
||||
GetElementOrParentByTagName(NS_LITERAL_STRING("table"), aElement);
|
||||
|
||||
// table might be null at this point, but if so GetTableSize will fail.
|
||||
int32_t rowCount, colCount;
|
||||
|
|
|
@ -302,23 +302,24 @@ interface nsIHTMLEditor : nsISupports
|
|||
void align(in AString aAlign);
|
||||
|
||||
/**
|
||||
* GetElementOrParentByTagName() looks for an element node whose name matches
|
||||
* aTagName from aNode or anchor node of Selection to <body> element.
|
||||
* Return the input node or a parent matching the given aTagName,
|
||||
* starting the search at the supplied node.
|
||||
* An example of use is for testing if a node is in a table cell
|
||||
* given a selection anchor node.
|
||||
*
|
||||
* @param aTagName The tag name which you want to look for.
|
||||
* Must not be empty string.
|
||||
* If "list", the result may be <ul>, <ol> or <dl>
|
||||
* element.
|
||||
* If "td", the result may be <td> or <th>.
|
||||
* If "href", the result may be <a> element
|
||||
* which has "href" attribute with non-empty value.
|
||||
* If "anchor", the result may be <a> which has
|
||||
* "name" attribute with non-empty value.
|
||||
* @param aNode If non-null, this starts to look for the result
|
||||
* from it. Otherwise, i.e., null, starts from
|
||||
* anchor node of Selection.
|
||||
* @return If an element which matches aTagName, returns
|
||||
* an Element. Otherwise, nullptr.
|
||||
* @param aTagName The HTML tagname
|
||||
* Special input values:
|
||||
* Use "href" to get a link node
|
||||
* (an "A" tag with the "href" attribute set)
|
||||
* Use "anchor" or "namedanchor" to get a named anchor node
|
||||
* (an "A" tag with the "name" attribute set)
|
||||
* Use "list" to get an OL, UL, or DL list node
|
||||
* Use "td" to get either a TD or TH cell node
|
||||
*
|
||||
* @param aNode The node in the document to start the search.
|
||||
* If it is null, the anchor node of the current selection is used.
|
||||
* @return NS_EDITOR_ELEMENT_NOT_FOUND if an element is not found
|
||||
* (passes NS_SUCCEEDED macro)
|
||||
*/
|
||||
Element getElementOrParentByTagName(in AString aTagName,
|
||||
in Node aNode);
|
||||
|
|
ΠΠ°Π³ΡΡΠ·ΠΊΠ°β¦
Π‘ΡΡΠ»ΠΊΠ° Π² Π½ΠΎΠ²ΠΎΠΉ Π·Π°Π΄Π°ΡΠ΅