зеркало из https://github.com/mozilla/pjs.git
Changed to use command nodes in XUL, with lots of XUL tidy-up (detabbing etc).
This commit is contained in:
Родитель
c4572ca892
Коммит
b6c71e8a29
|
@ -29,6 +29,7 @@
|
|||
#include "nsIDiskDocument.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMSelection.h"
|
||||
#include "nsIDOMAttr.h"
|
||||
|
||||
#include "nsIEditor.h"
|
||||
#include "nsIHTMLEditor.h"
|
||||
|
@ -129,11 +130,11 @@ nsInterfaceState::NotifySelectionChanged()
|
|||
// we don't really care if any of these fail.
|
||||
|
||||
// update bold
|
||||
rv = UpdateTextState("b", "Editor:Style:IsBold", "bold", mBoldState);
|
||||
rv = UpdateTextState("b", "Editor:Bold", "bold", mBoldState);
|
||||
// update italic
|
||||
rv = UpdateTextState("i", "Editor:Style:IsItalic", "italic", mItalicState);
|
||||
rv = UpdateTextState("i", "Editor:Italic", "italic", mItalicState);
|
||||
// update underline
|
||||
rv = UpdateTextState("u", "Editor:Style:IsUnderline", "underline", mUnderlineState);
|
||||
rv = UpdateTextState("u", "Editor:Underline", "underline", mUnderlineState);
|
||||
|
||||
// udpate the font face
|
||||
rv = UpdateFontFace("Editor:Font:Face", "font", mFontString);
|
||||
|
@ -263,8 +264,11 @@ nsInterfaceState::UpdateDirtyState(PRBool aNowDirty)
|
|||
{
|
||||
if (mDirtyState != aNowDirty)
|
||||
{
|
||||
nsresult rv = SetNodeAttribute("Editor:Document:Dirty", "dirty", aNowDirty ? "true" : "false");
|
||||
nsresult rv; // = SetNodeAttribute("Editor:Save", "disabled", aNowDirty ? "true" : "false");
|
||||
|
||||
rv = SetNodeAttribute("Editor:Save", "disabled", aNowDirty ? "false" : "true");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
mDirtyState = aNowDirty;
|
||||
}
|
||||
|
||||
|
@ -302,6 +306,36 @@ nsInterfaceState::SetNodeAttribute(const char* nodeID, const char* attributeName
|
|||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsInterfaceState::UnsetNodeAttribute(const char* nodeID, const char* attributeName)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (!mWebShell)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
nsCOMPtr<nsIContentViewer> cv;
|
||||
rv = mWebShell->GetContentViewer(getter_AddRefs(cv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIDocumentViewer> docViewer = do_QueryInterface(cv, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIDocument> chromeDoc;
|
||||
rv = docViewer->GetDocument(*getter_AddRefs(chromeDoc));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIDOMXULDocument> xulDoc = do_QueryInterface(chromeDoc, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIDOMElement> elem;
|
||||
rv = xulDoc->GetElementById( nodeID, getter_AddRefs(elem) );
|
||||
if (NS_FAILED(rv) || !elem) return rv;
|
||||
|
||||
return elem->RemoveAttribute(attributeName);
|
||||
}
|
||||
|
||||
|
||||
nsresult NS_NewInterfaceState(nsIHTMLEditor* aEditor, nsIWebShell* aWebShell, nsIDOMSelectionListener** aInstancePtrResult)
|
||||
{
|
||||
nsInterfaceState* newThang = new nsInterfaceState;
|
||||
|
|
|
@ -56,6 +56,7 @@ protected:
|
|||
};
|
||||
|
||||
nsresult SetNodeAttribute(const char* nodeID, const char* attributeName, const nsString& newValue);
|
||||
nsresult UnsetNodeAttribute(const char* nodeID, const char* attributeName);
|
||||
|
||||
nsresult UpdateParagraphState(const char* observerName, const char* attributeName, nsString& ioParaFormat);
|
||||
nsresult UpdateListState(const char* observerName);
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "nsIDiskDocument.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMSelection.h"
|
||||
#include "nsIDOMAttr.h"
|
||||
|
||||
#include "nsIEditor.h"
|
||||
#include "nsIHTMLEditor.h"
|
||||
|
@ -129,11 +130,11 @@ nsInterfaceState::NotifySelectionChanged()
|
|||
// we don't really care if any of these fail.
|
||||
|
||||
// update bold
|
||||
rv = UpdateTextState("b", "Editor:Style:IsBold", "bold", mBoldState);
|
||||
rv = UpdateTextState("b", "Editor:Bold", "bold", mBoldState);
|
||||
// update italic
|
||||
rv = UpdateTextState("i", "Editor:Style:IsItalic", "italic", mItalicState);
|
||||
rv = UpdateTextState("i", "Editor:Italic", "italic", mItalicState);
|
||||
// update underline
|
||||
rv = UpdateTextState("u", "Editor:Style:IsUnderline", "underline", mUnderlineState);
|
||||
rv = UpdateTextState("u", "Editor:Underline", "underline", mUnderlineState);
|
||||
|
||||
// udpate the font face
|
||||
rv = UpdateFontFace("Editor:Font:Face", "font", mFontString);
|
||||
|
@ -263,8 +264,11 @@ nsInterfaceState::UpdateDirtyState(PRBool aNowDirty)
|
|||
{
|
||||
if (mDirtyState != aNowDirty)
|
||||
{
|
||||
nsresult rv = SetNodeAttribute("Editor:Document:Dirty", "dirty", aNowDirty ? "true" : "false");
|
||||
nsresult rv; // = SetNodeAttribute("Editor:Save", "disabled", aNowDirty ? "true" : "false");
|
||||
|
||||
rv = SetNodeAttribute("Editor:Save", "disabled", aNowDirty ? "false" : "true");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
mDirtyState = aNowDirty;
|
||||
}
|
||||
|
||||
|
@ -302,6 +306,36 @@ nsInterfaceState::SetNodeAttribute(const char* nodeID, const char* attributeName
|
|||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsInterfaceState::UnsetNodeAttribute(const char* nodeID, const char* attributeName)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (!mWebShell)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
nsCOMPtr<nsIContentViewer> cv;
|
||||
rv = mWebShell->GetContentViewer(getter_AddRefs(cv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIDocumentViewer> docViewer = do_QueryInterface(cv, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIDocument> chromeDoc;
|
||||
rv = docViewer->GetDocument(*getter_AddRefs(chromeDoc));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIDOMXULDocument> xulDoc = do_QueryInterface(chromeDoc, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIDOMElement> elem;
|
||||
rv = xulDoc->GetElementById( nodeID, getter_AddRefs(elem) );
|
||||
if (NS_FAILED(rv) || !elem) return rv;
|
||||
|
||||
return elem->RemoveAttribute(attributeName);
|
||||
}
|
||||
|
||||
|
||||
nsresult NS_NewInterfaceState(nsIHTMLEditor* aEditor, nsIWebShell* aWebShell, nsIDOMSelectionListener** aInstancePtrResult)
|
||||
{
|
||||
nsInterfaceState* newThang = new nsInterfaceState;
|
||||
|
|
|
@ -56,6 +56,7 @@ protected:
|
|||
};
|
||||
|
||||
nsresult SetNodeAttribute(const char* nodeID, const char* attributeName, const nsString& newValue);
|
||||
nsresult UnsetNodeAttribute(const char* nodeID, const char* attributeName);
|
||||
|
||||
nsresult UpdateParagraphState(const char* observerName, const char* attributeName, nsString& ioParaFormat);
|
||||
nsresult UpdateListState(const char* observerName);
|
||||
|
|
Загрузка…
Ссылка в новой задаче