зеркало из https://github.com/mozilla/pjs.git
Exposed IsNodeBlock for JavaScript. Added comments for editor methods. Temporary fix for insert image bug (12917). Fixed bug 11857. Preliminary support for setting title and adding Cancel button in message dialogs.
This commit is contained in:
Родитель
701367771b
Коммит
699e5e802b
|
@ -2093,8 +2093,16 @@ nsEditor::GetLengthOfDOMNode(nsIDOMNode *aNode, PRUint32 &aCount)
|
|||
return result;
|
||||
}
|
||||
|
||||
// Non-static version for the nsIEditor interface and JavaScript
|
||||
NS_IMETHODIMP
|
||||
nsEditor::IsNodeBlock(nsIDOMNode *aNode, PRBool *aIsBlock)
|
||||
{
|
||||
if (!aNode || !aIsBlock) { return NS_ERROR_NULL_POINTER; }
|
||||
return IsNodeBlock(aNode, *aIsBlock);
|
||||
}
|
||||
|
||||
// The list of block nodes is shorter, so do the real work here...
|
||||
nsresult
|
||||
nsresult
|
||||
nsEditor::IsNodeBlock(nsIDOMNode *aNode, PRBool &aIsBlock)
|
||||
{
|
||||
// this is a content-based implementation
|
||||
|
|
|
@ -411,6 +411,9 @@ public:
|
|||
/** set aIsBlock to PR_TRUE if aNode is inline as defined by HTML DTD */
|
||||
static nsresult IsNodeBlock(nsIDOMNode *aNode, PRBool &aIsBlock);
|
||||
|
||||
/** This version is for exposure to JavaScript */
|
||||
NS_IMETHOD IsNodeBlock(nsIDOMNode *aNode, PRBool *aIsBlock);
|
||||
|
||||
/** returns the closest block parent of aNode, not including aNode itself.
|
||||
* can return null, for example if aNode is in a document fragment.
|
||||
* @param aNode The node whose parent we seek.
|
||||
|
|
|
@ -62,6 +62,8 @@
|
|||
#include "nsIDOMToolkitCore.h"
|
||||
#include "nsIFindComponent.h"
|
||||
#include "nsIPrompt.h"
|
||||
#include "nsICommonDialogs.h"
|
||||
//#include "nsIDialogParamBlock.h"
|
||||
|
||||
///////////////////////////////////////
|
||||
// Editor Includes
|
||||
|
@ -106,7 +108,8 @@ static NS_DEFINE_CID(kCSpellCheckerCID, NS_SPELLCHECKER_CID);
|
|||
static NS_DEFINE_IID(kCFileWidgetCID, NS_FILEWIDGET_CID);
|
||||
static NS_DEFINE_CID(kCStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
|
||||
static NS_DEFINE_CID(kCNetSupportDialogCID, NS_NETSUPPORTDIALOG_CID);
|
||||
|
||||
static NS_DEFINE_CID(kCommonDialogsCID, NS_CommonDialog_CID );
|
||||
static NS_DEFINE_CID(kDialogParamBlockCID, NS_DialogParamBlock_CID);
|
||||
/* Define Interface IDs */
|
||||
#ifdef NECKO
|
||||
#else
|
||||
|
@ -1024,9 +1027,9 @@ nsEditorShell::CheckAndSaveDocument(PRBool *_retval)
|
|||
if (modCount > 0)
|
||||
{
|
||||
// Ask user if they want to save current changes
|
||||
nsString saveFileQuestion = GetString("SaveFilePrompt");
|
||||
//nsString saveFileQuestion = GetString("SaveFilePrompt");
|
||||
// TODO: THIS DIALOG SHOULD HAVE A CANCEL BUTTON AS WELL
|
||||
if (Confirm(saveFileQuestion))
|
||||
if (Confirm(GetString("SaveFilePrompt"),GetString("SaveDocument")))
|
||||
{
|
||||
// Either save to existing file or prompt for name (as for SaveAs)
|
||||
rv = SaveDocument(PR_FALSE, PR_FALSE, _retval);
|
||||
|
@ -1077,8 +1080,7 @@ nsEditorShell::SaveDocument(PRBool saveAs, PRBool saveCopy, PRBool *_retval)
|
|||
{
|
||||
if (title->Length() == 0)
|
||||
{
|
||||
nsString message = GetString("NeedDocTitle");
|
||||
Alert(message);
|
||||
Alert(GetString("NeedDocTitle"),GetString("DocumentTitle"));
|
||||
// TODO: Popup a simple dialog and set the title
|
||||
// Note that this involves inserting a <title> tag
|
||||
// with a text nodechild in the <head> area of the document.
|
||||
|
@ -1151,8 +1153,7 @@ SkipFilters:
|
|||
res = editor->SaveFile(&docFileSpec, replacing, saveCopy, nsIEditor::eSaveFileHTML);
|
||||
if (NS_FAILED(res))
|
||||
{
|
||||
nsString message = GetString("SaveFileFailed");
|
||||
Alert(message);
|
||||
Alert(GetString("SaveFileFailed"), GetString("SaveDocument"));
|
||||
} else {
|
||||
// File was saved successfully
|
||||
*_retval = PR_TRUE;
|
||||
|
@ -1303,6 +1304,30 @@ nsEditorShell::GetLocalFileURL(nsIDOMWindow *parent, const PRUnichar *filterType
|
|||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditorShell::IsNodeBlock(nsIDOMNode *node, PRBool *_retval)
|
||||
{
|
||||
if (!node || !_retval) { return NS_ERROR_NULL_POINTER; }
|
||||
nsresult rv = NS_NOINTERFACE;
|
||||
|
||||
switch (mEditorType)
|
||||
{
|
||||
case ePlainTextEditorType:
|
||||
case eHTMLTextEditorType:
|
||||
{
|
||||
nsCOMPtr<nsIEditor> editor = do_QueryInterface(mEditor);
|
||||
if (editor)
|
||||
rv = editor->IsNodeBlock(node, _retval);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
rv = NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditorShell::Undo()
|
||||
{
|
||||
|
@ -1728,9 +1753,45 @@ nsEditorShell::GetString(const nsString& name)
|
|||
return *ptmpString;
|
||||
}
|
||||
|
||||
// Utility to bring up a Yes/No dialog. TODO: WE NEED A CANCEL BUTTON FOR FILE SAVE PROMPT!!!
|
||||
// Utility to bring up a Yes/No/Cancel dialog.
|
||||
PRInt32
|
||||
nsEditorShell::ConfirmWithCancel(const nsString& aQuestion, const nsString& aTitle)
|
||||
{
|
||||
nsresult rv;
|
||||
PRInt32 buttonPressed = 0;
|
||||
nsIDialogParamBlock* block = NULL;
|
||||
rv = nsComponentManager::CreateInstance(kDialogParamBlockCID,
|
||||
0,
|
||||
nsIDialogParamBlock::GetIID(),
|
||||
(void**)&block );
|
||||
|
||||
if ( NS_FAILED( rv ) )
|
||||
return rv;
|
||||
// Stuff in Parameters
|
||||
block->SetInt( nsICommonDialogs::eNumberButtons,2 );
|
||||
block->SetString( nsICommonDialogs::eMsg, aQuestion.GetUnicode());
|
||||
nsString url( "chrome://global/skin/question-icon.gif" );
|
||||
block->SetString( nsICommonDialogs::eIconURL, url.GetUnicode());
|
||||
|
||||
nsString yes("yes");
|
||||
nsString no("no");
|
||||
block->SetString( nsICommonDialogs::eButton0Text, yes.GetUnicode() );
|
||||
block->SetString( nsICommonDialogs::eButton1Text, no.GetUnicode() );
|
||||
|
||||
NS_WITH_SERVICE(nsICommonDialogs, dialog, kCommonDialogsCID, &rv);
|
||||
if ( NS_SUCCEEDED( rv ) )
|
||||
{
|
||||
nsCOMPtr<nsIDOMWindow> parent = do_QueryInterface(mWebShellWin);
|
||||
rv = dialog->DoDialog( parent, block, "chrome://global/content/commonDialog.xul" );
|
||||
block->GetInt( nsICommonDialogs::eButtonPressed, &buttonPressed );
|
||||
}
|
||||
NS_IF_RELEASE( block );
|
||||
return buttonPressed;
|
||||
}
|
||||
|
||||
// Utility to bring up a Yes/No dialog.
|
||||
PRBool
|
||||
nsEditorShell::Confirm(const nsString& aQuestion)
|
||||
nsEditorShell::Confirm(const nsString& aQuestion, const nsString& aTitle)
|
||||
{
|
||||
nsresult res;
|
||||
PRBool result = PR_FALSE;
|
||||
|
@ -1747,7 +1808,7 @@ nsEditorShell::Confirm(const nsString& aQuestion)
|
|||
}
|
||||
|
||||
void
|
||||
nsEditorShell::Alert(const nsString& aMsg)
|
||||
nsEditorShell::Alert(const nsString& aMsg, const nsString& aTitle)
|
||||
{
|
||||
nsresult res;
|
||||
NS_WITH_SERVICE(nsIPrompt, dialog, kCNetSupportDialogCID, &res);
|
||||
|
|
|
@ -160,9 +160,12 @@ class nsEditorShell : public nsIEditorShell,
|
|||
NS_IMETHOD CreateWindowWithURL(const char* urlStr);
|
||||
NS_IMETHOD PrepareDocumentForEditing(nsIURI *aUrl);
|
||||
NS_IMETHOD DoFind(PRBool aFindNext);
|
||||
|
||||
void Alert(const nsString& aMsg, const nsString& aTitle);
|
||||
// Bring up a Yes/No dialog WE REALLY NEED A Yes/No/Cancel dialog and would like to set our own caption as well!
|
||||
PRBool Confirm(const nsString& aQuestion);
|
||||
void Alert(const nsString& aMsg);
|
||||
PRBool Confirm(const nsString& aQuestion, const nsString& aTitle);
|
||||
// Return value: No=0, Yes=1, Cancel=2
|
||||
PRInt32 ConfirmWithCancel(const nsString& aQuestion, const nsString& aTitle);
|
||||
|
||||
// this returns an AddReffed nsIScriptContext. You must relase it.
|
||||
nsIScriptContext* GetScriptContext(nsIDOMWindow * aWin);
|
||||
|
|
|
@ -1330,7 +1330,9 @@ NS_IMETHODIMP nsHTMLEditor::SetParagraphFormat(const nsString& aParagraphFormat)
|
|||
NS_IMETHODIMP
|
||||
nsHTMLEditor::GetParagraphStyle(nsStringArray *aTagList)
|
||||
{
|
||||
#if 0
|
||||
if (gNoisy) { printf("---------- nsHTMLEditor::GetParagraphStyle ----------\n"); }
|
||||
#endif
|
||||
if (!aTagList) { return NS_ERROR_NULL_POINTER; }
|
||||
|
||||
nsresult res;
|
||||
|
@ -2087,9 +2089,12 @@ nsHTMLEditor::GetSelectedElement(const nsString& aTagName, nsIDOMElement** aRetu
|
|||
if (bNodeFound)
|
||||
{
|
||||
|
||||
*aReturn = selectedElement;
|
||||
// Getters must addref
|
||||
NS_ADDREF(*aReturn);
|
||||
*aReturn = selectedElement;
|
||||
if (selectedElement)
|
||||
{
|
||||
// Getters must addref
|
||||
NS_ADDREF(*aReturn);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -62,6 +62,8 @@
|
|||
#include "nsIDOMToolkitCore.h"
|
||||
#include "nsIFindComponent.h"
|
||||
#include "nsIPrompt.h"
|
||||
#include "nsICommonDialogs.h"
|
||||
//#include "nsIDialogParamBlock.h"
|
||||
|
||||
///////////////////////////////////////
|
||||
// Editor Includes
|
||||
|
@ -106,7 +108,8 @@ static NS_DEFINE_CID(kCSpellCheckerCID, NS_SPELLCHECKER_CID);
|
|||
static NS_DEFINE_IID(kCFileWidgetCID, NS_FILEWIDGET_CID);
|
||||
static NS_DEFINE_CID(kCStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
|
||||
static NS_DEFINE_CID(kCNetSupportDialogCID, NS_NETSUPPORTDIALOG_CID);
|
||||
|
||||
static NS_DEFINE_CID(kCommonDialogsCID, NS_CommonDialog_CID );
|
||||
static NS_DEFINE_CID(kDialogParamBlockCID, NS_DialogParamBlock_CID);
|
||||
/* Define Interface IDs */
|
||||
#ifdef NECKO
|
||||
#else
|
||||
|
@ -1024,9 +1027,9 @@ nsEditorShell::CheckAndSaveDocument(PRBool *_retval)
|
|||
if (modCount > 0)
|
||||
{
|
||||
// Ask user if they want to save current changes
|
||||
nsString saveFileQuestion = GetString("SaveFilePrompt");
|
||||
//nsString saveFileQuestion = GetString("SaveFilePrompt");
|
||||
// TODO: THIS DIALOG SHOULD HAVE A CANCEL BUTTON AS WELL
|
||||
if (Confirm(saveFileQuestion))
|
||||
if (Confirm(GetString("SaveFilePrompt"),GetString("SaveDocument")))
|
||||
{
|
||||
// Either save to existing file or prompt for name (as for SaveAs)
|
||||
rv = SaveDocument(PR_FALSE, PR_FALSE, _retval);
|
||||
|
@ -1077,8 +1080,7 @@ nsEditorShell::SaveDocument(PRBool saveAs, PRBool saveCopy, PRBool *_retval)
|
|||
{
|
||||
if (title->Length() == 0)
|
||||
{
|
||||
nsString message = GetString("NeedDocTitle");
|
||||
Alert(message);
|
||||
Alert(GetString("NeedDocTitle"),GetString("DocumentTitle"));
|
||||
// TODO: Popup a simple dialog and set the title
|
||||
// Note that this involves inserting a <title> tag
|
||||
// with a text nodechild in the <head> area of the document.
|
||||
|
@ -1151,8 +1153,7 @@ SkipFilters:
|
|||
res = editor->SaveFile(&docFileSpec, replacing, saveCopy, nsIEditor::eSaveFileHTML);
|
||||
if (NS_FAILED(res))
|
||||
{
|
||||
nsString message = GetString("SaveFileFailed");
|
||||
Alert(message);
|
||||
Alert(GetString("SaveFileFailed"), GetString("SaveDocument"));
|
||||
} else {
|
||||
// File was saved successfully
|
||||
*_retval = PR_TRUE;
|
||||
|
@ -1303,6 +1304,30 @@ nsEditorShell::GetLocalFileURL(nsIDOMWindow *parent, const PRUnichar *filterType
|
|||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditorShell::IsNodeBlock(nsIDOMNode *node, PRBool *_retval)
|
||||
{
|
||||
if (!node || !_retval) { return NS_ERROR_NULL_POINTER; }
|
||||
nsresult rv = NS_NOINTERFACE;
|
||||
|
||||
switch (mEditorType)
|
||||
{
|
||||
case ePlainTextEditorType:
|
||||
case eHTMLTextEditorType:
|
||||
{
|
||||
nsCOMPtr<nsIEditor> editor = do_QueryInterface(mEditor);
|
||||
if (editor)
|
||||
rv = editor->IsNodeBlock(node, _retval);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
rv = NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditorShell::Undo()
|
||||
{
|
||||
|
@ -1728,9 +1753,45 @@ nsEditorShell::GetString(const nsString& name)
|
|||
return *ptmpString;
|
||||
}
|
||||
|
||||
// Utility to bring up a Yes/No dialog. TODO: WE NEED A CANCEL BUTTON FOR FILE SAVE PROMPT!!!
|
||||
// Utility to bring up a Yes/No/Cancel dialog.
|
||||
PRInt32
|
||||
nsEditorShell::ConfirmWithCancel(const nsString& aQuestion, const nsString& aTitle)
|
||||
{
|
||||
nsresult rv;
|
||||
PRInt32 buttonPressed = 0;
|
||||
nsIDialogParamBlock* block = NULL;
|
||||
rv = nsComponentManager::CreateInstance(kDialogParamBlockCID,
|
||||
0,
|
||||
nsIDialogParamBlock::GetIID(),
|
||||
(void**)&block );
|
||||
|
||||
if ( NS_FAILED( rv ) )
|
||||
return rv;
|
||||
// Stuff in Parameters
|
||||
block->SetInt( nsICommonDialogs::eNumberButtons,2 );
|
||||
block->SetString( nsICommonDialogs::eMsg, aQuestion.GetUnicode());
|
||||
nsString url( "chrome://global/skin/question-icon.gif" );
|
||||
block->SetString( nsICommonDialogs::eIconURL, url.GetUnicode());
|
||||
|
||||
nsString yes("yes");
|
||||
nsString no("no");
|
||||
block->SetString( nsICommonDialogs::eButton0Text, yes.GetUnicode() );
|
||||
block->SetString( nsICommonDialogs::eButton1Text, no.GetUnicode() );
|
||||
|
||||
NS_WITH_SERVICE(nsICommonDialogs, dialog, kCommonDialogsCID, &rv);
|
||||
if ( NS_SUCCEEDED( rv ) )
|
||||
{
|
||||
nsCOMPtr<nsIDOMWindow> parent = do_QueryInterface(mWebShellWin);
|
||||
rv = dialog->DoDialog( parent, block, "chrome://global/content/commonDialog.xul" );
|
||||
block->GetInt( nsICommonDialogs::eButtonPressed, &buttonPressed );
|
||||
}
|
||||
NS_IF_RELEASE( block );
|
||||
return buttonPressed;
|
||||
}
|
||||
|
||||
// Utility to bring up a Yes/No dialog.
|
||||
PRBool
|
||||
nsEditorShell::Confirm(const nsString& aQuestion)
|
||||
nsEditorShell::Confirm(const nsString& aQuestion, const nsString& aTitle)
|
||||
{
|
||||
nsresult res;
|
||||
PRBool result = PR_FALSE;
|
||||
|
@ -1747,7 +1808,7 @@ nsEditorShell::Confirm(const nsString& aQuestion)
|
|||
}
|
||||
|
||||
void
|
||||
nsEditorShell::Alert(const nsString& aMsg)
|
||||
nsEditorShell::Alert(const nsString& aMsg, const nsString& aTitle)
|
||||
{
|
||||
nsresult res;
|
||||
NS_WITH_SERVICE(nsIPrompt, dialog, kCNetSupportDialogCID, &res);
|
||||
|
|
|
@ -160,9 +160,12 @@ class nsEditorShell : public nsIEditorShell,
|
|||
NS_IMETHOD CreateWindowWithURL(const char* urlStr);
|
||||
NS_IMETHOD PrepareDocumentForEditing(nsIURI *aUrl);
|
||||
NS_IMETHOD DoFind(PRBool aFindNext);
|
||||
|
||||
void Alert(const nsString& aMsg, const nsString& aTitle);
|
||||
// Bring up a Yes/No dialog WE REALLY NEED A Yes/No/Cancel dialog and would like to set our own caption as well!
|
||||
PRBool Confirm(const nsString& aQuestion);
|
||||
void Alert(const nsString& aMsg);
|
||||
PRBool Confirm(const nsString& aQuestion, const nsString& aTitle);
|
||||
// Return value: No=0, Yes=1, Cancel=2
|
||||
PRInt32 ConfirmWithCancel(const nsString& aQuestion, const nsString& aTitle);
|
||||
|
||||
// this returns an AddReffed nsIScriptContext. You must relase it.
|
||||
nsIScriptContext* GetScriptContext(nsIDOMWindow * aWin);
|
||||
|
|
|
@ -146,11 +146,75 @@ interface nsIEditorShell : nsISupports
|
|||
void Align(in wstring align);
|
||||
|
||||
/** Element insert and property editing */
|
||||
|
||||
/** Return an element only if it is the only node selected,
|
||||
* such as an image, horizontal rule, etc.
|
||||
* The exception is a link, which is more like a text attribute:
|
||||
* The Anchor tag is returned if the selection is within the textnode(s)
|
||||
* that are children of the "A" node.
|
||||
* This could be a collapsed selection, i.e., a caret within the link text.
|
||||
*
|
||||
* tagName: The HTML tagname or and empty string
|
||||
* to get any element (but only if it is the only element selected)
|
||||
* Special input values for Links and Named anchors:
|
||||
* Use "href" to get a link node
|
||||
* (an "A" tag with the "href" attribute set)
|
||||
* Use "anchor" or "namedanchor" to get a named anchor node
|
||||
* (an "A" tag with the "name" attribute set)
|
||||
*/
|
||||
nsIDOMElement GetSelectedElement(in wstring tagName);
|
||||
/** returns the element conversion of supplied node or a parent of required type */
|
||||
|
||||
/** Return the input node or a parent matching the given aTagName,
|
||||
* starting the search at the supplied node.
|
||||
* An example of use is for testing if a node is in a table cell
|
||||
* given a selection anchor node.
|
||||
*
|
||||
* tagName: The HTML tagname
|
||||
* Special input values for Links and Named anchors:
|
||||
* Use "href" to get a link node
|
||||
* (an "A" tag with the "href" attribute set)
|
||||
* Use "anchor" or "namedanchor" to get a named anchor node
|
||||
* (an "A" tag with the "name" attribute set)
|
||||
*
|
||||
* node: The node in the document to start the search
|
||||
* If it is null, the anchor node of the current selection is used
|
||||
*/
|
||||
nsIDOMElement GetElementOrParentByTagName(in wstring tagName, in nsIDOMNode node);
|
||||
|
||||
/** Return a new element with default attribute values
|
||||
*
|
||||
* This does not rely on the selection, and is not sensitive to context.
|
||||
*
|
||||
* Used primarily to supply new element for various insert element dialogs
|
||||
* (Image, Link, NamedAnchor, Table, and HorizontalRule
|
||||
* are the only returned elements as of 7/25/99)
|
||||
*
|
||||
* tagName: The HTML tagname
|
||||
* Special input values for Links and Named anchors:
|
||||
* Use "href" to get a link node
|
||||
* (an "A" tag with the "href" attribute set)
|
||||
* Use "anchor" or "namedanchor" to get a named anchor node
|
||||
* (an "A" tag with the "name" attribute set)
|
||||
*/
|
||||
nsIDOMElement CreateElementWithDefaults(in wstring tagName);
|
||||
|
||||
/** Insert an element, which may have child nodes, at the selection
|
||||
* Used primarily to insert a new element for various insert element dialogs,
|
||||
* but it enforces the HTML 4.0 DTD "CanContain" rules, so it should
|
||||
* be useful for other elements.
|
||||
*
|
||||
* element: The element to insert
|
||||
* deleteSelection: Delete the selection before inserting
|
||||
* If deleteSelection is PR_FALSE, then the element is inserted
|
||||
* after the end of the selection for all element except
|
||||
* Named Anchors, which insert before the selection
|
||||
*/
|
||||
void InsertElement(in nsIDOMElement element, in boolean deleteSelection);
|
||||
|
||||
/** Insert an link element as the parent of the current selection
|
||||
*
|
||||
* element An "A" element with a non-empty "href" attribute
|
||||
*/
|
||||
void InsertLinkAroundSelection(in nsIDOMElement anchorElement);
|
||||
void SelectElement(in nsIDOMElement element);
|
||||
void SetSelectionAfterElement(in nsIDOMElement element);
|
||||
|
@ -227,6 +291,12 @@ interface nsIEditorShell : nsISupports
|
|||
/* Utility */
|
||||
wstring GetLocalFileURL(in nsIDOMWindow parent, in wstring filterType);
|
||||
|
||||
/**
|
||||
* Tests if a node is a BLOCK element according the the HTML 4.0 DTD
|
||||
* This does NOT consider CSS effect on display type
|
||||
*/
|
||||
boolean IsNodeBlock(in nsIDOMNode node);
|
||||
|
||||
void BeginBatchChanges();
|
||||
void EndBatchChanges();
|
||||
void RunUnitTests();
|
||||
|
|
|
@ -2093,8 +2093,16 @@ nsEditor::GetLengthOfDOMNode(nsIDOMNode *aNode, PRUint32 &aCount)
|
|||
return result;
|
||||
}
|
||||
|
||||
// Non-static version for the nsIEditor interface and JavaScript
|
||||
NS_IMETHODIMP
|
||||
nsEditor::IsNodeBlock(nsIDOMNode *aNode, PRBool *aIsBlock)
|
||||
{
|
||||
if (!aNode || !aIsBlock) { return NS_ERROR_NULL_POINTER; }
|
||||
return IsNodeBlock(aNode, *aIsBlock);
|
||||
}
|
||||
|
||||
// The list of block nodes is shorter, so do the real work here...
|
||||
nsresult
|
||||
nsresult
|
||||
nsEditor::IsNodeBlock(nsIDOMNode *aNode, PRBool &aIsBlock)
|
||||
{
|
||||
// this is a content-based implementation
|
||||
|
|
|
@ -411,6 +411,9 @@ public:
|
|||
/** set aIsBlock to PR_TRUE if aNode is inline as defined by HTML DTD */
|
||||
static nsresult IsNodeBlock(nsIDOMNode *aNode, PRBool &aIsBlock);
|
||||
|
||||
/** This version is for exposure to JavaScript */
|
||||
NS_IMETHOD IsNodeBlock(nsIDOMNode *aNode, PRBool *aIsBlock);
|
||||
|
||||
/** returns the closest block parent of aNode, not including aNode itself.
|
||||
* can return null, for example if aNode is in a document fragment.
|
||||
* @param aNode The node whose parent we seek.
|
||||
|
|
|
@ -1330,7 +1330,9 @@ NS_IMETHODIMP nsHTMLEditor::SetParagraphFormat(const nsString& aParagraphFormat)
|
|||
NS_IMETHODIMP
|
||||
nsHTMLEditor::GetParagraphStyle(nsStringArray *aTagList)
|
||||
{
|
||||
#if 0
|
||||
if (gNoisy) { printf("---------- nsHTMLEditor::GetParagraphStyle ----------\n"); }
|
||||
#endif
|
||||
if (!aTagList) { return NS_ERROR_NULL_POINTER; }
|
||||
|
||||
nsresult res;
|
||||
|
@ -2087,9 +2089,12 @@ nsHTMLEditor::GetSelectedElement(const nsString& aTagName, nsIDOMElement** aRetu
|
|||
if (bNodeFound)
|
||||
{
|
||||
|
||||
*aReturn = selectedElement;
|
||||
// Getters must addref
|
||||
NS_ADDREF(*aReturn);
|
||||
*aReturn = selectedElement;
|
||||
if (selectedElement)
|
||||
{
|
||||
// Getters must addref
|
||||
NS_ADDREF(*aReturn);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -236,6 +236,14 @@ public:
|
|||
|
||||
/* ------------ Node manipulation methods -------------- */
|
||||
|
||||
/**
|
||||
* Tests if a node is a BLOCK element according the the HTML 4.0 DTD
|
||||
* This does NOT consider CSS effect on display type
|
||||
*
|
||||
* @param aNode the node to test
|
||||
*/
|
||||
NS_IMETHOD IsNodeBlock(nsIDOMNode *aNode, PRBool *aIsBlock)=0;
|
||||
|
||||
/**
|
||||
* SetAttribute() sets the attribute of aElement.
|
||||
* No checking is done to see if aAttribute is a legal attribute of the node,
|
||||
|
|
|
@ -263,7 +263,7 @@ public:
|
|||
*
|
||||
* @param aTagName The HTML tagname
|
||||
* Special input values for Links and Named anchors:
|
||||
* Use "link" or "href" to get a link node
|
||||
* Use "href" to get a link node
|
||||
* (an "A" tag with the "href" attribute set)
|
||||
* Use "anchor" or "namedanchor" to get a named anchor node
|
||||
* (an "A" tag with the "name" attribute set)
|
||||
|
@ -276,13 +276,14 @@ public:
|
|||
/** Return an element only if it is the only node selected,
|
||||
* such as an image, horizontal rule, etc.
|
||||
* The exception is a link, which is more like a text attribute:
|
||||
* The Ancho tag is returned if the selection is within the textnode(s)
|
||||
* The Anchor tag is returned if the selection is within the textnode(s)
|
||||
* that are children of the "A" node.
|
||||
* This could be a collapsed selection, i.e., a caret within the link text.
|
||||
*
|
||||
* @param aTagName The HTML tagname
|
||||
* @param aTagName The HTML tagname or and empty string
|
||||
* to get any element (but only if it is the only element selected)
|
||||
* Special input values for Links and Named anchors:
|
||||
* Use "link" or "href" to get a link node
|
||||
* Use "href" to get a link node
|
||||
* (an "A" tag with the "href" attribute set)
|
||||
* Use "anchor" or "namedanchor" to get a named anchor node
|
||||
* (an "A" tag with the "name" attribute set)
|
||||
|
@ -299,7 +300,7 @@ public:
|
|||
*
|
||||
* @param aTagName The HTML tagname
|
||||
* Special input values for Links and Named anchors:
|
||||
* Use "link" or "href" to get a link node
|
||||
* Use "href" to get a link node
|
||||
* (an "A" tag with the "href" attribute set)
|
||||
* Use "anchor" or "namedanchor" to get a named anchor node
|
||||
* (an "A" tag with the "name" attribute set)
|
||||
|
@ -307,7 +308,6 @@ public:
|
|||
NS_IMETHOD CreateElementWithDefaults(const nsString& aTagName, nsIDOMElement** aReturn)=0;
|
||||
|
||||
/** Insert an link element as the parent of the current selection
|
||||
* be useful for other elements.
|
||||
*
|
||||
* @param aElement An "A" element with a non-empty "href" attribute
|
||||
*/
|
||||
|
|
|
@ -14,4 +14,6 @@ HTMLFiles=HTML Files
|
|||
TextFiles=Text Files
|
||||
SaveFilePrompt=Save changes to current file?
|
||||
SaveFileFailed=Saving file failed!
|
||||
DocumentTitle=Document Title
|
||||
NeedDocTitle=Document does not have a title.
|
||||
SaveDocument=Save Document
|
||||
|
|
|
@ -539,7 +539,7 @@ function onOK()
|
|||
imageElement.setAttribute( "border", dialog.imageborderInput.value );
|
||||
else
|
||||
imageElement.removeAttribute( "border" );
|
||||
|
||||
/*
|
||||
alignpopup = document.getElementById("image.alignType");
|
||||
if ( alignpopup )
|
||||
{
|
||||
|
@ -550,7 +550,7 @@ function onOK()
|
|||
else
|
||||
imageElement.setAttribute("align", alignvalue );
|
||||
}
|
||||
|
||||
*/
|
||||
// handle insertion of new image
|
||||
|
||||
if (insertNew)
|
||||
|
|
Загрузка…
Ссылка в новой задаче