зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1002429 part 4 - Clean up nsHTMLEditor::CollapseSelectionToDeepestNonTableFirstChild; r=ehsan
This commit is contained in:
Родитель
c4c9d0bfa2
Коммит
b06c07ace4
|
@ -1095,8 +1095,8 @@ nsHTMLEditor::TabInTable(bool inIsShift, bool* outHandled)
|
|||
if (node && nsHTMLEditUtils::IsTableCell(node) &&
|
||||
GetEnclosingTable(node) == tbl)
|
||||
{
|
||||
res = CollapseSelectionToDeepestNonTableFirstChild(nullptr, node);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
CollapseSelectionToDeepestNonTableFirstChild(nullptr,
|
||||
iter->GetCurrentNode());
|
||||
*outHandled = true;
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1142,41 +1142,34 @@ NS_IMETHODIMP nsHTMLEditor::CreateBR(nsIDOMNode *aNode, int32_t aOffset, nsCOMPt
|
|||
return CreateBRImpl(address_of(parent), &offset, outBRNode, aSelect);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLEditor::CollapseSelectionToDeepestNonTableFirstChild(nsISelection *aSelection, nsIDOMNode *aNode)
|
||||
void
|
||||
nsHTMLEditor::CollapseSelectionToDeepestNonTableFirstChild(
|
||||
Selection* aSelection, nsINode* aNode)
|
||||
{
|
||||
NS_ENSURE_TRUE(aNode, NS_ERROR_NULL_POINTER);
|
||||
nsresult res;
|
||||
MOZ_ASSERT(aNode);
|
||||
|
||||
nsCOMPtr<nsISelection> selection;
|
||||
if (aSelection)
|
||||
{
|
||||
selection = aSelection;
|
||||
} else {
|
||||
res = GetSelection(getter_AddRefs(selection));
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
NS_ENSURE_TRUE(selection, NS_ERROR_FAILURE);
|
||||
nsRefPtr<Selection> selection = aSelection;
|
||||
if (!selection) {
|
||||
selection = GetSelection();
|
||||
}
|
||||
nsCOMPtr<nsIDOMNode> node = aNode;
|
||||
nsCOMPtr<nsIDOMNode> child;
|
||||
|
||||
do {
|
||||
node->GetFirstChild(getter_AddRefs(child));
|
||||
|
||||
if (child)
|
||||
{
|
||||
// Stop if we find a table
|
||||
// don't want to go into nested tables
|
||||
if (nsHTMLEditUtils::IsTable(child)) break;
|
||||
// hey, it'g gotta be a container too!
|
||||
if (!IsContainer(child)) break;
|
||||
node = child;
|
||||
if (!selection) {
|
||||
// Nothing to do
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsINode> node = aNode;
|
||||
|
||||
for (nsCOMPtr<nsIContent> child = node->GetFirstChild();
|
||||
child;
|
||||
child = child->GetFirstChild()) {
|
||||
// Stop if we find a table, don't want to go into nested tables
|
||||
if (nsHTMLEditUtils::IsTable(child) || !IsContainer(child)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (child);
|
||||
node = child;
|
||||
};
|
||||
|
||||
selection->Collapse(node,0);
|
||||
return NS_OK;
|
||||
selection->Collapse(node, 0);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -344,7 +344,8 @@ public:
|
|||
// This will stop at a table, however, since we don't want to
|
||||
// "drill down" into nested tables.
|
||||
// aSelection is optional -- if null, we get current seletion
|
||||
nsresult CollapseSelectionToDeepestNonTableFirstChild(nsISelection *aSelection, nsIDOMNode *aNode);
|
||||
void CollapseSelectionToDeepestNonTableFirstChild(
|
||||
mozilla::dom::Selection* aSelection, nsINode* aNode);
|
||||
|
||||
/**
|
||||
* aNode must be a non-null text node.
|
||||
|
|
|
@ -3086,9 +3086,8 @@ nsHTMLEditor::SetSelectionAfterTableEdit(nsIDOMElement* aTable, int32_t aRow, in
|
|||
{
|
||||
NS_ENSURE_TRUE(aTable, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
nsCOMPtr<nsISelection>selection;
|
||||
nsresult res = GetSelection(getter_AddRefs(selection));
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
nsRefPtr<Selection> selection = GetSelection();
|
||||
nsresult res;
|
||||
|
||||
if (!selection)
|
||||
{
|
||||
|
@ -3117,7 +3116,11 @@ nsHTMLEditor::SetSelectionAfterTableEdit(nsIDOMElement* aTable, int32_t aRow, in
|
|||
// but don't go into nested tables
|
||||
// TODO: Should we really be placing the caret at the END
|
||||
// of the cell content?
|
||||
return CollapseSelectionToDeepestNonTableFirstChild(selection, cell);
|
||||
nsCOMPtr<nsINode> cellNode = do_QueryInterface(cell);
|
||||
if (cellNode) {
|
||||
CollapseSelectionToDeepestNonTableFirstChild(selection, cellNode);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
} else {
|
||||
// Setup index to find another cell in the
|
||||
|
|
Загрузка…
Ссылка в новой задаче