Added transactions for applying and removing style sheets
This commit is contained in:
Родитель
2babf83eba
Коммит
2fa9524390
|
@ -39,9 +39,10 @@
|
|||
#include "DeleteTableColumnTxn.h"
|
||||
#include "DeleteTableRowTxn.h"
|
||||
#include "JoinTableCellsTxn.h"
|
||||
#include "nsStyleSheetTxns.h"
|
||||
#include "IMETextTxn.h"
|
||||
|
||||
#include "IMECommitTxn.h"
|
||||
|
||||
static NS_DEFINE_IID(kEditAggregateTxnIID, EDIT_AGGREGATE_TXN_IID);
|
||||
static NS_DEFINE_IID(kPlaceholderTxnIID, PLACEHOLDER_TXN_IID);
|
||||
static NS_DEFINE_IID(kInsertTextTxnIID, INSERT_TEXT_TXN_IID);
|
||||
|
@ -63,8 +64,10 @@ static NS_DEFINE_IID(kDeleteTableCellTxnIID, DELETE_CELL_TXN_IID);
|
|||
static NS_DEFINE_IID(kDeleteTableColumnTxnIID, DELETE_COLUMN_TXN_IID);
|
||||
static NS_DEFINE_IID(kDeleteTableRowTxnIID, DELETE_ROW_TXN_IID);
|
||||
static NS_DEFINE_IID(kJoinTableCellsTxnIID, JOIN_CELLS_TXN_IID);
|
||||
static NS_DEFINE_IID(kIMETextTxnIID, IME_TEXT_TXN_IID);
|
||||
static NS_DEFINE_IID(kIMECommitTxnIID, IME_COMMIT_TXN_IID);
|
||||
static NS_DEFINE_IID(kIMETextTxnIID, IME_TEXT_TXN_IID);
|
||||
static NS_DEFINE_IID(kIMECommitTxnIID, IME_COMMIT_TXN_IID);
|
||||
static NS_DEFINE_IID(kAddStyleSheetTxnIID, ADD_STYLESHEET_TXN_IID);
|
||||
static NS_DEFINE_IID(kRemoveStyleSheetTxnIID, REMOVE_STYLESHEET_TXN_IID);
|
||||
|
||||
TransactionFactory::TransactionFactory()
|
||||
{
|
||||
|
@ -105,6 +108,10 @@ TransactionFactory::GetNewTransaction(REFNSIID aTxnType, EditTxn **aResult)
|
|||
*aResult = new IMETextTxn();
|
||||
else if (aTxnType.Equals(kIMECommitTxnIID))
|
||||
*aResult = new IMECommitTxn();
|
||||
else if (aTxnType.Equals(kAddStyleSheetTxnIID))
|
||||
*aResult = new AddStyleSheetTxn();
|
||||
else if (aTxnType.Equals(kRemoveStyleSheetTxnIID))
|
||||
*aResult = new RemoveStyleSheetTxn();
|
||||
else if (aTxnType.Equals(kPlaceholderTxnIID))
|
||||
*aResult = new PlaceholderTxn();
|
||||
else
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
#include "nsICSSStyleSheet.h"
|
||||
#include "nsIHTMLContentContainer.h"
|
||||
#include "nsIStyleSet.h"
|
||||
#include "nsStyleSheetTxns.h"
|
||||
#include "nsIDocumentObserver.h"
|
||||
|
||||
|
||||
|
@ -137,6 +138,8 @@ static NS_DEFINE_IID(kSplitElementTxnIID, SPLIT_ELEMENT_TXN_IID);
|
|||
static NS_DEFINE_IID(kJoinElementTxnIID, JOIN_ELEMENT_TXN_IID);
|
||||
static NS_DEFINE_IID(kIMETextTxnIID, IME_TEXT_TXN_IID);
|
||||
static NS_DEFINE_IID(kIMECommitTxnIID, IME_COMMIT_TXN_IID);
|
||||
static NS_DEFINE_IID(kAddStyleSheetTxnIID, ADD_STYLESHEET_TXN_IID);
|
||||
static NS_DEFINE_IID(kRemoveStyleSheetTxnIID, REMOVE_STYLESHEET_TXN_IID);
|
||||
|
||||
static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
|
||||
static NS_DEFINE_CID(kCDOMRangeCID, NS_RANGE_CID);
|
||||
|
@ -1329,31 +1332,72 @@ NS_IMETHODIMP nsEditor::InsertAsQuotation(const nsString& aQuotedText)
|
|||
return InsertText(aQuotedText);
|
||||
}
|
||||
|
||||
extern "C" void
|
||||
ApplyStyleSheetToPresShellDocument(nsICSSStyleSheet* aSheet, void *aData)
|
||||
NS_IMETHODIMP
|
||||
nsEditor::AddStyleSheet(nsICSSStyleSheet* aSheet)
|
||||
{
|
||||
nsresult rv;
|
||||
AddStyleSheetTxn* aTxn;
|
||||
nsresult rv = CreateTxnForAddStyleSheet(aSheet, &aTxn);
|
||||
if (NS_SUCCEEDED(rv) && aTxn)
|
||||
{
|
||||
rv = Do(aTxn);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
mLastStyleSheet = do_QueryInterface(aSheet); // save it so we can remove before applying the next one
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsIPresShell *presShell = (nsIPresShell *)aData;
|
||||
|
||||
if (presShell) {
|
||||
nsCOMPtr<nsIStyleSet> styleSet;
|
||||
NS_IMETHODIMP
|
||||
nsEditor::RemoveStyleSheet(nsICSSStyleSheet* aSheet)
|
||||
{
|
||||
RemoveStyleSheetTxn* aTxn;
|
||||
nsresult rv = CreateTxnForRemoveStyleSheet(aSheet, &aTxn);
|
||||
if (NS_SUCCEEDED(rv) && aTxn)
|
||||
{
|
||||
rv = Do(aTxn);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
mLastStyleSheet = nsnull; // forget it
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = presShell->GetStyleSet(getter_AddRefs(styleSet));
|
||||
NS_IMETHODIMP
|
||||
nsEditor::ReplaceStyleSheet(nsICSSStyleSheet *aNewSheet)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
BeginTransaction();
|
||||
|
||||
if (NS_SUCCEEDED(rv) && styleSet) {
|
||||
styleSet->AppendOverrideStyleSheet(aSheet);
|
||||
|
||||
nsCOMPtr<nsIDocumentObserver> observer = do_QueryInterface(presShell);
|
||||
nsCOMPtr<nsIStyleSheet> styleSheet = do_QueryInterface(aSheet);
|
||||
nsCOMPtr<nsIDocument> document;
|
||||
|
||||
rv = presShell->GetDocument(getter_AddRefs(document));
|
||||
|
||||
if (NS_SUCCEEDED(rv) && document && observer && styleSheet)
|
||||
rv = observer->StyleSheetAdded(document, styleSheet);
|
||||
}
|
||||
if (mLastStyleSheet)
|
||||
{
|
||||
rv = RemoveStyleSheet(mLastStyleSheet);
|
||||
}
|
||||
|
||||
rv = AddStyleSheet(aNewSheet);
|
||||
|
||||
EndTransaction();
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* static */
|
||||
void nsEditor::ApplyStyleSheetToPresShellDocument(nsICSSStyleSheet* aSheet, void *aData)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsEditor *editor = NS_STATIC_CAST(nsEditor*, aData);
|
||||
if (editor)
|
||||
{
|
||||
rv = editor->ReplaceStyleSheet(aSheet);
|
||||
}
|
||||
|
||||
// we lose the return value here. Set a flag in the editor?
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsEditor::ApplyStyleSheet(const nsString& aURL)
|
||||
|
@ -1396,14 +1440,14 @@ NS_IMETHODIMP nsEditor::ApplyStyleSheet(const nsString& aURL)
|
|||
PRBool complete;
|
||||
|
||||
rv = cssLoader->LoadAgentSheet(uaURL, cssStyleSheet, complete,
|
||||
ApplyStyleSheetToPresShellDocument,
|
||||
mPresShell);
|
||||
nsEditor::ApplyStyleSheetToPresShellDocument,
|
||||
this);
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
if (complete) {
|
||||
if (cssStyleSheet) {
|
||||
ApplyStyleSheetToPresShellDocument(cssStyleSheet,
|
||||
mPresShell);
|
||||
nsEditor::ApplyStyleSheetToPresShellDocument(cssStyleSheet,
|
||||
this);
|
||||
}
|
||||
else
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
|
@ -3653,6 +3697,37 @@ nsEditor::CreateTxnForIMEText(const nsString & aStringToInsert,
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditor::CreateTxnForAddStyleSheet(nsICSSStyleSheet* aSheet, AddStyleSheetTxn* *aTxn)
|
||||
{
|
||||
nsresult rv = TransactionFactory::GetNewTransaction(kAddStyleSheetTxnIID, (EditTxn **)aTxn);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
if (! *aTxn)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
return (*aTxn)->Init(this, aSheet);
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditor::CreateTxnForRemoveStyleSheet(nsICSSStyleSheet* aSheet, RemoveStyleSheetTxn* *aTxn)
|
||||
{
|
||||
nsresult rv = TransactionFactory::GetNewTransaction(kRemoveStyleSheetTxnIID, (EditTxn **)aTxn);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
if (! *aTxn)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
return (*aTxn)->Init(this, aSheet);
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP nsEditor::DoInitialInputMethodInsert(const nsString & aStringToInsert,nsIDOMTextRangeList* aTextRangeList)
|
||||
{
|
||||
if (!mDoc) {
|
||||
|
|
|
@ -58,6 +58,9 @@ class nsIStringBundleService;
|
|||
class nsIStringBundle;
|
||||
class nsILocale;
|
||||
class IMETextTxn;
|
||||
class nsICSSStyleSheet;
|
||||
class AddStyleSheetTxn;
|
||||
class RemoveStyleSheetTxn;
|
||||
|
||||
#ifdef ENABLE_JS_EDITOR_LOG
|
||||
class nsJSEditorLog;
|
||||
|
@ -81,6 +84,7 @@ private:
|
|||
PRUint32 mUpdateCount;
|
||||
nsCOMPtr<nsITransactionManager> mTxnMgr;
|
||||
nsCOMPtr<nsIEditProperty> mEditProperty;
|
||||
nsCOMPtr<nsICSSStyleSheet> mLastStyleSheet; // is owning this dangerous?
|
||||
|
||||
//
|
||||
// data necessary to build IME transactions
|
||||
|
@ -230,6 +234,8 @@ public:
|
|||
NS_IMETHOD InsertAsQuotation(const nsString& aQuotedText);
|
||||
|
||||
NS_IMETHOD ApplyStyleSheet(const nsString& aURL);
|
||||
NS_IMETHOD AddStyleSheet(nsICSSStyleSheet* aSheet);
|
||||
NS_IMETHOD RemoveStyleSheet(nsICSSStyleSheet* aSheet);
|
||||
|
||||
NS_IMETHOD AddEditActionListener(nsIEditActionListener *aListener);
|
||||
|
||||
|
@ -242,6 +248,9 @@ public:
|
|||
|
||||
/*END nsIEditor interfaces*/
|
||||
|
||||
/* StyleSheet load callback */
|
||||
static void ApplyStyleSheetToPresShellDocument(nsICSSStyleSheet* aSheet, void *aData);
|
||||
|
||||
|
||||
/*BEGIN private methods used by the implementations of the above functions*/
|
||||
protected:
|
||||
|
@ -288,6 +297,17 @@ protected:
|
|||
nsIDOMTextRangeList* aTextRangeList,
|
||||
IMETextTxn ** aTxn);
|
||||
|
||||
/** create a transaction for adding a style sheet
|
||||
*/
|
||||
NS_IMETHOD CreateTxnForAddStyleSheet(nsICSSStyleSheet* aSheet, AddStyleSheetTxn* *aTxn);
|
||||
|
||||
/** create a transaction for removing a style sheet
|
||||
*/
|
||||
NS_IMETHOD CreateTxnForRemoveStyleSheet(nsICSSStyleSheet* aSheet, RemoveStyleSheetTxn* *aTxn);
|
||||
|
||||
/* remove the old style sheet, and apply the supplied one */
|
||||
NS_IMETHOD ReplaceStyleSheet(nsICSSStyleSheet *aNewSheet);
|
||||
|
||||
/** insert aStringToInsert as the first text in the document
|
||||
*/
|
||||
NS_IMETHOD DoInitialInsert(const nsString & aStringToInsert);
|
||||
|
|
|
@ -39,9 +39,10 @@
|
|||
#include "DeleteTableColumnTxn.h"
|
||||
#include "DeleteTableRowTxn.h"
|
||||
#include "JoinTableCellsTxn.h"
|
||||
#include "nsStyleSheetTxns.h"
|
||||
#include "IMETextTxn.h"
|
||||
|
||||
#include "IMECommitTxn.h"
|
||||
|
||||
static NS_DEFINE_IID(kEditAggregateTxnIID, EDIT_AGGREGATE_TXN_IID);
|
||||
static NS_DEFINE_IID(kPlaceholderTxnIID, PLACEHOLDER_TXN_IID);
|
||||
static NS_DEFINE_IID(kInsertTextTxnIID, INSERT_TEXT_TXN_IID);
|
||||
|
@ -63,8 +64,10 @@ static NS_DEFINE_IID(kDeleteTableCellTxnIID, DELETE_CELL_TXN_IID);
|
|||
static NS_DEFINE_IID(kDeleteTableColumnTxnIID, DELETE_COLUMN_TXN_IID);
|
||||
static NS_DEFINE_IID(kDeleteTableRowTxnIID, DELETE_ROW_TXN_IID);
|
||||
static NS_DEFINE_IID(kJoinTableCellsTxnIID, JOIN_CELLS_TXN_IID);
|
||||
static NS_DEFINE_IID(kIMETextTxnIID, IME_TEXT_TXN_IID);
|
||||
static NS_DEFINE_IID(kIMECommitTxnIID, IME_COMMIT_TXN_IID);
|
||||
static NS_DEFINE_IID(kIMETextTxnIID, IME_TEXT_TXN_IID);
|
||||
static NS_DEFINE_IID(kIMECommitTxnIID, IME_COMMIT_TXN_IID);
|
||||
static NS_DEFINE_IID(kAddStyleSheetTxnIID, ADD_STYLESHEET_TXN_IID);
|
||||
static NS_DEFINE_IID(kRemoveStyleSheetTxnIID, REMOVE_STYLESHEET_TXN_IID);
|
||||
|
||||
TransactionFactory::TransactionFactory()
|
||||
{
|
||||
|
@ -105,6 +108,10 @@ TransactionFactory::GetNewTransaction(REFNSIID aTxnType, EditTxn **aResult)
|
|||
*aResult = new IMETextTxn();
|
||||
else if (aTxnType.Equals(kIMECommitTxnIID))
|
||||
*aResult = new IMECommitTxn();
|
||||
else if (aTxnType.Equals(kAddStyleSheetTxnIID))
|
||||
*aResult = new AddStyleSheetTxn();
|
||||
else if (aTxnType.Equals(kRemoveStyleSheetTxnIID))
|
||||
*aResult = new RemoveStyleSheetTxn();
|
||||
else if (aTxnType.Equals(kPlaceholderTxnIID))
|
||||
*aResult = new PlaceholderTxn();
|
||||
else
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
#include "nsICSSStyleSheet.h"
|
||||
#include "nsIHTMLContentContainer.h"
|
||||
#include "nsIStyleSet.h"
|
||||
#include "nsStyleSheetTxns.h"
|
||||
#include "nsIDocumentObserver.h"
|
||||
|
||||
|
||||
|
@ -137,6 +138,8 @@ static NS_DEFINE_IID(kSplitElementTxnIID, SPLIT_ELEMENT_TXN_IID);
|
|||
static NS_DEFINE_IID(kJoinElementTxnIID, JOIN_ELEMENT_TXN_IID);
|
||||
static NS_DEFINE_IID(kIMETextTxnIID, IME_TEXT_TXN_IID);
|
||||
static NS_DEFINE_IID(kIMECommitTxnIID, IME_COMMIT_TXN_IID);
|
||||
static NS_DEFINE_IID(kAddStyleSheetTxnIID, ADD_STYLESHEET_TXN_IID);
|
||||
static NS_DEFINE_IID(kRemoveStyleSheetTxnIID, REMOVE_STYLESHEET_TXN_IID);
|
||||
|
||||
static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
|
||||
static NS_DEFINE_CID(kCDOMRangeCID, NS_RANGE_CID);
|
||||
|
@ -1329,31 +1332,72 @@ NS_IMETHODIMP nsEditor::InsertAsQuotation(const nsString& aQuotedText)
|
|||
return InsertText(aQuotedText);
|
||||
}
|
||||
|
||||
extern "C" void
|
||||
ApplyStyleSheetToPresShellDocument(nsICSSStyleSheet* aSheet, void *aData)
|
||||
NS_IMETHODIMP
|
||||
nsEditor::AddStyleSheet(nsICSSStyleSheet* aSheet)
|
||||
{
|
||||
nsresult rv;
|
||||
AddStyleSheetTxn* aTxn;
|
||||
nsresult rv = CreateTxnForAddStyleSheet(aSheet, &aTxn);
|
||||
if (NS_SUCCEEDED(rv) && aTxn)
|
||||
{
|
||||
rv = Do(aTxn);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
mLastStyleSheet = do_QueryInterface(aSheet); // save it so we can remove before applying the next one
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsIPresShell *presShell = (nsIPresShell *)aData;
|
||||
|
||||
if (presShell) {
|
||||
nsCOMPtr<nsIStyleSet> styleSet;
|
||||
NS_IMETHODIMP
|
||||
nsEditor::RemoveStyleSheet(nsICSSStyleSheet* aSheet)
|
||||
{
|
||||
RemoveStyleSheetTxn* aTxn;
|
||||
nsresult rv = CreateTxnForRemoveStyleSheet(aSheet, &aTxn);
|
||||
if (NS_SUCCEEDED(rv) && aTxn)
|
||||
{
|
||||
rv = Do(aTxn);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
mLastStyleSheet = nsnull; // forget it
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = presShell->GetStyleSet(getter_AddRefs(styleSet));
|
||||
NS_IMETHODIMP
|
||||
nsEditor::ReplaceStyleSheet(nsICSSStyleSheet *aNewSheet)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
BeginTransaction();
|
||||
|
||||
if (NS_SUCCEEDED(rv) && styleSet) {
|
||||
styleSet->AppendOverrideStyleSheet(aSheet);
|
||||
|
||||
nsCOMPtr<nsIDocumentObserver> observer = do_QueryInterface(presShell);
|
||||
nsCOMPtr<nsIStyleSheet> styleSheet = do_QueryInterface(aSheet);
|
||||
nsCOMPtr<nsIDocument> document;
|
||||
|
||||
rv = presShell->GetDocument(getter_AddRefs(document));
|
||||
|
||||
if (NS_SUCCEEDED(rv) && document && observer && styleSheet)
|
||||
rv = observer->StyleSheetAdded(document, styleSheet);
|
||||
}
|
||||
if (mLastStyleSheet)
|
||||
{
|
||||
rv = RemoveStyleSheet(mLastStyleSheet);
|
||||
}
|
||||
|
||||
rv = AddStyleSheet(aNewSheet);
|
||||
|
||||
EndTransaction();
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* static */
|
||||
void nsEditor::ApplyStyleSheetToPresShellDocument(nsICSSStyleSheet* aSheet, void *aData)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsEditor *editor = NS_STATIC_CAST(nsEditor*, aData);
|
||||
if (editor)
|
||||
{
|
||||
rv = editor->ReplaceStyleSheet(aSheet);
|
||||
}
|
||||
|
||||
// we lose the return value here. Set a flag in the editor?
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsEditor::ApplyStyleSheet(const nsString& aURL)
|
||||
|
@ -1396,14 +1440,14 @@ NS_IMETHODIMP nsEditor::ApplyStyleSheet(const nsString& aURL)
|
|||
PRBool complete;
|
||||
|
||||
rv = cssLoader->LoadAgentSheet(uaURL, cssStyleSheet, complete,
|
||||
ApplyStyleSheetToPresShellDocument,
|
||||
mPresShell);
|
||||
nsEditor::ApplyStyleSheetToPresShellDocument,
|
||||
this);
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
if (complete) {
|
||||
if (cssStyleSheet) {
|
||||
ApplyStyleSheetToPresShellDocument(cssStyleSheet,
|
||||
mPresShell);
|
||||
nsEditor::ApplyStyleSheetToPresShellDocument(cssStyleSheet,
|
||||
this);
|
||||
}
|
||||
else
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
|
@ -3653,6 +3697,37 @@ nsEditor::CreateTxnForIMEText(const nsString & aStringToInsert,
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditor::CreateTxnForAddStyleSheet(nsICSSStyleSheet* aSheet, AddStyleSheetTxn* *aTxn)
|
||||
{
|
||||
nsresult rv = TransactionFactory::GetNewTransaction(kAddStyleSheetTxnIID, (EditTxn **)aTxn);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
if (! *aTxn)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
return (*aTxn)->Init(this, aSheet);
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditor::CreateTxnForRemoveStyleSheet(nsICSSStyleSheet* aSheet, RemoveStyleSheetTxn* *aTxn)
|
||||
{
|
||||
nsresult rv = TransactionFactory::GetNewTransaction(kRemoveStyleSheetTxnIID, (EditTxn **)aTxn);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
if (! *aTxn)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
return (*aTxn)->Init(this, aSheet);
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP nsEditor::DoInitialInputMethodInsert(const nsString & aStringToInsert,nsIDOMTextRangeList* aTextRangeList)
|
||||
{
|
||||
if (!mDoc) {
|
||||
|
|
|
@ -58,6 +58,9 @@ class nsIStringBundleService;
|
|||
class nsIStringBundle;
|
||||
class nsILocale;
|
||||
class IMETextTxn;
|
||||
class nsICSSStyleSheet;
|
||||
class AddStyleSheetTxn;
|
||||
class RemoveStyleSheetTxn;
|
||||
|
||||
#ifdef ENABLE_JS_EDITOR_LOG
|
||||
class nsJSEditorLog;
|
||||
|
@ -81,6 +84,7 @@ private:
|
|||
PRUint32 mUpdateCount;
|
||||
nsCOMPtr<nsITransactionManager> mTxnMgr;
|
||||
nsCOMPtr<nsIEditProperty> mEditProperty;
|
||||
nsCOMPtr<nsICSSStyleSheet> mLastStyleSheet; // is owning this dangerous?
|
||||
|
||||
//
|
||||
// data necessary to build IME transactions
|
||||
|
@ -230,6 +234,8 @@ public:
|
|||
NS_IMETHOD InsertAsQuotation(const nsString& aQuotedText);
|
||||
|
||||
NS_IMETHOD ApplyStyleSheet(const nsString& aURL);
|
||||
NS_IMETHOD AddStyleSheet(nsICSSStyleSheet* aSheet);
|
||||
NS_IMETHOD RemoveStyleSheet(nsICSSStyleSheet* aSheet);
|
||||
|
||||
NS_IMETHOD AddEditActionListener(nsIEditActionListener *aListener);
|
||||
|
||||
|
@ -242,6 +248,9 @@ public:
|
|||
|
||||
/*END nsIEditor interfaces*/
|
||||
|
||||
/* StyleSheet load callback */
|
||||
static void ApplyStyleSheetToPresShellDocument(nsICSSStyleSheet* aSheet, void *aData);
|
||||
|
||||
|
||||
/*BEGIN private methods used by the implementations of the above functions*/
|
||||
protected:
|
||||
|
@ -288,6 +297,17 @@ protected:
|
|||
nsIDOMTextRangeList* aTextRangeList,
|
||||
IMETextTxn ** aTxn);
|
||||
|
||||
/** create a transaction for adding a style sheet
|
||||
*/
|
||||
NS_IMETHOD CreateTxnForAddStyleSheet(nsICSSStyleSheet* aSheet, AddStyleSheetTxn* *aTxn);
|
||||
|
||||
/** create a transaction for removing a style sheet
|
||||
*/
|
||||
NS_IMETHOD CreateTxnForRemoveStyleSheet(nsICSSStyleSheet* aSheet, RemoveStyleSheetTxn* *aTxn);
|
||||
|
||||
/* remove the old style sheet, and apply the supplied one */
|
||||
NS_IMETHOD ReplaceStyleSheet(nsICSSStyleSheet *aNewSheet);
|
||||
|
||||
/** insert aStringToInsert as the first text in the document
|
||||
*/
|
||||
NS_IMETHOD DoInitialInsert(const nsString & aStringToInsert);
|
||||
|
|
|
@ -28,6 +28,7 @@ class nsITransaction;
|
|||
class nsIEditActionListener;
|
||||
class nsIFileSpec;
|
||||
class nsIDOMTextRangeList;
|
||||
class nsICSSStyleSheet;
|
||||
|
||||
/*
|
||||
Editor interface to outside world
|
||||
|
@ -379,11 +380,24 @@ public:
|
|||
NS_IMETHOD InsertAsQuotation(const nsString& aQuotedText)=0;
|
||||
|
||||
/** load and apply the style sheet, specified by aURL, to
|
||||
* the editor's document.
|
||||
* the editor's document. This can involve asynchronous
|
||||
* network I/O
|
||||
* @param aURL The style sheet to be loaded and applied.
|
||||
*/
|
||||
NS_IMETHOD ApplyStyleSheet(const nsString& aURL)=0;
|
||||
|
||||
/** Add the given Style Sheet to the editor's document
|
||||
* This is always synchronous
|
||||
* @param aSheet The style sheet to be applied.
|
||||
*/
|
||||
NS_IMETHOD AddStyleSheet(nsICSSStyleSheet* aSheet)=0;
|
||||
|
||||
/** Remove the given Style Sheet from the editor's document
|
||||
* This is always synchronous
|
||||
* @param aSheet The style sheet to be applied.
|
||||
*/
|
||||
NS_IMETHOD RemoveStyleSheet(nsICSSStyleSheet* aSheet)=0;
|
||||
|
||||
/** add an EditActionListener to the editors list of listeners. */
|
||||
NS_IMETHOD AddEditActionListener(nsIEditActionListener *aListener)=0;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче