New method for table editing (b=20973, r=jfrancis); Use nsIStyleSheet::SetEnable() for editmode stylesheets instead of removing and reloading -- necessary for bug 40767. r=sfraser

This commit is contained in:
cmanske%netscape.com 2000-06-14 04:58:29 +00:00
Родитель 04ea758f0f
Коммит 4f01ada9bf
8 изменённых файлов: 256 добавлений и 74 удалений

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

@ -44,9 +44,10 @@
#include "nsIDOMNodeList.h"
#include "nsICSSLoader.h"
#include "nsICSSStyleSheet.h"
#include "nsIStyleSheet.h"
#include "nsIStyleSet.h"
#include "nsIContent.h"
#include "nsIHTMLContentContainer.h"
#include "nsIStyleSet.h"
#include "nsIURI.h"
#include "nsNetUtil.h"
@ -1271,55 +1272,76 @@ nsEditorShell::SetDisplayMode(PRInt32 aDisplayMode)
if (!styleSheets) return NS_NOINTERFACE;
mDisplayMode = aDisplayMode;
nsCOMPtr<nsIStyleSheet> nsISheet;
nsresult res = NS_OK;
if (aDisplayMode == eDisplayModePreview)
{
// Remove all extra "edit mode" style sheets
// Disable all extra "edit mode" style sheets
if (mEditModeStyleSheet)
{
styleSheets->RemoveOverrideStyleSheet(mEditModeStyleSheet);
mEditModeStyleSheet = nsnull;
nsISheet = do_QueryInterface(mEditModeStyleSheet);
res = nsISheet->SetEnabled(PR_FALSE);
}
if (mAllTagsModeStyleSheet)
{
styleSheets->RemoveOverrideStyleSheet(mAllTagsModeStyleSheet);
mAllTagsModeStyleSheet = nsnull;
nsISheet = do_QueryInterface(mAllTagsModeStyleSheet);
res = nsISheet->SetEnabled(PR_FALSE);
}
}
else if (aDisplayMode == eDisplayModeNormal)
{
// Remove the AllTags sheet
// Disable the AllTags sheet
if (mAllTagsModeStyleSheet)
{
styleSheets->RemoveOverrideStyleSheet(mAllTagsModeStyleSheet);
mAllTagsModeStyleSheet = nsnull;
nsISheet = do_QueryInterface(mAllTagsModeStyleSheet);
res = nsISheet->SetEnabled(PR_FALSE);
}
// We are already in the requested mode
if (mEditModeStyleSheet) return NS_OK;
// If loaded before, enable the sheet
if (mEditModeStyleSheet)
{
nsISheet = do_QueryInterface(mEditModeStyleSheet);
res = nsISheet->SetEnabled(PR_TRUE);
}
else
{
//Load the editmode style sheet
return styleSheets->ApplyOverrideStyleSheet(NS_ConvertASCIItoUCS2("chrome://editor/content/EditorContent.css"),
getter_AddRefs(mEditModeStyleSheet));
//Load the editmode style sheet
res = styleSheets->ApplyOverrideStyleSheet(NS_ConvertASCIItoUCS2("chrome://editor/content/EditorContent.css"),
getter_AddRefs(mEditModeStyleSheet));
}
}
else if (aDisplayMode == eDisplayModeAllTags)
{
// We are already in the requested mode
if (mAllTagsModeStyleSheet) return NS_OK;
//Load the normal mode style sheet
if (!mEditModeStyleSheet)
// If loaded before, enable the sheet
if (mAllTagsModeStyleSheet)
{
nsISheet = do_QueryInterface(mAllTagsModeStyleSheet);
res = nsISheet->SetEnabled(PR_TRUE);
}
else
{
// else load it
res = styleSheets->ApplyOverrideStyleSheet(NS_ConvertASCIItoUCS2("chrome://editor/content/EditorAllTags.css"),
getter_AddRefs(mAllTagsModeStyleSheet));
}
if (mEditModeStyleSheet)
{
nsISheet = do_QueryInterface(mEditModeStyleSheet);
res = nsISheet->SetEnabled(PR_TRUE);
}
else
{
// Note: using "@import url(chrome://editor/content/EditorContent.css);"
// in EditorAllTags.css doesn't seem to work!?
styleSheets->ApplyOverrideStyleSheet(NS_ConvertASCIItoUCS2("chrome://editor/content/EditorContent.css"),
getter_AddRefs(mEditModeStyleSheet));
res = styleSheets->ApplyOverrideStyleSheet(NS_ConvertASCIItoUCS2("chrome://editor/content/EditorContent.css"),
getter_AddRefs(mEditModeStyleSheet));
}
return styleSheets->ApplyOverrideStyleSheet(NS_ConvertASCIItoUCS2("chrome://editor/content/EditorAllTags.css"),
getter_AddRefs(mAllTagsModeStyleSheet));
}
return NS_OK;
return res;
}
NS_IMETHODIMP
@ -1329,21 +1351,25 @@ nsEditorShell::DisplayParagraphMarks(PRBool aShowMarks)
nsCOMPtr<nsIEditorStyleSheets> styleSheets = do_QueryInterface(mEditor);
if (!styleSheets) return NS_NOINTERFACE;
nsCOMPtr<nsIStyleSheet> nsISheet;
if (aShowMarks)
{
// Check if style sheet is already loaded
if (mParagraphMarksStyleSheet) return NS_OK;
//Load the style sheet
// Check if style sheet is already loaded -- just enable it
if (mParagraphMarksStyleSheet)
{
nsISheet = do_QueryInterface(mParagraphMarksStyleSheet);
return nsISheet->SetEnabled(PR_TRUE);
}
//First time used -- load the style sheet
nsCOMPtr<nsICSSStyleSheet> styleSheet;
res = styleSheets->ApplyOverrideStyleSheet(NS_ConvertASCIItoUCS2("chrome://editor/content/EditorParagraphMarks.css"),
getter_AddRefs(mParagraphMarksStyleSheet));
}
else if (mParagraphMarksStyleSheet)
{
res = styleSheets->RemoveOverrideStyleSheet(mParagraphMarksStyleSheet);
mParagraphMarksStyleSheet = nsnull;
// Disable the style sheet
nsISheet = do_QueryInterface(mParagraphMarksStyleSheet);
res = nsISheet->SetEnabled(PR_FALSE);
}
return res;
@ -3834,6 +3860,26 @@ nsEditorShell::DeleteTableColumn(PRInt32 aNumber)
return result;
}
NS_IMETHODIMP
nsEditorShell::SwitchTableCellHeaderType(nsIDOMElement *aSourceCell, nsIDOMElement **aNewCell)
{
nsresult result = NS_NOINTERFACE;
switch (mEditorType)
{
case eHTMLTextEditorType:
{
nsCOMPtr<nsITableEditor> tableEditor = do_QueryInterface(mEditor);
if (tableEditor)
result = tableEditor->SwitchTableCellHeaderType(aSourceCell, aNewCell);
}
break;
default:
result = NS_ERROR_NOT_IMPLEMENTED;
}
return result;
}
NS_IMETHODIMP
nsEditorShell::JoinTableCells()
{

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

@ -4176,6 +4176,8 @@ nsHTMLEditor::ApplyDocumentOrOverrideStyleSheet(const nsString& aURL, PRBool aOv
// Add the override style sheet
// (This checks if already exists)
styleSet->AppendOverrideStyleSheet(styleSheet);
// Save doc pointer to be able to use nsIStyleSheet::SetEnabled()
styleSheet->SetOwningDocument(document);
// This notifies document observers to rebuild all frames
// (this doesn't affect style sheet because it is not a doc sheet)

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

@ -200,6 +200,7 @@ public:
NS_IMETHOD SelectTableColumn();
NS_IMETHOD SelectTable();
NS_IMETHOD SelectAllTableCells();
NS_IMETHOD SwitchTableCellHeaderType(nsIDOMElement *aSourceCell, nsIDOMElement **aNewCell);
NS_IMETHOD JoinTableCells();
NS_IMETHOD SplitTableCell();
NS_IMETHOD NormalizeTable(nsIDOMElement *aTable);
@ -377,7 +378,7 @@ protected:
// Optional: If aNewCell supplied, returns the newly-created cell (addref'd, of course)
// This doesn't change or use the current selection
NS_IMETHOD InsertCell(nsIDOMElement *aCell, PRInt32 aRowSpan, PRInt32 aColSpan,
PRBool aAfter, nsIDOMElement **aNewCell);
PRBool aAfter, PRBool aIsHeader, nsIDOMElement **aNewCell);
// Move all contents from aCellToMerge into aTargetCell (append at end)
NS_IMETHOD MergeCells(nsCOMPtr<nsIDOMElement> aTargetCell, nsCOMPtr<nsIDOMElement> aCellToMerge, PRBool aDeleteCellToMerge);

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

@ -102,7 +102,7 @@ public:
NS_IMETHODIMP
nsHTMLEditor::InsertCell(nsIDOMElement *aCell, PRInt32 aRowSpan, PRInt32 aColSpan,
PRBool aAfter, nsIDOMElement **aNewCell)
PRBool aAfter, PRBool aIsHeader, nsIDOMElement **aNewCell)
{
if (!aCell) return NS_ERROR_NULL_POINTER;
if (aNewCell) *aNewCell = nsnull;
@ -119,7 +119,11 @@ nsHTMLEditor::InsertCell(nsIDOMElement *aCell, PRInt32 aRowSpan, PRInt32 aColSpa
if (NS_FAILED(res)) return res;
nsCOMPtr<nsIDOMElement> newCell;
res = CreateElementWithDefaults(NS_ConvertASCIItoUCS2("td"), getter_AddRefs(newCell));
if (aIsHeader)
res = CreateElementWithDefaults(NS_ConvertASCIItoUCS2("th"), getter_AddRefs(newCell));
else
res = CreateElementWithDefaults(NS_ConvertASCIItoUCS2("td"), getter_AddRefs(newCell));
if(NS_FAILED(res)) return res;
if(!newCell) return NS_ERROR_FAILURE;
@ -1401,7 +1405,7 @@ nsHTMLEditor::SplitCellIntoColumns(nsIDOMElement *aTable, PRInt32 aRowIndex, PRI
if (NS_FAILED(res)) return res;
// Insert new cell after using the remaining span;
return InsertCell(cell, actualRowSpan, aColSpanRight, PR_TRUE, aNewCell);
return InsertCell(cell, actualRowSpan, aColSpanRight, PR_TRUE, PR_FALSE, aNewCell);
}
NS_IMETHODIMP
@ -1488,13 +1492,51 @@ nsHTMLEditor::SplitCellIntoRows(nsIDOMElement *aTable, PRInt32 aRowIndex, PRInt3
insertAfter = PR_TRUE; // Should always be true, but let's be sure
}
res = InsertCell(cell2, aRowSpanBelow, actualColSpan, insertAfter, aNewCell);
res = InsertCell(cell2, aRowSpanBelow, actualColSpan, insertAfter, PR_FALSE, aNewCell);
if (NS_FAILED(res)) return res;
// Reduce rowspan of cell to split
return SetRowSpan(cell, aRowSpanAbove);
}
NS_IMETHODIMP
nsHTMLEditor::SwitchTableCellHeaderType(nsIDOMElement *aSourceCell, nsIDOMElement **aNewCell)
{
if (!aSourceCell) return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIDOMElement> sourceCell = aSourceCell;
nsCOMPtr<nsIDOMElement> newCell;
nsAutoString tagName;
nsEditor::GetTagString(aSourceCell, tagName);
// Set to the opposite of current type
PRBool headerType = (tagName == NS_ConvertASCIItoUCS2("td"));
// Create the new cell, inserting it just before existing cell
// Just assume colspan and rowspan = 1 (we'll copy real values with CloneAttributes)
nsresult res = InsertCell(aSourceCell, 1, 1, PR_TRUE, headerType, getter_AddRefs(newCell));
if (NS_FAILED(res)) return res;
if (!newCell) return res;
// Copy all of the original attributes to the new cell
nsCOMPtr<nsIDOMNode> sourceCellNode = do_QueryInterface(sourceCell);
nsCOMPtr<nsIDOMNode> newCellNode = do_QueryInterface(newCell);
res = CloneAttributes(newCellNode, sourceCellNode);
if (NS_FAILED(res)) return res;
// Move all contents from original cell to new cell then delete original (3rd param = PR_TRUE)
res = MergeCells(newCell, sourceCell, PR_TRUE);
if (NS_FAILED(res)) return res;
// Return the new cell
if (aNewCell)
{
*aNewCell = newCell.get();
NS_ADDREF(*aNewCell);
}
return NS_OK;
}
NS_IMETHODIMP
nsHTMLEditor::JoinTableCells()
{
@ -1926,7 +1968,7 @@ nsHTMLEditor::NormalizeTable(nsIDOMElement *aTable)
if(previousCellInRow)
{
// Insert a new cell after (PR_TRUE), and return the new cell to us
res = InsertCell(previousCellInRow, 1, 1, PR_TRUE, getter_AddRefs(cell));
res = InsertCell(previousCellInRow, 1, 1, PR_TRUE, PR_FALSE, getter_AddRefs(cell));
if (NS_FAILED(res)) return res;
// Set this so we use returned new "cell" to set previousCellInRow below

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

@ -44,9 +44,10 @@
#include "nsIDOMNodeList.h"
#include "nsICSSLoader.h"
#include "nsICSSStyleSheet.h"
#include "nsIStyleSheet.h"
#include "nsIStyleSet.h"
#include "nsIContent.h"
#include "nsIHTMLContentContainer.h"
#include "nsIStyleSet.h"
#include "nsIURI.h"
#include "nsNetUtil.h"
@ -1271,55 +1272,76 @@ nsEditorShell::SetDisplayMode(PRInt32 aDisplayMode)
if (!styleSheets) return NS_NOINTERFACE;
mDisplayMode = aDisplayMode;
nsCOMPtr<nsIStyleSheet> nsISheet;
nsresult res = NS_OK;
if (aDisplayMode == eDisplayModePreview)
{
// Remove all extra "edit mode" style sheets
// Disable all extra "edit mode" style sheets
if (mEditModeStyleSheet)
{
styleSheets->RemoveOverrideStyleSheet(mEditModeStyleSheet);
mEditModeStyleSheet = nsnull;
nsISheet = do_QueryInterface(mEditModeStyleSheet);
res = nsISheet->SetEnabled(PR_FALSE);
}
if (mAllTagsModeStyleSheet)
{
styleSheets->RemoveOverrideStyleSheet(mAllTagsModeStyleSheet);
mAllTagsModeStyleSheet = nsnull;
nsISheet = do_QueryInterface(mAllTagsModeStyleSheet);
res = nsISheet->SetEnabled(PR_FALSE);
}
}
else if (aDisplayMode == eDisplayModeNormal)
{
// Remove the AllTags sheet
// Disable the AllTags sheet
if (mAllTagsModeStyleSheet)
{
styleSheets->RemoveOverrideStyleSheet(mAllTagsModeStyleSheet);
mAllTagsModeStyleSheet = nsnull;
nsISheet = do_QueryInterface(mAllTagsModeStyleSheet);
res = nsISheet->SetEnabled(PR_FALSE);
}
// We are already in the requested mode
if (mEditModeStyleSheet) return NS_OK;
// If loaded before, enable the sheet
if (mEditModeStyleSheet)
{
nsISheet = do_QueryInterface(mEditModeStyleSheet);
res = nsISheet->SetEnabled(PR_TRUE);
}
else
{
//Load the editmode style sheet
return styleSheets->ApplyOverrideStyleSheet(NS_ConvertASCIItoUCS2("chrome://editor/content/EditorContent.css"),
getter_AddRefs(mEditModeStyleSheet));
//Load the editmode style sheet
res = styleSheets->ApplyOverrideStyleSheet(NS_ConvertASCIItoUCS2("chrome://editor/content/EditorContent.css"),
getter_AddRefs(mEditModeStyleSheet));
}
}
else if (aDisplayMode == eDisplayModeAllTags)
{
// We are already in the requested mode
if (mAllTagsModeStyleSheet) return NS_OK;
//Load the normal mode style sheet
if (!mEditModeStyleSheet)
// If loaded before, enable the sheet
if (mAllTagsModeStyleSheet)
{
nsISheet = do_QueryInterface(mAllTagsModeStyleSheet);
res = nsISheet->SetEnabled(PR_TRUE);
}
else
{
// else load it
res = styleSheets->ApplyOverrideStyleSheet(NS_ConvertASCIItoUCS2("chrome://editor/content/EditorAllTags.css"),
getter_AddRefs(mAllTagsModeStyleSheet));
}
if (mEditModeStyleSheet)
{
nsISheet = do_QueryInterface(mEditModeStyleSheet);
res = nsISheet->SetEnabled(PR_TRUE);
}
else
{
// Note: using "@import url(chrome://editor/content/EditorContent.css);"
// in EditorAllTags.css doesn't seem to work!?
styleSheets->ApplyOverrideStyleSheet(NS_ConvertASCIItoUCS2("chrome://editor/content/EditorContent.css"),
getter_AddRefs(mEditModeStyleSheet));
res = styleSheets->ApplyOverrideStyleSheet(NS_ConvertASCIItoUCS2("chrome://editor/content/EditorContent.css"),
getter_AddRefs(mEditModeStyleSheet));
}
return styleSheets->ApplyOverrideStyleSheet(NS_ConvertASCIItoUCS2("chrome://editor/content/EditorAllTags.css"),
getter_AddRefs(mAllTagsModeStyleSheet));
}
return NS_OK;
return res;
}
NS_IMETHODIMP
@ -1329,21 +1351,25 @@ nsEditorShell::DisplayParagraphMarks(PRBool aShowMarks)
nsCOMPtr<nsIEditorStyleSheets> styleSheets = do_QueryInterface(mEditor);
if (!styleSheets) return NS_NOINTERFACE;
nsCOMPtr<nsIStyleSheet> nsISheet;
if (aShowMarks)
{
// Check if style sheet is already loaded
if (mParagraphMarksStyleSheet) return NS_OK;
//Load the style sheet
// Check if style sheet is already loaded -- just enable it
if (mParagraphMarksStyleSheet)
{
nsISheet = do_QueryInterface(mParagraphMarksStyleSheet);
return nsISheet->SetEnabled(PR_TRUE);
}
//First time used -- load the style sheet
nsCOMPtr<nsICSSStyleSheet> styleSheet;
res = styleSheets->ApplyOverrideStyleSheet(NS_ConvertASCIItoUCS2("chrome://editor/content/EditorParagraphMarks.css"),
getter_AddRefs(mParagraphMarksStyleSheet));
}
else if (mParagraphMarksStyleSheet)
{
res = styleSheets->RemoveOverrideStyleSheet(mParagraphMarksStyleSheet);
mParagraphMarksStyleSheet = nsnull;
// Disable the style sheet
nsISheet = do_QueryInterface(mParagraphMarksStyleSheet);
res = nsISheet->SetEnabled(PR_FALSE);
}
return res;
@ -3834,6 +3860,26 @@ nsEditorShell::DeleteTableColumn(PRInt32 aNumber)
return result;
}
NS_IMETHODIMP
nsEditorShell::SwitchTableCellHeaderType(nsIDOMElement *aSourceCell, nsIDOMElement **aNewCell)
{
nsresult result = NS_NOINTERFACE;
switch (mEditorType)
{
case eHTMLTextEditorType:
{
nsCOMPtr<nsITableEditor> tableEditor = do_QueryInterface(mEditor);
if (tableEditor)
result = tableEditor->SwitchTableCellHeaderType(aSourceCell, aNewCell);
}
break;
default:
result = NS_ERROR_NOT_IMPLEMENTED;
}
return result;
}
NS_IMETHODIMP
nsEditorShell::JoinTableCells()
{

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

@ -4176,6 +4176,8 @@ nsHTMLEditor::ApplyDocumentOrOverrideStyleSheet(const nsString& aURL, PRBool aOv
// Add the override style sheet
// (This checks if already exists)
styleSet->AppendOverrideStyleSheet(styleSheet);
// Save doc pointer to be able to use nsIStyleSheet::SetEnabled()
styleSheet->SetOwningDocument(document);
// This notifies document observers to rebuild all frames
// (this doesn't affect style sheet because it is not a doc sheet)

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

@ -200,6 +200,7 @@ public:
NS_IMETHOD SelectTableColumn();
NS_IMETHOD SelectTable();
NS_IMETHOD SelectAllTableCells();
NS_IMETHOD SwitchTableCellHeaderType(nsIDOMElement *aSourceCell, nsIDOMElement **aNewCell);
NS_IMETHOD JoinTableCells();
NS_IMETHOD SplitTableCell();
NS_IMETHOD NormalizeTable(nsIDOMElement *aTable);
@ -377,7 +378,7 @@ protected:
// Optional: If aNewCell supplied, returns the newly-created cell (addref'd, of course)
// This doesn't change or use the current selection
NS_IMETHOD InsertCell(nsIDOMElement *aCell, PRInt32 aRowSpan, PRInt32 aColSpan,
PRBool aAfter, nsIDOMElement **aNewCell);
PRBool aAfter, PRBool aIsHeader, nsIDOMElement **aNewCell);
// Move all contents from aCellToMerge into aTargetCell (append at end)
NS_IMETHOD MergeCells(nsCOMPtr<nsIDOMElement> aTargetCell, nsCOMPtr<nsIDOMElement> aCellToMerge, PRBool aDeleteCellToMerge);

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

@ -102,7 +102,7 @@ public:
NS_IMETHODIMP
nsHTMLEditor::InsertCell(nsIDOMElement *aCell, PRInt32 aRowSpan, PRInt32 aColSpan,
PRBool aAfter, nsIDOMElement **aNewCell)
PRBool aAfter, PRBool aIsHeader, nsIDOMElement **aNewCell)
{
if (!aCell) return NS_ERROR_NULL_POINTER;
if (aNewCell) *aNewCell = nsnull;
@ -119,7 +119,11 @@ nsHTMLEditor::InsertCell(nsIDOMElement *aCell, PRInt32 aRowSpan, PRInt32 aColSpa
if (NS_FAILED(res)) return res;
nsCOMPtr<nsIDOMElement> newCell;
res = CreateElementWithDefaults(NS_ConvertASCIItoUCS2("td"), getter_AddRefs(newCell));
if (aIsHeader)
res = CreateElementWithDefaults(NS_ConvertASCIItoUCS2("th"), getter_AddRefs(newCell));
else
res = CreateElementWithDefaults(NS_ConvertASCIItoUCS2("td"), getter_AddRefs(newCell));
if(NS_FAILED(res)) return res;
if(!newCell) return NS_ERROR_FAILURE;
@ -1401,7 +1405,7 @@ nsHTMLEditor::SplitCellIntoColumns(nsIDOMElement *aTable, PRInt32 aRowIndex, PRI
if (NS_FAILED(res)) return res;
// Insert new cell after using the remaining span;
return InsertCell(cell, actualRowSpan, aColSpanRight, PR_TRUE, aNewCell);
return InsertCell(cell, actualRowSpan, aColSpanRight, PR_TRUE, PR_FALSE, aNewCell);
}
NS_IMETHODIMP
@ -1488,13 +1492,51 @@ nsHTMLEditor::SplitCellIntoRows(nsIDOMElement *aTable, PRInt32 aRowIndex, PRInt3
insertAfter = PR_TRUE; // Should always be true, but let's be sure
}
res = InsertCell(cell2, aRowSpanBelow, actualColSpan, insertAfter, aNewCell);
res = InsertCell(cell2, aRowSpanBelow, actualColSpan, insertAfter, PR_FALSE, aNewCell);
if (NS_FAILED(res)) return res;
// Reduce rowspan of cell to split
return SetRowSpan(cell, aRowSpanAbove);
}
NS_IMETHODIMP
nsHTMLEditor::SwitchTableCellHeaderType(nsIDOMElement *aSourceCell, nsIDOMElement **aNewCell)
{
if (!aSourceCell) return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIDOMElement> sourceCell = aSourceCell;
nsCOMPtr<nsIDOMElement> newCell;
nsAutoString tagName;
nsEditor::GetTagString(aSourceCell, tagName);
// Set to the opposite of current type
PRBool headerType = (tagName == NS_ConvertASCIItoUCS2("td"));
// Create the new cell, inserting it just before existing cell
// Just assume colspan and rowspan = 1 (we'll copy real values with CloneAttributes)
nsresult res = InsertCell(aSourceCell, 1, 1, PR_TRUE, headerType, getter_AddRefs(newCell));
if (NS_FAILED(res)) return res;
if (!newCell) return res;
// Copy all of the original attributes to the new cell
nsCOMPtr<nsIDOMNode> sourceCellNode = do_QueryInterface(sourceCell);
nsCOMPtr<nsIDOMNode> newCellNode = do_QueryInterface(newCell);
res = CloneAttributes(newCellNode, sourceCellNode);
if (NS_FAILED(res)) return res;
// Move all contents from original cell to new cell then delete original (3rd param = PR_TRUE)
res = MergeCells(newCell, sourceCell, PR_TRUE);
if (NS_FAILED(res)) return res;
// Return the new cell
if (aNewCell)
{
*aNewCell = newCell.get();
NS_ADDREF(*aNewCell);
}
return NS_OK;
}
NS_IMETHODIMP
nsHTMLEditor::JoinTableCells()
{
@ -1926,7 +1968,7 @@ nsHTMLEditor::NormalizeTable(nsIDOMElement *aTable)
if(previousCellInRow)
{
// Insert a new cell after (PR_TRUE), and return the new cell to us
res = InsertCell(previousCellInRow, 1, 1, PR_TRUE, getter_AddRefs(cell));
res = InsertCell(previousCellInRow, 1, 1, PR_TRUE, PR_FALSE, getter_AddRefs(cell));
if (NS_FAILED(res)) return res;
// Set this so we use returned new "cell" to set previousCellInRow below