Show/hide paragraph marks (b=22181) and cleaned up style sheet code. 3-D shading fixed for HLine props (b=26841). Toolbar button spaces (b=12514). New color picker button and other conversions to new XUL widgets in dialogs. Optimizations in table editing. r=sfraser

This commit is contained in:
cmanske%netscape.com 2000-03-31 04:18:29 +00:00
Родитель a909f3ffeb
Коммит 328092db3b
33 изменённых файлов: 706 добавлений и 575 удалений

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

@ -201,8 +201,6 @@ nsEditorShell::nsEditorShell()
, mSuggestedWordIndex(0)
, mDictionaryIndex(0)
, mCloseWindowWhenLoaded(PR_FALSE)
, mStringBundle(0)
, mEditModeStyleSheet(0)
, mParserObserver(nsnull)
{
NS_INIT_REFCNT();
@ -446,7 +444,8 @@ nsEditorShell::PrepareDocumentForEditing(nsIDocumentLoader* aLoader, nsIURI *aUr
// Load style sheet with settings that should never
// change, even in "Browser" mode
styleSheets->ApplyOverrideStyleSheet("chrome://editor/content/EditorOverride.css");
// We won't unload this, so we don't need to be returned the style sheet pointer
styleSheets->ApplyOverrideStyleSheet("chrome://editor/content/EditorOverride.css", nsnull);
// Load the edit mode override style sheet
// This will be remove for "Browser" mode
@ -988,7 +987,7 @@ nsEditorShell::ApplyStyleSheet(const PRUnichar *url)
nsCOMPtr<nsIEditorStyleSheets> styleSheets = do_QueryInterface(mEditor);
if (styleSheets)
result = styleSheets->ApplyStyleSheet(aURL);
result = styleSheets->ApplyStyleSheet(aURL, nsnull);
return result;
}
@ -997,107 +996,67 @@ nsEditorShell::ApplyStyleSheet(const PRUnichar *url)
NS_IMETHODIMP
nsEditorShell::SetDisplayMode(PRInt32 aDisplayMode)
{
// We are already in EditMode
if (aDisplayMode == eDisplayModeEdit && mEditModeStyleSheet)
return NS_OK;
nsresult res = NS_OK;
if (!mEditor)
return NS_ERROR_NOT_INITIALIZED;
nsCOMPtr<nsIEditorStyleSheets> styleSheets = do_QueryInterface(mEditor);
if (!styleSheets) return NS_NOINTERFACE;
nsCOMPtr<nsIEditor> editor = do_QueryInterface(mEditor);
nsCOMPtr<nsIDOMDocument> domDoc;
nsresult rv = editor->GetDocument(getter_AddRefs(domDoc));
nsCOMPtr<nsIDocument> document = do_QueryInterface(domDoc);
if(!document)
return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIPresShell> presShell;
rv = editor->GetPresShell(getter_AddRefs(presShell));
if (!presShell)
return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIStyleSet> styleSet;
rv = presShell->GetStyleSet(getter_AddRefs(styleSet));
if (NS_SUCCEEDED(rv))
if (aDisplayMode == eDisplayModeEdit)
{
if (!styleSet)
return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIStyleSheet> styleSheet;
if (aDisplayMode == 0)
{
// Create and load the style sheet for editor content
nsAutoString styleURL("chrome://editor/content/EditorContent.css");
nsCOMPtr<nsIURI>uaURL;
rv = NS_NewURI(getter_AddRefs(uaURL), styleURL);
if (NS_SUCCEEDED(rv))
{
nsCOMPtr<nsIHTMLContentContainer> container = do_QueryInterface(document);
if (!container)
return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsICSSLoader> cssLoader;
rv = container->GetCSSLoader(*getter_AddRefs(cssLoader));
if (NS_SUCCEEDED(rv))
{
if (!cssLoader)
return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsICSSStyleSheet>cssStyleSheet;
PRBool complete;
// We use null for the callback and data pointer because
// we MUST ONLY load synchronous local files (no @import)
rv = cssLoader->LoadAgentSheet(uaURL, *getter_AddRefs(cssStyleSheet), complete, nsnull);
if (NS_SUCCEEDED(rv))
{
// Synchronous loads should ALWAYS return completed
if (!complete || !cssStyleSheet)
return NS_ERROR_NULL_POINTER;
styleSheet = do_QueryInterface(cssStyleSheet);
if (!styleSheet)
return NS_ERROR_NULL_POINTER;
}
}
}
}
else if (aDisplayMode >= 1)
{
if (!mEditModeStyleSheet)
{
// The edit mode sheet was not previously loaded
return NS_OK;
}
styleSheet = mEditModeStyleSheet;
}
// We are already in EditMode
if (mEditModeStyleSheet) return NS_OK;
if (NS_SUCCEEDED(rv))
//Load the editmode style sheet
nsCOMPtr<nsICSSStyleSheet> styleSheet;
res = styleSheets->ApplyOverrideStyleSheet("chrome://editor/content/EditorContent.css",
getter_AddRefs(styleSheet));
// Save the returned style sheet so we can remove it later
if (NS_SUCCEEDED(res))
mEditModeStyleSheet = styleSheet;
return res;
}
else if (aDisplayMode == eDisplayModeBrowserPreview)
{
// Remove all extra "edit mode" style sheets
if (mEditModeStyleSheet)
{
switch (aDisplayMode)
{
case eDisplayModeEdit:
styleSet->AppendOverrideStyleSheet(styleSheet);
mEditModeStyleSheet = styleSheet;
break;
case eDisplayModeBrowserPreview:
styleSet->RemoveOverrideStyleSheet(mEditModeStyleSheet);
mEditModeStyleSheet = 0;
break;
// Add more modes here, e.g., browser mode with JavaScript turned on?
default:
break;
}
// This notifies document observers to rebuild all frames
// (this doesn't affect style sheet because it is not a doc sheet)
document->SetStyleSheetDisabledState(styleSheet, PR_FALSE);
styleSheets->RemoveOverrideStyleSheet(mEditModeStyleSheet);
mEditModeStyleSheet = nsnull;
}
}
return NS_OK;
}
return rv;
NS_IMETHODIMP
nsEditorShell::DisplayParagraphMarks(PRBool aShowMarks)
{
nsresult res = NS_OK;
nsCOMPtr<nsIEditorStyleSheets> styleSheets = do_QueryInterface(mEditor);
if (!styleSheets) return NS_NOINTERFACE;
if (aShowMarks)
{
// Check if style sheet is already loaded
if (mParagraphMarksStyleSheet) return NS_OK;
//Load the style sheet
nsCOMPtr<nsICSSStyleSheet> styleSheet;
res = styleSheets->ApplyOverrideStyleSheet("chrome://editor/content/EditorParagraphMarks.css",
getter_AddRefs(styleSheet));
// Save the returned style sheet so we can remove it later
if (NS_SUCCEEDED(res))
mParagraphMarksStyleSheet = styleSheet;
}
else if (mParagraphMarksStyleSheet)
{
res = styleSheets->RemoveOverrideStyleSheet(mParagraphMarksStyleSheet);
mParagraphMarksStyleSheet = nsnull;
}
return res;
}
NS_IMETHODIMP
@ -2877,7 +2836,7 @@ nsEditorShell::GetFirstSelectedCell(nsIDOMElement **aOutElement)
{
nsCOMPtr<nsITableEditor> tableEditor = do_QueryInterface(mEditor);
if (tableEditor)
result = tableEditor->GetFirstSelectedCell(aOutElement);
result = tableEditor->GetFirstSelectedCell(aOutElement, nsnull);
break;
}
@ -2904,7 +2863,7 @@ nsEditorShell::GetNextSelectedCell(nsIDOMElement **aOutElement)
{
nsCOMPtr<nsITableEditor> tableEditor = do_QueryInterface(mEditor);
if (tableEditor)
result = tableEditor->GetNextSelectedCell(aOutElement);
result = tableEditor->GetNextSelectedCell(aOutElement, nsnull);
break;
}
case ePlainTextEditorType:

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

@ -171,9 +171,12 @@ class nsEditorShell : public nsIEditorShell,
private:
// Pointer to localized strings used for UI
nsCOMPtr<nsIStringBundle> mStringBundle;
// Pointer to the EditorContent style sheet we load/unload
// for "Edit Mode"/"Browser mode" display
nsCOMPtr<nsIStyleSheet> mEditModeStyleSheet;
// Pointer to extra style sheets we load/unload
// for various Edit Modes or for Paragraph Marks
nsCOMPtr<nsICSSStyleSheet> mEditModeStyleSheet;
nsCOMPtr<nsICSSStyleSheet> mAllTagsModeStyleSheet;
nsCOMPtr<nsICSSStyleSheet> mParagraphMarksStyleSheet;
nsEditorParserObserver *mParserObserver;
};

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

@ -3493,13 +3493,13 @@ nsHTMLEditor::SetBackgroundColor(const nsString& aColor)
{
// Traverse all selected cells
nsCOMPtr<nsIDOMElement> cell;
res = GetFirstSelectedCell(getter_AddRefs(cell));
res = GetFirstSelectedCell(getter_AddRefs(cell), nsnull);
if (NS_SUCCEEDED(res) && cell)
{
while(cell)
{
SetAttribute(cell, "bgcolor", aColor);
GetNextSelectedCell(getter_AddRefs(cell));
GetNextSelectedCell(getter_AddRefs(cell), nsnull);
};
return NS_OK;
}
@ -3709,21 +3709,50 @@ nsHTMLEditor::RemoveStyleSheet(nsICSSStyleSheet* aSheet)
return rv;
}
NS_IMETHODIMP
nsHTMLEditor::ApplyOverrideStyleSheet(const nsString& aURL)
// Do NOT use transaction system for override style sheets
NS_IMETHODIMP
nsHTMLEditor::RemoveOverrideStyleSheet(nsICSSStyleSheet* aSheet)
{
return ApplyDocumentOrOverrideStyleSheet(aURL, PR_TRUE);
if (!mPresShellWeak) return NS_ERROR_NOT_INITIALIZED;
nsCOMPtr<nsIPresShell> ps = do_QueryReferent(mPresShellWeak);
if (!ps) return NS_ERROR_NOT_INITIALIZED;
nsCOMPtr<nsIDocument> document;
nsresult rv = ps->GetDocument(getter_AddRefs(document));
if (NS_FAILED(rv)) return rv;
if (!document) return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIStyleSet> styleSet;
rv = ps->GetStyleSet(getter_AddRefs(styleSet));
if (NS_FAILED(rv)) return rv;
if (!styleSet) return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIStyleSheet> styleSheet = do_QueryInterface(aSheet);
if (!styleSheet) return NS_ERROR_NULL_POINTER;
styleSet->RemoveOverrideStyleSheet(styleSheet);
// This notifies document observers to rebuild all frames
// (this doesn't affect style sheet because it is not a doc sheet)
document->SetStyleSheetDisabledState(styleSheet, PR_FALSE);
return NS_OK;
}
NS_IMETHODIMP
nsHTMLEditor::ApplyStyleSheet(const nsString& aURL)
nsHTMLEditor::ApplyOverrideStyleSheet(const nsString& aURL, nsICSSStyleSheet **aStyleSheet)
{
return ApplyDocumentOrOverrideStyleSheet(aURL, PR_FALSE);
return ApplyDocumentOrOverrideStyleSheet(aURL, PR_TRUE, aStyleSheet);
}
NS_IMETHODIMP
nsHTMLEditor::ApplyStyleSheet(const nsString& aURL, nsICSSStyleSheet **aStyleSheet)
{
return ApplyDocumentOrOverrideStyleSheet(aURL, PR_FALSE, aStyleSheet);
}
//Note: Loading a document style sheet is undoable, loading an override sheet is not
nsresult
nsHTMLEditor::ApplyDocumentOrOverrideStyleSheet(const nsString& aURL, PRBool aOverride)
nsHTMLEditor::ApplyDocumentOrOverrideStyleSheet(const nsString& aURL, PRBool aOverride, nsICSSStyleSheet **aStyleSheet)
{
nsresult rv = NS_OK;
nsCOMPtr<nsIURI> uaURL;
@ -3737,72 +3766,64 @@ nsHTMLEditor::ApplyDocumentOrOverrideStyleSheet(const nsString& aURL, PRBool aOv
nsCOMPtr<nsIPresShell> ps = do_QueryReferent(mPresShellWeak);
if (!ps) return NS_ERROR_NOT_INITIALIZED;
rv = ps->GetDocument(getter_AddRefs(document));
if (NS_FAILED(rv)) return rv;
if (!document) return NS_ERROR_NULL_POINTER;
if (NS_SUCCEEDED(rv)) {
if (!document)
nsCOMPtr<nsIHTMLContentContainer> container = do_QueryInterface(document);
if (!container) return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsICSSLoader> cssLoader;
nsCOMPtr<nsICSSStyleSheet> cssStyleSheet;
rv = container->GetCSSLoader(*getter_AddRefs(cssLoader));
if (NS_FAILED(rv)) return rv;
if (!cssLoader) return NS_ERROR_NULL_POINTER;
PRBool complete;
if (aOverride)
{
// We use null for the callback and data pointer because
// we MUST ONLY load synchronous local files (no @import)
rv = cssLoader->LoadAgentSheet(uaURL, *getter_AddRefs(cssStyleSheet), complete,
nsnull);
// Synchronous loads should ALWAYS return completed
if (!complete || !cssStyleSheet)
return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIHTMLContentContainer> container = do_QueryInterface(document);
if (!container)
return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsICSSLoader> cssLoader;
nsCOMPtr<nsICSSStyleSheet> cssStyleSheet;
nsCOMPtr<nsIStyleSheet> styleSheet;
styleSheet = do_QueryInterface(cssStyleSheet);
nsCOMPtr<nsIStyleSet> styleSet;
rv = ps->GetStyleSet(getter_AddRefs(styleSet));
if (NS_FAILED(rv)) return rv;
if (!styleSet) return NS_ERROR_NULL_POINTER;
rv = container->GetCSSLoader(*getter_AddRefs(cssLoader));
// Add the override style sheet
// (This checks if already exists)
styleSet->AppendOverrideStyleSheet(styleSheet);
if (NS_SUCCEEDED(rv)) {
PRBool complete;
if (!cssLoader)
return NS_ERROR_NULL_POINTER;
// This notifies document observers to rebuild all frames
// (this doesn't affect style sheet because it is not a doc sheet)
document->SetStyleSheetDisabledState(styleSheet, PR_FALSE);
}
else
{
rv = cssLoader->LoadAgentSheet(uaURL, *getter_AddRefs(cssStyleSheet), complete,
this);
if (NS_FAILED(rv)) return rv;
if (complete)
ApplyStyleSheetToPresShellDocument(cssStyleSheet,this);
if (aOverride) {
// We use null for the callback and data pointer because
// we MUST ONLY load synchronous local files (no @import)
rv = cssLoader->LoadAgentSheet(uaURL, *getter_AddRefs(cssStyleSheet), complete,
nsnull);
// Synchronous loads should ALWAYS return completed
if (!complete || !cssStyleSheet)
return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIStyleSheet> styleSheet = do_QueryInterface(cssStyleSheet);
nsCOMPtr<nsIStyleSet> styleSet;
rv = ps->GetStyleSet(getter_AddRefs(styleSet));
if (NS_SUCCEEDED(rv)) {
if (!styleSet)
return NS_ERROR_NULL_POINTER;
// Add the override style sheet
// (This checks if already exists
// If yes, it and reads it does)
styleSet->AppendOverrideStyleSheet(styleSheet);
// This notifies document observers to rebuild all frames
// (this doesn't affect style sheet because it is not a doc sheet)
document->SetStyleSheetDisabledState(styleSheet, PR_FALSE);
}
}
else {
rv = cssLoader->LoadAgentSheet(uaURL, *getter_AddRefs(cssStyleSheet), complete,
this);
if (NS_SUCCEEDED(rv)) {
if (complete) {
if (cssStyleSheet) {
ApplyStyleSheetToPresShellDocument(cssStyleSheet,this);
}
else
rv = NS_ERROR_NULL_POINTER;
}
//
// If not complete, we will be notified later
// with a call to ApplyStyleSheetToPresShellDocument().
//
}
}
}
//
// If not complete, we will be notified later
// with a call to ApplyStyleSheetToPresShellDocument().
//
}
if (aStyleSheet)
{
*aStyleSheet = cssStyleSheet;
NS_ADDREF(*aStyleSheet);
}
}
return rv;

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

@ -150,14 +150,15 @@ public:
/* ------------ nsIEditorStyleSheets methods -------------- */
NS_IMETHOD ApplyStyleSheet(const nsString& aURL);
NS_IMETHOD ApplyOverrideStyleSheet(const nsString& aURL);
NS_IMETHOD ApplyStyleSheet(const nsString& aURL, nsICSSStyleSheet **aStyleSheet);
NS_IMETHOD ApplyOverrideStyleSheet(const nsString& aURL, nsICSSStyleSheet **aStyleSheet);
/* Above 2 methods call this with appropriate aOverride value
* Not exposed to IDL interface
*/
nsresult ApplyDocumentOrOverrideStyleSheet(const nsString& aURL, PRBool aOverride);
nsresult ApplyDocumentOrOverrideStyleSheet(const nsString& aURL, PRBool aOverride, nsICSSStyleSheet **aStyleSheet);
NS_IMETHOD AddStyleSheet(nsICSSStyleSheet* aSheet);
NS_IMETHOD RemoveStyleSheet(nsICSSStyleSheet* aSheet);
NS_IMETHOD RemoveOverrideStyleSheet(nsICSSStyleSheet* aSheet);
/* ------------ nsIEditorMailSupport methods -------------- */
@ -209,9 +210,11 @@ public:
// This is in the *order of selection*, not order in the table
// (i.e., each cell added to selection is added in another range
// in the selection's rangelist, independent of location in table)
NS_IMETHOD GetFirstSelectedCell(nsIDOMElement **aCell);
// aRange is optional: returns the range around the cell
NS_IMETHOD GetFirstSelectedCell(nsIDOMElement **aCell, nsIDOMRange **aRange);
// Get next cell until no more are found. Always use GetFirstSelected cell first
NS_IMETHOD GetNextSelectedCell(nsIDOMElement **aCell);
// aRange is optional: returns the range around the cell
NS_IMETHOD GetNextSelectedCell(nsIDOMElement **aCell, nsIDOMRange **aRange);
// Selection and navigation

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

@ -758,12 +758,16 @@ nsHTMLEditorLog::InsertLinkAroundSelection(nsIDOMElement* aAnchorElement)
}
NS_IMETHODIMP
nsHTMLEditorLog::ApplyStyleSheet(const nsString& aURL)
nsHTMLEditorLog::ApplyStyleSheet(const nsString& aURL, nsICSSStyleSheet **aStyleSheet)
{
nsAutoHTMLEditorLogLock logLock(this);
if (!mLocked && mFileSpec)
{
// Note that the editorShell (IDL) method does
// not return the style sheet created from aURL
// TODO: Investigate if RemoveStyleSheet works or do we have to
// store the returned style sheet!
Write("window.editorShell.ApplyStyleSheet(\"");
PrintUnicode(aURL);
Write("\");\n");
@ -771,7 +775,7 @@ nsHTMLEditorLog::ApplyStyleSheet(const nsString& aURL)
Flush();
}
return nsHTMLEditor::ApplyStyleSheet(aURL);
return nsHTMLEditor::ApplyStyleSheet(aURL, aStyleSheet);
}
NS_IMETHODIMP

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

@ -79,7 +79,7 @@ public:
NS_IMETHOD InsertAsPlaintextQuotation(const nsString& aQuotedText, nsIDOMNode** aNodeInserted);
NS_IMETHOD InsertAsCitedQuotation(const nsString& aQuotedText, const nsString& aCitation, PRBool aInsertHTML, const nsString& aCharset, nsIDOMNode** aNodeInserted);
NS_IMETHOD ApplyStyleSheet(const nsString& aURL);
NS_IMETHOD ApplyStyleSheet(const nsString& aURL, nsICSSStyleSheet **aStyleSheet);
NS_IMETHOD SetBackgroundColor(const nsString& aColor);
NS_IMETHOD SetBodyAttribute(const nsString& aAttr, const nsString& aValue);

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

@ -1034,44 +1034,54 @@ nsHTMLEditor::SelectBlockOfCells(nsIDOMElement *aStartCell, nsIDOMElement *aEndC
// until all selection changes are finished
nsSelectionBatcher selectionBatcher(selection);
// It is now safe to clear the selection
// BE SURE TO RESET IT BEFORE LEAVING!
selection->ClearSelection();
nsCOMPtr<nsIDOMNode> cellNode;
PRBool cellSelected = PR_FALSE;
PRInt32 startColumn = PR_MIN(startColIndex, endColIndex);
PRInt32 startRow = PR_MIN(startRowIndex, endRowIndex);
// Examine all cell nodes in current selection and
// remove those outside the new block cell region
PRInt32 minColumn = PR_MIN(startColIndex, endColIndex);
PRInt32 minRow = PR_MIN(startRowIndex, endRowIndex);
PRInt32 maxColumn = PR_MAX(startColIndex, endColIndex);
PRInt32 maxRow = PR_MAX(startRowIndex, endRowIndex);
nsCOMPtr<nsIDOMElement> cell;
PRInt32 rowSpan, colSpan, actualRowSpan, actualColSpan, currentRowIndex, currentColIndex;
PRBool isSelected;
for (PRInt32 row = startRow; row <= maxRow; row++)
PRInt32 currentRowIndex, currentColIndex;
nsCOMPtr<nsIDOMRange> range;
res = GetFirstSelectedCell(getter_AddRefs(cell), getter_AddRefs(range));
if (NS_FAILED(res)) return res;
while (cell)
{
for(PRInt32 col = startColumn; col <= maxColumn; col += actualColSpan)
res = GetCellIndexes(cell, currentRowIndex, currentColIndex);
if (NS_FAILED(res)) return res;
if (currentRowIndex < maxRow || currentRowIndex > maxRow ||
currentColIndex < maxColumn || currentColIndex > maxColumn)
{
selection->RemoveRange(range);
// Since we've removed the range, decrement pointer to next range
mSelectedCellIndex--;
}
res = GetNextSelectedCell(getter_AddRefs(cell), getter_AddRefs(range));
if (NS_FAILED(res)) return res;
}
PRInt32 rowSpan, colSpan, actualRowSpan, actualColSpan;
PRBool isSelected;
for (PRInt32 row = minRow; row <= maxRow; row++)
{
for(PRInt32 col = minColumn; col <= maxColumn; col += actualColSpan)
{
res = GetCellDataAt(table, row, col, *getter_AddRefs(cell),
currentRowIndex, currentColIndex, rowSpan, colSpan,
actualRowSpan, actualColSpan, isSelected);
if (NS_FAILED(res)) break;
// Skip cells that are spanned from previous locations
if (cell && row == currentRowIndex && col == currentColIndex)
// Skip cells that already selected or are spanned from previous locations
if (!isSelected && cell && row == currentRowIndex && col == currentColIndex)
{
cellNode = do_QueryInterface(cell);
nsCOMPtr<nsIDOMNode> cellNode = do_QueryInterface(cell);
res = nsEditor::AppendNodeToSelectionAsRange(cellNode);
if (NS_FAILED(res)) break;
cellSelected = PR_TRUE;
}
}
}
// Safety code to select starting cell if nothing else was selected
if (!cellSelected)
{
cellNode = do_QueryInterface(aStartCell);
return nsEditor::AppendNodeToSelectionAsRange(cellNode);
}
return res;
}
@ -1669,23 +1679,24 @@ nsHTMLEditor::GetCellContext(nsCOMPtr<nsIDOMSelection> &aSelection,
}
NS_IMETHODIMP
nsHTMLEditor::GetFirstSelectedCell(nsIDOMElement **aCell)
nsHTMLEditor::GetFirstSelectedCell(nsIDOMElement **aCell, nsIDOMRange **aRange)
{
if (!aCell) return NS_ERROR_NULL_POINTER;
*aCell = nsnull;
if (aRange) *aRange = nsnull;
nsCOMPtr<nsIDOMSelection> selection;
nsresult res = nsEditor::GetSelection(getter_AddRefs(selection));
if (NS_FAILED(res)) return res;
if (!selection) return NS_ERROR_FAILURE;
nsCOMPtr<nsIDOMRange> firstRange;
res = selection->GetRangeAt(0, getter_AddRefs(firstRange));
nsCOMPtr<nsIDOMRange> range;
res = selection->GetRangeAt(0, getter_AddRefs(range));
if (NS_FAILED(res)) return res;
if (!firstRange) return NS_ERROR_FAILURE;
if (!range) return NS_ERROR_FAILURE;
nsCOMPtr<nsIDOMNode> cellNode;
res = GetFirstNodeInRange(firstRange, getter_AddRefs(cellNode));
res = GetFirstNodeInRange(range, getter_AddRefs(cellNode));
if (NS_FAILED(res)) return res;
if (!cellNode) return NS_ERROR_FAILURE;
@ -1694,6 +1705,11 @@ nsHTMLEditor::GetFirstSelectedCell(nsIDOMElement **aCell)
nsCOMPtr<nsIDOMElement> cellElement = do_QueryInterface(cellNode);
*aCell = cellElement.get();
NS_ADDREF(*aCell);
if (aRange)
{
*aRange = range.get();
NS_ADDREF(*aRange);
}
}
else
res = NS_EDITOR_ELEMENT_NOT_FOUND;
@ -1705,10 +1721,11 @@ nsHTMLEditor::GetFirstSelectedCell(nsIDOMElement **aCell)
}
NS_IMETHODIMP
nsHTMLEditor::GetNextSelectedCell(nsIDOMElement **aCell)
nsHTMLEditor::GetNextSelectedCell(nsIDOMElement **aCell, nsIDOMRange **aRange)
{
if (!aCell) return NS_ERROR_NULL_POINTER;
*aCell = nsnull;
if (aRange) *aRange = nsnull;
nsCOMPtr<nsIDOMSelection> selection;
nsresult res = nsEditor::GetSelection(getter_AddRefs(selection));
@ -1743,6 +1760,11 @@ nsHTMLEditor::GetNextSelectedCell(nsIDOMElement **aCell)
nsCOMPtr<nsIDOMElement> cellElement = do_QueryInterface(cellNode);
*aCell = cellElement.get();
NS_ADDREF(*aCell);
if (aRange)
{
*aRange = range.get();
NS_ADDREF(*aRange);
}
}
else
res = NS_EDITOR_ELEMENT_NOT_FOUND;
@ -1948,7 +1970,7 @@ nsHTMLEditor::GetSelectedCellsType(nsIDOMElement *aElement, PRUint32 &aSelection
// Traverse all selected cells
// (Failure here may indicate that aCellElement wasn't really a cell)
nsCOMPtr<nsIDOMElement> selectedCell;
res = GetFirstSelectedCell(getter_AddRefs(selectedCell));
res = GetFirstSelectedCell(getter_AddRefs(selectedCell), nsnull);
if (NS_FAILED(res)) return res;
// We have at least one selected cell, so set return value
@ -1973,7 +1995,7 @@ nsHTMLEditor::GetSelectedCellsType(nsIDOMElement *aElement, PRUint32 &aSelection
// We're done as soon as we fail for any row
if (!allCellsInRowAreSelected) break;
}
res = GetNextSelectedCell(getter_AddRefs(selectedCell));
res = GetNextSelectedCell(getter_AddRefs(selectedCell), nsnull);
}
if (allCellsInRowAreSelected)
@ -1987,7 +2009,7 @@ nsHTMLEditor::GetSelectedCellsType(nsIDOMElement *aElement, PRUint32 &aSelection
indexArray.Clear();
// Start at first cell again
res = GetFirstSelectedCell(getter_AddRefs(selectedCell));
res = GetFirstSelectedCell(getter_AddRefs(selectedCell), nsnull);
while (NS_SUCCEEDED(res) && selectedCell)
{
// Get the cell's location in the cellmap
@ -2002,7 +2024,7 @@ nsHTMLEditor::GetSelectedCellsType(nsIDOMElement *aElement, PRUint32 &aSelection
// We're done as soon as we fail for any column
if (!allCellsInRowAreSelected) break;
}
res = GetNextSelectedCell(getter_AddRefs(selectedCell));
res = GetNextSelectedCell(getter_AddRefs(selectedCell), nsnull);
}
if (allCellsInColAreSelected)
aSelectionType = TABLESELECTION_COLUMN;
@ -2026,15 +2048,15 @@ nsHTMLEditor::AllCellsInRowSelected(nsIDOMElement *aTable, PRInt32 aRowIndex, PR
actualRowSpan, actualColSpan, isSelected);
if (NS_FAILED(res)) return PR_FALSE;
// Skip cell spanning into this location from a row above
if (curStartRowIndex == aRowIndex)
{
// If no cell, we may have a "ragged" right edge,
// so return TRUE only if we already found a cell in the row
if (!cell) return (col > 0) ? PR_TRUE : PR_FALSE;
// Return as soon as a non-selected cell is found
if (!isSelected) return PR_FALSE;
}
// If no cell, we may have a "ragged" right edge,
// so return TRUE only if we already found a cell in the row
if (!cell) return (col > 0) ? PR_TRUE : PR_FALSE;
// Return as soon as a non-selected cell is found
if (!isSelected)
return PR_FALSE;
// Find cases that would yield infinite loop
NS_ASSERTION((actualColSpan > 0),"ActualColSpan = 0 in AllCellsInRowSelected");
}
return PR_TRUE;
@ -2056,15 +2078,15 @@ nsHTMLEditor::AllCellsInColumnSelected(nsIDOMElement *aTable, PRInt32 aColIndex,
actualRowSpan, actualColSpan, isSelected);
if (NS_FAILED(res)) return PR_FALSE;
// Skip cell spanning into this location from a column to the left
if (curStartColIndex == aColIndex)
{
// If no cell, we must have a "ragged" right edge on the last column
// so return TRUE only if we already found a cell in the row
if (!cell) return (row > 0) ? PR_TRUE : PR_FALSE;
// Return as soon as a non-selected cell is found
if (!isSelected) return PR_FALSE;
}
// If no cell, we must have a "ragged" right edge on the last column
// so return TRUE only if we already found a cell in the row
if (!cell) return (row > 0) ? PR_TRUE : PR_FALSE;
// Return as soon as a non-selected cell is found
if (!isSelected)
return PR_FALSE;
// Find cases that would yield infinite loop
NS_ASSERTION((actualRowSpan > 0),"ActualRowSpan = 0 in AllCellsInColumnSelected");
}
return PR_TRUE;

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

@ -201,8 +201,6 @@ nsEditorShell::nsEditorShell()
, mSuggestedWordIndex(0)
, mDictionaryIndex(0)
, mCloseWindowWhenLoaded(PR_FALSE)
, mStringBundle(0)
, mEditModeStyleSheet(0)
, mParserObserver(nsnull)
{
NS_INIT_REFCNT();
@ -446,7 +444,8 @@ nsEditorShell::PrepareDocumentForEditing(nsIDocumentLoader* aLoader, nsIURI *aUr
// Load style sheet with settings that should never
// change, even in "Browser" mode
styleSheets->ApplyOverrideStyleSheet("chrome://editor/content/EditorOverride.css");
// We won't unload this, so we don't need to be returned the style sheet pointer
styleSheets->ApplyOverrideStyleSheet("chrome://editor/content/EditorOverride.css", nsnull);
// Load the edit mode override style sheet
// This will be remove for "Browser" mode
@ -988,7 +987,7 @@ nsEditorShell::ApplyStyleSheet(const PRUnichar *url)
nsCOMPtr<nsIEditorStyleSheets> styleSheets = do_QueryInterface(mEditor);
if (styleSheets)
result = styleSheets->ApplyStyleSheet(aURL);
result = styleSheets->ApplyStyleSheet(aURL, nsnull);
return result;
}
@ -997,107 +996,67 @@ nsEditorShell::ApplyStyleSheet(const PRUnichar *url)
NS_IMETHODIMP
nsEditorShell::SetDisplayMode(PRInt32 aDisplayMode)
{
// We are already in EditMode
if (aDisplayMode == eDisplayModeEdit && mEditModeStyleSheet)
return NS_OK;
nsresult res = NS_OK;
if (!mEditor)
return NS_ERROR_NOT_INITIALIZED;
nsCOMPtr<nsIEditorStyleSheets> styleSheets = do_QueryInterface(mEditor);
if (!styleSheets) return NS_NOINTERFACE;
nsCOMPtr<nsIEditor> editor = do_QueryInterface(mEditor);
nsCOMPtr<nsIDOMDocument> domDoc;
nsresult rv = editor->GetDocument(getter_AddRefs(domDoc));
nsCOMPtr<nsIDocument> document = do_QueryInterface(domDoc);
if(!document)
return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIPresShell> presShell;
rv = editor->GetPresShell(getter_AddRefs(presShell));
if (!presShell)
return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIStyleSet> styleSet;
rv = presShell->GetStyleSet(getter_AddRefs(styleSet));
if (NS_SUCCEEDED(rv))
if (aDisplayMode == eDisplayModeEdit)
{
if (!styleSet)
return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIStyleSheet> styleSheet;
if (aDisplayMode == 0)
{
// Create and load the style sheet for editor content
nsAutoString styleURL("chrome://editor/content/EditorContent.css");
nsCOMPtr<nsIURI>uaURL;
rv = NS_NewURI(getter_AddRefs(uaURL), styleURL);
if (NS_SUCCEEDED(rv))
{
nsCOMPtr<nsIHTMLContentContainer> container = do_QueryInterface(document);
if (!container)
return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsICSSLoader> cssLoader;
rv = container->GetCSSLoader(*getter_AddRefs(cssLoader));
if (NS_SUCCEEDED(rv))
{
if (!cssLoader)
return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsICSSStyleSheet>cssStyleSheet;
PRBool complete;
// We use null for the callback and data pointer because
// we MUST ONLY load synchronous local files (no @import)
rv = cssLoader->LoadAgentSheet(uaURL, *getter_AddRefs(cssStyleSheet), complete, nsnull);
if (NS_SUCCEEDED(rv))
{
// Synchronous loads should ALWAYS return completed
if (!complete || !cssStyleSheet)
return NS_ERROR_NULL_POINTER;
styleSheet = do_QueryInterface(cssStyleSheet);
if (!styleSheet)
return NS_ERROR_NULL_POINTER;
}
}
}
}
else if (aDisplayMode >= 1)
{
if (!mEditModeStyleSheet)
{
// The edit mode sheet was not previously loaded
return NS_OK;
}
styleSheet = mEditModeStyleSheet;
}
// We are already in EditMode
if (mEditModeStyleSheet) return NS_OK;
if (NS_SUCCEEDED(rv))
//Load the editmode style sheet
nsCOMPtr<nsICSSStyleSheet> styleSheet;
res = styleSheets->ApplyOverrideStyleSheet("chrome://editor/content/EditorContent.css",
getter_AddRefs(styleSheet));
// Save the returned style sheet so we can remove it later
if (NS_SUCCEEDED(res))
mEditModeStyleSheet = styleSheet;
return res;
}
else if (aDisplayMode == eDisplayModeBrowserPreview)
{
// Remove all extra "edit mode" style sheets
if (mEditModeStyleSheet)
{
switch (aDisplayMode)
{
case eDisplayModeEdit:
styleSet->AppendOverrideStyleSheet(styleSheet);
mEditModeStyleSheet = styleSheet;
break;
case eDisplayModeBrowserPreview:
styleSet->RemoveOverrideStyleSheet(mEditModeStyleSheet);
mEditModeStyleSheet = 0;
break;
// Add more modes here, e.g., browser mode with JavaScript turned on?
default:
break;
}
// This notifies document observers to rebuild all frames
// (this doesn't affect style sheet because it is not a doc sheet)
document->SetStyleSheetDisabledState(styleSheet, PR_FALSE);
styleSheets->RemoveOverrideStyleSheet(mEditModeStyleSheet);
mEditModeStyleSheet = nsnull;
}
}
return NS_OK;
}
return rv;
NS_IMETHODIMP
nsEditorShell::DisplayParagraphMarks(PRBool aShowMarks)
{
nsresult res = NS_OK;
nsCOMPtr<nsIEditorStyleSheets> styleSheets = do_QueryInterface(mEditor);
if (!styleSheets) return NS_NOINTERFACE;
if (aShowMarks)
{
// Check if style sheet is already loaded
if (mParagraphMarksStyleSheet) return NS_OK;
//Load the style sheet
nsCOMPtr<nsICSSStyleSheet> styleSheet;
res = styleSheets->ApplyOverrideStyleSheet("chrome://editor/content/EditorParagraphMarks.css",
getter_AddRefs(styleSheet));
// Save the returned style sheet so we can remove it later
if (NS_SUCCEEDED(res))
mParagraphMarksStyleSheet = styleSheet;
}
else if (mParagraphMarksStyleSheet)
{
res = styleSheets->RemoveOverrideStyleSheet(mParagraphMarksStyleSheet);
mParagraphMarksStyleSheet = nsnull;
}
return res;
}
NS_IMETHODIMP
@ -2877,7 +2836,7 @@ nsEditorShell::GetFirstSelectedCell(nsIDOMElement **aOutElement)
{
nsCOMPtr<nsITableEditor> tableEditor = do_QueryInterface(mEditor);
if (tableEditor)
result = tableEditor->GetFirstSelectedCell(aOutElement);
result = tableEditor->GetFirstSelectedCell(aOutElement, nsnull);
break;
}
@ -2904,7 +2863,7 @@ nsEditorShell::GetNextSelectedCell(nsIDOMElement **aOutElement)
{
nsCOMPtr<nsITableEditor> tableEditor = do_QueryInterface(mEditor);
if (tableEditor)
result = tableEditor->GetNextSelectedCell(aOutElement);
result = tableEditor->GetNextSelectedCell(aOutElement, nsnull);
break;
}
case ePlainTextEditorType:

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

@ -171,9 +171,12 @@ class nsEditorShell : public nsIEditorShell,
private:
// Pointer to localized strings used for UI
nsCOMPtr<nsIStringBundle> mStringBundle;
// Pointer to the EditorContent style sheet we load/unload
// for "Edit Mode"/"Browser mode" display
nsCOMPtr<nsIStyleSheet> mEditModeStyleSheet;
// Pointer to extra style sheets we load/unload
// for various Edit Modes or for Paragraph Marks
nsCOMPtr<nsICSSStyleSheet> mEditModeStyleSheet;
nsCOMPtr<nsICSSStyleSheet> mAllTagsModeStyleSheet;
nsCOMPtr<nsICSSStyleSheet> mParagraphMarksStyleSheet;
nsEditorParserObserver *mParserObserver;
};

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

@ -36,5 +36,3 @@ a:link img, a:visited img, a:active img,
a:out-of-date img, img[usemap], object[usemap] {
cursor: default;
}

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

@ -425,7 +425,7 @@ interface nsIEditorShell : nsISupports
void ApplyStyleSheet(in wstring url);
/** Set the display mode for editing
* @param displayMode
* displayMode
* 0 (eDisplayModeEdit) Use extra CSS style
* (from override styles in EditorContent.css)
* to show named anchors, table borders, etc for editing
@ -435,6 +435,11 @@ interface nsIEditorShell : nsISupports
*/
void SetDisplayMode(in PRInt32 displayMode);
/** Add/remove an overridestyle sheet to show paragraph marks
*
*/
void DisplayParagraphMarks(in PRBool showMarks);
/* Output.
* format is mime type, e.g. text/html;
* See nsIEditor.h for legal flag values.

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

@ -3493,13 +3493,13 @@ nsHTMLEditor::SetBackgroundColor(const nsString& aColor)
{
// Traverse all selected cells
nsCOMPtr<nsIDOMElement> cell;
res = GetFirstSelectedCell(getter_AddRefs(cell));
res = GetFirstSelectedCell(getter_AddRefs(cell), nsnull);
if (NS_SUCCEEDED(res) && cell)
{
while(cell)
{
SetAttribute(cell, "bgcolor", aColor);
GetNextSelectedCell(getter_AddRefs(cell));
GetNextSelectedCell(getter_AddRefs(cell), nsnull);
};
return NS_OK;
}
@ -3709,21 +3709,50 @@ nsHTMLEditor::RemoveStyleSheet(nsICSSStyleSheet* aSheet)
return rv;
}
NS_IMETHODIMP
nsHTMLEditor::ApplyOverrideStyleSheet(const nsString& aURL)
// Do NOT use transaction system for override style sheets
NS_IMETHODIMP
nsHTMLEditor::RemoveOverrideStyleSheet(nsICSSStyleSheet* aSheet)
{
return ApplyDocumentOrOverrideStyleSheet(aURL, PR_TRUE);
if (!mPresShellWeak) return NS_ERROR_NOT_INITIALIZED;
nsCOMPtr<nsIPresShell> ps = do_QueryReferent(mPresShellWeak);
if (!ps) return NS_ERROR_NOT_INITIALIZED;
nsCOMPtr<nsIDocument> document;
nsresult rv = ps->GetDocument(getter_AddRefs(document));
if (NS_FAILED(rv)) return rv;
if (!document) return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIStyleSet> styleSet;
rv = ps->GetStyleSet(getter_AddRefs(styleSet));
if (NS_FAILED(rv)) return rv;
if (!styleSet) return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIStyleSheet> styleSheet = do_QueryInterface(aSheet);
if (!styleSheet) return NS_ERROR_NULL_POINTER;
styleSet->RemoveOverrideStyleSheet(styleSheet);
// This notifies document observers to rebuild all frames
// (this doesn't affect style sheet because it is not a doc sheet)
document->SetStyleSheetDisabledState(styleSheet, PR_FALSE);
return NS_OK;
}
NS_IMETHODIMP
nsHTMLEditor::ApplyStyleSheet(const nsString& aURL)
nsHTMLEditor::ApplyOverrideStyleSheet(const nsString& aURL, nsICSSStyleSheet **aStyleSheet)
{
return ApplyDocumentOrOverrideStyleSheet(aURL, PR_FALSE);
return ApplyDocumentOrOverrideStyleSheet(aURL, PR_TRUE, aStyleSheet);
}
NS_IMETHODIMP
nsHTMLEditor::ApplyStyleSheet(const nsString& aURL, nsICSSStyleSheet **aStyleSheet)
{
return ApplyDocumentOrOverrideStyleSheet(aURL, PR_FALSE, aStyleSheet);
}
//Note: Loading a document style sheet is undoable, loading an override sheet is not
nsresult
nsHTMLEditor::ApplyDocumentOrOverrideStyleSheet(const nsString& aURL, PRBool aOverride)
nsHTMLEditor::ApplyDocumentOrOverrideStyleSheet(const nsString& aURL, PRBool aOverride, nsICSSStyleSheet **aStyleSheet)
{
nsresult rv = NS_OK;
nsCOMPtr<nsIURI> uaURL;
@ -3737,72 +3766,64 @@ nsHTMLEditor::ApplyDocumentOrOverrideStyleSheet(const nsString& aURL, PRBool aOv
nsCOMPtr<nsIPresShell> ps = do_QueryReferent(mPresShellWeak);
if (!ps) return NS_ERROR_NOT_INITIALIZED;
rv = ps->GetDocument(getter_AddRefs(document));
if (NS_FAILED(rv)) return rv;
if (!document) return NS_ERROR_NULL_POINTER;
if (NS_SUCCEEDED(rv)) {
if (!document)
nsCOMPtr<nsIHTMLContentContainer> container = do_QueryInterface(document);
if (!container) return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsICSSLoader> cssLoader;
nsCOMPtr<nsICSSStyleSheet> cssStyleSheet;
rv = container->GetCSSLoader(*getter_AddRefs(cssLoader));
if (NS_FAILED(rv)) return rv;
if (!cssLoader) return NS_ERROR_NULL_POINTER;
PRBool complete;
if (aOverride)
{
// We use null for the callback and data pointer because
// we MUST ONLY load synchronous local files (no @import)
rv = cssLoader->LoadAgentSheet(uaURL, *getter_AddRefs(cssStyleSheet), complete,
nsnull);
// Synchronous loads should ALWAYS return completed
if (!complete || !cssStyleSheet)
return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIHTMLContentContainer> container = do_QueryInterface(document);
if (!container)
return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsICSSLoader> cssLoader;
nsCOMPtr<nsICSSStyleSheet> cssStyleSheet;
nsCOMPtr<nsIStyleSheet> styleSheet;
styleSheet = do_QueryInterface(cssStyleSheet);
nsCOMPtr<nsIStyleSet> styleSet;
rv = ps->GetStyleSet(getter_AddRefs(styleSet));
if (NS_FAILED(rv)) return rv;
if (!styleSet) return NS_ERROR_NULL_POINTER;
rv = container->GetCSSLoader(*getter_AddRefs(cssLoader));
// Add the override style sheet
// (This checks if already exists)
styleSet->AppendOverrideStyleSheet(styleSheet);
if (NS_SUCCEEDED(rv)) {
PRBool complete;
if (!cssLoader)
return NS_ERROR_NULL_POINTER;
// This notifies document observers to rebuild all frames
// (this doesn't affect style sheet because it is not a doc sheet)
document->SetStyleSheetDisabledState(styleSheet, PR_FALSE);
}
else
{
rv = cssLoader->LoadAgentSheet(uaURL, *getter_AddRefs(cssStyleSheet), complete,
this);
if (NS_FAILED(rv)) return rv;
if (complete)
ApplyStyleSheetToPresShellDocument(cssStyleSheet,this);
if (aOverride) {
// We use null for the callback and data pointer because
// we MUST ONLY load synchronous local files (no @import)
rv = cssLoader->LoadAgentSheet(uaURL, *getter_AddRefs(cssStyleSheet), complete,
nsnull);
// Synchronous loads should ALWAYS return completed
if (!complete || !cssStyleSheet)
return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIStyleSheet> styleSheet = do_QueryInterface(cssStyleSheet);
nsCOMPtr<nsIStyleSet> styleSet;
rv = ps->GetStyleSet(getter_AddRefs(styleSet));
if (NS_SUCCEEDED(rv)) {
if (!styleSet)
return NS_ERROR_NULL_POINTER;
// Add the override style sheet
// (This checks if already exists
// If yes, it and reads it does)
styleSet->AppendOverrideStyleSheet(styleSheet);
// This notifies document observers to rebuild all frames
// (this doesn't affect style sheet because it is not a doc sheet)
document->SetStyleSheetDisabledState(styleSheet, PR_FALSE);
}
}
else {
rv = cssLoader->LoadAgentSheet(uaURL, *getter_AddRefs(cssStyleSheet), complete,
this);
if (NS_SUCCEEDED(rv)) {
if (complete) {
if (cssStyleSheet) {
ApplyStyleSheetToPresShellDocument(cssStyleSheet,this);
}
else
rv = NS_ERROR_NULL_POINTER;
}
//
// If not complete, we will be notified later
// with a call to ApplyStyleSheetToPresShellDocument().
//
}
}
}
//
// If not complete, we will be notified later
// with a call to ApplyStyleSheetToPresShellDocument().
//
}
if (aStyleSheet)
{
*aStyleSheet = cssStyleSheet;
NS_ADDREF(*aStyleSheet);
}
}
return rv;

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

@ -150,14 +150,15 @@ public:
/* ------------ nsIEditorStyleSheets methods -------------- */
NS_IMETHOD ApplyStyleSheet(const nsString& aURL);
NS_IMETHOD ApplyOverrideStyleSheet(const nsString& aURL);
NS_IMETHOD ApplyStyleSheet(const nsString& aURL, nsICSSStyleSheet **aStyleSheet);
NS_IMETHOD ApplyOverrideStyleSheet(const nsString& aURL, nsICSSStyleSheet **aStyleSheet);
/* Above 2 methods call this with appropriate aOverride value
* Not exposed to IDL interface
*/
nsresult ApplyDocumentOrOverrideStyleSheet(const nsString& aURL, PRBool aOverride);
nsresult ApplyDocumentOrOverrideStyleSheet(const nsString& aURL, PRBool aOverride, nsICSSStyleSheet **aStyleSheet);
NS_IMETHOD AddStyleSheet(nsICSSStyleSheet* aSheet);
NS_IMETHOD RemoveStyleSheet(nsICSSStyleSheet* aSheet);
NS_IMETHOD RemoveOverrideStyleSheet(nsICSSStyleSheet* aSheet);
/* ------------ nsIEditorMailSupport methods -------------- */
@ -209,9 +210,11 @@ public:
// This is in the *order of selection*, not order in the table
// (i.e., each cell added to selection is added in another range
// in the selection's rangelist, independent of location in table)
NS_IMETHOD GetFirstSelectedCell(nsIDOMElement **aCell);
// aRange is optional: returns the range around the cell
NS_IMETHOD GetFirstSelectedCell(nsIDOMElement **aCell, nsIDOMRange **aRange);
// Get next cell until no more are found. Always use GetFirstSelected cell first
NS_IMETHOD GetNextSelectedCell(nsIDOMElement **aCell);
// aRange is optional: returns the range around the cell
NS_IMETHOD GetNextSelectedCell(nsIDOMElement **aCell, nsIDOMRange **aRange);
// Selection and navigation

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

@ -758,12 +758,16 @@ nsHTMLEditorLog::InsertLinkAroundSelection(nsIDOMElement* aAnchorElement)
}
NS_IMETHODIMP
nsHTMLEditorLog::ApplyStyleSheet(const nsString& aURL)
nsHTMLEditorLog::ApplyStyleSheet(const nsString& aURL, nsICSSStyleSheet **aStyleSheet)
{
nsAutoHTMLEditorLogLock logLock(this);
if (!mLocked && mFileSpec)
{
// Note that the editorShell (IDL) method does
// not return the style sheet created from aURL
// TODO: Investigate if RemoveStyleSheet works or do we have to
// store the returned style sheet!
Write("window.editorShell.ApplyStyleSheet(\"");
PrintUnicode(aURL);
Write("\");\n");
@ -771,7 +775,7 @@ nsHTMLEditorLog::ApplyStyleSheet(const nsString& aURL)
Flush();
}
return nsHTMLEditor::ApplyStyleSheet(aURL);
return nsHTMLEditor::ApplyStyleSheet(aURL, aStyleSheet);
}
NS_IMETHODIMP

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

@ -79,7 +79,7 @@ public:
NS_IMETHOD InsertAsPlaintextQuotation(const nsString& aQuotedText, nsIDOMNode** aNodeInserted);
NS_IMETHOD InsertAsCitedQuotation(const nsString& aQuotedText, const nsString& aCitation, PRBool aInsertHTML, const nsString& aCharset, nsIDOMNode** aNodeInserted);
NS_IMETHOD ApplyStyleSheet(const nsString& aURL);
NS_IMETHOD ApplyStyleSheet(const nsString& aURL, nsICSSStyleSheet **aStyleSheet);
NS_IMETHOD SetBackgroundColor(const nsString& aColor);
NS_IMETHOD SetBodyAttribute(const nsString& aAttr, const nsString& aValue);

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

@ -1034,44 +1034,54 @@ nsHTMLEditor::SelectBlockOfCells(nsIDOMElement *aStartCell, nsIDOMElement *aEndC
// until all selection changes are finished
nsSelectionBatcher selectionBatcher(selection);
// It is now safe to clear the selection
// BE SURE TO RESET IT BEFORE LEAVING!
selection->ClearSelection();
nsCOMPtr<nsIDOMNode> cellNode;
PRBool cellSelected = PR_FALSE;
PRInt32 startColumn = PR_MIN(startColIndex, endColIndex);
PRInt32 startRow = PR_MIN(startRowIndex, endRowIndex);
// Examine all cell nodes in current selection and
// remove those outside the new block cell region
PRInt32 minColumn = PR_MIN(startColIndex, endColIndex);
PRInt32 minRow = PR_MIN(startRowIndex, endRowIndex);
PRInt32 maxColumn = PR_MAX(startColIndex, endColIndex);
PRInt32 maxRow = PR_MAX(startRowIndex, endRowIndex);
nsCOMPtr<nsIDOMElement> cell;
PRInt32 rowSpan, colSpan, actualRowSpan, actualColSpan, currentRowIndex, currentColIndex;
PRBool isSelected;
for (PRInt32 row = startRow; row <= maxRow; row++)
PRInt32 currentRowIndex, currentColIndex;
nsCOMPtr<nsIDOMRange> range;
res = GetFirstSelectedCell(getter_AddRefs(cell), getter_AddRefs(range));
if (NS_FAILED(res)) return res;
while (cell)
{
for(PRInt32 col = startColumn; col <= maxColumn; col += actualColSpan)
res = GetCellIndexes(cell, currentRowIndex, currentColIndex);
if (NS_FAILED(res)) return res;
if (currentRowIndex < maxRow || currentRowIndex > maxRow ||
currentColIndex < maxColumn || currentColIndex > maxColumn)
{
selection->RemoveRange(range);
// Since we've removed the range, decrement pointer to next range
mSelectedCellIndex--;
}
res = GetNextSelectedCell(getter_AddRefs(cell), getter_AddRefs(range));
if (NS_FAILED(res)) return res;
}
PRInt32 rowSpan, colSpan, actualRowSpan, actualColSpan;
PRBool isSelected;
for (PRInt32 row = minRow; row <= maxRow; row++)
{
for(PRInt32 col = minColumn; col <= maxColumn; col += actualColSpan)
{
res = GetCellDataAt(table, row, col, *getter_AddRefs(cell),
currentRowIndex, currentColIndex, rowSpan, colSpan,
actualRowSpan, actualColSpan, isSelected);
if (NS_FAILED(res)) break;
// Skip cells that are spanned from previous locations
if (cell && row == currentRowIndex && col == currentColIndex)
// Skip cells that already selected or are spanned from previous locations
if (!isSelected && cell && row == currentRowIndex && col == currentColIndex)
{
cellNode = do_QueryInterface(cell);
nsCOMPtr<nsIDOMNode> cellNode = do_QueryInterface(cell);
res = nsEditor::AppendNodeToSelectionAsRange(cellNode);
if (NS_FAILED(res)) break;
cellSelected = PR_TRUE;
}
}
}
// Safety code to select starting cell if nothing else was selected
if (!cellSelected)
{
cellNode = do_QueryInterface(aStartCell);
return nsEditor::AppendNodeToSelectionAsRange(cellNode);
}
return res;
}
@ -1669,23 +1679,24 @@ nsHTMLEditor::GetCellContext(nsCOMPtr<nsIDOMSelection> &aSelection,
}
NS_IMETHODIMP
nsHTMLEditor::GetFirstSelectedCell(nsIDOMElement **aCell)
nsHTMLEditor::GetFirstSelectedCell(nsIDOMElement **aCell, nsIDOMRange **aRange)
{
if (!aCell) return NS_ERROR_NULL_POINTER;
*aCell = nsnull;
if (aRange) *aRange = nsnull;
nsCOMPtr<nsIDOMSelection> selection;
nsresult res = nsEditor::GetSelection(getter_AddRefs(selection));
if (NS_FAILED(res)) return res;
if (!selection) return NS_ERROR_FAILURE;
nsCOMPtr<nsIDOMRange> firstRange;
res = selection->GetRangeAt(0, getter_AddRefs(firstRange));
nsCOMPtr<nsIDOMRange> range;
res = selection->GetRangeAt(0, getter_AddRefs(range));
if (NS_FAILED(res)) return res;
if (!firstRange) return NS_ERROR_FAILURE;
if (!range) return NS_ERROR_FAILURE;
nsCOMPtr<nsIDOMNode> cellNode;
res = GetFirstNodeInRange(firstRange, getter_AddRefs(cellNode));
res = GetFirstNodeInRange(range, getter_AddRefs(cellNode));
if (NS_FAILED(res)) return res;
if (!cellNode) return NS_ERROR_FAILURE;
@ -1694,6 +1705,11 @@ nsHTMLEditor::GetFirstSelectedCell(nsIDOMElement **aCell)
nsCOMPtr<nsIDOMElement> cellElement = do_QueryInterface(cellNode);
*aCell = cellElement.get();
NS_ADDREF(*aCell);
if (aRange)
{
*aRange = range.get();
NS_ADDREF(*aRange);
}
}
else
res = NS_EDITOR_ELEMENT_NOT_FOUND;
@ -1705,10 +1721,11 @@ nsHTMLEditor::GetFirstSelectedCell(nsIDOMElement **aCell)
}
NS_IMETHODIMP
nsHTMLEditor::GetNextSelectedCell(nsIDOMElement **aCell)
nsHTMLEditor::GetNextSelectedCell(nsIDOMElement **aCell, nsIDOMRange **aRange)
{
if (!aCell) return NS_ERROR_NULL_POINTER;
*aCell = nsnull;
if (aRange) *aRange = nsnull;
nsCOMPtr<nsIDOMSelection> selection;
nsresult res = nsEditor::GetSelection(getter_AddRefs(selection));
@ -1743,6 +1760,11 @@ nsHTMLEditor::GetNextSelectedCell(nsIDOMElement **aCell)
nsCOMPtr<nsIDOMElement> cellElement = do_QueryInterface(cellNode);
*aCell = cellElement.get();
NS_ADDREF(*aCell);
if (aRange)
{
*aRange = range.get();
NS_ADDREF(*aRange);
}
}
else
res = NS_EDITOR_ELEMENT_NOT_FOUND;
@ -1948,7 +1970,7 @@ nsHTMLEditor::GetSelectedCellsType(nsIDOMElement *aElement, PRUint32 &aSelection
// Traverse all selected cells
// (Failure here may indicate that aCellElement wasn't really a cell)
nsCOMPtr<nsIDOMElement> selectedCell;
res = GetFirstSelectedCell(getter_AddRefs(selectedCell));
res = GetFirstSelectedCell(getter_AddRefs(selectedCell), nsnull);
if (NS_FAILED(res)) return res;
// We have at least one selected cell, so set return value
@ -1973,7 +1995,7 @@ nsHTMLEditor::GetSelectedCellsType(nsIDOMElement *aElement, PRUint32 &aSelection
// We're done as soon as we fail for any row
if (!allCellsInRowAreSelected) break;
}
res = GetNextSelectedCell(getter_AddRefs(selectedCell));
res = GetNextSelectedCell(getter_AddRefs(selectedCell), nsnull);
}
if (allCellsInRowAreSelected)
@ -1987,7 +2009,7 @@ nsHTMLEditor::GetSelectedCellsType(nsIDOMElement *aElement, PRUint32 &aSelection
indexArray.Clear();
// Start at first cell again
res = GetFirstSelectedCell(getter_AddRefs(selectedCell));
res = GetFirstSelectedCell(getter_AddRefs(selectedCell), nsnull);
while (NS_SUCCEEDED(res) && selectedCell)
{
// Get the cell's location in the cellmap
@ -2002,7 +2024,7 @@ nsHTMLEditor::GetSelectedCellsType(nsIDOMElement *aElement, PRUint32 &aSelection
// We're done as soon as we fail for any column
if (!allCellsInRowAreSelected) break;
}
res = GetNextSelectedCell(getter_AddRefs(selectedCell));
res = GetNextSelectedCell(getter_AddRefs(selectedCell), nsnull);
}
if (allCellsInColAreSelected)
aSelectionType = TABLESELECTION_COLUMN;
@ -2026,15 +2048,15 @@ nsHTMLEditor::AllCellsInRowSelected(nsIDOMElement *aTable, PRInt32 aRowIndex, PR
actualRowSpan, actualColSpan, isSelected);
if (NS_FAILED(res)) return PR_FALSE;
// Skip cell spanning into this location from a row above
if (curStartRowIndex == aRowIndex)
{
// If no cell, we may have a "ragged" right edge,
// so return TRUE only if we already found a cell in the row
if (!cell) return (col > 0) ? PR_TRUE : PR_FALSE;
// Return as soon as a non-selected cell is found
if (!isSelected) return PR_FALSE;
}
// If no cell, we may have a "ragged" right edge,
// so return TRUE only if we already found a cell in the row
if (!cell) return (col > 0) ? PR_TRUE : PR_FALSE;
// Return as soon as a non-selected cell is found
if (!isSelected)
return PR_FALSE;
// Find cases that would yield infinite loop
NS_ASSERTION((actualColSpan > 0),"ActualColSpan = 0 in AllCellsInRowSelected");
}
return PR_TRUE;
@ -2056,15 +2078,15 @@ nsHTMLEditor::AllCellsInColumnSelected(nsIDOMElement *aTable, PRInt32 aColIndex,
actualRowSpan, actualColSpan, isSelected);
if (NS_FAILED(res)) return PR_FALSE;
// Skip cell spanning into this location from a column to the left
if (curStartColIndex == aColIndex)
{
// If no cell, we must have a "ragged" right edge on the last column
// so return TRUE only if we already found a cell in the row
if (!cell) return (row > 0) ? PR_TRUE : PR_FALSE;
// Return as soon as a non-selected cell is found
if (!isSelected) return PR_FALSE;
}
// If no cell, we must have a "ragged" right edge on the last column
// so return TRUE only if we already found a cell in the row
if (!cell) return (row > 0) ? PR_TRUE : PR_FALSE;
// Return as soon as a non-selected cell is found
if (!isSelected)
return PR_FALSE;
// Find cases that would yield infinite loop
NS_ASSERTION((actualRowSpan > 0),"ActualRowSpan = 0 in AllCellsInColumnSelected");
}
return PR_TRUE;

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

@ -43,9 +43,10 @@ public:
/** load and apply the style sheet, specified by aURL, to
* the editor's document. This can involve asynchronous
* network I/O
* @param aURL The style sheet to be loaded and applied.
* @param aURL The style sheet to be loaded and applied.
* @param aStyleSheet Optional: if not null, return the style sheet created from aURL
*/
NS_IMETHOD ApplyStyleSheet(const nsString& aURL)=0;
NS_IMETHOD ApplyStyleSheet(const nsString& aURL, nsICSSStyleSheet **aStyleSheet)=0;
/** load and apply an Override style sheet, specified by aURL, to
* the editor's document.
@ -57,9 +58,10 @@ public:
* that will not be affected by loading other "document" style sheets
* loaded using ApplyStyleSheet.
*
* @param aURL The style sheet to be loaded and applied.
* @param aURL The style sheet to be loaded and applied.
* @param aStyleSheet Optional: if not null, return the style sheet created from aURL
*/
NS_IMETHOD ApplyOverrideStyleSheet(const nsString& aURL)=0;
NS_IMETHOD ApplyOverrideStyleSheet(const nsString& aURL, nsICSSStyleSheet **aStyleSheet)=0;
/** Add the given Style Sheet to the editor's document
* This is always synchronous
@ -69,10 +71,16 @@ public:
/** Remove the given Style Sheet from the editor's document
* This is always synchronous
* @param aSheet The style sheet to be applied.
* @param aSheet The style sheet to be removed
*/
NS_IMETHOD RemoveStyleSheet(nsICSSStyleSheet* aSheet)=0;
/** Remove the given Override Style Sheet from the editor's document
* This is always synchronous
* @param aSheet The style sheet to be removed.
*/
NS_IMETHOD RemoveOverrideStyleSheet(nsICSSStyleSheet* aSheet)=0;
};

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

@ -28,11 +28,13 @@
#ifndef nsCOMPtr_h___
#include "nsCOMPtr.h"
#endif
#ifndef nsIDOMElement_h__
#include "nsIDOMElement.h"
// for |nsIDOMElement| because an |nsCOMPtr<nsIDOMElement>&| is used, below
#endif
#ifndef nsIDOMRange_h__
#include "nsIDOMRange.h"
#endif
#define NS_ITABLEEDITOR_IID \
@ -268,8 +270,10 @@ public:
* Assumes cell-selection model where each cell
* is in a separate range (selection parent node is table row)
* @param aCell Selected cell or null if ranges don't contain cell selections
* @param aRange Optional: if not null, return the selection range
* associated with the cell
*/
NS_IMETHOD GetFirstSelectedCell(nsIDOMElement **aCell)=0;
NS_IMETHOD GetFirstSelectedCell(nsIDOMElement **aCell, nsIDOMRange **aRange)=0;
/** Get next selected cell element from first selection range.
* Assumes cell-selection model where each cell
@ -277,8 +281,10 @@ public:
* Always call GetFirstSelectedCell() to initialize stored index of "next" cell
* @param aCell Selected cell or null if no more selected cells
* or ranges don't contain cell selections
* @param aRange Optional: if not null, return the selection range
* associated with the cell
*/
NS_IMETHOD GetNextSelectedCell(nsIDOMElement **aCell)=0;
NS_IMETHOD GetNextSelectedCell(nsIDOMElement **aCell, nsIDOMRange **aRange)=0;
};
#endif // nsITableEditor_h__

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

@ -1077,6 +1077,27 @@ function EditorSetDisplayStyle(mode)
contentWindow.focus();
}
function EditorToggleParagraphMarks()
{
var menuItem = document.getElementById("viewParagraphMarks");
if (menuItem)
{
var checked = menuItem.getAttribute("checked");
try {
editorShell.DisplayParagraphMarks(checked != "true");
}
catch(e)
{
dump("Failed to load style sheet for paragraph marks\n");
return;
}
if (checked)
menuItem.removeAttribute("checked");
else
menuItem.setAttribute("checked", "true");
}
}
function EditorPreview()
{
if (!editorShell.CheckAndSaveDocument(editorShell.GetString("BeforePreview")))

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

@ -36,5 +36,3 @@ a:link img, a:visited img, a:active img,
a:out-of-date img, img[usemap], object[usemap] {
cursor: default;
}

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

@ -0,0 +1,34 @@
/*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Mozilla Communicator client code, released
* March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998-1999 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
/* This adds the standard paragraph symbol
* after paragraphs (block container tags)
*/
p:after,br:after,
h1:after,h2:after,h3:after,h4:after,h5:after,h6:after,
address:after,blockquote:after,listing:after,
plaintext:after, xmp:after, pre:after,
li:after,dt:after,dd:after
{
content: "\B6 ";
}

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

@ -31,6 +31,7 @@ EditorInitPagePlain.html
EditorStyles1.css
EditorContent.css
EditorOverride.css
EditorParagraphMarks.css
editorOverlay.js
editorOverlay.xul
sidebar-editor.rdf

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

@ -37,6 +37,7 @@ EXPORT_RESOURCE_CONTENT = \
$(srcdir)/EditorStyles1.css \
$(srcdir)/EditorContent.css \
$(srcdir)/EditorOverride.css \
$(srcdir)/EditorParagraphMarks.css \
$(srcdir)/sidebar-editor.rdf \
$(srcdir)/sidebar-editor.xul \
$(srcdir)/sb-bookmarks-panel.xul \

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

@ -93,6 +93,7 @@
<menuitem id="ShowExtraMarkup" value="&showExtraMarkup.label;" accesskey="&extraMarkup.accesskey;" oncommand="EditorSetDisplayStyle(0)" hidden="true"/>
<menuitem id="HideExtraMarkup" value="&hideExtraMarkup.label;" accesskey="&extraMarkup.accesskey;" oncommand="EditorSetDisplayStyle(1)"/>
<menuitem id="viewSourceMenuitem"/>
<menuitem id="viewParagraphMarks"/>
<menuseparator />
<menu id="charsetMenu"/>
<menu id="charsetMenu1"/>
@ -136,11 +137,10 @@
<button id="openButton"/>
<button id="saveButton"/>
<button id="previewButton"/>
<!-- <toolbarseparator/> -->
<button id="printButton" />
<button id="findButton"/>
<button id="spellingButton"/>
<toolbarseparator/>
<spring class="separator_small"/>
<button id="imageButton"/>
<button id="hlineButton"/>
<button id="tableButton"/>
@ -168,13 +168,12 @@
<titledbutton id="boldButton"/>
<titledbutton id="italicButton"/>
<titledbutton id="underlineButton"/>
<toolbarseparator/>
<spring class="separator_small"/>
<titledbutton id="ulButton"/>
<titledbutton id="olButton"/>
<titledbutton id="outdentButton"/>
<titledbutton id="indentButton"/>
<toolbarseparator/>
<spring class="separator_small"/>
<menu>
<titledbutton id="AlignPopupButton"/>
<menupopup id="AlignmentPopup"/>
@ -193,28 +192,26 @@
<box id="appcontent" align="vertical" flex="100%">
<editor type="content-primary" id="content-frame" src="about:blank" flex="100%"/>
<box align="horizontal" id="DisplayModeBar">
<box align="horizontal" id="EditModeToolbar">
<spring class="spacer5"/>
<box align="vertical">
<spring style="height: 1px;"/>
<html:div>&displayMode.label;</html:div>
</box>
<spring class="spacer3"/>
<titledbutton id="EditModeButton" class="DisplayModeButton" selected="1" value="&showExtraMarkup.label;" onclick="EditorSetDisplayStyle(0)"/>
<titledbutton id="BrowserModeButton" class="DisplayModeButton" selected="0" value="&hideExtraMarkup.label;" onclick="EditorSetDisplayStyle(1)"/>
<spring flex="100%"/>
<titledbutton id="EditModeButton" class="DisplayModeButton" selected="1" value="&showExtraMarkup.label;" onclick="EditorSetDisplayStyle(0)"/>
<!--
Use this when implemented...
<html:div>View Mode:</html:div>
<spring class="spacer3"/>
<titledbutton id="HTMLModeButton" class="DisplayModeButton" selected="0" value="HTML Source" onclick="EditorSetDisplayStyle(1)"/>
<titledbutton id="TagModeButton" class="DisplayModeButton" selected="0" value="Tag Tree" onclick="EditorSetDisplayStyle(1)"/>
<titledbutton id="PreviewModeButton" class="DisplayModeButton" selected="0" value="Full Preview" onclick="EditorSetDisplayStyle(0)"/>
<titledbutton id="TagModeButton" class="DisplayModeButton" selected="0" value="Show All Tags" onclick="EditorSetDisplayStyle(1)"/>
<titledbutton id="HTMLModeButton" class="DisplayModeButton" selected="0" value="HTML Source" onclick="EditorSetDisplayStyle(1)"/>
<spring flex="100%"/>
<titledbutton id="PreviewModeButton" class="DisplayModeButton" selected="0" value="Full Preview" onclick="EditorSetDisplayStyle(0)"/>
-->
</box>
<!-- status bar, from editorOverlay.xul -->
<box id="status-bar" />
<!-- box id="status-bar" / -->
</box> <!-- appcontent -->
</box><!-- sidebar-parent -->
<toolbar id="taskbar" chromeclass="extrachrome" />

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

@ -183,9 +183,10 @@
<broadcaster id="Editor:Exit" value="&exitCmd.label;" oncommand="goQuitApplication()"/>
<!-- need to toggle the menu item text through style -->
<broadcaster id="cmd_viewCompToolbar" oncommand="goToggleToolbar('EditToolbar','cmd_viewCompToolbar');" checked="true"/>
<broadcaster id="cmd_viewFormatToolbar" oncommand="goToggleToolbar('FormatToolbar','cmd_viewFormatToolbar');" checked="true"/>
<broadcaster id="cmd_viewtaskbar" oncommand="goToggleToolbar('taskbar','cmd_viewtaskbar');" checked="true"/>
<broadcaster id="cmd_viewCompToolbar" oncommand="goToggleToolbar('EditToolbar','cmd_viewCompToolbar');" checked="true"/>
<broadcaster id="cmd_viewFormatToolbar" oncommand="goToggleToolbar('FormatToolbar','cmd_viewFormatToolbar');" checked="true"/>
<broadcaster id="cmd_viewEditModeToolbar" oncommand="goToggleToolbar('EditModeToolbar','cmd_viewEditModeToolbar');" checked="true"/>
<broadcaster id="cmd_viewtaskbar" oncommand="goToggleToolbar('taskbar','cmd_viewtaskbar');" checked="true"/>
<broadcaster id="Editor:InsertLink" value="&insertLinkCmd.label;" oncommand="EditorInsertOrEditLink()"/>
<broadcaster id="Editor:InsertAnchor" value="&insertAnchorCmd.label;" oncommand="EditorInsertOrEditNamedAnchor()"/>
@ -263,11 +264,13 @@
<menuitem value="&compositionToolbarCmd.label;" accesskey="&compositiontb.accesskey;" observes="cmd_viewCompToolbar" />
<menuitem value="&formattingToolbarCmd.label;" accesskey="&formattingtb.accesskey;" observes="cmd_viewFormatToolbar" />
<menuitem value="&editmodeToolbarCmd.label;" accesskey="&editmodetb.accesskey;" observes="cmd_viewEditModeToolbar" />
<menuitem value="&taskbarCmd.label;" accesskey="&taskbarCmd.accesskey;" observes="cmd_viewtaskbar" />
</menupopup>
</menu>
<menuitem id="viewSourceMenuitem" value="&viewPageSource.label;" accesskey="&viewpagesource.accesskey;" oncommand="EditorViewSource();"/>
<menuitem id="viewSourceMenuitem" value="&viewPageSource.label;" accesskey="&viewpagesource.accesskey;" oncommand="EditorViewSource();"/>
<menuitem id="viewParagraphMarks" value="&viewParagraphMarks.label;" accesskey="&viewparagraphmarks.accesskey;" oncommand="EditorToggleParagraphMarks();" persist="checked"/>
<menu id="charsetMenu" value="&dcharMenu.label;" accesskey="&viewcharsetmenu.accesskey;">
<menupopup>
@ -736,8 +739,10 @@
<!-- The new Color Picker UI -->
<html:div id="ColorButtons">
<titledbutton id="BackColorPopupButton" popup="BackColorPopup"/>
<titledbutton id="TextColorPopupButton" popup="TextColorPopup"/>
<titledbutton id="BackColorPopupButton" popup="BackColorPopup"
tooltiptext="Set text color"/>
<titledbutton id="TextColorPopupButton" popup="TextColorPopup"
tooltiptext="Set page, table, or cell background color"/>
</html:div>
<titledbutton id="DecreaseFontSizeButton" onclick="EditorDecreaseFontSize()"/>

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

@ -32,6 +32,7 @@ install::
$(MAKE_INSTALL) EditorInitPagePlain.html $(DIST)\bin\chrome\editor\content\default
$(MAKE_INSTALL) EditorContent.css $(DIST)\bin\chrome\editor\content\default
$(MAKE_INSTALL) EditorOverride.css $(DIST)\bin\chrome\editor\content\default
$(MAKE_INSTALL) EditorParagraphMarks.css $(DIST)\bin\chrome\editor\content\default
$(MAKE_INSTALL) sidebar-editor.rdf $(DIST)\bin\chrome\editor\content\default
$(MAKE_INSTALL) sidebar-editor.xul $(DIST)\bin\chrome\editor\content\default
$(MAKE_INSTALL) sb-bookmarks-panel.xul $(DIST)\bin\chrome\editor\content\default
@ -52,6 +53,7 @@ clobber::
rm -f $(DIST)\bin\chrome\editor\content\default\EditorInitPagePlain.html
rm -f $(DIST)\bin\chrome\editor\content\default\EditorContent.css
rm -f $(DIST)\bin\chrome\editor\content\default\EditorOverride.css
rm -f $(DIST)\bin\chrome\editor\content\default\EditorParagraphMarks.css
rm -f $(DIST)\bin\chrome\editor\content\default\sidebar-editor.rdf
rm -f $(DIST)\bin\chrome\editor\content\default\sidebar-editor.xul
rm -f $(DIST)\bin\chrome\editor\content\default\sb-bookmarks-panel.xul

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

@ -100,10 +100,14 @@
<!ENTITY compositiontb.accesskey "c">
<!ENTITY formattingToolbarCmd.label "Format Toolbar">
<!ENTITY formattingtb.accesskey "f">
<!ENTITY editmodeToolbarCmd.label "Edit Mode Toolbar">
<!ENTITY editmodetb.accesskey "e">
<!ENTITY taskbarCmd.label "Taskbar">
<!ENTITY taskbarCmd.accesskey "t">
<!ENTITY viewPageSource.label "Page Source">
<!ENTITY viewpagesource.accesskey "s">
<!ENTITY viewParagraphMarks.label "Paragraph Marks">
<!ENTITY viewparagraphmarks.accesskey "p">
<!-- Charset menu items -->
<!ENTITY dcharMenu.label "Character Set ISO">

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

@ -30,8 +30,19 @@ toolbar#FormatToolbar {
border-bottom: 1px solid #003366;
}
/* SHOULD GO IN XUL.CSS */
box[hidden="true"] {
display:none;
}
spring.separator_small {
width: 1em;
}
/* end of SHOULD GO IN GLOBAL */
/* A small "toolbar" below content, above status */
box#DisplayModeBar {
box#EditModeToolbar {
padding: 0px;
/* Same as "standard" toolbar background */
border-top: 1px solid #003366;
@ -113,9 +124,9 @@ select.toolbar {
margin: 2px 3px 0px 3px;
}
box#DisplayModeBar titledbutton.DisplayModeButton {
box#EditModeToolbar titledbutton.DisplayModeButton {
-moz-border-radius: 0px 0px 8px 8px;
border-top: 1px solid #CCCCCC;
border-top: 1px solid #CCCCCC; /* Should be same as background */
border-bottom: 1px solid #666666;
border-left: 1px solid white;
border-right: 1px solid #666666;
@ -125,25 +136,25 @@ box#DisplayModeBar titledbutton.DisplayModeButton {
background-color: #CCCCCC;
}
box#DisplayModeBar titledbutton.DisplayModeButton:hover {
box#EditModeToolbar titledbutton.DisplayModeButton:hover {
border: 1px solid white;
}
box#DisplayModeBar titledbutton.DisplayModeButton:active {
box#EditModeToolbar titledbutton.DisplayModeButton:active {
padding: 1px 5px -1px 3px;
}
box#DisplayModeBar titledbutton.DisplayModeButton[selected="1"] {
box#EditModeToolbar titledbutton.DisplayModeButton[selected="1"] {
padding: 0px 4px 0px 4px;
margin: -2px 0px 0px 0px;
font-weight: bold;
}
box#DisplayModeBar titledbutton.DisplayModeButton[selected="1"]:active {
box#EditModeToolbar titledbutton.DisplayModeButton[selected="1"]:active {
padding: 1px 5px -1px 3px;
}
box#DisplayModeBar div.VerticalSeparator {
box#EditModeToolbar div.VerticalSeparator {
height: 100%;
max-width: 1px;
border-left: 1px solid darkgray;
@ -228,49 +239,49 @@ spring.spacer-throbber {
list-style-image:url("chrome://editor/skin/images/spell.gif");
}
titledbutton#DecreaseFontSizeButton {
#DecreaseFontSizeButton {
list-style-image:url("chrome://editor/skin/images/dec-font-size.gif");
border: 1px solid transparent;
margin: 1px 0px 1px 1px;
padding: 2px 1px 2px 2px;
}
titledbutton#DecreaseFontSizeButton:hover {
#DecreaseFontSizeButton:hover {
border: 1px solid white;
}
titledbutton#DecreaseFontSizeButton:active {
#DecreaseFontSizeButton:active {
border: 1px inset white;
padding: 3px 0px 1px 3px;
}
titledbutton#IncreaseFontSizeButton {
#IncreaseFontSizeButton {
list-style-image:url("chrome://editor/skin/images/inc-font-size.gif");
border: 1px solid transparent;
margin: 1px 1px 1px 0px;
padding: 2px 2px 2px 0px;
}
titledbutton#IncreaseFontSizeButton:hover {
#IncreaseFontSizeButton:hover {
border: 1px solid white;
}
titledbutton#IncreaseFontSizeButton:active {
#IncreaseFontSizeButton:active {
border: 1px inset white;
padding: 3px 1px 1px 1px;
}
titledbutton#ulButton {
#ulButton {
list-style-image:url("chrome://editor/skin/images/bullets.gif");
}
titledbutton#olButton {
#olButton {
list-style-image:url("chrome://editor/skin/images/numbers.gif");
}
titledbutton#outdentButton {
#outdentButton {
list-style-image:url("chrome://editor/skin/images/outdent.gif");
}
titledbutton#indentButton {
#indentButton {
list-style-image:url("chrome://editor/skin/images/indent.gif");
}
titledbutton#AlignPopupButton {
#AlignPopupButton {
list-style-image:url("chrome://editor/skin/images/align.gif");
}
titledbutton#InsertPopupButton {
#InsertPopupButton {
list-style-image:url("chrome://editor/skin/images/object-popup.gif");
}
@ -302,7 +313,7 @@ div#ColorButtons {
BackColorPopupButton button at lower right of the ColorButtons div
*/
titledbutton#TextColorPopupButton {
#TextColorPopupButton {
list-style-image:url("chrome://editor/skin/images/color.gif");
border: 1px solid #CCCCCC;
padding: 0px;
@ -315,7 +326,7 @@ titledbutton#TextColorPopupButton {
background-color: #AA0000;
}
titledbutton#TextColorPopupButton:hover {
#TextColorPopupButton:hover {
border: 1px solid white;
}
@ -331,11 +342,25 @@ titledbutton#BackColorPopupButton {
/* TEMP: Set color here. TODO: Set color from page */
background-color: yellow;
}
titledbutton#BackColorPopupButton:hover {
border: 1px solid white;
}
/* For when we use STACK to do overlapping buttons */
image#TextColorPopupButton {
list-style-image:url("chrome://editor/skin/images/color.gif");
border: 1px solid #CCCCCC;
padding: 0px;
margin: 0px;
}
image#BackColorPopupButton {
list-style-image:url("chrome://editor/skin/images/color.gif");
border: 1px solid #CCCCCC;
padding: 0px;
margin: 8px 8px 0px 0px;
}
titledbutton#text-align-left {
list-style-image:url("chrome://editor/skin/images/left.gif");
}

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

@ -76,8 +76,10 @@
<html:label class="margin-left-right"> &normalText.label; </html:label>
<spring flex="1"/>
<menu class="colorpicker">
<html:div id="textCW" class="color-well"/>
<titledbutton class="popup" align="right" flex="1" onclick="GetColorAndUpdate('textCP','textCW',this);"/>
<box>
<spring id="textCW" class="color-well"/>
<image class="popup-trigger"/>
</box>
<menupopup id="normalMenuPopup">
<colorpicker id="textCP" palettename="standard" onclick="GetColorAndUpdate('textCP','textCW',this);"/>
</menupopup>
@ -87,8 +89,10 @@
<html:label class="margin-left-right"> &linkText.label; </html:label>
<spring flex="1"/>
<menu class="colorpicker">
<html:div id="linkCW" class="color-well"/>
<titledbutton class="popup" align="right" flex="1"/>
<box>
<spring id="linkCW" class="color-well"/>
<image class="popup-trigger"/>
</box>
<menupopup>
<colorpicker id="linkCP" palettename="standard" onclick="GetColorAndUpdate('linkCP','linkCW',this);"/>
</menupopup>
@ -98,8 +102,10 @@
<html:label class="margin-left-right"> &activeLinkText.label; </html:label>
<spring flex="1"/>
<menu class="colorpicker">
<html:div id="activeCW" class="color-well"/>
<titledbutton class="popup" align="right" flex="1"/>
<box>
<spring id="activeCW" class="color-well"/>
<image class="popup-trigger"/>
</box>
<menupopup>
<colorpicker id="activeCP" palettename="standard" onclick="GetColorAndUpdate('activeCP','activeCW',this);"/>
</menupopup>
@ -109,8 +115,10 @@
<html:label class="margin-left-right"> &visitedLinkText.label; </html:label>
<spring flex="1"/>
<menu class="colorpicker">
<html:div id="visitedCW" class="color-well"/>
<titledbutton class="popup" align="right" flex="1"/>
<box>
<spring id="visitedCW" class="color-well"/>
<image class="popup-trigger"/>
</box>
<menupopup>
<colorpicker id="visitedCP" palettename="standard" onclick="GetColorAndUpdate('visitedCP','visitedCW',this);"/>
</menupopup>
@ -120,8 +128,10 @@
<html:label class="margin-left-right"> &background.label; </html:label>
<spring flex="1"/>
<menu class="colorpicker">
<html:div id="backgroundCW" class="color-well"/>
<titledbutton class="popup" align="right" flex="1"/>
<box>
<spring id="backgroundCW" class="color-well"/>
<image class="popup-trigger"/>
</box>
<menupopup>
<colorpicker id="backgroundCP" palettename="standard" onclick="GetColorAndUpdate('backgroundCP','backgroundCW',this);"/>
</menupopup>

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

@ -96,8 +96,14 @@ function InitDialog()
} else {
dialog.leftAlign.checked = true;
}
noshade = globalElement.getAttribute("noshade");
dialog.shading.checked = (noshade == "");
// This is tricky! Since the "noshade" attribute doesn't have a value,
// we can't use getAttribute to figure out if it's set!
// This gets the attribute NODE from the attributes NamedNodeMap
if (globalElement.attributes.getNamedItem("noshade"))
dialog.shading.checked = false;
else
dialog.shading.checked = true;
}
function onSaveDefault()

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

@ -117,7 +117,7 @@ dump("*** Found cell around selection\n");
// If the count is 0, then we are inside the cell, so select it
if (selectedCellCount == 0)
editorShell.SelectCell();
editorShell.SelectTableCell();
if(!TableElement)
{
@ -427,7 +427,7 @@ function ValidateNumber(inputWidgetID, selectWidget, minVal, maxVal, element, at
dump("Error returned from ValidateNumberString\n");
// Switch to appropriate panel for error reporting
SwitchValidatePanel(validatePanel)
SwitchPanel(validatePanel);
// Error - shift to offending input widget
inputWidget.focus();
@ -499,7 +499,7 @@ function ValidateTableData()
{
dialog.TableImageInput.focus();
// Switch to appropriate panel for error reporting
SwitchValidatePanel(validatePanel)
SwitchPanel(validatePanel);
ShowInputErrorMessage(GetString("MissingImageError"));
return false;
}
@ -568,7 +568,7 @@ dump("Alignment char="+alignChar+" Align Value="+dialog.CellHAlignSelect.value+"
{
dialog.CellImageInput.focus();
// Switch to appropriate panel for error reporting
SwitchValidatePanel(validatePanel)
SwitchPanel(validatePanel);
ShowInputErrorMessage(GetString("MissingImageError"));
}
} else {

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

@ -134,11 +134,13 @@
<box valign="middle" autostretch="never">
<text class="MinWidth50" align="left" value="&color.label;"/>
<menu class="colorpicker">
<html:div id="tableBackgroundCW" class="color-well"/>
<titledbutton class="popup" align="right" flex="1"/>
<box>
<spring id="tableBackgroundCW" class="color-well"/>
<image class="popup-trigger"/>
</box>
<menupopup>
<colorpicker id="tableBackgroundCP" palettename="standard" onclick="GetColorAndUpdate('tableBackgroundCP','tableBackgroundCW',this);"/>
<titledbutton class="push" value="&defaultColor.label;" onclick="GetColorAndUpdate('tableBackgroundCP','tableBackgroundCW',this)"/>
<button class="dialog" value="&defaultColor.label;" onclick="GetColorAndUpdate('tableBackgroundCP','tableBackgroundCW',this)"/>
</menupopup>
</menu>
<spring class="spacer"/>
@ -148,7 +150,7 @@
<box valign="middle" autostretch="never">
<text class="MinWidth50" align="left" for="TableImageInput" value="&image.label;"/>
<html:input type="text" id="TableImageInput" flex="1"/>
<titledbutton class="push" value="&ChooseImage.label;" id="bgimage.button"/>
<button class="dialog" value="&ChooseImage.label;" id="bgimage.button"/>
</box>
<!-- Not sure if we will support this
<box valign="middle" autostretch="never">
@ -162,7 +164,7 @@
<box flex="1" autostretch="never">
<spring flex="1"/>
<!-- From EdDialogOvlerlay.xul -->
<titledbutton id="AdvancedEditButton2"/>
<button class="dialog" id="AdvancedEditButton2"/>
</box>
<spring flex="1"/>
</box>
@ -180,9 +182,9 @@
</menupopup>
</menulist>
<spring class="bigspacer"/>
<titledbutton class="push MinWidth50" value="&cellSelectionPrevious.label;" onclick="SelectPrevious()" disabled="true"/>
<button class="dialog MinWidth50" value="&cellSelectionPrevious.label;" onclick="SelectPrevious()" disabled="true"/>
<spring class="bigspacer"/>
<titledbutton class="push MinWidth50" value="&cellSelectionNext.label;" onclick="SelectNext()" disabled="true"/>
<button class="dialog MinWidth50" value="&cellSelectionNext.label;" onclick="SelectNext()" disabled="true"/>
</titledbox>
<!-- cell size titledbox -->
<titledbox class="NoBottomPad"><title><text align="left" value="&size.label;"/></title>
@ -258,12 +260,14 @@
<box valign="middle" autostretch="never">
<text class="MinWidth50" align="left" value="&color.label;"/>
<menu class="colorpicker">
<html:div id="cellBackgroundCW" class="color-well"/>
<titledbutton class="popup" align="right" flex="1"/>
<box>
<spring id="cellBackgroundCW" class="color-well"/>
<image class="popup-trigger"/>
</box>
<menupopup>
<colorpicker id="cellBackgroundCP" palettename="standard"
onclick="GetColorAndUpdate('cellBackgroundCP','cellBackgroundCW',this)"/>
<titledbutton class="push" value="&defaultColor.label;"
<button class="dialog" value="&defaultColor.label;"
onclick="GetColorAndUpdate('cellBackgroundCP','cellBackgroundCW',this)"/>
</menupopup>
</menu>
@ -274,7 +278,7 @@
<box valign="middle" autostretch="never">
<text class="MinWidth50" align="left" for="CellImageInput" value="&image.label;"/>
<html:input type="text" id="CellImageInput" flex="1"/>
<titledbutton class="push" value="&ChooseImage.label;" id="cellbgimage.button"/>
<button class="dialog" value="&ChooseImage.label;" id="cellbgimage.button"/>
</box>
<!-- Not sure if we will support this
<box valign="middle" autostretch="never">
@ -288,13 +292,17 @@
<box autostretch="never">
<spring flex="1"/>
<!-- From EdDialogOvlerlay.xul -->
<titledbutton id="AdvancedEditButton3"/>
<button class="dialog" id="AdvancedEditButton3"/>
</box>
</box>
</tabpanel>
<spring class="spacer"/>
<!-- from EdDialogOverlay -->
<box id="okCancelButtons"/>
<box>
<spring flex="1"/>
<button class="dialog" value="Apply"/>
<box id="okCancelButtons"/>
</box>
</tabcontrol>
</window>

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

@ -41,21 +41,6 @@ tr {
vertical-align: middle;
}
/* input widgets are too high! This doesn't seem to help */
input {
height: 1em;
max-height: 1em;
padding-top: 2px;
padding-bottom: 2px;
margin: 0px;
}
/* This also doesn't work! */
input[disabled="true"]
{
background-color: #CCCCCC;
}
/* This strategy for hidding allows widget to keep layout space
while using "hidden" attribute sets to display: none, removing space
*/
@ -64,7 +49,6 @@ input[visibility=hidden]
visibility: hidden;
}
input.MinWidth200,select.MinWidth200,div.MinWidth200,titledbutton.MinWidth200,text.MinWidth200,spring.MinWidth100 {
min-width: 200px;
}
@ -113,16 +97,22 @@ div.middle-align {
margin-right: 5px;
}
div.color-well {
width:20px;
*.color-well {
width:20px;
height: 1em;
border: 1px inset #CCCCCC;
/* Background color is set at runtime */
}
div.color-well[default="true"] {
*.color-well[default="true"] {
border: 1px solid transparent;
background-color: inherit;
}
image.popup-trigger {
list-style-image: url(chrome://global/skin/scroll-down.gif);
}
td#ColorPreview {
border: 1px inset #CCCCCC;
padding-left: 5px;
@ -209,27 +199,15 @@ text.right {
min-width: 10em;
}
/* need rule for outset shape */
/* use outset shape for a button look */
menu.colorpicker {
border: 1px outset #CCCCCC;
/* For a little extra space between buttons */
margin-bottom: 2px;
}
titledbutton.color-well {
list-style-image:url("chrome://editor/skin/images/color.gif");
border: 1px solid #CCCCCC;
padding: 0px;
margin: 0px;
}
titledbutton.color-well[default="true"] {
border: 1px solid transparent;
background-color: inherit;
}
titledbutton.color-well:hover {
border: 1px solid white;
menu.colorpicker:active {
border: 1px inset #CCCCCC;
}
/* THIS SHOULD BE IN GLOBAL.CSS */