From 4ccb7d43f3f9f79693a2d669fd7dea2e866f4d46 Mon Sep 17 00:00:00 2001 From: "hyatt%netscape.com" Date: Fri, 25 Feb 2000 08:37:49 +0000 Subject: [PATCH] XUL Property APIs, b=26109, r=ben git-svn-id: svn://10.0.0.236/trunk@61661 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/content/shared/public/nsXULAtomList.h | 21 +- mozilla/content/xbl/src/nsXBLBinding.cpp | 15 +- mozilla/content/xbl/src/nsXBLEventHandler.cpp | 56 +- mozilla/content/xbl/src/nsXBLEventHandler.h | 11 +- .../content/xul/content/src/nsXULElement.cpp | 95 +++- .../content/xul/content/src/nsXULElement.h | 5 + mozilla/dom/public/nsDOMPropEnums.h | 26 + mozilla/dom/public/nsDOMPropNames.h | 26 + mozilla/layout/base/nsCSSFrameConstructor.cpp | 49 +- .../html/style/src/nsCSSFrameConstructor.cpp | 49 +- mozilla/layout/xbl/src/nsXBLBinding.cpp | 15 +- mozilla/layout/xbl/src/nsXBLEventHandler.cpp | 56 +- mozilla/layout/xbl/src/nsXBLEventHandler.h | 11 +- mozilla/layout/xul/base/src/Makefile.in | 1 + mozilla/layout/xul/base/src/makefile.win | 2 + mozilla/layout/xul/base/src/nsMenuFrame.cpp | 190 +++++-- mozilla/layout/xul/base/src/nsMenuFrame.h | 1 + .../xul/base/src/nsTitledButtonFrame.cpp | 64 ++- .../layout/xul/base/src/nsTitledButtonFrame.h | 1 + .../xul/base/src/nsXULCheckboxFrame.cpp | 88 +++ .../layout/xul/base/src/nsXULCheckboxFrame.h | 42 ++ .../layout/xul/content/src/nsXULAtomList.h | 21 +- mozilla/rdf/content/public/MANIFEST | 6 + mozilla/rdf/content/public/Makefile.in | 6 +- .../content/public/idl/XULCheckboxElement.idl | 12 + .../content/public/idl/XULMenuListElement.idl | 10 + .../content/public/idl/XULRadioElement.idl | 13 + .../public/idl/XULTitledButtonElement.idl | 10 + mozilla/rdf/content/public/idl/makefile.win | 4 + mozilla/rdf/content/public/makefile.win | 4 + .../content/public/nsIDOMXULCheckboxElement.h | 103 ++++ .../content/public/nsIDOMXULMenuListElement.h | 97 ++++ .../content/public/nsIDOMXULRadioElement.h | 103 ++++ .../public/nsIDOMXULTitledButtonElement.h | 96 ++++ mozilla/rdf/content/src/Makefile.in | 8 + mozilla/rdf/content/src/makefile.win | 8 + .../content/src/nsJSXULCheckboxElement.cpp | 522 ++++++++++++++++++ .../content/src/nsJSXULMenuListElement.cpp | 495 +++++++++++++++++ .../rdf/content/src/nsJSXULRadioElement.cpp | 522 ++++++++++++++++++ .../src/nsJSXULTitledButtonElement.cpp | 488 ++++++++++++++++ .../rdf/content/src/nsXULCheckboxElement.cpp | 181 ++++++ .../rdf/content/src/nsXULCheckboxElement.h | 58 ++ mozilla/rdf/content/src/nsXULElement.cpp | 95 +++- mozilla/rdf/content/src/nsXULElement.h | 5 + .../rdf/content/src/nsXULMenuListElement.cpp | 170 ++++++ .../rdf/content/src/nsXULMenuListElement.h | 62 +++ mozilla/rdf/content/src/nsXULRadioElement.cpp | 182 ++++++ mozilla/rdf/content/src/nsXULRadioElement.h | 58 ++ .../content/src/nsXULTitledButtonElement.cpp | 157 ++++++ .../content/src/nsXULTitledButtonElement.h | 60 ++ mozilla/xpfe/global/resources/skin/global.css | 74 +++ mozilla/xpfe/global/resources/skin/xul.css | 16 + .../global/resources/skin/xulBindings.xml | 31 +- 53 files changed, 4398 insertions(+), 103 deletions(-) create mode 100644 mozilla/layout/xul/base/src/nsXULCheckboxFrame.cpp create mode 100644 mozilla/layout/xul/base/src/nsXULCheckboxFrame.h create mode 100644 mozilla/rdf/content/public/idl/XULCheckboxElement.idl create mode 100644 mozilla/rdf/content/public/idl/XULMenuListElement.idl create mode 100644 mozilla/rdf/content/public/idl/XULRadioElement.idl create mode 100644 mozilla/rdf/content/public/idl/XULTitledButtonElement.idl create mode 100644 mozilla/rdf/content/public/nsIDOMXULCheckboxElement.h create mode 100644 mozilla/rdf/content/public/nsIDOMXULMenuListElement.h create mode 100644 mozilla/rdf/content/public/nsIDOMXULRadioElement.h create mode 100644 mozilla/rdf/content/public/nsIDOMXULTitledButtonElement.h create mode 100644 mozilla/rdf/content/src/nsJSXULCheckboxElement.cpp create mode 100644 mozilla/rdf/content/src/nsJSXULMenuListElement.cpp create mode 100644 mozilla/rdf/content/src/nsJSXULRadioElement.cpp create mode 100644 mozilla/rdf/content/src/nsJSXULTitledButtonElement.cpp create mode 100644 mozilla/rdf/content/src/nsXULCheckboxElement.cpp create mode 100644 mozilla/rdf/content/src/nsXULCheckboxElement.h create mode 100644 mozilla/rdf/content/src/nsXULMenuListElement.cpp create mode 100644 mozilla/rdf/content/src/nsXULMenuListElement.h create mode 100644 mozilla/rdf/content/src/nsXULRadioElement.cpp create mode 100644 mozilla/rdf/content/src/nsXULRadioElement.h create mode 100644 mozilla/rdf/content/src/nsXULTitledButtonElement.cpp create mode 100644 mozilla/rdf/content/src/nsXULTitledButtonElement.h diff --git a/mozilla/content/shared/public/nsXULAtomList.h b/mozilla/content/shared/public/nsXULAtomList.h index 9b559c2b966..66904c92208 100644 --- a/mozilla/content/shared/public/nsXULAtomList.h +++ b/mozilla/content/shared/public/nsXULAtomList.h @@ -65,7 +65,6 @@ XUL_ATOM(allowevents, "allowevents") // Lets events be handled on the cell conte XUL_ATOM(treecol, "treecol") // A column in the tree view XUL_ATOM(treecolgroup, "treecolgroup") // A column group in the tree view XUL_ATOM(treefoot, "treefoot") // The footer of the tree view -XUL_ATOM(treepusher, "treepusher") // A column pusher (left or right) for the tree view XUL_ATOM(scrollbarlist, "scrollbarlist") // An atom for internal use by the tree view XUL_ATOM(indent, "indent") // indicates that a cell should be indented @@ -141,3 +140,23 @@ XUL_ATOM(iframe, "iframe") XUL_ATOM(browser, "browser") XUL_ATOM(editor, "editor") +// + +XUL_ATOM(checkbox, "checkbox") +XUL_ATOM(radio, "radio") +XUL_ATOM(menulist, "menulist") +XUL_ATOM(menubutton, "menubutton") +XUL_ATOM(textfield, "textfield") +XUL_ATOM(textarea, "textarea") +XUL_ATOM(listbox, "listbox") + +XUL_ATOM(listcaption, "listcaption") // The caption of a list view +XUL_ATOM(listhead, "listhead") // The header of the list view +XUL_ATOM(listrow, "listrow") // A row in the list view +XUL_ATOM(listcell, "listcell") // An item in the list view +XUL_ATOM(listitem, "listitem") // A cell in the list view +XUL_ATOM(listchildren, "listchildren") // The children of an item in the list view +XUL_ATOM(listindentation, "listindentation") // Specifies that the indentation for the level should occur here. +XUL_ATOM(listcol, "listcol") // A column in the list view +XUL_ATOM(listcolgroup, "listcolgroup") // A column group in the list view +XUL_ATOM(listfoot, "listfoot") // The footer of the list view diff --git a/mozilla/content/xbl/src/nsXBLBinding.cpp b/mozilla/content/xbl/src/nsXBLBinding.cpp index 7e5a3c6d4a4..f4baa3fa54b 100644 --- a/mozilla/content/xbl/src/nsXBLBinding.cpp +++ b/mozilla/content/xbl/src/nsXBLBinding.cpp @@ -121,6 +121,7 @@ protected: PRBool IsMouseHandler(const nsString& aName); PRBool IsKeyHandler(const nsString& aName); + PRBool IsXULHandler(const nsString& aName); static void GetEventHandlerIID(nsIAtom* aName, nsIID* aIID, PRBool* aFound); @@ -406,8 +407,9 @@ nsXBLBinding::InstallEventHandlers(nsIContent* aBoundElement) // Add an event listener for mouse and key events only. PRBool mouse = IsMouseHandler(type); PRBool key = IsKeyHandler(type); + PRBool xul = IsXULHandler(type); - if (mouse || key) { + if (mouse || key || xul) { // Create a new nsXBLEventHandler. nsXBLEventHandler* handler; NS_NewXBLEventHandler(mBoundElement, child, type, &handler); @@ -423,8 +425,10 @@ nsXBLBinding::InstallEventHandlers(nsIContent* aBoundElement) nsCOMPtr receiver = do_QueryInterface(mBoundElement); if (mouse) receiver->AddEventListener(type, (nsIDOMMouseListener*)handler, useCapture); - else + else if(key) receiver->AddEventListener(type, (nsIDOMKeyListener*)handler, useCapture); + else + receiver->AddEventListener(type, (nsIDOMMenuListener*)handler, useCapture); NS_RELEASE(handler); } @@ -657,6 +661,13 @@ nsXBLBinding::IsKeyHandler(const nsString& aName) return ((aName == "keypress") || (aName == "keydown") || (aName == "keyup")); } +PRBool +nsXBLBinding::IsXULHandler(const nsString& aName) +{ + return ((aName == "create") || (aName == "destroy") || (aName=="broadcast") || + (aName == "command") || (aName == "commandupdate") || (aName == "close")); +} + // Creation Routine /////////////////////////////////////////////////////////////////////// nsresult diff --git a/mozilla/content/xbl/src/nsXBLEventHandler.cpp b/mozilla/content/xbl/src/nsXBLEventHandler.cpp index 200b2b94251..40c77a80949 100644 --- a/mozilla/content/xbl/src/nsXBLEventHandler.cpp +++ b/mozilla/content/xbl/src/nsXBLEventHandler.cpp @@ -67,7 +67,7 @@ nsXBLEventHandler::~nsXBLEventHandler() } } -NS_IMPL_ISUPPORTS2(nsXBLEventHandler, nsIDOMKeyListener, nsIDOMMouseListener) +NS_IMPL_ISUPPORTS3(nsXBLEventHandler, nsIDOMKeyListener, nsIDOMMouseListener, nsIDOMMenuListener) nsresult nsXBLEventHandler::HandleEvent(nsIDOMEvent* aEvent) { @@ -174,6 +174,60 @@ nsresult nsXBLEventHandler::MouseOut(nsIDOMEvent* aMouseEvent) return NS_OK; } +nsresult nsXBLEventHandler::Action(nsIDOMEvent* aEvent) +{ + if (mEventName != "command") + return NS_OK; + + ExecuteHandler(nsAutoString("command"), aEvent); + return NS_OK; +} + +nsresult nsXBLEventHandler::Create(nsIDOMEvent* aEvent) +{ + if (mEventName != "create") + return NS_OK; + + ExecuteHandler(nsAutoString("create"), aEvent); + return NS_OK; +} + +nsresult nsXBLEventHandler::Close(nsIDOMEvent* aEvent) +{ + if (mEventName != "close") + return NS_OK; + + ExecuteHandler(nsAutoString("close"), aEvent); + return NS_OK; +} + +nsresult nsXBLEventHandler::Broadcast(nsIDOMEvent* aEvent) +{ + if (mEventName != "broadcast") + return NS_OK; + + ExecuteHandler(nsAutoString("broadcast"), aEvent); + return NS_OK; +} + +nsresult nsXBLEventHandler::CommandUpdate(nsIDOMEvent* aEvent) +{ + if (mEventName != "commandupdate") + return NS_OK; + + ExecuteHandler(nsAutoString("commandupdate"), aEvent); + return NS_OK; +} + +nsresult nsXBLEventHandler::Destroy(nsIDOMEvent* aEvent) +{ + if (mEventName != "destroy") + return NS_OK; + + ExecuteHandler(nsAutoString("destroy"), aEvent); + return NS_OK; +} + /////////////////////////////////////////////////////////////////////////////////// PRBool diff --git a/mozilla/content/xbl/src/nsXBLEventHandler.h b/mozilla/content/xbl/src/nsXBLEventHandler.h index 538cfb1657a..4dfaa56e1fe 100644 --- a/mozilla/content/xbl/src/nsXBLEventHandler.h +++ b/mozilla/content/xbl/src/nsXBLEventHandler.h @@ -25,6 +25,7 @@ #include "nsIDOMMouseListener.h" #include "nsIDOMKeyListener.h" +#include "nsIDOMMenuListener.h" class nsIXBLBinding; class nsIDOMEvent; @@ -35,7 +36,8 @@ class nsIAtom; class nsIController; class nsXBLEventHandler : public nsIDOMKeyListener, - public nsIDOMMouseListener + public nsIDOMMouseListener, + public nsIDOMMenuListener { public: nsXBLEventHandler(nsIContent* aBoundElement, nsIContent* aHandlerElement, const nsString& aEventName); @@ -54,6 +56,13 @@ public: virtual nsresult MouseOver(nsIDOMEvent* aMouseEvent); virtual nsresult MouseOut(nsIDOMEvent* aMouseEvent); + NS_IMETHOD Create(nsIDOMEvent* aEvent); + NS_IMETHOD Close(nsIDOMEvent* aEvent); + NS_IMETHOD Destroy(nsIDOMEvent* aEvent); + NS_IMETHOD Action(nsIDOMEvent* aEvent); + NS_IMETHOD Broadcast(nsIDOMEvent* aEvent); + NS_IMETHOD CommandUpdate(nsIDOMEvent* aEvent); + NS_DECL_ISUPPORTS protected: diff --git a/mozilla/content/xul/content/src/nsXULElement.cpp b/mozilla/content/xul/content/src/nsXULElement.cpp index 8711f0410ba..3e7536a439c 100644 --- a/mozilla/content/xul/content/src/nsXULElement.cpp +++ b/mozilla/content/xul/content/src/nsXULElement.cpp @@ -93,6 +93,11 @@ #include "nsXULEditorElement.h" #include "nsXULTreeElement.h" #include "nsXULPopupElement.h" +#include "nsXULTitledButtonElement.h" +#include "nsXULCheckboxElement.h" +#include "nsXULRadioElement.h" +#include "nsXULMenuListElement.h" + #include "prlog.h" #include "rdf.h" #include "rdfutil.h" @@ -288,6 +293,11 @@ nsIAtom* nsXULElement::kBrowserAtom; nsIAtom* nsXULElement::kEditorAtom; nsIAtom* nsXULElement::kWidthAtom; nsIAtom* nsXULElement::kWindowAtom; +nsIAtom* nsXULElement::kNullAtom; +nsIAtom* nsXULElement::kCheckboxAtom; +nsIAtom* nsXULElement::kRadioAtom; +nsIAtom* nsXULElement::kMenuListAtom; +nsIAtom* nsXULElement::kMenuButtonAtom; #ifdef XUL_PROTOTYPE_ATTRIBUTE_METERING PRUint32 nsXULPrototypeAttribute::gNumElements; @@ -355,6 +365,11 @@ nsXULElement::Init() kEditorAtom = NS_NewAtom("editor"); kWidthAtom = NS_NewAtom("width"); kWindowAtom = NS_NewAtom("window"); + kCheckboxAtom = NS_NewAtom("checkbox"); + kRadioAtom = NS_NewAtom("radio"); + kMenuListAtom = NS_NewAtom("menulist"); + kMenuButtonAtom = NS_NewAtom("menubutton"); + kNullAtom = NS_NewAtom(""); rv = nsComponentManager::CreateInstance(kNameSpaceManagerCID, nsnull, @@ -432,6 +447,11 @@ nsXULElement::~nsXULElement() NS_IF_RELEASE(kEditorAtom); NS_IF_RELEASE(kWidthAtom); NS_IF_RELEASE(kWindowAtom); + NS_IF_RELEASE(kCheckboxAtom); + NS_IF_RELEASE(kRadioAtom); + NS_IF_RELEASE(kMenuListAtom); + NS_IF_RELEASE(kMenuButtonAtom); + NS_IF_RELEASE(kNullAtom); NS_IF_RELEASE(gNameSpaceManager); @@ -660,6 +680,62 @@ nsXULElement::QueryInterface(REFNSIID iid, void** result) return InnerXULElement()->QueryInterface(iid, result); } + else if (iid.Equals(NS_GET_IID(nsIDOMXULTitledButtonElement)) && + (NameSpaceID() == kNameSpaceID_XUL) && + (Tag() == kTitledButtonAtom)) { + // We delegate XULTitledButtonElement APIs to an aggregate object + if (! InnerXULElement()) { + rv = EnsureSlots(); + if (NS_FAILED(rv)) return rv; + + if ((mSlots->mInnerXULElement = new nsXULTitledButtonElement(this)) == nsnull) + return NS_ERROR_OUT_OF_MEMORY; + } + + return InnerXULElement()->QueryInterface(iid, result); + } + else if (iid.Equals(NS_GET_IID(nsIDOMXULCheckboxElement)) && + (NameSpaceID() == kNameSpaceID_XUL) && + (Tag() == kCheckboxAtom)) { + // We delegate XULCheckboxElement APIs to an aggregate object + if (! InnerXULElement()) { + rv = EnsureSlots(); + if (NS_FAILED(rv)) return rv; + + if ((mSlots->mInnerXULElement = new nsXULCheckboxElement(this)) == nsnull) + return NS_ERROR_OUT_OF_MEMORY; + } + + return InnerXULElement()->QueryInterface(iid, result); + } + else if (iid.Equals(NS_GET_IID(nsIDOMXULRadioElement)) && + (NameSpaceID() == kNameSpaceID_XUL) && + (Tag() == kRadioAtom)) { + // We delegate XULRadioElement APIs to an aggregate object + if (! InnerXULElement()) { + rv = EnsureSlots(); + if (NS_FAILED(rv)) return rv; + + if ((mSlots->mInnerXULElement = new nsXULRadioElement(this)) == nsnull) + return NS_ERROR_OUT_OF_MEMORY; + } + + return InnerXULElement()->QueryInterface(iid, result); + } + else if (iid.Equals(NS_GET_IID(nsIDOMXULMenuListElement)) && + (NameSpaceID() == kNameSpaceID_XUL) && + (Tag() == kMenuListAtom)) { + // We delegate XULMenuListElement APIs to an aggregate object + if (! InnerXULElement()) { + rv = EnsureSlots(); + if (NS_FAILED(rv)) return rv; + + if ((mSlots->mInnerXULElement = new nsXULMenuListElement(this)) == nsnull) + return NS_ERROR_OUT_OF_MEMORY; + } + + return InnerXULElement()->QueryInterface(iid, result); + } else if (iid.Equals(NS_GET_IID(nsIDOMXULEditorElement)) && (NameSpaceID() == kNameSpaceID_XUL) && (Tag() == kEditorAtom)) { @@ -1700,6 +1776,22 @@ nsXULElement::GetScriptObject(nsIScriptContext* aContext, void** aScriptObject) fn = NS_NewScriptXULBrowserElement; rootname = "nsXULBrowserElement::mScriptObject"; } + else if (Tag() == kTitledButtonAtom) { + fn = NS_NewScriptXULTitledButtonElement; + rootname = "nsXULTitledButtonElement::mScriptObject"; + } + else if (Tag() == kCheckboxAtom) { + fn = NS_NewScriptXULCheckboxElement; + rootname = "nsXULCheckboxElement::mScriptObject"; + } + else if (Tag() == kRadioAtom) { + fn = NS_NewScriptXULRadioElement; + rootname = "nsXULRadioElement::mScriptObject"; + } + else if (Tag() == kMenuListAtom) { + fn = NS_NewScriptXULMenuListElement; + rootname = "nsXULMenuListElement::mScriptObject"; + } else if (Tag() == kEditorAtom) { fn = NS_NewScriptXULEditorElement; rootname = "nsXULEditorElement::mScriptObject"; @@ -3850,7 +3942,8 @@ nsXULElement::RemoveFocus(nsIPresContext* aPresContext) PRBool nsXULElement::IsFocusableContent() { - return (Tag() == kTitledButtonAtom) || (Tag() == kTreeAtom); + return (Tag() == kTitledButtonAtom) || (Tag() == kTreeAtom) || (Tag() == kCheckboxAtom) || (Tag() == kRadioAtom) || + (Tag() == kMenuListAtom) || (Tag() == kMenuButtonAtom); } // nsIBindableContent Interface diff --git a/mozilla/content/xul/content/src/nsXULElement.h b/mozilla/content/xul/content/src/nsXULElement.h index 38ce4248b78..ada726b92b6 100644 --- a/mozilla/content/xul/content/src/nsXULElement.h +++ b/mozilla/content/xul/content/src/nsXULElement.h @@ -342,6 +342,8 @@ protected: static nsIAtom* kSelectedAtom; static nsIAtom* kStyleAtom; static nsIAtom* kTitledButtonAtom; + static nsIAtom* kCheckboxAtom; + static nsIAtom* kRadioAtom; static nsIAtom* kTooltipAtom; static nsIAtom* kTreeAtom; static nsIAtom* kTreeCellAtom; @@ -355,6 +357,9 @@ protected: static nsIAtom* kEditorAtom; static nsIAtom* kWidthAtom; static nsIAtom* kWindowAtom; + static nsIAtom* kMenuButtonAtom; + static nsIAtom* kMenuListAtom; + static nsIAtom* kNullAtom; public: static nsresult diff --git a/mozilla/dom/public/nsDOMPropEnums.h b/mozilla/dom/public/nsDOMPropEnums.h index b948aef3cbf..af79c7f21ed 100644 --- a/mozilla/dom/public/nsDOMPropEnums.h +++ b/mozilla/dom/public/nsDOMPropEnums.h @@ -888,6 +888,13 @@ enum nsDOMProp { NS_DOM_PROP_WINDOWCOLLECTION_ITEM, NS_DOM_PROP_WINDOWCOLLECTION_LENGTH, NS_DOM_PROP_WINDOWCOLLECTION_NAMEDITEM, + NS_DOM_PROP_XULCHECKBOXELEMENT_ACCESSKEY, + NS_DOM_PROP_XULCHECKBOXELEMENT_CHECKED, + NS_DOM_PROP_XULCHECKBOXELEMENT_CROP, + NS_DOM_PROP_XULCHECKBOXELEMENT_DISABLED, + NS_DOM_PROP_XULCHECKBOXELEMENT_IMGALIGN, + NS_DOM_PROP_XULCHECKBOXELEMENT_SRC, + NS_DOM_PROP_XULCHECKBOXELEMENT_VALUE, NS_DOM_PROP_XULCOMMANDDISPATCHER_ADDCOMMANDUPDATER, NS_DOM_PROP_XULCOMMANDDISPATCHER_FOCUSEDELEMENT, NS_DOM_PROP_XULCOMMANDDISPATCHER_FOCUSEDWINDOW, @@ -919,8 +926,27 @@ enum nsDOMProp { NS_DOM_PROP_XULELEMENT_REMOVEBROADCASTLISTENER, NS_DOM_PROP_XULELEMENT_RESOURCE, NS_DOM_PROP_XULELEMENT_STYLE, + NS_DOM_PROP_XULMENULISTELEMENT_CROP, + NS_DOM_PROP_XULMENULISTELEMENT_DATA, + NS_DOM_PROP_XULMENULISTELEMENT_DISABLED, + NS_DOM_PROP_XULMENULISTELEMENT_SELECTEDITEM, + NS_DOM_PROP_XULMENULISTELEMENT_SRC, + NS_DOM_PROP_XULMENULISTELEMENT_VALUE, NS_DOM_PROP_XULPOPUPELEMENT_OPENPOPUP, NS_DOM_PROP_XULPOPUPELEMENT_CLOSEPOPUP, + NS_DOM_PROP_XULRADIOELEMENT_ACCESSKEY, + NS_DOM_PROP_XULRADIOELEMENT_CHECKED, + NS_DOM_PROP_XULRADIOELEMENT_CROP, + NS_DOM_PROP_XULRADIOELEMENT_DISABLED, + NS_DOM_PROP_XULRADIOELEMENT_IMGALIGN, + NS_DOM_PROP_XULRADIOELEMENT_SRC, + NS_DOM_PROP_XULRADIOELEMENT_VALUE, + NS_DOM_PROP_XULTITLEDBUTTONELEMENT_ACCESSKEY, + NS_DOM_PROP_XULTITLEDBUTTONELEMENT_CROP, + NS_DOM_PROP_XULTITLEDBUTTONELEMENT_DISABLED, + NS_DOM_PROP_XULTITLEDBUTTONELEMENT_IMGALIGN, + NS_DOM_PROP_XULTITLEDBUTTONELEMENT_SRC, + NS_DOM_PROP_XULTITLEDBUTTONELEMENT_VALUE, NS_DOM_PROP_XULTREEELEMENT_ADDCELLTOSELECTION, NS_DOM_PROP_XULTREEELEMENT_ADDITEMTOSELECTION, NS_DOM_PROP_XULTREEELEMENT_CLEARCELLSELECTION, diff --git a/mozilla/dom/public/nsDOMPropNames.h b/mozilla/dom/public/nsDOMPropNames.h index 2c8eb165bce..2ccc87d3306 100644 --- a/mozilla/dom/public/nsDOMPropNames.h +++ b/mozilla/dom/public/nsDOMPropNames.h @@ -887,6 +887,13 @@ "windowcollection.item", \ "windowcollection.length", \ "windowcollection.nameditem", \ + "xulcheckboxelement.accesskey", \ + "xulcheckboxelement.checked", \ + "xulcheckboxelement.crop", \ + "xulcheckboxelement.disabled", \ + "xulcheckboxelement.imgalign", \ + "xulcheckboxelement.src", \ + "xulcheckboxelement.value", \ "xulcommanddispatcher.addcommandupdater", \ "xulcommanddispatcher.focusedelement", \ "xulcommanddispatcher.focusedwindow", \ @@ -918,8 +925,27 @@ "xulelement.removebroadcastlistener", \ "xulelement.resource", \ "xulelement.style", \ + "xulmenulistelement.crop", \ + "xulmenulistelement.data", \ + "xulmenulistelement.disabled", \ + "xulmenulistelement.selecteditem", \ + "xulmenulistelement.src", \ + "xulmenulistelement.value", \ "xulpopupelement.openpopup", \ "xulpopupelement.closepopup", \ + "xulradioelement.accesskey", \ + "xulradioelement.checked", \ + "xulradioelement.crop", \ + "xulradioelement.disabled", \ + "xulradioelement.imgalign", \ + "xulradioelement.src", \ + "xulradioelement.value", \ + "xultitledbuttonelement.accesskey", \ + "xultitledbuttonelement.crop", \ + "xultitledbuttonelement.disabled", \ + "xultitledbuttonelement.imgalign", \ + "xultitledbuttonelement.src", \ + "xultitledbuttonelement.value", \ "xultreeelement.addcelltoselection", \ "xultreeelement.additemtoselection", \ "xultreeelement.clearcellselection", \ diff --git a/mozilla/layout/base/nsCSSFrameConstructor.cpp b/mozilla/layout/base/nsCSSFrameConstructor.cpp index 32ad7df7390..a88ed685ef0 100644 --- a/mozilla/layout/base/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/base/nsCSSFrameConstructor.cpp @@ -114,6 +114,7 @@ #include "nsIDOMDocument.h" #include "nsDocument.h" #include "nsToolbarItemFrame.h" +#include "nsXULCheckboxFrame.h" #ifdef DEBUG static PRBool gNoisyContentUpdates = PR_FALSE; @@ -2047,7 +2048,7 @@ nsCSSFrameConstructor::TableIsValidCellContent(nsIPresContext* aPresContext, #ifdef INCLUDE_XUL if ( (nsXULAtoms::button == tag.get()) || - (nsXULAtoms::titledbutton == tag.get()) || + (nsXULAtoms::titledbutton == tag.get()) || (nsXULAtoms::image == tag.get()) || (nsXULAtoms::grippy == tag.get()) || (nsXULAtoms::splitter == tag.get()) || @@ -2069,7 +2070,6 @@ nsCSSFrameConstructor::TableIsValidCellContent(nsIPresContext* aPresContext, (nsXULAtoms::treecol == tag.get()) || (nsXULAtoms::treecolgroup == tag.get()) || (nsXULAtoms::treefoot == tag.get()) || - (nsXULAtoms::treepusher == tag.get()) || (nsXULAtoms::menu == tag.get()) || (nsXULAtoms::menuitem == tag.get()) || (nsXULAtoms::menubar == tag.get()) || @@ -2084,8 +2084,25 @@ nsCSSFrameConstructor::TableIsValidCellContent(nsIPresContext* aPresContext, (nsXULAtoms::tabbox == tag.get()) || (nsXULAtoms::tabpanel == tag.get()) || (nsXULAtoms::tabpage == tag.get()) || - (nsXULAtoms::progressmeter == tag.get()) || - (nsXULAtoms::window == tag.get())) { + (nsXULAtoms::progressmeter == tag.get()) || + (nsXULAtoms::checkbox == tag.get()) || + (nsXULAtoms::radio == tag.get()) || + (nsXULAtoms::menulist == tag.get()) || + (nsXULAtoms::menubutton == tag.get()) || + (nsXULAtoms::textfield == tag.get()) || + (nsXULAtoms::textarea == tag.get()) || + (nsXULAtoms::listbox == tag.get()) || + (nsXULAtoms::listcaption == tag.get()) || + (nsXULAtoms::listhead == tag.get()) || + (nsXULAtoms::listrow == tag.get()) || + (nsXULAtoms::listcell == tag.get()) || + (nsXULAtoms::listitem == tag.get()) || + (nsXULAtoms::listchildren == tag.get()) || + (nsXULAtoms::listindentation == tag.get()) || + (nsXULAtoms::listcol == tag.get()) || + (nsXULAtoms::listcolgroup == tag.get()) || + (nsXULAtoms::listfoot == tag.get()) +) { return PR_TRUE; } #endif @@ -4130,12 +4147,6 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell, { rv = NS_NewTreeIndentationFrame(aPresShell, &newFrame); } - else if (aTag == nsXULAtoms::treepusher) - { - processChildren = PR_TRUE; - isReplaced = PR_TRUE; - rv = NS_NewTitledButtonFrame(aPresShell, &newFrame); - } // End of TREE CONSTRUCTION code here (there's more later on in the function) // TOOLBAR CONSTRUCTION @@ -4199,13 +4210,15 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell, // Menu Construction else if (aTag == nsXULAtoms::menu || - aTag == nsXULAtoms::menuitem) { + aTag == nsXULAtoms::menuitem || + aTag == nsXULAtoms::menulist || + aTag == nsXULAtoms::menubutton) { // A derived class box frame // that has custom reflow to prevent menu children // from becoming part of the flow. processChildren = PR_TRUE; // Will need this to be custom. isReplaced = PR_TRUE; - rv = NS_NewMenuFrame(aPresShell, &newFrame, (aTag == nsXULAtoms::menu)); + rv = NS_NewMenuFrame(aPresShell, &newFrame, (aTag != nsXULAtoms::menuitem)); } else if (aTag == nsXULAtoms::menubar) { #ifdef XP_MAC // The Mac uses its native menu bar. @@ -4311,12 +4324,21 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell, else if (aTag == nsXULAtoms::titledbutton || aTag == nsXULAtoms::image) { - processChildren = PR_TRUE; + processChildren = PR_TRUE; isReplaced = PR_TRUE; rv = NS_NewTitledButtonFrame(aPresShell, &newFrame); } // End of TITLED BUTTON CONSTRUCTION logic + // XULCHECKBOX CONSTRUCTION + else if (aTag == nsXULAtoms::checkbox || + aTag == nsXULAtoms::radio) { + processChildren = PR_TRUE; + isReplaced = PR_TRUE; + rv = NS_NewXULCheckboxFrame(aPresShell, &newFrame); + } + // End of XULCHECKBOX CONSTRUCTION logic + // TEXT CONSTRUCTION else if (aTag == nsXULAtoms::text) { processChildren = PR_TRUE; @@ -4325,7 +4347,6 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell, } // End of TEXT CONSTRUCTION logic - // DECK CONSTRUCTION else if (aTag == nsXULAtoms::deck || aTag == nsXULAtoms::tabpanel) { processChildren = PR_TRUE; diff --git a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp index 32ad7df7390..a88ed685ef0 100644 --- a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp @@ -114,6 +114,7 @@ #include "nsIDOMDocument.h" #include "nsDocument.h" #include "nsToolbarItemFrame.h" +#include "nsXULCheckboxFrame.h" #ifdef DEBUG static PRBool gNoisyContentUpdates = PR_FALSE; @@ -2047,7 +2048,7 @@ nsCSSFrameConstructor::TableIsValidCellContent(nsIPresContext* aPresContext, #ifdef INCLUDE_XUL if ( (nsXULAtoms::button == tag.get()) || - (nsXULAtoms::titledbutton == tag.get()) || + (nsXULAtoms::titledbutton == tag.get()) || (nsXULAtoms::image == tag.get()) || (nsXULAtoms::grippy == tag.get()) || (nsXULAtoms::splitter == tag.get()) || @@ -2069,7 +2070,6 @@ nsCSSFrameConstructor::TableIsValidCellContent(nsIPresContext* aPresContext, (nsXULAtoms::treecol == tag.get()) || (nsXULAtoms::treecolgroup == tag.get()) || (nsXULAtoms::treefoot == tag.get()) || - (nsXULAtoms::treepusher == tag.get()) || (nsXULAtoms::menu == tag.get()) || (nsXULAtoms::menuitem == tag.get()) || (nsXULAtoms::menubar == tag.get()) || @@ -2084,8 +2084,25 @@ nsCSSFrameConstructor::TableIsValidCellContent(nsIPresContext* aPresContext, (nsXULAtoms::tabbox == tag.get()) || (nsXULAtoms::tabpanel == tag.get()) || (nsXULAtoms::tabpage == tag.get()) || - (nsXULAtoms::progressmeter == tag.get()) || - (nsXULAtoms::window == tag.get())) { + (nsXULAtoms::progressmeter == tag.get()) || + (nsXULAtoms::checkbox == tag.get()) || + (nsXULAtoms::radio == tag.get()) || + (nsXULAtoms::menulist == tag.get()) || + (nsXULAtoms::menubutton == tag.get()) || + (nsXULAtoms::textfield == tag.get()) || + (nsXULAtoms::textarea == tag.get()) || + (nsXULAtoms::listbox == tag.get()) || + (nsXULAtoms::listcaption == tag.get()) || + (nsXULAtoms::listhead == tag.get()) || + (nsXULAtoms::listrow == tag.get()) || + (nsXULAtoms::listcell == tag.get()) || + (nsXULAtoms::listitem == tag.get()) || + (nsXULAtoms::listchildren == tag.get()) || + (nsXULAtoms::listindentation == tag.get()) || + (nsXULAtoms::listcol == tag.get()) || + (nsXULAtoms::listcolgroup == tag.get()) || + (nsXULAtoms::listfoot == tag.get()) +) { return PR_TRUE; } #endif @@ -4130,12 +4147,6 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell, { rv = NS_NewTreeIndentationFrame(aPresShell, &newFrame); } - else if (aTag == nsXULAtoms::treepusher) - { - processChildren = PR_TRUE; - isReplaced = PR_TRUE; - rv = NS_NewTitledButtonFrame(aPresShell, &newFrame); - } // End of TREE CONSTRUCTION code here (there's more later on in the function) // TOOLBAR CONSTRUCTION @@ -4199,13 +4210,15 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell, // Menu Construction else if (aTag == nsXULAtoms::menu || - aTag == nsXULAtoms::menuitem) { + aTag == nsXULAtoms::menuitem || + aTag == nsXULAtoms::menulist || + aTag == nsXULAtoms::menubutton) { // A derived class box frame // that has custom reflow to prevent menu children // from becoming part of the flow. processChildren = PR_TRUE; // Will need this to be custom. isReplaced = PR_TRUE; - rv = NS_NewMenuFrame(aPresShell, &newFrame, (aTag == nsXULAtoms::menu)); + rv = NS_NewMenuFrame(aPresShell, &newFrame, (aTag != nsXULAtoms::menuitem)); } else if (aTag == nsXULAtoms::menubar) { #ifdef XP_MAC // The Mac uses its native menu bar. @@ -4311,12 +4324,21 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell, else if (aTag == nsXULAtoms::titledbutton || aTag == nsXULAtoms::image) { - processChildren = PR_TRUE; + processChildren = PR_TRUE; isReplaced = PR_TRUE; rv = NS_NewTitledButtonFrame(aPresShell, &newFrame); } // End of TITLED BUTTON CONSTRUCTION logic + // XULCHECKBOX CONSTRUCTION + else if (aTag == nsXULAtoms::checkbox || + aTag == nsXULAtoms::radio) { + processChildren = PR_TRUE; + isReplaced = PR_TRUE; + rv = NS_NewXULCheckboxFrame(aPresShell, &newFrame); + } + // End of XULCHECKBOX CONSTRUCTION logic + // TEXT CONSTRUCTION else if (aTag == nsXULAtoms::text) { processChildren = PR_TRUE; @@ -4325,7 +4347,6 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell, } // End of TEXT CONSTRUCTION logic - // DECK CONSTRUCTION else if (aTag == nsXULAtoms::deck || aTag == nsXULAtoms::tabpanel) { processChildren = PR_TRUE; diff --git a/mozilla/layout/xbl/src/nsXBLBinding.cpp b/mozilla/layout/xbl/src/nsXBLBinding.cpp index 7e5a3c6d4a4..f4baa3fa54b 100644 --- a/mozilla/layout/xbl/src/nsXBLBinding.cpp +++ b/mozilla/layout/xbl/src/nsXBLBinding.cpp @@ -121,6 +121,7 @@ protected: PRBool IsMouseHandler(const nsString& aName); PRBool IsKeyHandler(const nsString& aName); + PRBool IsXULHandler(const nsString& aName); static void GetEventHandlerIID(nsIAtom* aName, nsIID* aIID, PRBool* aFound); @@ -406,8 +407,9 @@ nsXBLBinding::InstallEventHandlers(nsIContent* aBoundElement) // Add an event listener for mouse and key events only. PRBool mouse = IsMouseHandler(type); PRBool key = IsKeyHandler(type); + PRBool xul = IsXULHandler(type); - if (mouse || key) { + if (mouse || key || xul) { // Create a new nsXBLEventHandler. nsXBLEventHandler* handler; NS_NewXBLEventHandler(mBoundElement, child, type, &handler); @@ -423,8 +425,10 @@ nsXBLBinding::InstallEventHandlers(nsIContent* aBoundElement) nsCOMPtr receiver = do_QueryInterface(mBoundElement); if (mouse) receiver->AddEventListener(type, (nsIDOMMouseListener*)handler, useCapture); - else + else if(key) receiver->AddEventListener(type, (nsIDOMKeyListener*)handler, useCapture); + else + receiver->AddEventListener(type, (nsIDOMMenuListener*)handler, useCapture); NS_RELEASE(handler); } @@ -657,6 +661,13 @@ nsXBLBinding::IsKeyHandler(const nsString& aName) return ((aName == "keypress") || (aName == "keydown") || (aName == "keyup")); } +PRBool +nsXBLBinding::IsXULHandler(const nsString& aName) +{ + return ((aName == "create") || (aName == "destroy") || (aName=="broadcast") || + (aName == "command") || (aName == "commandupdate") || (aName == "close")); +} + // Creation Routine /////////////////////////////////////////////////////////////////////// nsresult diff --git a/mozilla/layout/xbl/src/nsXBLEventHandler.cpp b/mozilla/layout/xbl/src/nsXBLEventHandler.cpp index 200b2b94251..40c77a80949 100644 --- a/mozilla/layout/xbl/src/nsXBLEventHandler.cpp +++ b/mozilla/layout/xbl/src/nsXBLEventHandler.cpp @@ -67,7 +67,7 @@ nsXBLEventHandler::~nsXBLEventHandler() } } -NS_IMPL_ISUPPORTS2(nsXBLEventHandler, nsIDOMKeyListener, nsIDOMMouseListener) +NS_IMPL_ISUPPORTS3(nsXBLEventHandler, nsIDOMKeyListener, nsIDOMMouseListener, nsIDOMMenuListener) nsresult nsXBLEventHandler::HandleEvent(nsIDOMEvent* aEvent) { @@ -174,6 +174,60 @@ nsresult nsXBLEventHandler::MouseOut(nsIDOMEvent* aMouseEvent) return NS_OK; } +nsresult nsXBLEventHandler::Action(nsIDOMEvent* aEvent) +{ + if (mEventName != "command") + return NS_OK; + + ExecuteHandler(nsAutoString("command"), aEvent); + return NS_OK; +} + +nsresult nsXBLEventHandler::Create(nsIDOMEvent* aEvent) +{ + if (mEventName != "create") + return NS_OK; + + ExecuteHandler(nsAutoString("create"), aEvent); + return NS_OK; +} + +nsresult nsXBLEventHandler::Close(nsIDOMEvent* aEvent) +{ + if (mEventName != "close") + return NS_OK; + + ExecuteHandler(nsAutoString("close"), aEvent); + return NS_OK; +} + +nsresult nsXBLEventHandler::Broadcast(nsIDOMEvent* aEvent) +{ + if (mEventName != "broadcast") + return NS_OK; + + ExecuteHandler(nsAutoString("broadcast"), aEvent); + return NS_OK; +} + +nsresult nsXBLEventHandler::CommandUpdate(nsIDOMEvent* aEvent) +{ + if (mEventName != "commandupdate") + return NS_OK; + + ExecuteHandler(nsAutoString("commandupdate"), aEvent); + return NS_OK; +} + +nsresult nsXBLEventHandler::Destroy(nsIDOMEvent* aEvent) +{ + if (mEventName != "destroy") + return NS_OK; + + ExecuteHandler(nsAutoString("destroy"), aEvent); + return NS_OK; +} + /////////////////////////////////////////////////////////////////////////////////// PRBool diff --git a/mozilla/layout/xbl/src/nsXBLEventHandler.h b/mozilla/layout/xbl/src/nsXBLEventHandler.h index 538cfb1657a..4dfaa56e1fe 100644 --- a/mozilla/layout/xbl/src/nsXBLEventHandler.h +++ b/mozilla/layout/xbl/src/nsXBLEventHandler.h @@ -25,6 +25,7 @@ #include "nsIDOMMouseListener.h" #include "nsIDOMKeyListener.h" +#include "nsIDOMMenuListener.h" class nsIXBLBinding; class nsIDOMEvent; @@ -35,7 +36,8 @@ class nsIAtom; class nsIController; class nsXBLEventHandler : public nsIDOMKeyListener, - public nsIDOMMouseListener + public nsIDOMMouseListener, + public nsIDOMMenuListener { public: nsXBLEventHandler(nsIContent* aBoundElement, nsIContent* aHandlerElement, const nsString& aEventName); @@ -54,6 +56,13 @@ public: virtual nsresult MouseOver(nsIDOMEvent* aMouseEvent); virtual nsresult MouseOut(nsIDOMEvent* aMouseEvent); + NS_IMETHOD Create(nsIDOMEvent* aEvent); + NS_IMETHOD Close(nsIDOMEvent* aEvent); + NS_IMETHOD Destroy(nsIDOMEvent* aEvent); + NS_IMETHOD Action(nsIDOMEvent* aEvent); + NS_IMETHOD Broadcast(nsIDOMEvent* aEvent); + NS_IMETHOD CommandUpdate(nsIDOMEvent* aEvent); + NS_DECL_ISUPPORTS protected: diff --git a/mozilla/layout/xul/base/src/Makefile.in b/mozilla/layout/xul/base/src/Makefile.in index 0f2fca70309..3f98884cfe4 100644 --- a/mozilla/layout/xul/base/src/Makefile.in +++ b/mozilla/layout/xul/base/src/Makefile.in @@ -68,6 +68,7 @@ CPPSRCS = \ nsMenuDismissalListener.cpp \ nsPopupSetFrame.cpp \ nsRepeatService.cpp \ + nsXULCheckboxFrame.cpp \ $(NULL) include $(topsrcdir)/config/config.mk diff --git a/mozilla/layout/xul/base/src/makefile.win b/mozilla/layout/xul/base/src/makefile.win index 694eb5e84b5..cc68f157c29 100644 --- a/mozilla/layout/xul/base/src/makefile.win +++ b/mozilla/layout/xul/base/src/makefile.win @@ -66,6 +66,7 @@ CPPSRCS= \ nsMenuListener.cpp \ nsMenuDismissalListener.cpp \ nsPopupSetFrame.cpp \ + nsXULCheckboxFrame.cpp \ $(NULL) CPP_OBJS= \ @@ -107,6 +108,7 @@ CPP_OBJS= \ .\$(OBJDIR)\nsMenuListener.obj \ .\$(OBJDIR)\nsMenuDismissalListener.obj \ .\$(OBJDIR)\nsPopupSetFrame.obj \ + .\$(OBJDIR)\nsXULCheckboxFrame.obj \ $(NULL) EXPORTS = \ diff --git a/mozilla/layout/xul/base/src/nsMenuFrame.cpp b/mozilla/layout/xul/base/src/nsMenuFrame.cpp index 4563654f3d5..fac5ab1c574 100644 --- a/mozilla/layout/xul/base/src/nsMenuFrame.cpp +++ b/mozilla/layout/xul/base/src/nsMenuFrame.cpp @@ -45,6 +45,7 @@ #include "nsIDOMNSDocument.h" #include "nsIDOMDocument.h" #include "nsIDOMXULDocument.h" +#include "nsIDOMXULMenuListElement.h" #include "nsIDOMElement.h" #include "nsISupportsArray.h" #include "nsIDOMText.h" @@ -191,6 +192,31 @@ nsMenuFrame::SetInitialChildList(nsIPresContext* aPresContext, // Didn't find it. rv = nsBoxFrame::SetInitialChildList(aPresContext, aListName, aChildList); + + nsCOMPtr list(do_QueryInterface(mContent)); + if (list) { + nsCOMPtr element; + list->GetSelectedItem(getter_AddRefs(element)); + if (!element) { + nsAutoString value; + list->GetValue(value); + if (value == "") { + nsCOMPtr child; + GetMenuChildrenElement(getter_AddRefs(child)); + if (child) { + PRInt32 count; + child->ChildCount(count); + if (count > 0) { + nsCOMPtr item; + child->ChildAt(0, *getter_AddRefs(item)); + nsCOMPtr selectedElement(do_QueryInterface(item)); + if (selectedElement) + list->SetSelectedItem(selectedElement); + } + } + } + } + } } return rv; } @@ -243,7 +269,15 @@ nsMenuFrame::HandleEvent(nsIPresContext* aPresContext, if (IsDisabled()) // Disabled menus process no events. return NS_OK; - if (aEvent->message == NS_MOUSE_LEFT_BUTTON_DOWN) { + if (aEvent->message == NS_KEY_PRESS) { + nsKeyEvent* keyEvent = (nsKeyEvent*)aEvent; + PRUint32 keyCode = keyEvent->keyCode; + if (keyCode == NS_VK_UP || keyCode == NS_VK_DOWN) { + if (!IsOpen()) + OpenMenu(PR_TRUE); + } + } + else if (aEvent->message == NS_MOUSE_LEFT_BUTTON_DOWN) { PRBool isMenuBar = PR_FALSE; if (mMenuParent) mMenuParent->IsMenuBar(isMenuBar); @@ -532,10 +566,34 @@ nsMenuFrame::OpenMenuInternal(PRBool aActivateFlag) if (mMenuParent) mMenuParent->SetActive(PR_TRUE); - // Sync up the view. nsCOMPtr menuPopupContent; menuPopup->GetContent(getter_AddRefs(menuPopupContent)); + // See if we're a menulist and set our selection accordingly. + nsCOMPtr list = do_QueryInterface(mContent); + if (list) { + nsCOMPtr element; + list->GetSelectedItem(getter_AddRefs(element)); + if (element) { + nsCOMPtr selectedContent = do_QueryInterface(element); + nsIFrame* curr; + menuPopup->FirstChild(mPresContext, nsnull, &curr); + while (curr) { + nsCOMPtr child; + curr->GetContent(getter_AddRefs(child)); + if (selectedContent == child.get()) { + nsCOMPtr menuframe(do_QueryInterface(curr)); + if (menuframe) + menuPopup->SetCurrentMenuItem(menuframe); + } + curr->GetNextSibling(&curr); + } + } + } + // End of menulist stuff. We now return to our regularly scheduled + // programming. + + // Sync up the view. nsAutoString popupAnchor, popupAlign; menuPopupContent->GetAttribute(kNameSpaceID_None, nsXULAtoms::popupanchor, popupAnchor); @@ -644,44 +702,53 @@ nsMenuFrame::Reflow(nsIPresContext* aPresContext, { //NS_ASSERTION(aReflowState.reason != eReflowReason_Incremental,"Incremental Reflow not supported!"); - nsIFrame* popupChild = mPopupFrames.FirstChild(); + nsIFrame* popupChild = mPopupFrames.FirstChild(); - nsHTMLReflowState boxState(aReflowState); + nsHTMLReflowState boxState(aReflowState); - if (aReflowState.reason == eReflowReason_Incremental) { + if (aReflowState.reason == eReflowReason_Incremental) { + nsIFrame* incrementalChild; - nsIFrame* incrementalChild; + // get the child but don't pull it off + aReflowState.reflowCommand->GetNext(incrementalChild, PR_FALSE); + + // see if it is in the mPopupFrames list + nsIFrame* child = mPopupFrames.FirstChild(); + popupChild = nsnull; - // get the child but don't pull it off - aReflowState.reflowCommand->GetNext(incrementalChild, PR_FALSE); - - // see if it is in the mPopupFrames list - nsIFrame* child = mPopupFrames.FirstChild(); - popupChild = nsnull; + while (nsnull != child) + { + // if it is then flow the popup incrementally then flow + // us with a resize just to get our correct desired size. + if (child == incrementalChild) { + // pull it off now + aReflowState.reflowCommand->GetNext(incrementalChild); - while (nsnull != child) - { - // if it is then flow the popup incrementally then flow - // us with a resize just to get our correct desired size. - if (child == incrementalChild) { - // pull it off now - aReflowState.reflowCommand->GetNext(incrementalChild); + // we know what child + popupChild = child; - // we know what child - popupChild = child; + // relow the box with resize just to get the + // aDesiredSize set correctly + boxState.reason = eReflowReason_Resize; + break; + } - // relow the box with resize just to get the - // aDesiredSize set correctly - boxState.reason = eReflowReason_Resize; - break; - } + nsresult rv = child->GetNextSibling(&child); + NS_ASSERTION(rv == NS_OK,"failed to get next child"); + } + } - nsresult rv = child->GetNextSibling(&child); - NS_ASSERTION(rv == NS_OK,"failed to get next child"); - } - } + // If we're a menulist AND if we're intrinsically sized, then + // we need to flow our popup and use its width as our own width. + PRBool constrainMenuWidth = PR_FALSE; + nsCOMPtr menulist = do_QueryInterface(mContent); + if (menulist && (aReflowState.mComputedWidth == NS_UNCONSTRAINEDSIZE)) { + constrainMenuWidth = PR_TRUE; + MarkAsGenerated(); + } // Handle reflowing our subordinate popup + nsHTMLReflowMetrics kidDesiredSize(aDesiredSize); if (popupChild) { // Constrain the child's width and height to aAvailableWidth and aAvailableHeight nsSize availSize(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE); @@ -689,8 +756,7 @@ nsMenuFrame::Reflow(nsIPresContext* aPresContext, availSize); kidReflowState.mComputedWidth = NS_UNCONSTRAINEDSIZE; kidReflowState.mComputedHeight = NS_UNCONSTRAINEDSIZE; - nsHTMLReflowMetrics kidDesiredSize(aDesiredSize); - + nsRect rect; popupChild->GetRect(rect); nsresult rv = ReflowChild(popupChild, aPresContext, kidDesiredSize, kidReflowState, @@ -702,8 +768,36 @@ nsMenuFrame::Reflow(nsIPresContext* aPresContext, FinishReflowChild(popupChild, aPresContext, kidDesiredSize, rect.x, rect.y, NS_FRAME_NO_MOVE_VIEW); } + if (constrainMenuWidth) { + boxState.mComputedWidth = kidDesiredSize.width; + } + nsresult rv = nsBoxFrame::Reflow(aPresContext, aDesiredSize, boxState, aStatus); + // If we're a menulist, then we might potentially flow the popup a second time + // (its width may be too small). + if (menulist && popupChild) { + if (kidDesiredSize.width < aDesiredSize.width) { + // Flow the popup again. + // Constrain the child's width and height to aAvailableWidth and aAvailableHeight + nsSize availSize(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE); + nsHTMLReflowState kidReflowState(aPresContext, aReflowState, popupChild, + availSize); + kidReflowState.mComputedWidth = aDesiredSize.width; + kidReflowState.mComputedHeight = NS_UNCONSTRAINEDSIZE; + + nsRect rect; + popupChild->GetRect(rect); + nsresult rv = ReflowChild(popupChild, aPresContext, kidDesiredSize, kidReflowState, + rect.x, rect.y, NS_FRAME_NO_MOVE_VIEW, aStatus); + + // Set the child's width and height to its desired size + // Note: don't position or size the view now, we'll do that in the + // DidReflow() function + FinishReflowChild(popupChild, aPresContext, kidDesiredSize, rect.x, rect.y, NS_FRAME_NO_MOVE_VIEW); + } + } + return rv; } @@ -1272,3 +1366,35 @@ nsMenuFrame::UpdateDismissalListener(nsIMenuParent* aMenuParent) // innermost menu popup frame is. nsMenuFrame::mDismissalListener->SetCurrentMenuParent(aMenuParent); } + +NS_IMETHODIMP +nsMenuFrame::GetBoxInfo(nsIPresContext* aPresContext, const nsHTMLReflowState& aReflowState, nsBoxInfo& aSize) +{ + nsresult rv = nsBoxFrame::GetBoxInfo(aPresContext, aReflowState, aSize); + nsCOMPtr menulist(do_QueryInterface(mContent)); + if (menulist) { + nsCalculatedBoxInfo boxInfo; + boxInfo.frame = this; + boxInfo.prefSize.width = NS_UNCONSTRAINEDSIZE; + boxInfo.prefSize.height = NS_UNCONSTRAINEDSIZE; + boxInfo.flex = 0; + GetRedefinedMinPrefMax(aPresContext, this, boxInfo); + if (boxInfo.prefSize.width == NS_UNCONSTRAINEDSIZE && + boxInfo.prefSize.height == NS_UNCONSTRAINEDSIZE && + boxInfo.flex == 0) { + nsIFrame* frame = mPopupFrames.FirstChild(); + if (!frame) { + MarkAsGenerated(); + frame = mPopupFrames.FirstChild(); + } + + nsCOMPtr box(do_QueryInterface(frame)); + nsCalculatedBoxInfo childInfo; + childInfo.frame = frame; + box->GetBoxInfo(aPresContext, aReflowState, childInfo); + GetRedefinedMinPrefMax(aPresContext, this, childInfo); + aSize.prefSize.width = childInfo.prefSize.width; + } + } + return rv; +} \ No newline at end of file diff --git a/mozilla/layout/xul/base/src/nsMenuFrame.h b/mozilla/layout/xul/base/src/nsMenuFrame.h index 8e0ced01d11..77f5fa9711f 100644 --- a/mozilla/layout/xul/base/src/nsMenuFrame.h +++ b/mozilla/layout/xul/base/src/nsMenuFrame.h @@ -184,6 +184,7 @@ protected: PRInt32 aNameSpaceID, nsIAtom* aAttribute, PRInt32 aHint); + NS_IMETHOD GetBoxInfo(nsIPresContext* aPresContext, const nsHTMLReflowState& aReflowState, nsBoxInfo& aSize); protected: nsFrameList mPopupFrames; diff --git a/mozilla/layout/xul/base/src/nsTitledButtonFrame.cpp b/mozilla/layout/xul/base/src/nsTitledButtonFrame.cpp index 32fd71c4ae9..dbb006cf918 100644 --- a/mozilla/layout/xul/base/src/nsTitledButtonFrame.cpp +++ b/mozilla/layout/xul/base/src/nsTitledButtonFrame.cpp @@ -213,7 +213,7 @@ nsTitledButtonFrame::AttributeChanged(nsIPresContext* aPresContext, nsTitledButtonFrame::nsTitledButtonFrame() { mTitle = ""; - mAlign = NS_SIDE_TOP; + mAlign = GetDefaultAlignment(); mCropType = CropRight; mNeedsLayout = PR_TRUE; mNeedsAccessUpdate = PR_TRUE; @@ -340,6 +340,11 @@ nsTitledButtonFrame::GetImageSource(nsString& aResult) } } +PRIntn nsTitledButtonFrame::GetDefaultAlignment() +{ + return NS_SIDE_TOP; +} + void nsTitledButtonFrame::UpdateAttributes(nsIPresContext* aPresContext, nsIAtom* aAttribute, PRBool& aResize, PRBool& aRedraw, PRBool& aUpdateAccessUnderline) { @@ -359,7 +364,7 @@ nsTitledButtonFrame::UpdateAttributes(nsIPresContext* aPresContext, nsIAtom* aA else if (value.EqualsIgnoreCase(ALIGN_BOTTOM)) align = NS_SIDE_BOTTOM; else - align = NS_SIDE_TOP; + align = GetDefaultAlignment(); if (align != mAlign) { aRedraw = PR_TRUE; @@ -1223,8 +1228,34 @@ nsTitledButtonFrame::HandleEvent(nsIPresContext* aPresContext, break; case NS_MOUSE_LEFT_CLICK: - MouseClicked(aPresContext); - break; + MouseClicked(aPresContext); + break; + case NS_MOUSE_LEFT_BUTTON_UP: + // if we are not toggling then do nothing + CheckState oldState = GetCurrentCheckState(); + if (oldState == eUnset) + break; + + CheckState newState = eOn; + switch ( oldState ) { + case eOn: + newState = eOff; + break; + + case eMixed: + newState = eOn; + break; + + case eOff: + newState = mHasOnceBeenInMixedState ? eMixed: eOn; + break; + + case eUnset: + newState = eOn; + break; + } + SetCurrentCheckState(newState); + break; } return nsLeafFrame::HandleEvent(aPresContext, aEvent, aEventStatus); @@ -1293,31 +1324,6 @@ nsTitledButtonFrame::MouseClicked (nsIPresContext* aPresContext) event.clickCount = 0; event.widget = nsnull; mContent->HandleDOMEvent(aPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status); - - // if we are not toggling then do nothing - CheckState oldState = GetCurrentCheckState(); - if (oldState == eUnset) - return; - - CheckState newState = eOn; - switch ( oldState ) { - case eOn: - newState = eOff; - break; - - case eMixed: - newState = eOn; - break; - - case eOff: - newState = mHasOnceBeenInMixedState ? eMixed: eOn; - break; - - case eUnset: - newState = eOn; - break; - } - SetCurrentCheckState(newState); } // diff --git a/mozilla/layout/xul/base/src/nsTitledButtonFrame.h b/mozilla/layout/xul/base/src/nsTitledButtonFrame.h index eef6a12c70d..99c412eb493 100644 --- a/mozilla/layout/xul/base/src/nsTitledButtonFrame.h +++ b/mozilla/layout/xul/base/src/nsTitledButtonFrame.h @@ -65,6 +65,7 @@ public: NS_IMETHOD GetFrameName(nsString& aResult) const; + virtual PRIntn GetDefaultAlignment(); virtual void UpdateAttributes(nsIPresContext* aPresContext, nsIAtom* aAttribute, PRBool& aResize, PRBool& aRedraw, PRBool& aUpdateAccessUnderline); virtual void UpdateImage(nsIPresContext* aPresContext, PRBool& aResize); diff --git a/mozilla/layout/xul/base/src/nsXULCheckboxFrame.cpp b/mozilla/layout/xul/base/src/nsXULCheckboxFrame.cpp new file mode 100644 index 00000000000..7c2524e1eee --- /dev/null +++ b/mozilla/layout/xul/base/src/nsXULCheckboxFrame.cpp @@ -0,0 +1,88 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * 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. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + */ +#include "nsCOMPtr.h" +#include "nsXULCheckboxFrame.h" +#include "nsIDOMXULCheckboxElement.h" +#include "nsIContent.h" + +// +// NS_NewXULCheckboxFrame +// +// Creates a new checkbox frame and returns it in |aNewFrame| +// +nsresult +NS_NewXULCheckboxFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame ) +{ + NS_PRECONDITION(aNewFrame, "null OUT ptr"); + if (nsnull == aNewFrame) { + return NS_ERROR_NULL_POINTER; + } + nsXULCheckboxFrame* it = new (aPresShell) nsXULCheckboxFrame; + if (nsnull == it) + return NS_ERROR_OUT_OF_MEMORY; + + // it->SetFlags(aFlags); + *aNewFrame = it; + return NS_OK; + +} // NS_NewXULCheckboxFrame + +void nsXULCheckboxFrame::ToggleCheckState() +{ + nsCOMPtr element = do_QueryInterface(mContent); + if(element) { + PRBool disabled; + element->GetDisabled(&disabled); + if(!disabled) { + PRBool checked; + element->GetChecked(&checked); + element->SetChecked(!checked); + } + } +} + +NS_IMETHODIMP nsXULCheckboxFrame::HandleEvent( + nsIPresContext* aPresContext, + nsGUIEvent* aEvent, + nsEventStatus* aEventStatus) +{ + switch (aEvent->message) { + case NS_MOUSE_LEFT_BUTTON_UP: + ToggleCheckState(); + break; + case NS_KEY_PRESS: + if (NS_KEY_EVENT == aEvent->eventStructType) { + nsKeyEvent* keyEvent = (nsKeyEvent*)aEvent; + if (NS_VK_SPACE == keyEvent->keyCode) + ToggleCheckState(); + } + break; + } + + return nsTitledButtonFrame::HandleEvent(aPresContext, aEvent, aEventStatus); +} + +PRIntn nsXULCheckboxFrame::GetDefaultAlignment() +{ + return NS_SIDE_LEFT; +} + diff --git a/mozilla/layout/xul/base/src/nsXULCheckboxFrame.h b/mozilla/layout/xul/base/src/nsXULCheckboxFrame.h new file mode 100644 index 00000000000..f5b3e7ab386 --- /dev/null +++ b/mozilla/layout/xul/base/src/nsXULCheckboxFrame.h @@ -0,0 +1,42 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * 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. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + */ +#ifndef nsXULCheckboxFrame_h___ +#define nsXULCheckboxFrame_h___ + +#include "nsTitledButtonFrame.h" + +class nsXULCheckboxFrame : public nsTitledButtonFrame +{ +public: + + friend nsresult NS_NewXULCheckboxFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame); + + NS_IMETHOD HandleEvent(nsIPresContext* aPresContext, + nsGUIEvent* aEvent, + nsEventStatus* aEventStatus); + + PRIntn GetDefaultAlignment(); + void ToggleCheckState(); + +}; // class nsXULCheckboxFrame + +#endif /* nsXULCheckboxFrame_h___ */ diff --git a/mozilla/layout/xul/content/src/nsXULAtomList.h b/mozilla/layout/xul/content/src/nsXULAtomList.h index 9b559c2b966..66904c92208 100644 --- a/mozilla/layout/xul/content/src/nsXULAtomList.h +++ b/mozilla/layout/xul/content/src/nsXULAtomList.h @@ -65,7 +65,6 @@ XUL_ATOM(allowevents, "allowevents") // Lets events be handled on the cell conte XUL_ATOM(treecol, "treecol") // A column in the tree view XUL_ATOM(treecolgroup, "treecolgroup") // A column group in the tree view XUL_ATOM(treefoot, "treefoot") // The footer of the tree view -XUL_ATOM(treepusher, "treepusher") // A column pusher (left or right) for the tree view XUL_ATOM(scrollbarlist, "scrollbarlist") // An atom for internal use by the tree view XUL_ATOM(indent, "indent") // indicates that a cell should be indented @@ -141,3 +140,23 @@ XUL_ATOM(iframe, "iframe") XUL_ATOM(browser, "browser") XUL_ATOM(editor, "editor") +// + +XUL_ATOM(checkbox, "checkbox") +XUL_ATOM(radio, "radio") +XUL_ATOM(menulist, "menulist") +XUL_ATOM(menubutton, "menubutton") +XUL_ATOM(textfield, "textfield") +XUL_ATOM(textarea, "textarea") +XUL_ATOM(listbox, "listbox") + +XUL_ATOM(listcaption, "listcaption") // The caption of a list view +XUL_ATOM(listhead, "listhead") // The header of the list view +XUL_ATOM(listrow, "listrow") // A row in the list view +XUL_ATOM(listcell, "listcell") // An item in the list view +XUL_ATOM(listitem, "listitem") // A cell in the list view +XUL_ATOM(listchildren, "listchildren") // The children of an item in the list view +XUL_ATOM(listindentation, "listindentation") // Specifies that the indentation for the level should occur here. +XUL_ATOM(listcol, "listcol") // A column in the list view +XUL_ATOM(listcolgroup, "listcolgroup") // A column group in the list view +XUL_ATOM(listfoot, "listfoot") // The footer of the list view diff --git a/mozilla/rdf/content/public/MANIFEST b/mozilla/rdf/content/public/MANIFEST index cea01a15cd2..a41321701ce 100644 --- a/mozilla/rdf/content/public/MANIFEST +++ b/mozilla/rdf/content/public/MANIFEST @@ -15,3 +15,9 @@ nsIXULPopupListener.h nsIXULPrototypeCache.h nsIXULPrototypeDocument.h nsIXULContent.h +nsIDOMXULTitledButtonElement.h +nsIDOMXULCheckboxElement.h +nsIDOMXULRadioElement.h +nsIDOMXULMenuListElement.h + + diff --git a/mozilla/rdf/content/public/Makefile.in b/mozilla/rdf/content/public/Makefile.in index 0fc3b04ea3a..f50d5b5c36b 100644 --- a/mozilla/rdf/content/public/Makefile.in +++ b/mozilla/rdf/content/public/Makefile.in @@ -45,7 +45,11 @@ EXPORTS = \ nsIXULPopupListener.h \ nsIXULPrototypeCache.h \ nsIXULPrototypeDocument.h \ - nsIXULContent.h \ + nsIXULContent.h \ + nsIDOMXULTitledButtonElement.h \ + nsIDOMXULCheckboxElement.h \ + nsIDOMXULRadioElement.h \ + nsIDOMXULMenuListElement.h \ $(NULL) EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS)) diff --git a/mozilla/rdf/content/public/idl/XULCheckboxElement.idl b/mozilla/rdf/content/public/idl/XULCheckboxElement.idl new file mode 100644 index 00000000000..b29b90e41bd --- /dev/null +++ b/mozilla/rdf/content/public/idl/XULCheckboxElement.idl @@ -0,0 +1,12 @@ +interface XULCheckboxElement : XULElement { +/* IID: { 0xa5f00fa2, 0xe874, 0x11d3, \ + { 0xbf, 0x87, 0x0, 0x10, 0x5a, 0x1b, 0x6, 0x27 } } */ + + attribute DOMString value; + attribute DOMString crop; + attribute boolean disabled; + attribute DOMString src; + attribute DOMString imgalign; + attribute DOMString accesskey; + attribute boolean checked; +}; diff --git a/mozilla/rdf/content/public/idl/XULMenuListElement.idl b/mozilla/rdf/content/public/idl/XULMenuListElement.idl new file mode 100644 index 00000000000..d667a043245 --- /dev/null +++ b/mozilla/rdf/content/public/idl/XULMenuListElement.idl @@ -0,0 +1,10 @@ +interface XULMenuListElement : XULElement { +/* IID: { 0xb30561c1, 0xea1a, 0x11d3, \ + { 0xbf, 0x87, 0x0, 0x10, 0x5a, 0x1b, 0x6, 0x27 } } */ + attribute DOMString value; + attribute DOMString data; + attribute Element selectedItem; + attribute DOMString crop; + attribute boolean disabled; + attribute DOMString src; +}; diff --git a/mozilla/rdf/content/public/idl/XULRadioElement.idl b/mozilla/rdf/content/public/idl/XULRadioElement.idl new file mode 100644 index 00000000000..e9c90272a51 --- /dev/null +++ b/mozilla/rdf/content/public/idl/XULRadioElement.idl @@ -0,0 +1,13 @@ +interface XULRadioElement : XULElement { +/* IID: { 0xa5f00fa1, 0xe874, 0x11d3, \ + { 0xbf, 0x87, 0x0, 0x10, 0x5a, 0x1b, 0x6, 0x27 } } */ + + attribute DOMString value; + attribute DOMString crop; + attribute boolean disabled; + attribute DOMString src; + attribute DOMString imgalign; + attribute DOMString accesskey; + attribute boolean checked; +}; + diff --git a/mozilla/rdf/content/public/idl/XULTitledButtonElement.idl b/mozilla/rdf/content/public/idl/XULTitledButtonElement.idl new file mode 100644 index 00000000000..590ded48b51 --- /dev/null +++ b/mozilla/rdf/content/public/idl/XULTitledButtonElement.idl @@ -0,0 +1,10 @@ +interface XULTitledButtonElement : XULElement { +/* IID: { 0xa5f00fa3, 0xe874, 0x11d3, \ + { 0xbf, 0x87, 0x0, 0x10, 0x5a, 0x1b, 0x6, 0x27 } } */ + attribute DOMString value; + attribute DOMString crop; + attribute boolean disabled; + attribute DOMString src; + attribute DOMString imgalign; + attribute DOMString accesskey; +}; diff --git a/mozilla/rdf/content/public/idl/makefile.win b/mozilla/rdf/content/public/idl/makefile.win index 15de9b78c32..38aaf31f533 100644 --- a/mozilla/rdf/content/public/idl/makefile.win +++ b/mozilla/rdf/content/public/idl/makefile.win @@ -33,6 +33,10 @@ IDLSRCS = \ XULTreeElement.idl \ XULEditorElement.idl \ XULPopupElement.idl \ + XULTitledButtonElement.idl \ + XULCheckboxElement.idl \ + XULRadioElement.idl \ + XULMenuListElement.idl \ $(NULL) XPCOM_DESTDIR=$(DEPTH)\rdf\content\public diff --git a/mozilla/rdf/content/public/makefile.win b/mozilla/rdf/content/public/makefile.win index cb494a387c6..c15ab219c8a 100644 --- a/mozilla/rdf/content/public/makefile.win +++ b/mozilla/rdf/content/public/makefile.win @@ -42,6 +42,10 @@ EXPORTS = \ nsIXULPrototypeCache.h \ nsIXULPrototypeDocument.h \ nsIXULContent.h \ + nsIDOMXULTitledButtonElement.h \ + nsIDOMXULCheckboxElement.h \ + nsIDOMXULRadioElement.h \ + nsIDOMXULMenuListElement.h \ $(NULL) include <$(DEPTH)/config/rules.mak> diff --git a/mozilla/rdf/content/public/nsIDOMXULCheckboxElement.h b/mozilla/rdf/content/public/nsIDOMXULCheckboxElement.h new file mode 100644 index 00000000000..5fa8fa5bea3 --- /dev/null +++ b/mozilla/rdf/content/public/nsIDOMXULCheckboxElement.h @@ -0,0 +1,103 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * 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.org code. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + */ +/* AUTO-GENERATED. DO NOT EDIT!!! */ + +#ifndef nsIDOMXULCheckboxElement_h__ +#define nsIDOMXULCheckboxElement_h__ + +#include "nsISupports.h" +#include "nsString.h" +#include "nsIScriptContext.h" +#include "nsIDOMXULElement.h" + + +#define NS_IDOMXULCHECKBOXELEMENT_IID \ + { 0xa5f00fa2, 0xe874, 0x11d3, \ + { 0xbf, 0x87, 0x0, 0x10, 0x5a, 0x1b, 0x6, 0x27 } } + +class nsIDOMXULCheckboxElement : public nsIDOMXULElement { +public: + static const nsIID& GetIID() { static nsIID iid = NS_IDOMXULCHECKBOXELEMENT_IID; return iid; } + + NS_IMETHOD GetValue(nsString& aValue)=0; + NS_IMETHOD SetValue(const nsString& aValue)=0; + + NS_IMETHOD GetCrop(nsString& aCrop)=0; + NS_IMETHOD SetCrop(const nsString& aCrop)=0; + + NS_IMETHOD GetDisabled(PRBool* aDisabled)=0; + NS_IMETHOD SetDisabled(PRBool aDisabled)=0; + + NS_IMETHOD GetSrc(nsString& aSrc)=0; + NS_IMETHOD SetSrc(const nsString& aSrc)=0; + + NS_IMETHOD GetImgalign(nsString& aImgalign)=0; + NS_IMETHOD SetImgalign(const nsString& aImgalign)=0; + + NS_IMETHOD GetAccesskey(nsString& aAccesskey)=0; + NS_IMETHOD SetAccesskey(const nsString& aAccesskey)=0; + + NS_IMETHOD GetChecked(PRBool* aChecked)=0; + NS_IMETHOD SetChecked(PRBool aChecked)=0; +}; + + +#define NS_DECL_IDOMXULCHECKBOXELEMENT \ + NS_IMETHOD GetValue(nsString& aValue); \ + NS_IMETHOD SetValue(const nsString& aValue); \ + NS_IMETHOD GetCrop(nsString& aCrop); \ + NS_IMETHOD SetCrop(const nsString& aCrop); \ + NS_IMETHOD GetDisabled(PRBool* aDisabled); \ + NS_IMETHOD SetDisabled(PRBool aDisabled); \ + NS_IMETHOD GetSrc(nsString& aSrc); \ + NS_IMETHOD SetSrc(const nsString& aSrc); \ + NS_IMETHOD GetImgalign(nsString& aImgalign); \ + NS_IMETHOD SetImgalign(const nsString& aImgalign); \ + NS_IMETHOD GetAccesskey(nsString& aAccesskey); \ + NS_IMETHOD SetAccesskey(const nsString& aAccesskey); \ + NS_IMETHOD GetChecked(PRBool* aChecked); \ + NS_IMETHOD SetChecked(PRBool aChecked); \ + + + +#define NS_FORWARD_IDOMXULCHECKBOXELEMENT(_to) \ + NS_IMETHOD GetValue(nsString& aValue) { return _to GetValue(aValue); } \ + NS_IMETHOD SetValue(const nsString& aValue) { return _to SetValue(aValue); } \ + NS_IMETHOD GetCrop(nsString& aCrop) { return _to GetCrop(aCrop); } \ + NS_IMETHOD SetCrop(const nsString& aCrop) { return _to SetCrop(aCrop); } \ + NS_IMETHOD GetDisabled(PRBool* aDisabled) { return _to GetDisabled(aDisabled); } \ + NS_IMETHOD SetDisabled(PRBool aDisabled) { return _to SetDisabled(aDisabled); } \ + NS_IMETHOD GetSrc(nsString& aSrc) { return _to GetSrc(aSrc); } \ + NS_IMETHOD SetSrc(const nsString& aSrc) { return _to SetSrc(aSrc); } \ + NS_IMETHOD GetImgalign(nsString& aImgalign) { return _to GetImgalign(aImgalign); } \ + NS_IMETHOD SetImgalign(const nsString& aImgalign) { return _to SetImgalign(aImgalign); } \ + NS_IMETHOD GetAccesskey(nsString& aAccesskey) { return _to GetAccesskey(aAccesskey); } \ + NS_IMETHOD SetAccesskey(const nsString& aAccesskey) { return _to SetAccesskey(aAccesskey); } \ + NS_IMETHOD GetChecked(PRBool* aChecked) { return _to GetChecked(aChecked); } \ + NS_IMETHOD SetChecked(PRBool aChecked) { return _to SetChecked(aChecked); } \ + + +extern "C" NS_DOM nsresult NS_InitXULCheckboxElementClass(nsIScriptContext *aContext, void **aPrototype); + +extern "C" NS_DOM nsresult NS_NewScriptXULCheckboxElement(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn); + +#endif // nsIDOMXULCheckboxElement_h__ diff --git a/mozilla/rdf/content/public/nsIDOMXULMenuListElement.h b/mozilla/rdf/content/public/nsIDOMXULMenuListElement.h new file mode 100644 index 00000000000..fd64ba69a13 --- /dev/null +++ b/mozilla/rdf/content/public/nsIDOMXULMenuListElement.h @@ -0,0 +1,97 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * 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.org code. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + */ +/* AUTO-GENERATED. DO NOT EDIT!!! */ + +#ifndef nsIDOMXULMenuListElement_h__ +#define nsIDOMXULMenuListElement_h__ + +#include "nsISupports.h" +#include "nsString.h" +#include "nsIScriptContext.h" +#include "nsIDOMXULElement.h" + +class nsIDOMElement; + +#define NS_IDOMXULMENULISTELEMENT_IID \ + { 0xb30561c1, 0xea1a, 0x11d3, \ + { 0xbf, 0x87, 0x0, 0x10, 0x5a, 0x1b, 0x6, 0x27 } } + +class nsIDOMXULMenuListElement : public nsIDOMXULElement { +public: + static const nsIID& GetIID() { static nsIID iid = NS_IDOMXULMENULISTELEMENT_IID; return iid; } + + NS_IMETHOD GetValue(nsString& aValue)=0; + NS_IMETHOD SetValue(const nsString& aValue)=0; + + NS_IMETHOD GetData(nsString& aData)=0; + NS_IMETHOD SetData(const nsString& aData)=0; + + NS_IMETHOD GetSelectedItem(nsIDOMElement** aSelectedItem)=0; + NS_IMETHOD SetSelectedItem(nsIDOMElement* aSelectedItem)=0; + + NS_IMETHOD GetCrop(nsString& aCrop)=0; + NS_IMETHOD SetCrop(const nsString& aCrop)=0; + + NS_IMETHOD GetDisabled(PRBool* aDisabled)=0; + NS_IMETHOD SetDisabled(PRBool aDisabled)=0; + + NS_IMETHOD GetSrc(nsString& aSrc)=0; + NS_IMETHOD SetSrc(const nsString& aSrc)=0; +}; + + +#define NS_DECL_IDOMXULMENULISTELEMENT \ + NS_IMETHOD GetValue(nsString& aValue); \ + NS_IMETHOD SetValue(const nsString& aValue); \ + NS_IMETHOD GetData(nsString& aData); \ + NS_IMETHOD SetData(const nsString& aData); \ + NS_IMETHOD GetSelectedItem(nsIDOMElement** aSelectedItem); \ + NS_IMETHOD SetSelectedItem(nsIDOMElement* aSelectedItem); \ + NS_IMETHOD GetCrop(nsString& aCrop); \ + NS_IMETHOD SetCrop(const nsString& aCrop); \ + NS_IMETHOD GetDisabled(PRBool* aDisabled); \ + NS_IMETHOD SetDisabled(PRBool aDisabled); \ + NS_IMETHOD GetSrc(nsString& aSrc); \ + NS_IMETHOD SetSrc(const nsString& aSrc); \ + + + +#define NS_FORWARD_IDOMXULMENULISTELEMENT(_to) \ + NS_IMETHOD GetValue(nsString& aValue) { return _to GetValue(aValue); } \ + NS_IMETHOD SetValue(const nsString& aValue) { return _to SetValue(aValue); } \ + NS_IMETHOD GetData(nsString& aData) { return _to GetData(aData); } \ + NS_IMETHOD SetData(const nsString& aData) { return _to SetData(aData); } \ + NS_IMETHOD GetSelectedItem(nsIDOMElement** aSelectedItem) { return _to GetSelectedItem(aSelectedItem); } \ + NS_IMETHOD SetSelectedItem(nsIDOMElement* aSelectedItem) { return _to SetSelectedItem(aSelectedItem); } \ + NS_IMETHOD GetCrop(nsString& aCrop) { return _to GetCrop(aCrop); } \ + NS_IMETHOD SetCrop(const nsString& aCrop) { return _to SetCrop(aCrop); } \ + NS_IMETHOD GetDisabled(PRBool* aDisabled) { return _to GetDisabled(aDisabled); } \ + NS_IMETHOD SetDisabled(PRBool aDisabled) { return _to SetDisabled(aDisabled); } \ + NS_IMETHOD GetSrc(nsString& aSrc) { return _to GetSrc(aSrc); } \ + NS_IMETHOD SetSrc(const nsString& aSrc) { return _to SetSrc(aSrc); } \ + + +extern "C" NS_DOM nsresult NS_InitXULMenuListElementClass(nsIScriptContext *aContext, void **aPrototype); + +extern "C" NS_DOM nsresult NS_NewScriptXULMenuListElement(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn); + +#endif // nsIDOMXULMenuListElement_h__ diff --git a/mozilla/rdf/content/public/nsIDOMXULRadioElement.h b/mozilla/rdf/content/public/nsIDOMXULRadioElement.h new file mode 100644 index 00000000000..11a56cc64d1 --- /dev/null +++ b/mozilla/rdf/content/public/nsIDOMXULRadioElement.h @@ -0,0 +1,103 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * 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.org code. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + */ +/* AUTO-GENERATED. DO NOT EDIT!!! */ + +#ifndef nsIDOMXULRadioElement_h__ +#define nsIDOMXULRadioElement_h__ + +#include "nsISupports.h" +#include "nsString.h" +#include "nsIScriptContext.h" +#include "nsIDOMXULElement.h" + + +#define NS_IDOMXULRADIOELEMENT_IID \ + { 0xa5f00fa1, 0xe874, 0x11d3, \ + { 0xbf, 0x87, 0x0, 0x10, 0x5a, 0x1b, 0x6, 0x27 } } + +class nsIDOMXULRadioElement : public nsIDOMXULElement { +public: + static const nsIID& GetIID() { static nsIID iid = NS_IDOMXULRADIOELEMENT_IID; return iid; } + + NS_IMETHOD GetValue(nsString& aValue)=0; + NS_IMETHOD SetValue(const nsString& aValue)=0; + + NS_IMETHOD GetCrop(nsString& aCrop)=0; + NS_IMETHOD SetCrop(const nsString& aCrop)=0; + + NS_IMETHOD GetDisabled(PRBool* aDisabled)=0; + NS_IMETHOD SetDisabled(PRBool aDisabled)=0; + + NS_IMETHOD GetSrc(nsString& aSrc)=0; + NS_IMETHOD SetSrc(const nsString& aSrc)=0; + + NS_IMETHOD GetImgalign(nsString& aImgalign)=0; + NS_IMETHOD SetImgalign(const nsString& aImgalign)=0; + + NS_IMETHOD GetAccesskey(nsString& aAccesskey)=0; + NS_IMETHOD SetAccesskey(const nsString& aAccesskey)=0; + + NS_IMETHOD GetChecked(PRBool* aChecked)=0; + NS_IMETHOD SetChecked(PRBool aChecked)=0; +}; + + +#define NS_DECL_IDOMXULRADIOELEMENT \ + NS_IMETHOD GetValue(nsString& aValue); \ + NS_IMETHOD SetValue(const nsString& aValue); \ + NS_IMETHOD GetCrop(nsString& aCrop); \ + NS_IMETHOD SetCrop(const nsString& aCrop); \ + NS_IMETHOD GetDisabled(PRBool* aDisabled); \ + NS_IMETHOD SetDisabled(PRBool aDisabled); \ + NS_IMETHOD GetSrc(nsString& aSrc); \ + NS_IMETHOD SetSrc(const nsString& aSrc); \ + NS_IMETHOD GetImgalign(nsString& aImgalign); \ + NS_IMETHOD SetImgalign(const nsString& aImgalign); \ + NS_IMETHOD GetAccesskey(nsString& aAccesskey); \ + NS_IMETHOD SetAccesskey(const nsString& aAccesskey); \ + NS_IMETHOD GetChecked(PRBool* aChecked); \ + NS_IMETHOD SetChecked(PRBool aChecked); \ + + + +#define NS_FORWARD_IDOMXULRADIOELEMENT(_to) \ + NS_IMETHOD GetValue(nsString& aValue) { return _to GetValue(aValue); } \ + NS_IMETHOD SetValue(const nsString& aValue) { return _to SetValue(aValue); } \ + NS_IMETHOD GetCrop(nsString& aCrop) { return _to GetCrop(aCrop); } \ + NS_IMETHOD SetCrop(const nsString& aCrop) { return _to SetCrop(aCrop); } \ + NS_IMETHOD GetDisabled(PRBool* aDisabled) { return _to GetDisabled(aDisabled); } \ + NS_IMETHOD SetDisabled(PRBool aDisabled) { return _to SetDisabled(aDisabled); } \ + NS_IMETHOD GetSrc(nsString& aSrc) { return _to GetSrc(aSrc); } \ + NS_IMETHOD SetSrc(const nsString& aSrc) { return _to SetSrc(aSrc); } \ + NS_IMETHOD GetImgalign(nsString& aImgalign) { return _to GetImgalign(aImgalign); } \ + NS_IMETHOD SetImgalign(const nsString& aImgalign) { return _to SetImgalign(aImgalign); } \ + NS_IMETHOD GetAccesskey(nsString& aAccesskey) { return _to GetAccesskey(aAccesskey); } \ + NS_IMETHOD SetAccesskey(const nsString& aAccesskey) { return _to SetAccesskey(aAccesskey); } \ + NS_IMETHOD GetChecked(PRBool* aChecked) { return _to GetChecked(aChecked); } \ + NS_IMETHOD SetChecked(PRBool aChecked) { return _to SetChecked(aChecked); } \ + + +extern "C" NS_DOM nsresult NS_InitXULRadioElementClass(nsIScriptContext *aContext, void **aPrototype); + +extern "C" NS_DOM nsresult NS_NewScriptXULRadioElement(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn); + +#endif // nsIDOMXULRadioElement_h__ diff --git a/mozilla/rdf/content/public/nsIDOMXULTitledButtonElement.h b/mozilla/rdf/content/public/nsIDOMXULTitledButtonElement.h new file mode 100644 index 00000000000..d6e492303d8 --- /dev/null +++ b/mozilla/rdf/content/public/nsIDOMXULTitledButtonElement.h @@ -0,0 +1,96 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * 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.org code. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + */ +/* AUTO-GENERATED. DO NOT EDIT!!! */ + +#ifndef nsIDOMXULTitledButtonElement_h__ +#define nsIDOMXULTitledButtonElement_h__ + +#include "nsISupports.h" +#include "nsString.h" +#include "nsIScriptContext.h" +#include "nsIDOMXULElement.h" + + +#define NS_IDOMXULTITLEDBUTTONELEMENT_IID \ + { 0xa5f00fa3, 0xe874, 0x11d3, \ + { 0xbf, 0x87, 0x0, 0x10, 0x5a, 0x1b, 0x6, 0x27 } } + +class nsIDOMXULTitledButtonElement : public nsIDOMXULElement { +public: + static const nsIID& GetIID() { static nsIID iid = NS_IDOMXULTITLEDBUTTONELEMENT_IID; return iid; } + + NS_IMETHOD GetValue(nsString& aValue)=0; + NS_IMETHOD SetValue(const nsString& aValue)=0; + + NS_IMETHOD GetCrop(nsString& aCrop)=0; + NS_IMETHOD SetCrop(const nsString& aCrop)=0; + + NS_IMETHOD GetDisabled(PRBool* aDisabled)=0; + NS_IMETHOD SetDisabled(PRBool aDisabled)=0; + + NS_IMETHOD GetSrc(nsString& aSrc)=0; + NS_IMETHOD SetSrc(const nsString& aSrc)=0; + + NS_IMETHOD GetImgalign(nsString& aImgalign)=0; + NS_IMETHOD SetImgalign(const nsString& aImgalign)=0; + + NS_IMETHOD GetAccesskey(nsString& aAccesskey)=0; + NS_IMETHOD SetAccesskey(const nsString& aAccesskey)=0; +}; + + +#define NS_DECL_IDOMXULTITLEDBUTTONELEMENT \ + NS_IMETHOD GetValue(nsString& aValue); \ + NS_IMETHOD SetValue(const nsString& aValue); \ + NS_IMETHOD GetCrop(nsString& aCrop); \ + NS_IMETHOD SetCrop(const nsString& aCrop); \ + NS_IMETHOD GetDisabled(PRBool* aDisabled); \ + NS_IMETHOD SetDisabled(PRBool aDisabled); \ + NS_IMETHOD GetSrc(nsString& aSrc); \ + NS_IMETHOD SetSrc(const nsString& aSrc); \ + NS_IMETHOD GetImgalign(nsString& aImgalign); \ + NS_IMETHOD SetImgalign(const nsString& aImgalign); \ + NS_IMETHOD GetAccesskey(nsString& aAccesskey); \ + NS_IMETHOD SetAccesskey(const nsString& aAccesskey); \ + + + +#define NS_FORWARD_IDOMXULTITLEDBUTTONELEMENT(_to) \ + NS_IMETHOD GetValue(nsString& aValue) { return _to GetValue(aValue); } \ + NS_IMETHOD SetValue(const nsString& aValue) { return _to SetValue(aValue); } \ + NS_IMETHOD GetCrop(nsString& aCrop) { return _to GetCrop(aCrop); } \ + NS_IMETHOD SetCrop(const nsString& aCrop) { return _to SetCrop(aCrop); } \ + NS_IMETHOD GetDisabled(PRBool* aDisabled) { return _to GetDisabled(aDisabled); } \ + NS_IMETHOD SetDisabled(PRBool aDisabled) { return _to SetDisabled(aDisabled); } \ + NS_IMETHOD GetSrc(nsString& aSrc) { return _to GetSrc(aSrc); } \ + NS_IMETHOD SetSrc(const nsString& aSrc) { return _to SetSrc(aSrc); } \ + NS_IMETHOD GetImgalign(nsString& aImgalign) { return _to GetImgalign(aImgalign); } \ + NS_IMETHOD SetImgalign(const nsString& aImgalign) { return _to SetImgalign(aImgalign); } \ + NS_IMETHOD GetAccesskey(nsString& aAccesskey) { return _to GetAccesskey(aAccesskey); } \ + NS_IMETHOD SetAccesskey(const nsString& aAccesskey) { return _to SetAccesskey(aAccesskey); } \ + + +extern "C" NS_DOM nsresult NS_InitXULTitledButtonElementClass(nsIScriptContext *aContext, void **aPrototype); + +extern "C" NS_DOM nsresult NS_NewScriptXULTitledButtonElement(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn); + +#endif // nsIDOMXULTitledButtonElement_h__ diff --git a/mozilla/rdf/content/src/Makefile.in b/mozilla/rdf/content/src/Makefile.in index 383cffb7c72..5504304dd49 100644 --- a/mozilla/rdf/content/src/Makefile.in +++ b/mozilla/rdf/content/src/Makefile.in @@ -42,6 +42,10 @@ CPPSRCS = \ nsJSXULIFrameElement.cpp \ nsJSXULBrowserElement.cpp \ nsJSXULEditorElement.cpp \ + nsJSXULTitledButtonElement.cpp \ + nsJSXULCheckboxElement.cpp \ + nsJSXULRadioElement.cpp \ + nsJSXULMenuListElement.cpp \ nsRDFDOMNodeList.cpp \ nsXULElement.cpp \ nsRDFGenericBuilder.cpp \ @@ -61,6 +65,10 @@ CPPSRCS = \ nsXULEditorElement.cpp \ nsXULPrototypeDocument.cpp \ nsXULPrototypeCache.cpp \ + nsXULTitledButtonElement.cpp \ + nsXULCheckboxElement.cpp \ + nsXULRadioElement.cpp \ + nsXULMenuListElement.cpp \ $(NULL) # we don't want the shared lib, but we want to force the creation of a static lib. diff --git a/mozilla/rdf/content/src/makefile.win b/mozilla/rdf/content/src/makefile.win index 7d3a35700fa..bcb9463084a 100644 --- a/mozilla/rdf/content/src/makefile.win +++ b/mozilla/rdf/content/src/makefile.win @@ -48,6 +48,10 @@ CPP_OBJS=\ .\$(OBJDIR)\nsJSXULIFrameElement.obj \ .\$(OBJDIR)\nsJSXULBrowserElement.obj \ .\$(OBJDIR)\nsJSXULEditorElement.obj \ + .\$(OBJDIR)\nsJSXULTitledButtonElement.obj \ + .\$(OBJDIR)\nsJSXULCheckboxElement.obj \ + .\$(OBJDIR)\nsJSXULRadioElement.obj \ + .\$(OBJDIR)\nsJSXULMenuListElement.obj \ .\$(OBJDIR)\nsRDFDOMNodeList.obj \ .\$(OBJDIR)\nsXULElement.obj \ .\$(OBJDIR)\nsXULContentUtils.obj \ @@ -60,6 +64,10 @@ CPP_OBJS=\ .\$(OBJDIR)\nsXULBrowserElement.obj \ .\$(OBJDIR)\nsXULEditorElement.obj \ .\$(OBJDIR)\nsXULPopupElement.obj \ + .\$(OBJDIR)\nsXULTitledButtonElement.obj \ + .\$(OBJDIR)\nsXULMenuListElement.obj \ + .\$(OBJDIR)\nsXULCheckboxElement.obj \ + .\$(OBJDIR)\nsXULRadioElement.obj \ $(NULL) # XXX we are including layout\html\base\src to get HTML elements diff --git a/mozilla/rdf/content/src/nsJSXULCheckboxElement.cpp b/mozilla/rdf/content/src/nsJSXULCheckboxElement.cpp new file mode 100644 index 00000000000..d46697c8654 --- /dev/null +++ b/mozilla/rdf/content/src/nsJSXULCheckboxElement.cpp @@ -0,0 +1,522 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * 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.org code. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + */ +/* AUTO-GENERATED. DO NOT EDIT!!! */ + +#include "jsapi.h" +#include "nsJSUtils.h" +#include "nsDOMError.h" +#include "nscore.h" +#include "nsIServiceManager.h" +#include "nsIScriptContext.h" +#include "nsIScriptSecurityManager.h" +#include "nsIJSScriptObject.h" +#include "nsIScriptObjectOwner.h" +#include "nsIScriptGlobalObject.h" +#include "nsCOMPtr.h" +#include "nsDOMPropEnums.h" +#include "nsString.h" +#include "nsIDOMXULCheckboxElement.h" + + +static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID); +static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID); +static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID); +static NS_DEFINE_IID(kIXULCheckboxElementIID, NS_IDOMXULCHECKBOXELEMENT_IID); + +// +// XULCheckboxElement property ids +// +enum XULCheckboxElement_slots { + XULCHECKBOXELEMENT_VALUE = -1, + XULCHECKBOXELEMENT_CROP = -2, + XULCHECKBOXELEMENT_DISABLED = -3, + XULCHECKBOXELEMENT_SRC = -4, + XULCHECKBOXELEMENT_IMGALIGN = -5, + XULCHECKBOXELEMENT_ACCESSKEY = -6, + XULCHECKBOXELEMENT_CHECKED = -7 +}; + +/***********************************************************************/ +// +// XULCheckboxElement Properties Getter +// +PR_STATIC_CALLBACK(JSBool) +GetXULCheckboxElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) +{ + nsIDOMXULCheckboxElement *a = (nsIDOMXULCheckboxElement*)nsJSUtils::nsGetNativeThis(cx, obj); + + // If there's no private data, this must be the prototype, so ignore + if (nsnull == a) { + return JS_TRUE; + } + + if (JSVAL_IS_INT(id)) { + nsresult rv; + NS_WITH_SERVICE(nsIScriptSecurityManager, secMan, + NS_SCRIPTSECURITYMANAGER_PROGID, &rv); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_SECMAN_ERR); + } + switch(JSVAL_TO_INT(id)) { + case XULCHECKBOXELEMENT_VALUE: + { + rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_XULCHECKBOXELEMENT_VALUE, PR_FALSE); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, rv); + } + nsAutoString prop; + nsresult result = NS_OK; + result = a->GetValue(prop); + if (NS_SUCCEEDED(result)) { + nsJSUtils::nsConvertStringToJSVal(prop, cx, vp); + } + else { + return nsJSUtils::nsReportError(cx, obj, result); + } + break; + } + case XULCHECKBOXELEMENT_CROP: + { + rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_XULCHECKBOXELEMENT_CROP, PR_FALSE); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, rv); + } + nsAutoString prop; + nsresult result = NS_OK; + result = a->GetCrop(prop); + if (NS_SUCCEEDED(result)) { + nsJSUtils::nsConvertStringToJSVal(prop, cx, vp); + } + else { + return nsJSUtils::nsReportError(cx, obj, result); + } + break; + } + case XULCHECKBOXELEMENT_DISABLED: + { + rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_XULCHECKBOXELEMENT_DISABLED, PR_FALSE); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, rv); + } + PRBool prop; + nsresult result = NS_OK; + result = a->GetDisabled(&prop); + if (NS_SUCCEEDED(result)) { + *vp = BOOLEAN_TO_JSVAL(prop); + } + else { + return nsJSUtils::nsReportError(cx, obj, result); + } + break; + } + case XULCHECKBOXELEMENT_SRC: + { + rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_XULCHECKBOXELEMENT_SRC, PR_FALSE); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, rv); + } + nsAutoString prop; + nsresult result = NS_OK; + result = a->GetSrc(prop); + if (NS_SUCCEEDED(result)) { + nsJSUtils::nsConvertStringToJSVal(prop, cx, vp); + } + else { + return nsJSUtils::nsReportError(cx, obj, result); + } + break; + } + case XULCHECKBOXELEMENT_IMGALIGN: + { + rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_XULCHECKBOXELEMENT_IMGALIGN, PR_FALSE); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, rv); + } + nsAutoString prop; + nsresult result = NS_OK; + result = a->GetImgalign(prop); + if (NS_SUCCEEDED(result)) { + nsJSUtils::nsConvertStringToJSVal(prop, cx, vp); + } + else { + return nsJSUtils::nsReportError(cx, obj, result); + } + break; + } + case XULCHECKBOXELEMENT_ACCESSKEY: + { + rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_XULCHECKBOXELEMENT_ACCESSKEY, PR_FALSE); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, rv); + } + nsAutoString prop; + nsresult result = NS_OK; + result = a->GetAccesskey(prop); + if (NS_SUCCEEDED(result)) { + nsJSUtils::nsConvertStringToJSVal(prop, cx, vp); + } + else { + return nsJSUtils::nsReportError(cx, obj, result); + } + break; + } + case XULCHECKBOXELEMENT_CHECKED: + { + rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_XULCHECKBOXELEMENT_CHECKED, PR_FALSE); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, rv); + } + PRBool prop; + nsresult result = NS_OK; + result = a->GetChecked(&prop); + if (NS_SUCCEEDED(result)) { + *vp = BOOLEAN_TO_JSVAL(prop); + } + else { + return nsJSUtils::nsReportError(cx, obj, result); + } + break; + } + default: + return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, obj, id, vp); + } + } + else { + return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, obj, id, vp); + } + + return PR_TRUE; +} + +/***********************************************************************/ +// +// XULCheckboxElement Properties Setter +// +PR_STATIC_CALLBACK(JSBool) +SetXULCheckboxElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) +{ + nsIDOMXULCheckboxElement *a = (nsIDOMXULCheckboxElement*)nsJSUtils::nsGetNativeThis(cx, obj); + + // If there's no private data, this must be the prototype, so ignore + if (nsnull == a) { + return JS_TRUE; + } + + if (JSVAL_IS_INT(id)) { + nsresult rv; + NS_WITH_SERVICE(nsIScriptSecurityManager, secMan, + NS_SCRIPTSECURITYMANAGER_PROGID, &rv); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_SECMAN_ERR); + } + switch(JSVAL_TO_INT(id)) { + case XULCHECKBOXELEMENT_VALUE: + { + rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_XULCHECKBOXELEMENT_VALUE, PR_TRUE); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, rv); + } + nsAutoString prop; + nsJSUtils::nsConvertJSValToString(prop, cx, *vp); + + a->SetValue(prop); + + break; + } + case XULCHECKBOXELEMENT_CROP: + { + rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_XULCHECKBOXELEMENT_CROP, PR_TRUE); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, rv); + } + nsAutoString prop; + nsJSUtils::nsConvertJSValToString(prop, cx, *vp); + + a->SetCrop(prop); + + break; + } + case XULCHECKBOXELEMENT_DISABLED: + { + rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_XULCHECKBOXELEMENT_DISABLED, PR_TRUE); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, rv); + } + PRBool prop; + if (PR_FALSE == nsJSUtils::nsConvertJSValToBool(&prop, cx, *vp)) { + return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_NOT_BOOLEAN_ERR); + } + + a->SetDisabled(prop); + + break; + } + case XULCHECKBOXELEMENT_SRC: + { + rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_XULCHECKBOXELEMENT_SRC, PR_TRUE); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, rv); + } + nsAutoString prop; + nsJSUtils::nsConvertJSValToString(prop, cx, *vp); + + a->SetSrc(prop); + + break; + } + case XULCHECKBOXELEMENT_IMGALIGN: + { + rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_XULCHECKBOXELEMENT_IMGALIGN, PR_TRUE); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, rv); + } + nsAutoString prop; + nsJSUtils::nsConvertJSValToString(prop, cx, *vp); + + a->SetImgalign(prop); + + break; + } + case XULCHECKBOXELEMENT_ACCESSKEY: + { + rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_XULCHECKBOXELEMENT_ACCESSKEY, PR_TRUE); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, rv); + } + nsAutoString prop; + nsJSUtils::nsConvertJSValToString(prop, cx, *vp); + + a->SetAccesskey(prop); + + break; + } + case XULCHECKBOXELEMENT_CHECKED: + { + rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_XULCHECKBOXELEMENT_CHECKED, PR_TRUE); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, rv); + } + PRBool prop; + if (PR_FALSE == nsJSUtils::nsConvertJSValToBool(&prop, cx, *vp)) { + return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_NOT_BOOLEAN_ERR); + } + + a->SetChecked(prop); + + break; + } + default: + return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, obj, id, vp); + } + } + else { + return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, obj, id, vp); + } + + return PR_TRUE; +} + + +// +// XULCheckboxElement finalizer +// +PR_STATIC_CALLBACK(void) +FinalizeXULCheckboxElement(JSContext *cx, JSObject *obj) +{ + nsJSUtils::nsGenericFinalize(cx, obj); +} + + +// +// XULCheckboxElement enumerate +// +PR_STATIC_CALLBACK(JSBool) +EnumerateXULCheckboxElement(JSContext *cx, JSObject *obj) +{ + return nsJSUtils::nsGenericEnumerate(cx, obj); +} + + +// +// XULCheckboxElement resolve +// +PR_STATIC_CALLBACK(JSBool) +ResolveXULCheckboxElement(JSContext *cx, JSObject *obj, jsval id) +{ + return nsJSUtils::nsGenericResolve(cx, obj, id); +} + + +/***********************************************************************/ +// +// class for XULCheckboxElement +// +JSClass XULCheckboxElementClass = { + "XULCheckboxElement", + JSCLASS_HAS_PRIVATE | JSCLASS_PRIVATE_IS_NSISUPPORTS, + JS_PropertyStub, + JS_PropertyStub, + GetXULCheckboxElementProperty, + SetXULCheckboxElementProperty, + EnumerateXULCheckboxElement, + ResolveXULCheckboxElement, + JS_ConvertStub, + FinalizeXULCheckboxElement, + nsnull, + nsJSUtils::nsCheckAccess +}; + + +// +// XULCheckboxElement class properties +// +static JSPropertySpec XULCheckboxElementProperties[] = +{ + {"value", XULCHECKBOXELEMENT_VALUE, JSPROP_ENUMERATE}, + {"crop", XULCHECKBOXELEMENT_CROP, JSPROP_ENUMERATE}, + {"disabled", XULCHECKBOXELEMENT_DISABLED, JSPROP_ENUMERATE}, + {"src", XULCHECKBOXELEMENT_SRC, JSPROP_ENUMERATE}, + {"imgalign", XULCHECKBOXELEMENT_IMGALIGN, JSPROP_ENUMERATE}, + {"accesskey", XULCHECKBOXELEMENT_ACCESSKEY, JSPROP_ENUMERATE}, + {"checked", XULCHECKBOXELEMENT_CHECKED, JSPROP_ENUMERATE}, + {0} +}; + + +// +// XULCheckboxElement class methods +// +static JSFunctionSpec XULCheckboxElementMethods[] = +{ + {0} +}; + + +// +// XULCheckboxElement constructor +// +PR_STATIC_CALLBACK(JSBool) +XULCheckboxElement(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + return JS_FALSE; +} + + +// +// XULCheckboxElement class initialization +// +extern "C" NS_DOM nsresult NS_InitXULCheckboxElementClass(nsIScriptContext *aContext, void **aPrototype) +{ + JSContext *jscontext = (JSContext *)aContext->GetNativeContext(); + JSObject *proto = nsnull; + JSObject *constructor = nsnull; + JSObject *parent_proto = nsnull; + JSObject *global = JS_GetGlobalObject(jscontext); + jsval vp; + + if ((PR_TRUE != JS_LookupProperty(jscontext, global, "XULCheckboxElement", &vp)) || + !JSVAL_IS_OBJECT(vp) || + ((constructor = JSVAL_TO_OBJECT(vp)) == nsnull) || + (PR_TRUE != JS_LookupProperty(jscontext, JSVAL_TO_OBJECT(vp), "prototype", &vp)) || + !JSVAL_IS_OBJECT(vp)) { + + if (NS_OK != NS_InitXULElementClass(aContext, (void **)&parent_proto)) { + return NS_ERROR_FAILURE; + } + proto = JS_InitClass(jscontext, // context + global, // global object + parent_proto, // parent proto + &XULCheckboxElementClass, // JSClass + XULCheckboxElement, // JSNative ctor + 0, // ctor args + XULCheckboxElementProperties, // proto props + XULCheckboxElementMethods, // proto funcs + nsnull, // ctor props (static) + nsnull); // ctor funcs (static) + if (nsnull == proto) { + return NS_ERROR_FAILURE; + } + + } + else if ((nsnull != constructor) && JSVAL_IS_OBJECT(vp)) { + proto = JSVAL_TO_OBJECT(vp); + } + else { + return NS_ERROR_FAILURE; + } + + if (aPrototype) { + *aPrototype = proto; + } + return NS_OK; +} + + +// +// Method for creating a new XULCheckboxElement JavaScript object +// +extern "C" NS_DOM nsresult NS_NewScriptXULCheckboxElement(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn) +{ + NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null argument to NS_NewScriptXULCheckboxElement"); + JSObject *proto; + JSObject *parent; + nsIScriptObjectOwner *owner; + JSContext *jscontext = (JSContext *)aContext->GetNativeContext(); + nsresult result = NS_OK; + nsIDOMXULCheckboxElement *aXULCheckboxElement; + + if (nsnull == aParent) { + parent = nsnull; + } + else if (NS_OK == aParent->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) { + if (NS_OK != owner->GetScriptObject(aContext, (void **)&parent)) { + NS_RELEASE(owner); + return NS_ERROR_FAILURE; + } + NS_RELEASE(owner); + } + else { + return NS_ERROR_FAILURE; + } + + if (NS_OK != NS_InitXULCheckboxElementClass(aContext, (void **)&proto)) { + return NS_ERROR_FAILURE; + } + + result = aSupports->QueryInterface(kIXULCheckboxElementIID, (void **)&aXULCheckboxElement); + if (NS_OK != result) { + return result; + } + + // create a js object for this class + *aReturn = JS_NewObject(jscontext, &XULCheckboxElementClass, proto, parent); + if (nsnull != *aReturn) { + // connect the native object to the js object + JS_SetPrivate(jscontext, (JSObject *)*aReturn, aXULCheckboxElement); + } + else { + NS_RELEASE(aXULCheckboxElement); + return NS_ERROR_FAILURE; + } + + return NS_OK; +} diff --git a/mozilla/rdf/content/src/nsJSXULMenuListElement.cpp b/mozilla/rdf/content/src/nsJSXULMenuListElement.cpp new file mode 100644 index 00000000000..26868127388 --- /dev/null +++ b/mozilla/rdf/content/src/nsJSXULMenuListElement.cpp @@ -0,0 +1,495 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * 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.org code. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + */ +/* AUTO-GENERATED. DO NOT EDIT!!! */ + +#include "jsapi.h" +#include "nsJSUtils.h" +#include "nsDOMError.h" +#include "nscore.h" +#include "nsIServiceManager.h" +#include "nsIScriptContext.h" +#include "nsIScriptSecurityManager.h" +#include "nsIJSScriptObject.h" +#include "nsIScriptObjectOwner.h" +#include "nsIScriptGlobalObject.h" +#include "nsCOMPtr.h" +#include "nsDOMPropEnums.h" +#include "nsString.h" +#include "nsIDOMElement.h" +#include "nsIDOMXULMenuListElement.h" + + +static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID); +static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID); +static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID); +static NS_DEFINE_IID(kIElementIID, NS_IDOMELEMENT_IID); +static NS_DEFINE_IID(kIXULMenuListElementIID, NS_IDOMXULMENULISTELEMENT_IID); + +// +// XULMenuListElement property ids +// +enum XULMenuListElement_slots { + XULMENULISTELEMENT_VALUE = -1, + XULMENULISTELEMENT_DATA = -2, + XULMENULISTELEMENT_SELECTEDITEM = -3, + XULMENULISTELEMENT_CROP = -4, + XULMENULISTELEMENT_DISABLED = -5, + XULMENULISTELEMENT_SRC = -6 +}; + +/***********************************************************************/ +// +// XULMenuListElement Properties Getter +// +PR_STATIC_CALLBACK(JSBool) +GetXULMenuListElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) +{ + nsIDOMXULMenuListElement *a = (nsIDOMXULMenuListElement*)nsJSUtils::nsGetNativeThis(cx, obj); + + // If there's no private data, this must be the prototype, so ignore + if (nsnull == a) { + return JS_TRUE; + } + + if (JSVAL_IS_INT(id)) { + nsresult rv; + NS_WITH_SERVICE(nsIScriptSecurityManager, secMan, + NS_SCRIPTSECURITYMANAGER_PROGID, &rv); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_SECMAN_ERR); + } + switch(JSVAL_TO_INT(id)) { + case XULMENULISTELEMENT_VALUE: + { + rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_XULMENULISTELEMENT_VALUE, PR_FALSE); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, rv); + } + nsAutoString prop; + nsresult result = NS_OK; + result = a->GetValue(prop); + if (NS_SUCCEEDED(result)) { + nsJSUtils::nsConvertStringToJSVal(prop, cx, vp); + } + else { + return nsJSUtils::nsReportError(cx, obj, result); + } + break; + } + case XULMENULISTELEMENT_DATA: + { + rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_XULMENULISTELEMENT_DATA, PR_FALSE); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, rv); + } + nsAutoString prop; + nsresult result = NS_OK; + result = a->GetData(prop); + if (NS_SUCCEEDED(result)) { + nsJSUtils::nsConvertStringToJSVal(prop, cx, vp); + } + else { + return nsJSUtils::nsReportError(cx, obj, result); + } + break; + } + case XULMENULISTELEMENT_SELECTEDITEM: + { + rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_XULMENULISTELEMENT_SELECTEDITEM, PR_FALSE); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, rv); + } + nsIDOMElement* prop; + nsresult result = NS_OK; + result = a->GetSelectedItem(&prop); + if (NS_SUCCEEDED(result)) { + // get the js object + nsJSUtils::nsConvertObjectToJSVal((nsISupports *)prop, cx, obj, vp); + } + else { + return nsJSUtils::nsReportError(cx, obj, result); + } + break; + } + case XULMENULISTELEMENT_CROP: + { + rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_XULMENULISTELEMENT_CROP, PR_FALSE); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, rv); + } + nsAutoString prop; + nsresult result = NS_OK; + result = a->GetCrop(prop); + if (NS_SUCCEEDED(result)) { + nsJSUtils::nsConvertStringToJSVal(prop, cx, vp); + } + else { + return nsJSUtils::nsReportError(cx, obj, result); + } + break; + } + case XULMENULISTELEMENT_DISABLED: + { + rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_XULMENULISTELEMENT_DISABLED, PR_FALSE); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, rv); + } + PRBool prop; + nsresult result = NS_OK; + result = a->GetDisabled(&prop); + if (NS_SUCCEEDED(result)) { + *vp = BOOLEAN_TO_JSVAL(prop); + } + else { + return nsJSUtils::nsReportError(cx, obj, result); + } + break; + } + case XULMENULISTELEMENT_SRC: + { + rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_XULMENULISTELEMENT_SRC, PR_FALSE); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, rv); + } + nsAutoString prop; + nsresult result = NS_OK; + result = a->GetSrc(prop); + if (NS_SUCCEEDED(result)) { + nsJSUtils::nsConvertStringToJSVal(prop, cx, vp); + } + else { + return nsJSUtils::nsReportError(cx, obj, result); + } + break; + } + default: + return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, obj, id, vp); + } + } + else { + return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, obj, id, vp); + } + + return PR_TRUE; +} + +/***********************************************************************/ +// +// XULMenuListElement Properties Setter +// +PR_STATIC_CALLBACK(JSBool) +SetXULMenuListElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) +{ + nsIDOMXULMenuListElement *a = (nsIDOMXULMenuListElement*)nsJSUtils::nsGetNativeThis(cx, obj); + + // If there's no private data, this must be the prototype, so ignore + if (nsnull == a) { + return JS_TRUE; + } + + if (JSVAL_IS_INT(id)) { + nsresult rv; + NS_WITH_SERVICE(nsIScriptSecurityManager, secMan, + NS_SCRIPTSECURITYMANAGER_PROGID, &rv); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_SECMAN_ERR); + } + switch(JSVAL_TO_INT(id)) { + case XULMENULISTELEMENT_VALUE: + { + rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_XULMENULISTELEMENT_VALUE, PR_TRUE); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, rv); + } + nsAutoString prop; + nsJSUtils::nsConvertJSValToString(prop, cx, *vp); + + a->SetValue(prop); + + break; + } + case XULMENULISTELEMENT_DATA: + { + rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_XULMENULISTELEMENT_DATA, PR_TRUE); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, rv); + } + nsAutoString prop; + nsJSUtils::nsConvertJSValToString(prop, cx, *vp); + + a->SetData(prop); + + break; + } + case XULMENULISTELEMENT_SELECTEDITEM: + { + rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_XULMENULISTELEMENT_SELECTEDITEM, PR_TRUE); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, rv); + } + nsIDOMElement* prop; + if (PR_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&prop, + kIElementIID, "Element", + cx, *vp)) { + return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_NOT_OBJECT_ERR); + } + + a->SetSelectedItem(prop); + NS_IF_RELEASE(prop); + break; + } + case XULMENULISTELEMENT_CROP: + { + rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_XULMENULISTELEMENT_CROP, PR_TRUE); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, rv); + } + nsAutoString prop; + nsJSUtils::nsConvertJSValToString(prop, cx, *vp); + + a->SetCrop(prop); + + break; + } + case XULMENULISTELEMENT_DISABLED: + { + rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_XULMENULISTELEMENT_DISABLED, PR_TRUE); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, rv); + } + PRBool prop; + if (PR_FALSE == nsJSUtils::nsConvertJSValToBool(&prop, cx, *vp)) { + return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_NOT_BOOLEAN_ERR); + } + + a->SetDisabled(prop); + + break; + } + case XULMENULISTELEMENT_SRC: + { + rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_XULMENULISTELEMENT_SRC, PR_TRUE); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, rv); + } + nsAutoString prop; + nsJSUtils::nsConvertJSValToString(prop, cx, *vp); + + a->SetSrc(prop); + + break; + } + default: + return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, obj, id, vp); + } + } + else { + return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, obj, id, vp); + } + + return PR_TRUE; +} + + +// +// XULMenuListElement finalizer +// +PR_STATIC_CALLBACK(void) +FinalizeXULMenuListElement(JSContext *cx, JSObject *obj) +{ + nsJSUtils::nsGenericFinalize(cx, obj); +} + + +// +// XULMenuListElement enumerate +// +PR_STATIC_CALLBACK(JSBool) +EnumerateXULMenuListElement(JSContext *cx, JSObject *obj) +{ + return nsJSUtils::nsGenericEnumerate(cx, obj); +} + + +// +// XULMenuListElement resolve +// +PR_STATIC_CALLBACK(JSBool) +ResolveXULMenuListElement(JSContext *cx, JSObject *obj, jsval id) +{ + return nsJSUtils::nsGenericResolve(cx, obj, id); +} + + +/***********************************************************************/ +// +// class for XULMenuListElement +// +JSClass XULMenuListElementClass = { + "XULMenuListElement", + JSCLASS_HAS_PRIVATE | JSCLASS_PRIVATE_IS_NSISUPPORTS, + JS_PropertyStub, + JS_PropertyStub, + GetXULMenuListElementProperty, + SetXULMenuListElementProperty, + EnumerateXULMenuListElement, + ResolveXULMenuListElement, + JS_ConvertStub, + FinalizeXULMenuListElement, + nsnull, + nsJSUtils::nsCheckAccess +}; + + +// +// XULMenuListElement class properties +// +static JSPropertySpec XULMenuListElementProperties[] = +{ + {"value", XULMENULISTELEMENT_VALUE, JSPROP_ENUMERATE}, + {"data", XULMENULISTELEMENT_DATA, JSPROP_ENUMERATE}, + {"selectedItem", XULMENULISTELEMENT_SELECTEDITEM, JSPROP_ENUMERATE}, + {"crop", XULMENULISTELEMENT_CROP, JSPROP_ENUMERATE}, + {"disabled", XULMENULISTELEMENT_DISABLED, JSPROP_ENUMERATE}, + {"src", XULMENULISTELEMENT_SRC, JSPROP_ENUMERATE}, + {0} +}; + + +// +// XULMenuListElement class methods +// +static JSFunctionSpec XULMenuListElementMethods[] = +{ + {0} +}; + + +// +// XULMenuListElement constructor +// +PR_STATIC_CALLBACK(JSBool) +XULMenuListElement(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + return JS_FALSE; +} + + +// +// XULMenuListElement class initialization +// +extern "C" NS_DOM nsresult NS_InitXULMenuListElementClass(nsIScriptContext *aContext, void **aPrototype) +{ + JSContext *jscontext = (JSContext *)aContext->GetNativeContext(); + JSObject *proto = nsnull; + JSObject *constructor = nsnull; + JSObject *parent_proto = nsnull; + JSObject *global = JS_GetGlobalObject(jscontext); + jsval vp; + + if ((PR_TRUE != JS_LookupProperty(jscontext, global, "XULMenuListElement", &vp)) || + !JSVAL_IS_OBJECT(vp) || + ((constructor = JSVAL_TO_OBJECT(vp)) == nsnull) || + (PR_TRUE != JS_LookupProperty(jscontext, JSVAL_TO_OBJECT(vp), "prototype", &vp)) || + !JSVAL_IS_OBJECT(vp)) { + + if (NS_OK != NS_InitXULElementClass(aContext, (void **)&parent_proto)) { + return NS_ERROR_FAILURE; + } + proto = JS_InitClass(jscontext, // context + global, // global object + parent_proto, // parent proto + &XULMenuListElementClass, // JSClass + XULMenuListElement, // JSNative ctor + 0, // ctor args + XULMenuListElementProperties, // proto props + XULMenuListElementMethods, // proto funcs + nsnull, // ctor props (static) + nsnull); // ctor funcs (static) + if (nsnull == proto) { + return NS_ERROR_FAILURE; + } + + } + else if ((nsnull != constructor) && JSVAL_IS_OBJECT(vp)) { + proto = JSVAL_TO_OBJECT(vp); + } + else { + return NS_ERROR_FAILURE; + } + + if (aPrototype) { + *aPrototype = proto; + } + return NS_OK; +} + + +// +// Method for creating a new XULMenuListElement JavaScript object +// +extern "C" NS_DOM nsresult NS_NewScriptXULMenuListElement(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn) +{ + NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null argument to NS_NewScriptXULMenuListElement"); + JSObject *proto; + JSObject *parent; + nsIScriptObjectOwner *owner; + JSContext *jscontext = (JSContext *)aContext->GetNativeContext(); + nsresult result = NS_OK; + nsIDOMXULMenuListElement *aXULMenuListElement; + + if (nsnull == aParent) { + parent = nsnull; + } + else if (NS_OK == aParent->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) { + if (NS_OK != owner->GetScriptObject(aContext, (void **)&parent)) { + NS_RELEASE(owner); + return NS_ERROR_FAILURE; + } + NS_RELEASE(owner); + } + else { + return NS_ERROR_FAILURE; + } + + if (NS_OK != NS_InitXULMenuListElementClass(aContext, (void **)&proto)) { + return NS_ERROR_FAILURE; + } + + result = aSupports->QueryInterface(kIXULMenuListElementIID, (void **)&aXULMenuListElement); + if (NS_OK != result) { + return result; + } + + // create a js object for this class + *aReturn = JS_NewObject(jscontext, &XULMenuListElementClass, proto, parent); + if (nsnull != *aReturn) { + // connect the native object to the js object + JS_SetPrivate(jscontext, (JSObject *)*aReturn, aXULMenuListElement); + } + else { + NS_RELEASE(aXULMenuListElement); + return NS_ERROR_FAILURE; + } + + return NS_OK; +} diff --git a/mozilla/rdf/content/src/nsJSXULRadioElement.cpp b/mozilla/rdf/content/src/nsJSXULRadioElement.cpp new file mode 100644 index 00000000000..80072eaf0d2 --- /dev/null +++ b/mozilla/rdf/content/src/nsJSXULRadioElement.cpp @@ -0,0 +1,522 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * 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.org code. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + */ +/* AUTO-GENERATED. DO NOT EDIT!!! */ + +#include "jsapi.h" +#include "nsJSUtils.h" +#include "nsDOMError.h" +#include "nscore.h" +#include "nsIServiceManager.h" +#include "nsIScriptContext.h" +#include "nsIScriptSecurityManager.h" +#include "nsIJSScriptObject.h" +#include "nsIScriptObjectOwner.h" +#include "nsIScriptGlobalObject.h" +#include "nsCOMPtr.h" +#include "nsDOMPropEnums.h" +#include "nsString.h" +#include "nsIDOMXULRadioElement.h" + + +static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID); +static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID); +static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID); +static NS_DEFINE_IID(kIXULRadioElementIID, NS_IDOMXULRADIOELEMENT_IID); + +// +// XULRadioElement property ids +// +enum XULRadioElement_slots { + XULRADIOELEMENT_VALUE = -1, + XULRADIOELEMENT_CROP = -2, + XULRADIOELEMENT_DISABLED = -3, + XULRADIOELEMENT_SRC = -4, + XULRADIOELEMENT_IMGALIGN = -5, + XULRADIOELEMENT_ACCESSKEY = -6, + XULRADIOELEMENT_CHECKED = -7 +}; + +/***********************************************************************/ +// +// XULRadioElement Properties Getter +// +PR_STATIC_CALLBACK(JSBool) +GetXULRadioElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) +{ + nsIDOMXULRadioElement *a = (nsIDOMXULRadioElement*)nsJSUtils::nsGetNativeThis(cx, obj); + + // If there's no private data, this must be the prototype, so ignore + if (nsnull == a) { + return JS_TRUE; + } + + if (JSVAL_IS_INT(id)) { + nsresult rv; + NS_WITH_SERVICE(nsIScriptSecurityManager, secMan, + NS_SCRIPTSECURITYMANAGER_PROGID, &rv); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_SECMAN_ERR); + } + switch(JSVAL_TO_INT(id)) { + case XULRADIOELEMENT_VALUE: + { + rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_XULRADIOELEMENT_VALUE, PR_FALSE); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, rv); + } + nsAutoString prop; + nsresult result = NS_OK; + result = a->GetValue(prop); + if (NS_SUCCEEDED(result)) { + nsJSUtils::nsConvertStringToJSVal(prop, cx, vp); + } + else { + return nsJSUtils::nsReportError(cx, obj, result); + } + break; + } + case XULRADIOELEMENT_CROP: + { + rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_XULRADIOELEMENT_CROP, PR_FALSE); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, rv); + } + nsAutoString prop; + nsresult result = NS_OK; + result = a->GetCrop(prop); + if (NS_SUCCEEDED(result)) { + nsJSUtils::nsConvertStringToJSVal(prop, cx, vp); + } + else { + return nsJSUtils::nsReportError(cx, obj, result); + } + break; + } + case XULRADIOELEMENT_DISABLED: + { + rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_XULRADIOELEMENT_DISABLED, PR_FALSE); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, rv); + } + PRBool prop; + nsresult result = NS_OK; + result = a->GetDisabled(&prop); + if (NS_SUCCEEDED(result)) { + *vp = BOOLEAN_TO_JSVAL(prop); + } + else { + return nsJSUtils::nsReportError(cx, obj, result); + } + break; + } + case XULRADIOELEMENT_SRC: + { + rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_XULRADIOELEMENT_SRC, PR_FALSE); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, rv); + } + nsAutoString prop; + nsresult result = NS_OK; + result = a->GetSrc(prop); + if (NS_SUCCEEDED(result)) { + nsJSUtils::nsConvertStringToJSVal(prop, cx, vp); + } + else { + return nsJSUtils::nsReportError(cx, obj, result); + } + break; + } + case XULRADIOELEMENT_IMGALIGN: + { + rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_XULRADIOELEMENT_IMGALIGN, PR_FALSE); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, rv); + } + nsAutoString prop; + nsresult result = NS_OK; + result = a->GetImgalign(prop); + if (NS_SUCCEEDED(result)) { + nsJSUtils::nsConvertStringToJSVal(prop, cx, vp); + } + else { + return nsJSUtils::nsReportError(cx, obj, result); + } + break; + } + case XULRADIOELEMENT_ACCESSKEY: + { + rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_XULRADIOELEMENT_ACCESSKEY, PR_FALSE); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, rv); + } + nsAutoString prop; + nsresult result = NS_OK; + result = a->GetAccesskey(prop); + if (NS_SUCCEEDED(result)) { + nsJSUtils::nsConvertStringToJSVal(prop, cx, vp); + } + else { + return nsJSUtils::nsReportError(cx, obj, result); + } + break; + } + case XULRADIOELEMENT_CHECKED: + { + rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_XULRADIOELEMENT_CHECKED, PR_FALSE); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, rv); + } + PRBool prop; + nsresult result = NS_OK; + result = a->GetChecked(&prop); + if (NS_SUCCEEDED(result)) { + *vp = BOOLEAN_TO_JSVAL(prop); + } + else { + return nsJSUtils::nsReportError(cx, obj, result); + } + break; + } + default: + return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, obj, id, vp); + } + } + else { + return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, obj, id, vp); + } + + return PR_TRUE; +} + +/***********************************************************************/ +// +// XULRadioElement Properties Setter +// +PR_STATIC_CALLBACK(JSBool) +SetXULRadioElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) +{ + nsIDOMXULRadioElement *a = (nsIDOMXULRadioElement*)nsJSUtils::nsGetNativeThis(cx, obj); + + // If there's no private data, this must be the prototype, so ignore + if (nsnull == a) { + return JS_TRUE; + } + + if (JSVAL_IS_INT(id)) { + nsresult rv; + NS_WITH_SERVICE(nsIScriptSecurityManager, secMan, + NS_SCRIPTSECURITYMANAGER_PROGID, &rv); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_SECMAN_ERR); + } + switch(JSVAL_TO_INT(id)) { + case XULRADIOELEMENT_VALUE: + { + rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_XULRADIOELEMENT_VALUE, PR_TRUE); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, rv); + } + nsAutoString prop; + nsJSUtils::nsConvertJSValToString(prop, cx, *vp); + + a->SetValue(prop); + + break; + } + case XULRADIOELEMENT_CROP: + { + rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_XULRADIOELEMENT_CROP, PR_TRUE); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, rv); + } + nsAutoString prop; + nsJSUtils::nsConvertJSValToString(prop, cx, *vp); + + a->SetCrop(prop); + + break; + } + case XULRADIOELEMENT_DISABLED: + { + rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_XULRADIOELEMENT_DISABLED, PR_TRUE); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, rv); + } + PRBool prop; + if (PR_FALSE == nsJSUtils::nsConvertJSValToBool(&prop, cx, *vp)) { + return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_NOT_BOOLEAN_ERR); + } + + a->SetDisabled(prop); + + break; + } + case XULRADIOELEMENT_SRC: + { + rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_XULRADIOELEMENT_SRC, PR_TRUE); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, rv); + } + nsAutoString prop; + nsJSUtils::nsConvertJSValToString(prop, cx, *vp); + + a->SetSrc(prop); + + break; + } + case XULRADIOELEMENT_IMGALIGN: + { + rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_XULRADIOELEMENT_IMGALIGN, PR_TRUE); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, rv); + } + nsAutoString prop; + nsJSUtils::nsConvertJSValToString(prop, cx, *vp); + + a->SetImgalign(prop); + + break; + } + case XULRADIOELEMENT_ACCESSKEY: + { + rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_XULRADIOELEMENT_ACCESSKEY, PR_TRUE); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, rv); + } + nsAutoString prop; + nsJSUtils::nsConvertJSValToString(prop, cx, *vp); + + a->SetAccesskey(prop); + + break; + } + case XULRADIOELEMENT_CHECKED: + { + rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_XULRADIOELEMENT_CHECKED, PR_TRUE); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, rv); + } + PRBool prop; + if (PR_FALSE == nsJSUtils::nsConvertJSValToBool(&prop, cx, *vp)) { + return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_NOT_BOOLEAN_ERR); + } + + a->SetChecked(prop); + + break; + } + default: + return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, obj, id, vp); + } + } + else { + return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, obj, id, vp); + } + + return PR_TRUE; +} + + +// +// XULRadioElement finalizer +// +PR_STATIC_CALLBACK(void) +FinalizeXULRadioElement(JSContext *cx, JSObject *obj) +{ + nsJSUtils::nsGenericFinalize(cx, obj); +} + + +// +// XULRadioElement enumerate +// +PR_STATIC_CALLBACK(JSBool) +EnumerateXULRadioElement(JSContext *cx, JSObject *obj) +{ + return nsJSUtils::nsGenericEnumerate(cx, obj); +} + + +// +// XULRadioElement resolve +// +PR_STATIC_CALLBACK(JSBool) +ResolveXULRadioElement(JSContext *cx, JSObject *obj, jsval id) +{ + return nsJSUtils::nsGenericResolve(cx, obj, id); +} + + +/***********************************************************************/ +// +// class for XULRadioElement +// +JSClass XULRadioElementClass = { + "XULRadioElement", + JSCLASS_HAS_PRIVATE | JSCLASS_PRIVATE_IS_NSISUPPORTS, + JS_PropertyStub, + JS_PropertyStub, + GetXULRadioElementProperty, + SetXULRadioElementProperty, + EnumerateXULRadioElement, + ResolveXULRadioElement, + JS_ConvertStub, + FinalizeXULRadioElement, + nsnull, + nsJSUtils::nsCheckAccess +}; + + +// +// XULRadioElement class properties +// +static JSPropertySpec XULRadioElementProperties[] = +{ + {"value", XULRADIOELEMENT_VALUE, JSPROP_ENUMERATE}, + {"crop", XULRADIOELEMENT_CROP, JSPROP_ENUMERATE}, + {"disabled", XULRADIOELEMENT_DISABLED, JSPROP_ENUMERATE}, + {"src", XULRADIOELEMENT_SRC, JSPROP_ENUMERATE}, + {"imgalign", XULRADIOELEMENT_IMGALIGN, JSPROP_ENUMERATE}, + {"accesskey", XULRADIOELEMENT_ACCESSKEY, JSPROP_ENUMERATE}, + {"checked", XULRADIOELEMENT_CHECKED, JSPROP_ENUMERATE}, + {0} +}; + + +// +// XULRadioElement class methods +// +static JSFunctionSpec XULRadioElementMethods[] = +{ + {0} +}; + + +// +// XULRadioElement constructor +// +PR_STATIC_CALLBACK(JSBool) +XULRadioElement(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + return JS_FALSE; +} + + +// +// XULRadioElement class initialization +// +extern "C" NS_DOM nsresult NS_InitXULRadioElementClass(nsIScriptContext *aContext, void **aPrototype) +{ + JSContext *jscontext = (JSContext *)aContext->GetNativeContext(); + JSObject *proto = nsnull; + JSObject *constructor = nsnull; + JSObject *parent_proto = nsnull; + JSObject *global = JS_GetGlobalObject(jscontext); + jsval vp; + + if ((PR_TRUE != JS_LookupProperty(jscontext, global, "XULRadioElement", &vp)) || + !JSVAL_IS_OBJECT(vp) || + ((constructor = JSVAL_TO_OBJECT(vp)) == nsnull) || + (PR_TRUE != JS_LookupProperty(jscontext, JSVAL_TO_OBJECT(vp), "prototype", &vp)) || + !JSVAL_IS_OBJECT(vp)) { + + if (NS_OK != NS_InitXULElementClass(aContext, (void **)&parent_proto)) { + return NS_ERROR_FAILURE; + } + proto = JS_InitClass(jscontext, // context + global, // global object + parent_proto, // parent proto + &XULRadioElementClass, // JSClass + XULRadioElement, // JSNative ctor + 0, // ctor args + XULRadioElementProperties, // proto props + XULRadioElementMethods, // proto funcs + nsnull, // ctor props (static) + nsnull); // ctor funcs (static) + if (nsnull == proto) { + return NS_ERROR_FAILURE; + } + + } + else if ((nsnull != constructor) && JSVAL_IS_OBJECT(vp)) { + proto = JSVAL_TO_OBJECT(vp); + } + else { + return NS_ERROR_FAILURE; + } + + if (aPrototype) { + *aPrototype = proto; + } + return NS_OK; +} + + +// +// Method for creating a new XULRadioElement JavaScript object +// +extern "C" NS_DOM nsresult NS_NewScriptXULRadioElement(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn) +{ + NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null argument to NS_NewScriptXULRadioElement"); + JSObject *proto; + JSObject *parent; + nsIScriptObjectOwner *owner; + JSContext *jscontext = (JSContext *)aContext->GetNativeContext(); + nsresult result = NS_OK; + nsIDOMXULRadioElement *aXULRadioElement; + + if (nsnull == aParent) { + parent = nsnull; + } + else if (NS_OK == aParent->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) { + if (NS_OK != owner->GetScriptObject(aContext, (void **)&parent)) { + NS_RELEASE(owner); + return NS_ERROR_FAILURE; + } + NS_RELEASE(owner); + } + else { + return NS_ERROR_FAILURE; + } + + if (NS_OK != NS_InitXULRadioElementClass(aContext, (void **)&proto)) { + return NS_ERROR_FAILURE; + } + + result = aSupports->QueryInterface(kIXULRadioElementIID, (void **)&aXULRadioElement); + if (NS_OK != result) { + return result; + } + + // create a js object for this class + *aReturn = JS_NewObject(jscontext, &XULRadioElementClass, proto, parent); + if (nsnull != *aReturn) { + // connect the native object to the js object + JS_SetPrivate(jscontext, (JSObject *)*aReturn, aXULRadioElement); + } + else { + NS_RELEASE(aXULRadioElement); + return NS_ERROR_FAILURE; + } + + return NS_OK; +} diff --git a/mozilla/rdf/content/src/nsJSXULTitledButtonElement.cpp b/mozilla/rdf/content/src/nsJSXULTitledButtonElement.cpp new file mode 100644 index 00000000000..699fc89a1d7 --- /dev/null +++ b/mozilla/rdf/content/src/nsJSXULTitledButtonElement.cpp @@ -0,0 +1,488 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * 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.org code. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + */ +/* AUTO-GENERATED. DO NOT EDIT!!! */ + +#include "jsapi.h" +#include "nsJSUtils.h" +#include "nsDOMError.h" +#include "nscore.h" +#include "nsIServiceManager.h" +#include "nsIScriptContext.h" +#include "nsIScriptSecurityManager.h" +#include "nsIJSScriptObject.h" +#include "nsIScriptObjectOwner.h" +#include "nsIScriptGlobalObject.h" +#include "nsCOMPtr.h" +#include "nsDOMPropEnums.h" +#include "nsString.h" +#include "nsIDOMXULTitledButtonElement.h" + + +static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID); +static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID); +static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID); +static NS_DEFINE_IID(kIXULTitledButtonElementIID, NS_IDOMXULTITLEDBUTTONELEMENT_IID); + +// +// XULTitledButtonElement property ids +// +enum XULTitledButtonElement_slots { + XULTITLEDBUTTONELEMENT_VALUE = -1, + XULTITLEDBUTTONELEMENT_CROP = -2, + XULTITLEDBUTTONELEMENT_DISABLED = -3, + XULTITLEDBUTTONELEMENT_SRC = -4, + XULTITLEDBUTTONELEMENT_IMGALIGN = -5, + XULTITLEDBUTTONELEMENT_ACCESSKEY = -6 +}; + +/***********************************************************************/ +// +// XULTitledButtonElement Properties Getter +// +PR_STATIC_CALLBACK(JSBool) +GetXULTitledButtonElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) +{ + nsIDOMXULTitledButtonElement *a = (nsIDOMXULTitledButtonElement*)nsJSUtils::nsGetNativeThis(cx, obj); + + // If there's no private data, this must be the prototype, so ignore + if (nsnull == a) { + return JS_TRUE; + } + + if (JSVAL_IS_INT(id)) { + nsresult rv; + NS_WITH_SERVICE(nsIScriptSecurityManager, secMan, + NS_SCRIPTSECURITYMANAGER_PROGID, &rv); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_SECMAN_ERR); + } + switch(JSVAL_TO_INT(id)) { + case XULTITLEDBUTTONELEMENT_VALUE: + { + rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_XULTITLEDBUTTONELEMENT_VALUE, PR_FALSE); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, rv); + } + nsAutoString prop; + nsresult result = NS_OK; + result = a->GetValue(prop); + if (NS_SUCCEEDED(result)) { + nsJSUtils::nsConvertStringToJSVal(prop, cx, vp); + } + else { + return nsJSUtils::nsReportError(cx, obj, result); + } + break; + } + case XULTITLEDBUTTONELEMENT_CROP: + { + rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_XULTITLEDBUTTONELEMENT_CROP, PR_FALSE); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, rv); + } + nsAutoString prop; + nsresult result = NS_OK; + result = a->GetCrop(prop); + if (NS_SUCCEEDED(result)) { + nsJSUtils::nsConvertStringToJSVal(prop, cx, vp); + } + else { + return nsJSUtils::nsReportError(cx, obj, result); + } + break; + } + case XULTITLEDBUTTONELEMENT_DISABLED: + { + rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_XULTITLEDBUTTONELEMENT_DISABLED, PR_FALSE); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, rv); + } + PRBool prop; + nsresult result = NS_OK; + result = a->GetDisabled(&prop); + if (NS_SUCCEEDED(result)) { + *vp = BOOLEAN_TO_JSVAL(prop); + } + else { + return nsJSUtils::nsReportError(cx, obj, result); + } + break; + } + case XULTITLEDBUTTONELEMENT_SRC: + { + rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_XULTITLEDBUTTONELEMENT_SRC, PR_FALSE); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, rv); + } + nsAutoString prop; + nsresult result = NS_OK; + result = a->GetSrc(prop); + if (NS_SUCCEEDED(result)) { + nsJSUtils::nsConvertStringToJSVal(prop, cx, vp); + } + else { + return nsJSUtils::nsReportError(cx, obj, result); + } + break; + } + case XULTITLEDBUTTONELEMENT_IMGALIGN: + { + rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_XULTITLEDBUTTONELEMENT_IMGALIGN, PR_FALSE); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, rv); + } + nsAutoString prop; + nsresult result = NS_OK; + result = a->GetImgalign(prop); + if (NS_SUCCEEDED(result)) { + nsJSUtils::nsConvertStringToJSVal(prop, cx, vp); + } + else { + return nsJSUtils::nsReportError(cx, obj, result); + } + break; + } + case XULTITLEDBUTTONELEMENT_ACCESSKEY: + { + rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_XULTITLEDBUTTONELEMENT_ACCESSKEY, PR_FALSE); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, rv); + } + nsAutoString prop; + nsresult result = NS_OK; + result = a->GetAccesskey(prop); + if (NS_SUCCEEDED(result)) { + nsJSUtils::nsConvertStringToJSVal(prop, cx, vp); + } + else { + return nsJSUtils::nsReportError(cx, obj, result); + } + break; + } + default: + return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, obj, id, vp); + } + } + else { + return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, obj, id, vp); + } + + return PR_TRUE; +} + +/***********************************************************************/ +// +// XULTitledButtonElement Properties Setter +// +PR_STATIC_CALLBACK(JSBool) +SetXULTitledButtonElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) +{ + nsIDOMXULTitledButtonElement *a = (nsIDOMXULTitledButtonElement*)nsJSUtils::nsGetNativeThis(cx, obj); + + // If there's no private data, this must be the prototype, so ignore + if (nsnull == a) { + return JS_TRUE; + } + + if (JSVAL_IS_INT(id)) { + nsresult rv; + NS_WITH_SERVICE(nsIScriptSecurityManager, secMan, + NS_SCRIPTSECURITYMANAGER_PROGID, &rv); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_SECMAN_ERR); + } + switch(JSVAL_TO_INT(id)) { + case XULTITLEDBUTTONELEMENT_VALUE: + { + rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_XULTITLEDBUTTONELEMENT_VALUE, PR_TRUE); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, rv); + } + nsAutoString prop; + nsJSUtils::nsConvertJSValToString(prop, cx, *vp); + + a->SetValue(prop); + + break; + } + case XULTITLEDBUTTONELEMENT_CROP: + { + rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_XULTITLEDBUTTONELEMENT_CROP, PR_TRUE); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, rv); + } + nsAutoString prop; + nsJSUtils::nsConvertJSValToString(prop, cx, *vp); + + a->SetCrop(prop); + + break; + } + case XULTITLEDBUTTONELEMENT_DISABLED: + { + rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_XULTITLEDBUTTONELEMENT_DISABLED, PR_TRUE); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, rv); + } + PRBool prop; + if (PR_FALSE == nsJSUtils::nsConvertJSValToBool(&prop, cx, *vp)) { + return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_NOT_BOOLEAN_ERR); + } + + a->SetDisabled(prop); + + break; + } + case XULTITLEDBUTTONELEMENT_SRC: + { + rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_XULTITLEDBUTTONELEMENT_SRC, PR_TRUE); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, rv); + } + nsAutoString prop; + nsJSUtils::nsConvertJSValToString(prop, cx, *vp); + + a->SetSrc(prop); + + break; + } + case XULTITLEDBUTTONELEMENT_IMGALIGN: + { + rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_XULTITLEDBUTTONELEMENT_IMGALIGN, PR_TRUE); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, rv); + } + nsAutoString prop; + nsJSUtils::nsConvertJSValToString(prop, cx, *vp); + + a->SetImgalign(prop); + + break; + } + case XULTITLEDBUTTONELEMENT_ACCESSKEY: + { + rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_XULTITLEDBUTTONELEMENT_ACCESSKEY, PR_TRUE); + if (NS_FAILED(rv)) { + return nsJSUtils::nsReportError(cx, obj, rv); + } + nsAutoString prop; + nsJSUtils::nsConvertJSValToString(prop, cx, *vp); + + a->SetAccesskey(prop); + + break; + } + default: + return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, obj, id, vp); + } + } + else { + return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, obj, id, vp); + } + + return PR_TRUE; +} + + +// +// XULTitledButtonElement finalizer +// +PR_STATIC_CALLBACK(void) +FinalizeXULTitledButtonElement(JSContext *cx, JSObject *obj) +{ + nsJSUtils::nsGenericFinalize(cx, obj); +} + + +// +// XULTitledButtonElement enumerate +// +PR_STATIC_CALLBACK(JSBool) +EnumerateXULTitledButtonElement(JSContext *cx, JSObject *obj) +{ + return nsJSUtils::nsGenericEnumerate(cx, obj); +} + + +// +// XULTitledButtonElement resolve +// +PR_STATIC_CALLBACK(JSBool) +ResolveXULTitledButtonElement(JSContext *cx, JSObject *obj, jsval id) +{ + return nsJSUtils::nsGenericResolve(cx, obj, id); +} + + +/***********************************************************************/ +// +// class for XULTitledButtonElement +// +JSClass XULTitledButtonElementClass = { + "XULTitledButtonElement", + JSCLASS_HAS_PRIVATE | JSCLASS_PRIVATE_IS_NSISUPPORTS, + JS_PropertyStub, + JS_PropertyStub, + GetXULTitledButtonElementProperty, + SetXULTitledButtonElementProperty, + EnumerateXULTitledButtonElement, + ResolveXULTitledButtonElement, + JS_ConvertStub, + FinalizeXULTitledButtonElement, + nsnull, + nsJSUtils::nsCheckAccess +}; + + +// +// XULTitledButtonElement class properties +// +static JSPropertySpec XULTitledButtonElementProperties[] = +{ + {"value", XULTITLEDBUTTONELEMENT_VALUE, JSPROP_ENUMERATE}, + {"crop", XULTITLEDBUTTONELEMENT_CROP, JSPROP_ENUMERATE}, + {"disabled", XULTITLEDBUTTONELEMENT_DISABLED, JSPROP_ENUMERATE}, + {"src", XULTITLEDBUTTONELEMENT_SRC, JSPROP_ENUMERATE}, + {"imgalign", XULTITLEDBUTTONELEMENT_IMGALIGN, JSPROP_ENUMERATE}, + {"accesskey", XULTITLEDBUTTONELEMENT_ACCESSKEY, JSPROP_ENUMERATE}, + {0} +}; + + +// +// XULTitledButtonElement class methods +// +static JSFunctionSpec XULTitledButtonElementMethods[] = +{ + {0} +}; + + +// +// XULTitledButtonElement constructor +// +PR_STATIC_CALLBACK(JSBool) +XULTitledButtonElement(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + return JS_FALSE; +} + + +// +// XULTitledButtonElement class initialization +// +extern "C" NS_DOM nsresult NS_InitXULTitledButtonElementClass(nsIScriptContext *aContext, void **aPrototype) +{ + JSContext *jscontext = (JSContext *)aContext->GetNativeContext(); + JSObject *proto = nsnull; + JSObject *constructor = nsnull; + JSObject *parent_proto = nsnull; + JSObject *global = JS_GetGlobalObject(jscontext); + jsval vp; + + if ((PR_TRUE != JS_LookupProperty(jscontext, global, "XULTitledButtonElement", &vp)) || + !JSVAL_IS_OBJECT(vp) || + ((constructor = JSVAL_TO_OBJECT(vp)) == nsnull) || + (PR_TRUE != JS_LookupProperty(jscontext, JSVAL_TO_OBJECT(vp), "prototype", &vp)) || + !JSVAL_IS_OBJECT(vp)) { + + if (NS_OK != NS_InitXULElementClass(aContext, (void **)&parent_proto)) { + return NS_ERROR_FAILURE; + } + proto = JS_InitClass(jscontext, // context + global, // global object + parent_proto, // parent proto + &XULTitledButtonElementClass, // JSClass + XULTitledButtonElement, // JSNative ctor + 0, // ctor args + XULTitledButtonElementProperties, // proto props + XULTitledButtonElementMethods, // proto funcs + nsnull, // ctor props (static) + nsnull); // ctor funcs (static) + if (nsnull == proto) { + return NS_ERROR_FAILURE; + } + + } + else if ((nsnull != constructor) && JSVAL_IS_OBJECT(vp)) { + proto = JSVAL_TO_OBJECT(vp); + } + else { + return NS_ERROR_FAILURE; + } + + if (aPrototype) { + *aPrototype = proto; + } + return NS_OK; +} + + +// +// Method for creating a new XULTitledButtonElement JavaScript object +// +extern "C" NS_DOM nsresult NS_NewScriptXULTitledButtonElement(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn) +{ + NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null argument to NS_NewScriptXULTitledButtonElement"); + JSObject *proto; + JSObject *parent; + nsIScriptObjectOwner *owner; + JSContext *jscontext = (JSContext *)aContext->GetNativeContext(); + nsresult result = NS_OK; + nsIDOMXULTitledButtonElement *aXULTitledButtonElement; + + if (nsnull == aParent) { + parent = nsnull; + } + else if (NS_OK == aParent->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) { + if (NS_OK != owner->GetScriptObject(aContext, (void **)&parent)) { + NS_RELEASE(owner); + return NS_ERROR_FAILURE; + } + NS_RELEASE(owner); + } + else { + return NS_ERROR_FAILURE; + } + + if (NS_OK != NS_InitXULTitledButtonElementClass(aContext, (void **)&proto)) { + return NS_ERROR_FAILURE; + } + + result = aSupports->QueryInterface(kIXULTitledButtonElementIID, (void **)&aXULTitledButtonElement); + if (NS_OK != result) { + return result; + } + + // create a js object for this class + *aReturn = JS_NewObject(jscontext, &XULTitledButtonElementClass, proto, parent); + if (nsnull != *aReturn) { + // connect the native object to the js object + JS_SetPrivate(jscontext, (JSObject *)*aReturn, aXULTitledButtonElement); + } + else { + NS_RELEASE(aXULTitledButtonElement); + return NS_ERROR_FAILURE; + } + + return NS_OK; +} diff --git a/mozilla/rdf/content/src/nsXULCheckboxElement.cpp b/mozilla/rdf/content/src/nsXULCheckboxElement.cpp new file mode 100644 index 00000000000..f0ebdf9f061 --- /dev/null +++ b/mozilla/rdf/content/src/nsXULCheckboxElement.cpp @@ -0,0 +1,181 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * 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. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + */ + +/* + + Implementation methods for the XUL checkbox element APIs. + +*/ + +#include "nsCOMPtr.h" +#include "nsRDFCID.h" +#include "nsXULCheckboxElement.h" +#include "nsIContent.h" +#include "nsIDocument.h" +#include "nsIPresContext.h" +#include "nsIPresShell.h" +#include "nsINameSpaceManager.h" +#include "nsIServiceManager.h" +#include "nsString.h" +//#include "nsIPopupSetFrame.h" +//#include "nsIMenuFrame.h" +//#include "nsIFrame.h" + +NS_IMPL_ADDREF_INHERITED(nsXULCheckboxElement, nsXULAggregateElement); +NS_IMPL_RELEASE_INHERITED(nsXULCheckboxElement, nsXULAggregateElement); + +nsresult +nsXULCheckboxElement::QueryInterface(REFNSIID aIID, void** aResult) +{ + NS_PRECONDITION(aResult != nsnull, "null ptr"); + if (! aResult) + return NS_ERROR_NULL_POINTER; + + if (aIID.Equals(NS_GET_IID(nsIDOMXULCheckboxElement))) { + *aResult = NS_STATIC_CAST(nsIDOMXULCheckboxElement*, this); + } + else { + return nsXULAggregateElement::QueryInterface(aIID, aResult); + } + + NS_ADDREF(NS_REINTERPRET_CAST(nsISupports*, *aResult)); + return NS_OK; +} + +MOZ_DECL_CTOR_COUNTER(RDF_nsXULCheckboxElement); + +nsXULCheckboxElement::nsXULCheckboxElement(nsIDOMXULElement* aOuter) +: nsXULAggregateElement(aOuter) +{ +} + +nsXULCheckboxElement::~nsXULCheckboxElement() +{ +} + +NS_IMETHODIMP +nsXULCheckboxElement::GetValue(nsString& aValue) +{ + return mOuter->GetAttribute("value", aValue); +} + +NS_IMETHODIMP +nsXULCheckboxElement::SetValue(const nsString& aValue) +{ + return mOuter->SetAttribute("value", aValue); +} + +NS_IMETHODIMP +nsXULCheckboxElement::GetCrop(nsString& aCrop) +{ + return mOuter->GetAttribute("crop", aCrop); +} + +NS_IMETHODIMP +nsXULCheckboxElement::SetCrop(const nsString& aCrop) +{ + return mOuter->SetAttribute("crop", aCrop); +} + +NS_IMETHODIMP +nsXULCheckboxElement::GetSrc(nsString& aSrc) +{ + return mOuter->GetAttribute("src", aSrc); +} + +NS_IMETHODIMP +nsXULCheckboxElement::SetSrc(const nsString& aSrc) +{ + return mOuter->SetAttribute("src", aSrc); +} + +NS_IMETHODIMP +nsXULCheckboxElement::GetImgalign(nsString& aImgalign) +{ + return mOuter->GetAttribute("imgalign", aImgalign); +} + +NS_IMETHODIMP +nsXULCheckboxElement::SetImgalign(const nsString& aImgalign) +{ + return mOuter->SetAttribute("imgalign", aImgalign); +} + +NS_IMETHODIMP +nsXULCheckboxElement::GetAccesskey(nsString& aAccesskey) +{ + return mOuter->GetAttribute("accesskey", aAccesskey); +} + +NS_IMETHODIMP +nsXULCheckboxElement::SetAccesskey(const nsString& aAccesskey) +{ + return mOuter->SetAttribute("accesskey", aAccesskey); +} + +NS_IMETHODIMP +nsXULCheckboxElement::GetChecked(PRBool* aChecked) +{ + nsAutoString value; + mOuter->GetAttribute("checked", value); + if(value == "true") + *aChecked = PR_TRUE; + else + *aChecked = PR_FALSE; + + return NS_OK; +} + +NS_IMETHODIMP +nsXULCheckboxElement::SetChecked(PRBool aChecked) +{ + if(aChecked) + mOuter->SetAttribute("checked", "true"); + else + mOuter->RemoveAttribute("checked"); + + return NS_OK; +} + +NS_IMETHODIMP +nsXULCheckboxElement::GetDisabled(PRBool* aDisabled) +{ + nsAutoString value; + mOuter->GetAttribute("disabled", value); + if(value == "true") + *aDisabled = PR_TRUE; + else + *aDisabled = PR_FALSE; + + return NS_OK; +} + +NS_IMETHODIMP +nsXULCheckboxElement::SetDisabled(PRBool aDisabled) +{ + if(aDisabled) + mOuter->SetAttribute("disabled", "true"); + else + mOuter->RemoveAttribute("disabled"); + + return NS_OK; +} \ No newline at end of file diff --git a/mozilla/rdf/content/src/nsXULCheckboxElement.h b/mozilla/rdf/content/src/nsXULCheckboxElement.h new file mode 100644 index 00000000000..c6809ca8b81 --- /dev/null +++ b/mozilla/rdf/content/src/nsXULCheckboxElement.h @@ -0,0 +1,58 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * 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. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + */ + +/* + + An aggregate object that implements the XUL titledbutton widget APIs + +*/ + +#ifndef nsXULCheckboxElement_h__ +#define nsXULCheckboxElement_h__ + +#include "nsXULElement.h" +#include "nsIDOMXULCheckboxElement.h" + +class nsXULCheckboxElement : public nsXULAggregateElement, + public nsIDOMXULCheckboxElement +{ +public: + nsXULCheckboxElement(nsIDOMXULElement* aOuter); + ~nsXULCheckboxElement(); + + NS_DECL_ISUPPORTS_INHERITED + + // nsIDOMNode interface + NS_FORWARD_IDOMNODE(mOuter->); + + // nsIDOMElement interface + NS_FORWARD_IDOMELEMENT(mOuter->); + + // nsIDOMXULElement interface + NS_FORWARD_IDOMXULELEMENT(mOuter->); + + // nsIDOMXULCheckboxElement interface + NS_DECL_IDOMXULCHECKBOXELEMENT +}; + + +#endif // nsXULCheckboxElement_h__ diff --git a/mozilla/rdf/content/src/nsXULElement.cpp b/mozilla/rdf/content/src/nsXULElement.cpp index 8711f0410ba..3e7536a439c 100644 --- a/mozilla/rdf/content/src/nsXULElement.cpp +++ b/mozilla/rdf/content/src/nsXULElement.cpp @@ -93,6 +93,11 @@ #include "nsXULEditorElement.h" #include "nsXULTreeElement.h" #include "nsXULPopupElement.h" +#include "nsXULTitledButtonElement.h" +#include "nsXULCheckboxElement.h" +#include "nsXULRadioElement.h" +#include "nsXULMenuListElement.h" + #include "prlog.h" #include "rdf.h" #include "rdfutil.h" @@ -288,6 +293,11 @@ nsIAtom* nsXULElement::kBrowserAtom; nsIAtom* nsXULElement::kEditorAtom; nsIAtom* nsXULElement::kWidthAtom; nsIAtom* nsXULElement::kWindowAtom; +nsIAtom* nsXULElement::kNullAtom; +nsIAtom* nsXULElement::kCheckboxAtom; +nsIAtom* nsXULElement::kRadioAtom; +nsIAtom* nsXULElement::kMenuListAtom; +nsIAtom* nsXULElement::kMenuButtonAtom; #ifdef XUL_PROTOTYPE_ATTRIBUTE_METERING PRUint32 nsXULPrototypeAttribute::gNumElements; @@ -355,6 +365,11 @@ nsXULElement::Init() kEditorAtom = NS_NewAtom("editor"); kWidthAtom = NS_NewAtom("width"); kWindowAtom = NS_NewAtom("window"); + kCheckboxAtom = NS_NewAtom("checkbox"); + kRadioAtom = NS_NewAtom("radio"); + kMenuListAtom = NS_NewAtom("menulist"); + kMenuButtonAtom = NS_NewAtom("menubutton"); + kNullAtom = NS_NewAtom(""); rv = nsComponentManager::CreateInstance(kNameSpaceManagerCID, nsnull, @@ -432,6 +447,11 @@ nsXULElement::~nsXULElement() NS_IF_RELEASE(kEditorAtom); NS_IF_RELEASE(kWidthAtom); NS_IF_RELEASE(kWindowAtom); + NS_IF_RELEASE(kCheckboxAtom); + NS_IF_RELEASE(kRadioAtom); + NS_IF_RELEASE(kMenuListAtom); + NS_IF_RELEASE(kMenuButtonAtom); + NS_IF_RELEASE(kNullAtom); NS_IF_RELEASE(gNameSpaceManager); @@ -660,6 +680,62 @@ nsXULElement::QueryInterface(REFNSIID iid, void** result) return InnerXULElement()->QueryInterface(iid, result); } + else if (iid.Equals(NS_GET_IID(nsIDOMXULTitledButtonElement)) && + (NameSpaceID() == kNameSpaceID_XUL) && + (Tag() == kTitledButtonAtom)) { + // We delegate XULTitledButtonElement APIs to an aggregate object + if (! InnerXULElement()) { + rv = EnsureSlots(); + if (NS_FAILED(rv)) return rv; + + if ((mSlots->mInnerXULElement = new nsXULTitledButtonElement(this)) == nsnull) + return NS_ERROR_OUT_OF_MEMORY; + } + + return InnerXULElement()->QueryInterface(iid, result); + } + else if (iid.Equals(NS_GET_IID(nsIDOMXULCheckboxElement)) && + (NameSpaceID() == kNameSpaceID_XUL) && + (Tag() == kCheckboxAtom)) { + // We delegate XULCheckboxElement APIs to an aggregate object + if (! InnerXULElement()) { + rv = EnsureSlots(); + if (NS_FAILED(rv)) return rv; + + if ((mSlots->mInnerXULElement = new nsXULCheckboxElement(this)) == nsnull) + return NS_ERROR_OUT_OF_MEMORY; + } + + return InnerXULElement()->QueryInterface(iid, result); + } + else if (iid.Equals(NS_GET_IID(nsIDOMXULRadioElement)) && + (NameSpaceID() == kNameSpaceID_XUL) && + (Tag() == kRadioAtom)) { + // We delegate XULRadioElement APIs to an aggregate object + if (! InnerXULElement()) { + rv = EnsureSlots(); + if (NS_FAILED(rv)) return rv; + + if ((mSlots->mInnerXULElement = new nsXULRadioElement(this)) == nsnull) + return NS_ERROR_OUT_OF_MEMORY; + } + + return InnerXULElement()->QueryInterface(iid, result); + } + else if (iid.Equals(NS_GET_IID(nsIDOMXULMenuListElement)) && + (NameSpaceID() == kNameSpaceID_XUL) && + (Tag() == kMenuListAtom)) { + // We delegate XULMenuListElement APIs to an aggregate object + if (! InnerXULElement()) { + rv = EnsureSlots(); + if (NS_FAILED(rv)) return rv; + + if ((mSlots->mInnerXULElement = new nsXULMenuListElement(this)) == nsnull) + return NS_ERROR_OUT_OF_MEMORY; + } + + return InnerXULElement()->QueryInterface(iid, result); + } else if (iid.Equals(NS_GET_IID(nsIDOMXULEditorElement)) && (NameSpaceID() == kNameSpaceID_XUL) && (Tag() == kEditorAtom)) { @@ -1700,6 +1776,22 @@ nsXULElement::GetScriptObject(nsIScriptContext* aContext, void** aScriptObject) fn = NS_NewScriptXULBrowserElement; rootname = "nsXULBrowserElement::mScriptObject"; } + else if (Tag() == kTitledButtonAtom) { + fn = NS_NewScriptXULTitledButtonElement; + rootname = "nsXULTitledButtonElement::mScriptObject"; + } + else if (Tag() == kCheckboxAtom) { + fn = NS_NewScriptXULCheckboxElement; + rootname = "nsXULCheckboxElement::mScriptObject"; + } + else if (Tag() == kRadioAtom) { + fn = NS_NewScriptXULRadioElement; + rootname = "nsXULRadioElement::mScriptObject"; + } + else if (Tag() == kMenuListAtom) { + fn = NS_NewScriptXULMenuListElement; + rootname = "nsXULMenuListElement::mScriptObject"; + } else if (Tag() == kEditorAtom) { fn = NS_NewScriptXULEditorElement; rootname = "nsXULEditorElement::mScriptObject"; @@ -3850,7 +3942,8 @@ nsXULElement::RemoveFocus(nsIPresContext* aPresContext) PRBool nsXULElement::IsFocusableContent() { - return (Tag() == kTitledButtonAtom) || (Tag() == kTreeAtom); + return (Tag() == kTitledButtonAtom) || (Tag() == kTreeAtom) || (Tag() == kCheckboxAtom) || (Tag() == kRadioAtom) || + (Tag() == kMenuListAtom) || (Tag() == kMenuButtonAtom); } // nsIBindableContent Interface diff --git a/mozilla/rdf/content/src/nsXULElement.h b/mozilla/rdf/content/src/nsXULElement.h index 38ce4248b78..ada726b92b6 100644 --- a/mozilla/rdf/content/src/nsXULElement.h +++ b/mozilla/rdf/content/src/nsXULElement.h @@ -342,6 +342,8 @@ protected: static nsIAtom* kSelectedAtom; static nsIAtom* kStyleAtom; static nsIAtom* kTitledButtonAtom; + static nsIAtom* kCheckboxAtom; + static nsIAtom* kRadioAtom; static nsIAtom* kTooltipAtom; static nsIAtom* kTreeAtom; static nsIAtom* kTreeCellAtom; @@ -355,6 +357,9 @@ protected: static nsIAtom* kEditorAtom; static nsIAtom* kWidthAtom; static nsIAtom* kWindowAtom; + static nsIAtom* kMenuButtonAtom; + static nsIAtom* kMenuListAtom; + static nsIAtom* kNullAtom; public: static nsresult diff --git a/mozilla/rdf/content/src/nsXULMenuListElement.cpp b/mozilla/rdf/content/src/nsXULMenuListElement.cpp new file mode 100644 index 00000000000..c778522a85f --- /dev/null +++ b/mozilla/rdf/content/src/nsXULMenuListElement.cpp @@ -0,0 +1,170 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * 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. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + */ + +/* + + Implementation methods for the XULMenuList element APIs. + +*/ + +#include "nsCOMPtr.h" +#include "nsRDFCID.h" +#include "nsXULMenuListElement.h" +#include "nsIContent.h" +#include "nsIDocument.h" +#include "nsIPresContext.h" +#include "nsIPresShell.h" +#include "nsINameSpaceManager.h" +#include "nsIServiceManager.h" +#include "nsString.h" +#include "nsIPopupSetFrame.h" +#include "nsIMenuFrame.h" +#include "nsIFrame.h" + +NS_IMPL_ADDREF_INHERITED(nsXULMenuListElement, nsXULAggregateElement); +NS_IMPL_RELEASE_INHERITED(nsXULMenuListElement, nsXULAggregateElement); + +nsresult +nsXULMenuListElement::QueryInterface(REFNSIID aIID, void** aResult) +{ + NS_PRECONDITION(aResult != nsnull, "null ptr"); + if (! aResult) + return NS_ERROR_NULL_POINTER; + + if (aIID.Equals(NS_GET_IID(nsIDOMXULMenuListElement))) { + *aResult = NS_STATIC_CAST(nsIDOMXULMenuListElement*, this); + } + else { + return nsXULAggregateElement::QueryInterface(aIID, aResult); + } + + NS_ADDREF(NS_REINTERPRET_CAST(nsISupports*, *aResult)); + return NS_OK; +} + +MOZ_DECL_CTOR_COUNTER(RDF_nsXULMenuListElement); + +nsXULMenuListElement::nsXULMenuListElement(nsIDOMXULElement* aOuter) + : nsXULAggregateElement(aOuter) +{ +} + +nsXULMenuListElement::~nsXULMenuListElement() +{ +} + +NS_IMETHODIMP +nsXULMenuListElement::GetValue(nsString& aValue) +{ + return mOuter->GetAttribute("value", aValue); +} + +NS_IMETHODIMP +nsXULMenuListElement::SetValue(const nsString& aValue) +{ + return mOuter->SetAttribute("value", aValue); +} + +NS_IMETHODIMP +nsXULMenuListElement::GetCrop(nsString& aCrop) +{ + return mOuter->GetAttribute("crop", aCrop); +} + +NS_IMETHODIMP +nsXULMenuListElement::SetCrop(const nsString& aCrop) +{ + return mOuter->SetAttribute("crop", aCrop); +} + +NS_IMETHODIMP +nsXULMenuListElement::GetSrc(nsString& aSrc) +{ + return mOuter->GetAttribute("src", aSrc); +} + +NS_IMETHODIMP +nsXULMenuListElement::SetSrc(const nsString& aSrc) +{ + return mOuter->SetAttribute("src", aSrc); +} + +NS_IMETHODIMP +nsXULMenuListElement::GetData(nsString& aData) +{ + return mOuter->GetAttribute("data", aData); +} + +NS_IMETHODIMP +nsXULMenuListElement::SetData(const nsString& aData) +{ + return mOuter->SetAttribute("data", aData); +} + +NS_IMETHODIMP +nsXULMenuListElement::GetDisabled(PRBool* aDisabled) +{ + nsAutoString value; + mOuter->GetAttribute("disabled", value); + if(value == "true") + *aDisabled = PR_TRUE; + else + *aDisabled = PR_FALSE; + + return NS_OK; +} + +NS_IMETHODIMP +nsXULMenuListElement::SetDisabled(PRBool aDisabled) +{ + if(aDisabled) + mOuter->SetAttribute("disabled", "true"); + else + mOuter->RemoveAttribute("disabled"); + + return NS_OK; +} + +NS_IMETHODIMP +nsXULMenuListElement::GetSelectedItem(nsIDOMElement** aResult) +{ + *aResult = mSelectedItem; + NS_IF_ADDREF(*aResult); + + return NS_OK; +} + +NS_IMETHODIMP +nsXULMenuListElement::SetSelectedItem(nsIDOMElement* aElement) +{ + mSelectedItem = aElement; + nsAutoString value, src, data; + aElement->GetAttribute(nsAutoString("value"), value); + aElement->GetAttribute(nsAutoString("src"), src); + aElement->GetAttribute(nsAutoString("data"), data); + mOuter->SetAttribute(nsAutoString("value"), value); + mOuter->SetAttribute(nsAutoString("src"), src); + mOuter->SetAttribute(nsAutoString("data"), data); + + return NS_OK; +} + diff --git a/mozilla/rdf/content/src/nsXULMenuListElement.h b/mozilla/rdf/content/src/nsXULMenuListElement.h new file mode 100644 index 00000000000..5110c613f55 --- /dev/null +++ b/mozilla/rdf/content/src/nsXULMenuListElement.h @@ -0,0 +1,62 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * 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. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + */ + +/* + + An aggregate object that implements the XUL MenuList widget APIs + +*/ + +#ifndef nsXULMenuListElement_h__ +#define nsXULMenuListElement_h__ + +#include "nsCOMPtr.h" +#include "nsXULElement.h" +#include "nsIDOMXULMenuListElement.h" + +class nsXULMenuListElement : public nsXULAggregateElement, + public nsIDOMXULMenuListElement +{ +public: + nsXULMenuListElement(nsIDOMXULElement* aOuter); + ~nsXULMenuListElement(); + + NS_DECL_ISUPPORTS_INHERITED + + // nsIDOMNode interface + NS_FORWARD_IDOMNODE(mOuter->); + + // nsIDOMElement interface + NS_FORWARD_IDOMELEMENT(mOuter->); + + // nsIDOMXULElement interface + NS_FORWARD_IDOMXULELEMENT(mOuter->); + + // nsIDOMXULMenuListElement interface + NS_DECL_IDOMXULMENULISTELEMENT + +protected: + nsCOMPtr mSelectedItem; +}; + + +#endif // nsXULMenuListElement_h__ diff --git a/mozilla/rdf/content/src/nsXULRadioElement.cpp b/mozilla/rdf/content/src/nsXULRadioElement.cpp new file mode 100644 index 00000000000..7ca8105e9a2 --- /dev/null +++ b/mozilla/rdf/content/src/nsXULRadioElement.cpp @@ -0,0 +1,182 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * 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. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + */ + +/* + + Implementation methods for the XUL radio element APIs. + +*/ + +#include "nsCOMPtr.h" +#include "nsRDFCID.h" +#include "nsXULRadioElement.h" +#include "nsIContent.h" +#include "nsIDocument.h" +#include "nsIPresContext.h" +#include "nsIPresShell.h" +#include "nsINameSpaceManager.h" +#include "nsIServiceManager.h" +#include "nsString.h" +//#include "nsIPopupSetFrame.h" +//#include "nsIMenuFrame.h" +//#include "nsIFrame.h" + +NS_IMPL_ADDREF_INHERITED(nsXULRadioElement, nsXULAggregateElement); +NS_IMPL_RELEASE_INHERITED(nsXULRadioElement, nsXULAggregateElement); + +nsresult +nsXULRadioElement::QueryInterface(REFNSIID aIID, void** aResult) +{ + NS_PRECONDITION(aResult != nsnull, "null ptr"); + if (! aResult) + return NS_ERROR_NULL_POINTER; + + if (aIID.Equals(NS_GET_IID(nsIDOMXULRadioElement))) { + *aResult = NS_STATIC_CAST(nsIDOMXULRadioElement*, this); + } + else { + return nsXULAggregateElement::QueryInterface(aIID, aResult); + } + + NS_ADDREF(NS_REINTERPRET_CAST(nsISupports*, *aResult)); + return NS_OK; +} + +MOZ_DECL_CTOR_COUNTER(RDF_nsXULRadioElement); + +nsXULRadioElement::nsXULRadioElement(nsIDOMXULElement* aOuter) + : nsXULAggregateElement(aOuter) +{ +} + +nsXULRadioElement::~nsXULRadioElement() +{ +} + +NS_IMETHODIMP +nsXULRadioElement::GetValue(nsString& aValue) +{ + return mOuter->GetAttribute("value", aValue); +} + +NS_IMETHODIMP +nsXULRadioElement::SetValue(const nsString& aValue) +{ + return mOuter->SetAttribute("value", aValue); +} + +NS_IMETHODIMP +nsXULRadioElement::GetCrop(nsString& aCrop) +{ + return mOuter->GetAttribute("crop", aCrop); +} + +NS_IMETHODIMP +nsXULRadioElement::SetCrop(const nsString& aCrop) +{ + return mOuter->SetAttribute("crop", aCrop); +} + +NS_IMETHODIMP +nsXULRadioElement::GetSrc(nsString& aSrc) +{ + return mOuter->GetAttribute("src", aSrc); +} + +NS_IMETHODIMP +nsXULRadioElement::SetSrc(const nsString& aSrc) +{ + return mOuter->SetAttribute("src", aSrc); +} + +NS_IMETHODIMP +nsXULRadioElement::GetImgalign(nsString& aImgalign) +{ + return mOuter->GetAttribute("imgalign", aImgalign); +} + +NS_IMETHODIMP +nsXULRadioElement::SetImgalign(const nsString& aImgalign) +{ + return mOuter->SetAttribute("imgalign", aImgalign); +} + +NS_IMETHODIMP +nsXULRadioElement::GetAccesskey(nsString& aAccesskey) +{ + return mOuter->GetAttribute("accesskey", aAccesskey); +} + +NS_IMETHODIMP +nsXULRadioElement::SetAccesskey(const nsString& aAccesskey) +{ + return mOuter->SetAttribute("accesskey", aAccesskey); +} + +NS_IMETHODIMP +nsXULRadioElement::GetChecked(PRBool* aChecked) +{ + nsAutoString value; + mOuter->GetAttribute("checked", value); + if(value == "true") + *aChecked = PR_TRUE; + else + *aChecked = PR_FALSE; + + return NS_OK; +} + +NS_IMETHODIMP +nsXULRadioElement::SetChecked(PRBool aChecked) +{ + if(aChecked) + mOuter->SetAttribute("checked", "true"); + else + mOuter->RemoveAttribute("checked"); + + return NS_OK; +} + + +NS_IMETHODIMP +nsXULRadioElement::GetDisabled(PRBool* aDisabled) +{ + nsAutoString value; + mOuter->GetAttribute("disabled", value); + if(value == "true") + *aDisabled = PR_TRUE; + else + *aDisabled = PR_FALSE; + + return NS_OK; +} + +NS_IMETHODIMP +nsXULRadioElement::SetDisabled(PRBool aDisabled) +{ + if(aDisabled) + mOuter->SetAttribute("disabled", "true"); + else + mOuter->RemoveAttribute("disabled"); + + return NS_OK; +} \ No newline at end of file diff --git a/mozilla/rdf/content/src/nsXULRadioElement.h b/mozilla/rdf/content/src/nsXULRadioElement.h new file mode 100644 index 00000000000..230c70d347b --- /dev/null +++ b/mozilla/rdf/content/src/nsXULRadioElement.h @@ -0,0 +1,58 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * 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. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + */ + +/* + + An aggregate object that implements the XUL Radio widget APIs + +*/ + +#ifndef nsXULRadioElement_h__ +#define nsXULRadioElement_h__ + +#include "nsXULElement.h" +#include "nsIDOMXULRadioElement.h" + +class nsXULRadioElement : public nsXULAggregateElement, + public nsIDOMXULRadioElement +{ +public: + nsXULRadioElement(nsIDOMXULElement* aOuter); + ~nsXULRadioElement(); + + NS_DECL_ISUPPORTS_INHERITED + + // nsIDOMNode interface + NS_FORWARD_IDOMNODE(mOuter->); + + // nsIDOMElement interface + NS_FORWARD_IDOMELEMENT(mOuter->); + + // nsIDOMXULElement interface + NS_FORWARD_IDOMXULELEMENT(mOuter->); + + // nsIDOMXULRadioElement interface + NS_DECL_IDOMXULRADIOELEMENT +}; + + +#endif // nsXULRadioElement_h__ diff --git a/mozilla/rdf/content/src/nsXULTitledButtonElement.cpp b/mozilla/rdf/content/src/nsXULTitledButtonElement.cpp new file mode 100644 index 00000000000..26b7d2e3031 --- /dev/null +++ b/mozilla/rdf/content/src/nsXULTitledButtonElement.cpp @@ -0,0 +1,157 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * 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. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + */ + +/* + + Implementation methods for the XULTitledButton element APIs. + +*/ + +#include "nsCOMPtr.h" +#include "nsRDFCID.h" +#include "nsXULTitledButtonElement.h" +#include "nsIContent.h" +#include "nsIDocument.h" +#include "nsIPresContext.h" +#include "nsIPresShell.h" +#include "nsINameSpaceManager.h" +#include "nsIServiceManager.h" +#include "nsString.h" +#include "nsIPopupSetFrame.h" +#include "nsIMenuFrame.h" +#include "nsIFrame.h" + +NS_IMPL_ADDREF_INHERITED(nsXULTitledButtonElement, nsXULAggregateElement); +NS_IMPL_RELEASE_INHERITED(nsXULTitledButtonElement, nsXULAggregateElement); + +nsresult +nsXULTitledButtonElement::QueryInterface(REFNSIID aIID, void** aResult) +{ + NS_PRECONDITION(aResult != nsnull, "null ptr"); + if (! aResult) + return NS_ERROR_NULL_POINTER; + + if (aIID.Equals(NS_GET_IID(nsIDOMXULTitledButtonElement))) { + *aResult = NS_STATIC_CAST(nsIDOMXULTitledButtonElement*, this); + } + else { + return nsXULAggregateElement::QueryInterface(aIID, aResult); + } + + NS_ADDREF(NS_REINTERPRET_CAST(nsISupports*, *aResult)); + return NS_OK; +} + +MOZ_DECL_CTOR_COUNTER(RDF_nsXULTitledButtonElement); + +nsXULTitledButtonElement::nsXULTitledButtonElement(nsIDOMXULElement* aOuter) + : nsXULAggregateElement(aOuter) +{ +} + +nsXULTitledButtonElement::~nsXULTitledButtonElement() +{ +} + +NS_IMETHODIMP +nsXULTitledButtonElement::GetValue(nsString& aValue) +{ + return mOuter->GetAttribute("value", aValue); +} + +NS_IMETHODIMP +nsXULTitledButtonElement::SetValue(const nsString& aValue) +{ + return mOuter->SetAttribute("value", aValue); +} + +NS_IMETHODIMP +nsXULTitledButtonElement::GetCrop(nsString& aCrop) +{ + return mOuter->GetAttribute("crop", aCrop); +} + +NS_IMETHODIMP +nsXULTitledButtonElement::SetCrop(const nsString& aCrop) +{ + return mOuter->SetAttribute("crop", aCrop); +} + +NS_IMETHODIMP +nsXULTitledButtonElement::GetSrc(nsString& aSrc) +{ + return mOuter->GetAttribute("src", aSrc); +} + +NS_IMETHODIMP +nsXULTitledButtonElement::SetSrc(const nsString& aSrc) +{ + return mOuter->SetAttribute("src", aSrc); +} + +NS_IMETHODIMP +nsXULTitledButtonElement::GetImgalign(nsString& aImgalign) +{ + return mOuter->GetAttribute("imgalign", aImgalign); +} + +NS_IMETHODIMP +nsXULTitledButtonElement::SetImgalign(const nsString& aImgalign) +{ + return mOuter->SetAttribute("imgalign", aImgalign); +} + +NS_IMETHODIMP +nsXULTitledButtonElement::GetAccesskey(nsString& aAccesskey) +{ + return mOuter->GetAttribute("accesskey", aAccesskey); +} + +NS_IMETHODIMP +nsXULTitledButtonElement::SetAccesskey(const nsString& aAccesskey) +{ + return mOuter->SetAttribute("accesskey", aAccesskey); +} + +NS_IMETHODIMP +nsXULTitledButtonElement::GetDisabled(PRBool* aDisabled) +{ + nsAutoString value; + mOuter->GetAttribute("disabled", value); + if(value == "true") + *aDisabled = PR_TRUE; + else + *aDisabled = PR_FALSE; + + return NS_OK; +} + +NS_IMETHODIMP +nsXULTitledButtonElement::SetDisabled(PRBool aDisabled) +{ + if(aDisabled) + mOuter->SetAttribute("disabled", "true"); + else + mOuter->RemoveAttribute("disabled"); + + return NS_OK; +} \ No newline at end of file diff --git a/mozilla/rdf/content/src/nsXULTitledButtonElement.h b/mozilla/rdf/content/src/nsXULTitledButtonElement.h new file mode 100644 index 00000000000..7390db377d8 --- /dev/null +++ b/mozilla/rdf/content/src/nsXULTitledButtonElement.h @@ -0,0 +1,60 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * 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. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + */ + +/* + + An aggregate object that implements the XUL titledbutton widget APIs + +*/ + +#ifndef nsXULTitledButtonElement_h__ +#define nsXULTitledButtonElement_h__ + +#include "nsXULElement.h" +#include "nsIDOMXULTitledButtonElement.h" + +class nsXULTitledButtonElement : public nsXULAggregateElement, + public nsIDOMXULTitledButtonElement +{ +public: + nsXULTitledButtonElement(nsIDOMXULElement* aOuter); + ~nsXULTitledButtonElement(); + + NS_DECL_ISUPPORTS_INHERITED + + // nsIDOMNode interface + NS_FORWARD_IDOMNODE(mOuter->); + + // nsIDOMElement interface + NS_FORWARD_IDOMELEMENT(mOuter->); + + // nsIDOMXULElement interface + NS_FORWARD_IDOMXULELEMENT(mOuter->); + + // nsIDOMXULTitledButtonElement interface + NS_DECL_IDOMXULTITLEDBUTTONELEMENT + +protected: +}; + + +#endif // nsXULTitledButtonElement_h__ diff --git a/mozilla/xpfe/global/resources/skin/global.css b/mozilla/xpfe/global/resources/skin/global.css index d3921dd8c36..2b7561c7da3 100644 --- a/mozilla/xpfe/global/resources/skin/global.css +++ b/mozilla/xpfe/global/resources/skin/global.css @@ -938,6 +938,80 @@ menu[menuactive="true"] > .menu-right { list-style-image: url("chrome://global/skin/menu-arrow-hover.gif"); } + +menulist, menubutton { + padding: 1px 0px 1px 0px; +} + +menulist > .menu-text, +menubutton > .menu-text { + padding-left: 4px; + padding-right: 4px; + border: 1px inset #CCCCCC; +} + +menubutton > .menu-button { + border: 1px outset #CCCCCC; + padding: 2px; +} + +menubutton > .menu-button:active { + border: 1px inset #CCCCCC; + padding: 3px 1px 1px 3px; +} + + +menubutton > .menu-dropmarker, +menulist > .menu-dropmarker { + border: 1px outset #CCCCCC; + list-style-image: url("chrome://global/skin/scroll-down.gif"); + padding: 0px 2px 0px 2px; +} + +menubutton[open="true"] > .menu-dropmarker, +menulist[open="true"] > .menu-dropmarker { + border: 1px inset #CCCCCC; + padding: 1px 1px -1px 3px; +} + +menubutton menupopup, menulist menupopup { + border: 1px outset #CCCCCC; +} + +menulist[editable="true"] { + padding: 0px; +} + +menulist[editable="true"] > .menu-text { + border-left: none; + border-top: 1px inset #CCCCCC; + border-right: 1px inset #CCCCCC; + border-bottom: 1px inset #CCCCCC; + margin: 0px 2px 0px 0px; +} + +menulist[editable="true"] > .menu-dropmarker { + border: 1px outset #CCCCCC; +} + +menulist[editable="true"][open="true"] > .menu-dropmarker { + border: 1px inset #CCCCCC; +} + +menulist[editable="true"] > .menu-icon { + list-style-image: url("chrome://bookmarks/skin/bookmark-item.gif"); + background-color: white; + padding: 1px; + border-left: 1px inset #CCCCCC; + border-top: 1px inset #CCCCCC; + border-right: none; + border-bottom: 1px inset #CCCCCC; +} + +menulist menupopup > menuseparator { + border-bottom: 2px groove #CCCCCC; +} + /******** Rules for menus on the standard toolbars ***************/ menu.standard { diff --git a/mozilla/xpfe/global/resources/skin/xul.css b/mozilla/xpfe/global/resources/skin/xul.css index 41c42125f0d..02957a8257e 100644 --- a/mozilla/xpfe/global/resources/skin/xul.css +++ b/mozilla/xpfe/global/resources/skin/xul.css @@ -8,6 +8,10 @@ @namespace url(http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul); /* set default namespace to XUL */ +* { + display: block; +} + /** * All elements that have no visual representation */ @@ -170,6 +174,18 @@ menuseparator[hidden="true"] { display: none; } +menulist { + behavior: url("resource:/chrome/xulBindings.xml#menulist"); +} + +menulist[editable="true"] { + behavior: url("resource:/chrome/xulBindings.xml#menulist-editable"); +} + +menubutton { + behavior: url("resource:/chrome/xulBindings.xml#menubutton"); +} + /******** Titled buttons **********/ titledbutton { diff --git a/mozilla/xpfe/global/resources/skin/xulBindings.xml b/mozilla/xpfe/global/resources/skin/xulBindings.xml index 0d5bae6ae08..c05f5d41064 100644 --- a/mozilla/xpfe/global/resources/skin/xulBindings.xml +++ b/mozilla/xpfe/global/resources/skin/xulBindings.xml @@ -2,6 +2,7 @@ @@ -23,12 +24,40 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + +