fix for 45281, cannot insert a table caption. r=fm

This commit is contained in:
jfrancis%netscape.com 2000-08-13 23:53:34 +00:00
Родитель 98f503b9ee
Коммит 43aec439d4
12 изменённых файлов: 124 добавлений и 150 удалений

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

@ -1050,7 +1050,7 @@ nsHTMLEditRules::WillDeleteSelection(nsIDOMSelection *aSelection,
return NS_OK; // bail to default
// do not delete across table structures
if (mEditor->IsTableElement(leftParent) || mEditor->IsTableElement(rightParent))
if (nsHTMLEditUtils::IsTableElement(leftParent) || nsHTMLEditUtils::IsTableElement(rightParent))
{
*aCancel = PR_TRUE;
return NS_OK;
@ -1159,7 +1159,7 @@ nsHTMLEditRules::WillDeleteSelection(nsIDOMSelection *aSelection,
return NS_OK; // bail to default
// do not delete across table structures
if (mEditor->IsTableElement(leftParent) || mEditor->IsTableElement(rightParent))
if (nsHTMLEditUtils::IsTableElement(leftParent) || nsHTMLEditUtils::IsTableElement(rightParent))
{
*aCancel = PR_TRUE;
return NS_OK;
@ -1197,7 +1197,7 @@ nsHTMLEditRules::WillDeleteSelection(nsIDOMSelection *aSelection,
// Note: do NOT delete table elements this way.
PRBool bIsEmptyNode;
res = mEditor->IsEmptyNode(node, &bIsEmptyNode, PR_TRUE, PR_FALSE);
if (bIsEmptyNode && !mEditor->IsTableElement(node))
if (bIsEmptyNode && !nsHTMLEditUtils::IsTableElement(node))
nodeToDelete = node;
else
{
@ -1336,7 +1336,7 @@ nsHTMLEditRules::WillDeleteSelection(nsIDOMSelection *aSelection,
rightParent = mEditor->GetBlockNodeParent(endNode);
// do not delete across table structures
if (mEditor->IsTableElement(leftParent) || mEditor->IsTableElement(rightParent))
if (nsHTMLEditUtils::IsTableElement(leftParent) || nsHTMLEditUtils::IsTableElement(rightParent))
{
*aCancel = PR_TRUE;
return NS_OK;
@ -2346,7 +2346,7 @@ nsHTMLEditRules::WillAlign(nsIDOMSelection *aSelection,
// if it's a table element (but not a table), forget any "current" div, and
// instead put divs inside any th's and td's inside the table element
if (mEditor->IsTableElement(curNode) && !mEditor->IsTable(curNode))
if (nsHTMLEditUtils::IsTableElement(curNode) && !nsHTMLEditUtils::IsTable(curNode))
{
res = AlignTableElement(curNode, alignType);
if (NS_FAILED(res)) return res;
@ -2417,7 +2417,7 @@ nsHTMLEditRules::AlignTableElement(nsIDOMNode *aNode, const nsString *alignType)
if (NS_FAILED(res)) return res;
node = do_QueryInterface(content);
if (!node) return NS_ERROR_FAILURE;
if (mEditor->IsTableCell(node))
if (nsHTMLEditUtils::IsTableCell(node))
{
isupports = do_QueryInterface(node);
arrayOfNodes->AppendElement(isupports);
@ -2514,7 +2514,7 @@ nsHTMLEditRules::GetInnerContent(nsIDOMNode *aNode, nsISupportsArray *outArrayOf
{
if ( ( aList && (nsHTMLEditUtils::IsList(node) ||
nsHTMLEditUtils::IsListItem(node) ) )
|| ( aTbl && mEditor->IsTableElement(node) ) )
|| ( aTbl && nsHTMLEditUtils::IsTableElement(node) ) )
{
res = GetInnerContent(node, outArrayOfNodes, aList, aTbl);
if (NS_FAILED(res)) return res;
@ -3096,7 +3096,7 @@ nsHTMLEditRules::GetListActionNodes(nsCOMPtr<nsISupportsArray> *outArrayOfNodes,
// scan for table elements. If we find table elements other than table,
// replace it with a list of any editable non-table content.
if (mEditor->IsTableElement(testNode) && !mEditor->IsTable(testNode))
if (nsHTMLEditUtils::IsTableElement(testNode) && !nsHTMLEditUtils::IsTable(testNode))
{
(*outArrayOfNodes)->RemoveElementAt(i);
res = GetInnerContent(testNode, *outArrayOfNodes, PR_FALSE);
@ -3166,7 +3166,7 @@ nsHTMLEditRules::GetParagraphFormatNodes(nsCOMPtr<nsISupportsArray> *outArrayOfN
// 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 (mEditor->IsTableElement(testNode) ||
if (nsHTMLEditUtils::IsTableElement(testNode) ||
nsHTMLEditUtils::IsList(testNode) ||
nsHTMLEditUtils::IsListItem(testNode) )
{
@ -3709,7 +3709,7 @@ nsHTMLEditRules::ShouldMakeEmptyBlock(nsIDOMSelection *aSelection,
if (NS_FAILED(res)) return res;
// is selection point in the body? or a cell?
if (nsHTMLEditUtils::IsBody(parent) || mEditor->IsTableCell(parent))
if (nsHTMLEditUtils::IsBody(parent) || nsHTMLEditUtils::IsTableCellOrCaption(parent))
{
*outMakeEmpty = PR_TRUE;
return res;
@ -3816,7 +3816,7 @@ nsHTMLEditRules::MakeBlockquote(nsISupportsArray *arrayOfNodes)
if (NS_FAILED(res)) return res;
// if the node is a table element or list item, dive inside
if ( (mEditor->IsTableElement(curNode) && !(mEditor->IsTable(curNode))) ||
if ( (nsHTMLEditUtils::IsTableElement(curNode) && !(nsHTMLEditUtils::IsTable(curNode))) ||
nsHTMLEditUtils::IsListItem(curNode) )
{
curBlock = 0; // forget any previous block
@ -4234,7 +4234,7 @@ nsHTMLEditRules::AdjustSpecialBreaks(PRBool aSafeToAskFrames)
res = mEditor->IsEmptyNode(node, &bIsEmptyNode, PR_FALSE, PR_FALSE, aSafeToAskFrames);
if (NS_FAILED(res)) return res;
if (bIsEmptyNode
&& (nsHTMLEditUtils::IsListItem(node) || mEditor->IsTableCell(node)))
&& (nsHTMLEditUtils::IsListItem(node) || nsHTMLEditUtils::IsTableCellOrCaption(node)))
{
isupports = do_QueryInterface(node);
arrayOfNodes->AppendElement(isupports);
@ -4541,7 +4541,7 @@ nsHTMLEditRules::InDifferentTableElements(nsIDOMNode *aNode1, nsIDOMNode *aNode2
nsCOMPtr<nsIDOMNode> tn1, tn2, node = aNode1, temp;
while (node && !mEditor->IsTableElement(node))
while (node && !nsHTMLEditUtils::IsTableElement(node))
{
node->GetParentNode(getter_AddRefs(temp));
node = temp;
@ -4549,7 +4549,7 @@ nsHTMLEditRules::InDifferentTableElements(nsIDOMNode *aNode1, nsIDOMNode *aNode2
tn1 = node;
node = aNode2;
while (node && !mEditor->IsTableElement(node))
while (node && !nsHTMLEditUtils::IsTableElement(node))
{
node->GetParentNode(getter_AddRefs(temp));
node = temp;

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

@ -233,6 +233,26 @@ nsHTMLEditUtils::IsListItem(nsIDOMNode *node)
}
///////////////////////////////////////////////////////////////////////////
// IsTableElement: true if node an html table, td, tr, ...
//
PRBool
nsHTMLEditUtils::IsTableElement(nsIDOMNode *node)
{
NS_PRECONDITION(node, "null node passed to nsHTMLEditor::IsTableElement");
nsAutoString tagName;
nsEditor::GetTagString(node,tagName);
if (tagName.EqualsWithConversion("table") || tagName.EqualsWithConversion("tr") ||
tagName.EqualsWithConversion("td") || tagName.EqualsWithConversion("th") ||
tagName.EqualsWithConversion("thead") || tagName.EqualsWithConversion("tfoot") ||
tagName.EqualsWithConversion("tbody") || tagName.EqualsWithConversion("caption"))
{
return PR_TRUE;
}
return PR_FALSE;
}
///////////////////////////////////////////////////////////////////////////
// IsTable: true if node an html table
//
@ -284,6 +304,26 @@ nsHTMLEditUtils::IsTableCell(nsIDOMNode *node)
}
///////////////////////////////////////////////////////////////////////////
// IsTableCell: true if node an html td or th
//
PRBool
nsHTMLEditUtils::IsTableCellOrCaption(nsIDOMNode *node)
{
NS_PRECONDITION(node, "null parent passed to nsHTMLEditUtils::IsTableCell");
nsAutoString tag;
nsEditor::GetTagString(node,tag);
tag.ToLowerCase();
if (tag.EqualsWithConversion("td") ||
tag.EqualsWithConversion("th") ||
tag.EqualsWithConversion("caption") )
{
return PR_TRUE;
}
return PR_FALSE;
}
///////////////////////////////////////////////////////////////////////////
// IsList: true if node an html list
//

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

@ -46,7 +46,9 @@ public:
static PRBool IsListItem(nsIDOMNode *aNode);
static PRBool IsTable(nsIDOMNode *aNode);
static PRBool IsTableRow(nsIDOMNode *aNode);
static PRBool IsTableElement(nsIDOMNode *aNode);
static PRBool IsTableCell(nsIDOMNode *aNode);
static PRBool IsTableCellOrCaption(nsIDOMNode *aNode);
static PRBool IsList(nsIDOMNode *aNode);
static PRBool IsOrderedList(nsIDOMNode *aNode);
static PRBool IsUnorderedList(nsIDOMNode *aNode);

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

@ -730,7 +730,7 @@ NS_IMETHODIMP nsHTMLEditor::EditorKeyPress(nsIDOMKeyEvent* aKeyEvent)
{
PRBool bHandled = PR_FALSE;
if (IsTableElement(blockParent))
if (nsHTMLEditUtils::IsTableElement(blockParent))
res = TabInTable(isShift, &bHandled);
else if (nsHTMLEditUtils::IsListItem(blockParent))
{
@ -845,7 +845,7 @@ NS_IMETHODIMP nsHTMLEditor::TabInTable(PRBool inIsShift, PRBool *outHandled)
res = iter->CurrentNode(getter_AddRefs(cNode));
if (NS_FAILED(res)) break;
node = do_QueryInterface(cNode);
if (IsTableCell(node) && (GetEnclosingTable(node) == tbl))
if (nsHTMLEditUtils::IsTableCell(node) && (GetEnclosingTable(node) == tbl))
{
res = CollapseSelectionToDeepestNonTableFirstChild(nsnull, node);
if (NS_FAILED(res)) return res;
@ -2262,7 +2262,7 @@ nsHTMLEditor::CollapseSelectionToDeepestNonTableFirstChild(nsIDOMSelection *aSel
{
// Stop if we find a table
// don't want to go into nested tables
if (IsTable(child)) break;
if (nsHTMLEditUtils::IsTable(child)) break;
// hey, it'g gotta be a container too!
if (!IsContainer(child)) break;
node = child;
@ -6237,58 +6237,6 @@ nsHTMLEditor::IsSubordinateBlock(nsString &aTag, PRBool &aIsTag)
return NS_OK;
}
///////////////////////////////////////////////////////////////////////////
// IsTable: true if node an html table
//
PRBool
nsHTMLEditor::IsTable(nsIDOMNode *node)
{
NS_PRECONDITION(node, "null node passed to nsHTMLEditor::IsTable");
nsAutoString tag;
nsEditor::GetTagString(node,tag);
if (tag.EqualsWithConversion("table"))
{
return PR_TRUE;
}
return PR_FALSE;
}
///////////////////////////////////////////////////////////////////////////
// IsTableCell: true if node an html td
//
PRBool
nsHTMLEditor::IsTableCell(nsIDOMNode *node)
{
NS_PRECONDITION(node, "null node passed to nsHTMLEditor::IsTableCell");
nsAutoString tag;
nsEditor::GetTagString(node,tag);
if (tag.EqualsWithConversion("td") || tag.EqualsWithConversion("th"))
{
return PR_TRUE;
}
return PR_FALSE;
}
///////////////////////////////////////////////////////////////////////////
// IsTableElement: true if node an html table, td, tr, ...
//
PRBool
nsHTMLEditor::IsTableElement(nsIDOMNode *node)
{
NS_PRECONDITION(node, "null node passed to nsHTMLEditor::IsTableElement");
nsAutoString tagName;
nsEditor::GetTagString(node,tagName);
if (tagName.EqualsWithConversion("table") || tagName.EqualsWithConversion("tr") ||
tagName.EqualsWithConversion("td") || tagName.EqualsWithConversion("th") ||
tagName.EqualsWithConversion("thead") || tagName.EqualsWithConversion("tfoot") ||
tagName.EqualsWithConversion("tbody") || tagName.EqualsWithConversion("caption"))
{
return PR_TRUE;
}
return PR_FALSE;
}
///////////////////////////////////////////////////////////////////////////
@ -6304,7 +6252,7 @@ nsHTMLEditor::GetEnclosingTable(nsIDOMNode *aNode)
{
tmp = GetBlockNodeParent(node);
if (!tmp) break;
if (IsTable(tmp)) tbl = tmp;
if (nsHTMLEditUtils::IsTable(tmp)) tbl = tmp;
node = tmp;
}
return tbl;
@ -7249,7 +7197,7 @@ nsHTMLEditor::IsEmptyNode( nsIDOMNode *aNode,
// cells empty if caller desires.
if (!IsContainer(aNode) || nsHTMLEditUtils::IsAnchor(aNode) ||
(aListOrCellNotEmpty && nsHTMLEditUtils::IsListItem(aNode)) ||
(aListOrCellNotEmpty && nsHTMLEditUtils::IsTableCell(aNode)) )
(aListOrCellNotEmpty && nsHTMLEditUtils::nsHTMLEditUtils::IsTableCell(aNode)) )
{
*outIsEmptyNode = PR_FALSE;
return NS_OK;

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

@ -442,9 +442,6 @@ protected:
NS_IMETHOD IsSubordinateBlock(nsString &aTag, PRBool &aIsTag);
static PRBool IsTable(nsIDOMNode *aNode);
static PRBool IsTableCell(nsIDOMNode *aNode);
static PRBool IsTableElement(nsIDOMNode *aNode);
static nsCOMPtr<nsIDOMNode> GetEnclosingTable(nsIDOMNode *aNode);
/** content-based query returns PR_TRUE if <aProperty aAttribute=aValue> effects aNode

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

@ -2786,7 +2786,7 @@ nsHTMLEditor::GetCellFromRange(nsIDOMRange *aRange, nsIDOMElement **aCell)
// so tell caller the cell wasn't found
if (startParent == endParent &&
endOffset == startOffset+1 &&
IsTableCell(childNode))
nsHTMLEditUtils::IsTableCell(childNode))
{
// Should we also test if frame is selected? (Use GetCellDataAt())
// (Let's not for now -- more efficient)

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

@ -1050,7 +1050,7 @@ nsHTMLEditRules::WillDeleteSelection(nsIDOMSelection *aSelection,
return NS_OK; // bail to default
// do not delete across table structures
if (mEditor->IsTableElement(leftParent) || mEditor->IsTableElement(rightParent))
if (nsHTMLEditUtils::IsTableElement(leftParent) || nsHTMLEditUtils::IsTableElement(rightParent))
{
*aCancel = PR_TRUE;
return NS_OK;
@ -1159,7 +1159,7 @@ nsHTMLEditRules::WillDeleteSelection(nsIDOMSelection *aSelection,
return NS_OK; // bail to default
// do not delete across table structures
if (mEditor->IsTableElement(leftParent) || mEditor->IsTableElement(rightParent))
if (nsHTMLEditUtils::IsTableElement(leftParent) || nsHTMLEditUtils::IsTableElement(rightParent))
{
*aCancel = PR_TRUE;
return NS_OK;
@ -1197,7 +1197,7 @@ nsHTMLEditRules::WillDeleteSelection(nsIDOMSelection *aSelection,
// Note: do NOT delete table elements this way.
PRBool bIsEmptyNode;
res = mEditor->IsEmptyNode(node, &bIsEmptyNode, PR_TRUE, PR_FALSE);
if (bIsEmptyNode && !mEditor->IsTableElement(node))
if (bIsEmptyNode && !nsHTMLEditUtils::IsTableElement(node))
nodeToDelete = node;
else
{
@ -1336,7 +1336,7 @@ nsHTMLEditRules::WillDeleteSelection(nsIDOMSelection *aSelection,
rightParent = mEditor->GetBlockNodeParent(endNode);
// do not delete across table structures
if (mEditor->IsTableElement(leftParent) || mEditor->IsTableElement(rightParent))
if (nsHTMLEditUtils::IsTableElement(leftParent) || nsHTMLEditUtils::IsTableElement(rightParent))
{
*aCancel = PR_TRUE;
return NS_OK;
@ -2346,7 +2346,7 @@ nsHTMLEditRules::WillAlign(nsIDOMSelection *aSelection,
// if it's a table element (but not a table), forget any "current" div, and
// instead put divs inside any th's and td's inside the table element
if (mEditor->IsTableElement(curNode) && !mEditor->IsTable(curNode))
if (nsHTMLEditUtils::IsTableElement(curNode) && !nsHTMLEditUtils::IsTable(curNode))
{
res = AlignTableElement(curNode, alignType);
if (NS_FAILED(res)) return res;
@ -2417,7 +2417,7 @@ nsHTMLEditRules::AlignTableElement(nsIDOMNode *aNode, const nsString *alignType)
if (NS_FAILED(res)) return res;
node = do_QueryInterface(content);
if (!node) return NS_ERROR_FAILURE;
if (mEditor->IsTableCell(node))
if (nsHTMLEditUtils::IsTableCell(node))
{
isupports = do_QueryInterface(node);
arrayOfNodes->AppendElement(isupports);
@ -2514,7 +2514,7 @@ nsHTMLEditRules::GetInnerContent(nsIDOMNode *aNode, nsISupportsArray *outArrayOf
{
if ( ( aList && (nsHTMLEditUtils::IsList(node) ||
nsHTMLEditUtils::IsListItem(node) ) )
|| ( aTbl && mEditor->IsTableElement(node) ) )
|| ( aTbl && nsHTMLEditUtils::IsTableElement(node) ) )
{
res = GetInnerContent(node, outArrayOfNodes, aList, aTbl);
if (NS_FAILED(res)) return res;
@ -3096,7 +3096,7 @@ nsHTMLEditRules::GetListActionNodes(nsCOMPtr<nsISupportsArray> *outArrayOfNodes,
// scan for table elements. If we find table elements other than table,
// replace it with a list of any editable non-table content.
if (mEditor->IsTableElement(testNode) && !mEditor->IsTable(testNode))
if (nsHTMLEditUtils::IsTableElement(testNode) && !nsHTMLEditUtils::IsTable(testNode))
{
(*outArrayOfNodes)->RemoveElementAt(i);
res = GetInnerContent(testNode, *outArrayOfNodes, PR_FALSE);
@ -3166,7 +3166,7 @@ nsHTMLEditRules::GetParagraphFormatNodes(nsCOMPtr<nsISupportsArray> *outArrayOfN
// 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 (mEditor->IsTableElement(testNode) ||
if (nsHTMLEditUtils::IsTableElement(testNode) ||
nsHTMLEditUtils::IsList(testNode) ||
nsHTMLEditUtils::IsListItem(testNode) )
{
@ -3709,7 +3709,7 @@ nsHTMLEditRules::ShouldMakeEmptyBlock(nsIDOMSelection *aSelection,
if (NS_FAILED(res)) return res;
// is selection point in the body? or a cell?
if (nsHTMLEditUtils::IsBody(parent) || mEditor->IsTableCell(parent))
if (nsHTMLEditUtils::IsBody(parent) || nsHTMLEditUtils::IsTableCellOrCaption(parent))
{
*outMakeEmpty = PR_TRUE;
return res;
@ -3816,7 +3816,7 @@ nsHTMLEditRules::MakeBlockquote(nsISupportsArray *arrayOfNodes)
if (NS_FAILED(res)) return res;
// if the node is a table element or list item, dive inside
if ( (mEditor->IsTableElement(curNode) && !(mEditor->IsTable(curNode))) ||
if ( (nsHTMLEditUtils::IsTableElement(curNode) && !(nsHTMLEditUtils::IsTable(curNode))) ||
nsHTMLEditUtils::IsListItem(curNode) )
{
curBlock = 0; // forget any previous block
@ -4234,7 +4234,7 @@ nsHTMLEditRules::AdjustSpecialBreaks(PRBool aSafeToAskFrames)
res = mEditor->IsEmptyNode(node, &bIsEmptyNode, PR_FALSE, PR_FALSE, aSafeToAskFrames);
if (NS_FAILED(res)) return res;
if (bIsEmptyNode
&& (nsHTMLEditUtils::IsListItem(node) || mEditor->IsTableCell(node)))
&& (nsHTMLEditUtils::IsListItem(node) || nsHTMLEditUtils::IsTableCellOrCaption(node)))
{
isupports = do_QueryInterface(node);
arrayOfNodes->AppendElement(isupports);
@ -4541,7 +4541,7 @@ nsHTMLEditRules::InDifferentTableElements(nsIDOMNode *aNode1, nsIDOMNode *aNode2
nsCOMPtr<nsIDOMNode> tn1, tn2, node = aNode1, temp;
while (node && !mEditor->IsTableElement(node))
while (node && !nsHTMLEditUtils::IsTableElement(node))
{
node->GetParentNode(getter_AddRefs(temp));
node = temp;
@ -4549,7 +4549,7 @@ nsHTMLEditRules::InDifferentTableElements(nsIDOMNode *aNode1, nsIDOMNode *aNode2
tn1 = node;
node = aNode2;
while (node && !mEditor->IsTableElement(node))
while (node && !nsHTMLEditUtils::IsTableElement(node))
{
node->GetParentNode(getter_AddRefs(temp));
node = temp;

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

@ -233,6 +233,26 @@ nsHTMLEditUtils::IsListItem(nsIDOMNode *node)
}
///////////////////////////////////////////////////////////////////////////
// IsTableElement: true if node an html table, td, tr, ...
//
PRBool
nsHTMLEditUtils::IsTableElement(nsIDOMNode *node)
{
NS_PRECONDITION(node, "null node passed to nsHTMLEditor::IsTableElement");
nsAutoString tagName;
nsEditor::GetTagString(node,tagName);
if (tagName.EqualsWithConversion("table") || tagName.EqualsWithConversion("tr") ||
tagName.EqualsWithConversion("td") || tagName.EqualsWithConversion("th") ||
tagName.EqualsWithConversion("thead") || tagName.EqualsWithConversion("tfoot") ||
tagName.EqualsWithConversion("tbody") || tagName.EqualsWithConversion("caption"))
{
return PR_TRUE;
}
return PR_FALSE;
}
///////////////////////////////////////////////////////////////////////////
// IsTable: true if node an html table
//
@ -284,6 +304,26 @@ nsHTMLEditUtils::IsTableCell(nsIDOMNode *node)
}
///////////////////////////////////////////////////////////////////////////
// IsTableCell: true if node an html td or th
//
PRBool
nsHTMLEditUtils::IsTableCellOrCaption(nsIDOMNode *node)
{
NS_PRECONDITION(node, "null parent passed to nsHTMLEditUtils::IsTableCell");
nsAutoString tag;
nsEditor::GetTagString(node,tag);
tag.ToLowerCase();
if (tag.EqualsWithConversion("td") ||
tag.EqualsWithConversion("th") ||
tag.EqualsWithConversion("caption") )
{
return PR_TRUE;
}
return PR_FALSE;
}
///////////////////////////////////////////////////////////////////////////
// IsList: true if node an html list
//

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

@ -46,7 +46,9 @@ public:
static PRBool IsListItem(nsIDOMNode *aNode);
static PRBool IsTable(nsIDOMNode *aNode);
static PRBool IsTableRow(nsIDOMNode *aNode);
static PRBool IsTableElement(nsIDOMNode *aNode);
static PRBool IsTableCell(nsIDOMNode *aNode);
static PRBool IsTableCellOrCaption(nsIDOMNode *aNode);
static PRBool IsList(nsIDOMNode *aNode);
static PRBool IsOrderedList(nsIDOMNode *aNode);
static PRBool IsUnorderedList(nsIDOMNode *aNode);

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

@ -730,7 +730,7 @@ NS_IMETHODIMP nsHTMLEditor::EditorKeyPress(nsIDOMKeyEvent* aKeyEvent)
{
PRBool bHandled = PR_FALSE;
if (IsTableElement(blockParent))
if (nsHTMLEditUtils::IsTableElement(blockParent))
res = TabInTable(isShift, &bHandled);
else if (nsHTMLEditUtils::IsListItem(blockParent))
{
@ -845,7 +845,7 @@ NS_IMETHODIMP nsHTMLEditor::TabInTable(PRBool inIsShift, PRBool *outHandled)
res = iter->CurrentNode(getter_AddRefs(cNode));
if (NS_FAILED(res)) break;
node = do_QueryInterface(cNode);
if (IsTableCell(node) && (GetEnclosingTable(node) == tbl))
if (nsHTMLEditUtils::IsTableCell(node) && (GetEnclosingTable(node) == tbl))
{
res = CollapseSelectionToDeepestNonTableFirstChild(nsnull, node);
if (NS_FAILED(res)) return res;
@ -2262,7 +2262,7 @@ nsHTMLEditor::CollapseSelectionToDeepestNonTableFirstChild(nsIDOMSelection *aSel
{
// Stop if we find a table
// don't want to go into nested tables
if (IsTable(child)) break;
if (nsHTMLEditUtils::IsTable(child)) break;
// hey, it'g gotta be a container too!
if (!IsContainer(child)) break;
node = child;
@ -6237,58 +6237,6 @@ nsHTMLEditor::IsSubordinateBlock(nsString &aTag, PRBool &aIsTag)
return NS_OK;
}
///////////////////////////////////////////////////////////////////////////
// IsTable: true if node an html table
//
PRBool
nsHTMLEditor::IsTable(nsIDOMNode *node)
{
NS_PRECONDITION(node, "null node passed to nsHTMLEditor::IsTable");
nsAutoString tag;
nsEditor::GetTagString(node,tag);
if (tag.EqualsWithConversion("table"))
{
return PR_TRUE;
}
return PR_FALSE;
}
///////////////////////////////////////////////////////////////////////////
// IsTableCell: true if node an html td
//
PRBool
nsHTMLEditor::IsTableCell(nsIDOMNode *node)
{
NS_PRECONDITION(node, "null node passed to nsHTMLEditor::IsTableCell");
nsAutoString tag;
nsEditor::GetTagString(node,tag);
if (tag.EqualsWithConversion("td") || tag.EqualsWithConversion("th"))
{
return PR_TRUE;
}
return PR_FALSE;
}
///////////////////////////////////////////////////////////////////////////
// IsTableElement: true if node an html table, td, tr, ...
//
PRBool
nsHTMLEditor::IsTableElement(nsIDOMNode *node)
{
NS_PRECONDITION(node, "null node passed to nsHTMLEditor::IsTableElement");
nsAutoString tagName;
nsEditor::GetTagString(node,tagName);
if (tagName.EqualsWithConversion("table") || tagName.EqualsWithConversion("tr") ||
tagName.EqualsWithConversion("td") || tagName.EqualsWithConversion("th") ||
tagName.EqualsWithConversion("thead") || tagName.EqualsWithConversion("tfoot") ||
tagName.EqualsWithConversion("tbody") || tagName.EqualsWithConversion("caption"))
{
return PR_TRUE;
}
return PR_FALSE;
}
///////////////////////////////////////////////////////////////////////////
@ -6304,7 +6252,7 @@ nsHTMLEditor::GetEnclosingTable(nsIDOMNode *aNode)
{
tmp = GetBlockNodeParent(node);
if (!tmp) break;
if (IsTable(tmp)) tbl = tmp;
if (nsHTMLEditUtils::IsTable(tmp)) tbl = tmp;
node = tmp;
}
return tbl;
@ -7249,7 +7197,7 @@ nsHTMLEditor::IsEmptyNode( nsIDOMNode *aNode,
// cells empty if caller desires.
if (!IsContainer(aNode) || nsHTMLEditUtils::IsAnchor(aNode) ||
(aListOrCellNotEmpty && nsHTMLEditUtils::IsListItem(aNode)) ||
(aListOrCellNotEmpty && nsHTMLEditUtils::IsTableCell(aNode)) )
(aListOrCellNotEmpty && nsHTMLEditUtils::nsHTMLEditUtils::IsTableCell(aNode)) )
{
*outIsEmptyNode = PR_FALSE;
return NS_OK;

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

@ -442,9 +442,6 @@ protected:
NS_IMETHOD IsSubordinateBlock(nsString &aTag, PRBool &aIsTag);
static PRBool IsTable(nsIDOMNode *aNode);
static PRBool IsTableCell(nsIDOMNode *aNode);
static PRBool IsTableElement(nsIDOMNode *aNode);
static nsCOMPtr<nsIDOMNode> GetEnclosingTable(nsIDOMNode *aNode);
/** content-based query returns PR_TRUE if <aProperty aAttribute=aValue> effects aNode

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

@ -2786,7 +2786,7 @@ nsHTMLEditor::GetCellFromRange(nsIDOMRange *aRange, nsIDOMElement **aCell)
// so tell caller the cell wasn't found
if (startParent == endParent &&
endOffset == startOffset+1 &&
IsTableCell(childNode))
nsHTMLEditUtils::IsTableCell(childNode))
{
// Should we also test if frame is selected? (Use GetCellDataAt())
// (Let's not for now -- more efficient)