mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 03:45:46 +00:00
Remove unused appcore. Replaced by JS code.
This commit is contained in:
parent
6ad46f9849
commit
4122a667f2
@ -1,511 +0,0 @@
|
||||
/* -*- 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.0 (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.
|
||||
*/
|
||||
|
||||
|
||||
#include "nsAppCoresManager.h"
|
||||
#include "nsAppShellCIDs.h"
|
||||
#include "nsIAppShellService.h"
|
||||
#include "nsIDOMBaseAppCore.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsIURL.h"
|
||||
#ifdef NECKO
|
||||
#include "nsIIOService.h"
|
||||
#include "nsIURL.h"
|
||||
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
#endif // NECKO
|
||||
#include "nsIWebShell.h"
|
||||
#include "nsIWebShellWindow.h"
|
||||
#include "nsIWidget.h"
|
||||
#include "nsDOMPropsCore.h"
|
||||
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMNamedNodeMap.h"
|
||||
//#include "nsIDOMNode.h"
|
||||
//#include <iostream.h>
|
||||
|
||||
// Stuff to implement properties dialog.
|
||||
#include "nsIDOMXULDocument.h"
|
||||
#include "nsIDocumentViewer.h"
|
||||
#include "nsIDOMHTMLImageElement.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsIXULWindowCallbacks.h"
|
||||
#include "nsIDocumentObserver.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
|
||||
class nsIScriptContext;
|
||||
|
||||
static NS_DEFINE_IID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID);
|
||||
static NS_DEFINE_IID(kIAppShellServiceIID, NS_IAPPSHELL_SERVICE_IID);
|
||||
static NS_DEFINE_IID(kIDOMBaseAppCoreIID, NS_IDOMBASEAPPCORE_IID);
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIDOMPropsCoreIID, NS_IDOMDOMPROPSCORE_IID);
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// nsPropertiesDialog
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// Note: This is only a temporary home for nsPropertiesDialog
|
||||
// It will be moving to it's own component .h/.cpp file soon.
|
||||
struct nsPropertiesDialog : public nsIXULWindowCallbacks,
|
||||
nsIDocumentObserver {
|
||||
// Declare implementation of ISupports stuff.
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// Declare implementations of nsIXULWindowCallbacks interface functions.
|
||||
NS_IMETHOD ConstructBeforeJavaScript(nsIWebShell *aWebShell);
|
||||
NS_IMETHOD ConstructAfterJavaScript(nsIWebShell *aWebShell) { return NS_OK; }
|
||||
|
||||
// Declare implementations of nsIDocumentObserver functions.
|
||||
NS_IMETHOD BeginUpdate(nsIDocument *aDocument) { return NS_OK; }
|
||||
NS_IMETHOD EndUpdate(nsIDocument *aDocument) { return NS_OK; }
|
||||
NS_IMETHOD BeginLoad(nsIDocument *aDocument) { return NS_OK; }
|
||||
NS_IMETHOD EndLoad(nsIDocument *aDocument) { return NS_OK; }
|
||||
NS_IMETHOD BeginReflow(nsIDocument *aDocument, nsIPresShell* aShell)
|
||||
{ return NS_OK; }
|
||||
NS_IMETHOD EndReflow(nsIDocument *aDocument, nsIPresShell* aShell)
|
||||
{ return NS_OK; }
|
||||
NS_IMETHOD ContentChanged(nsIDocument *aDocument,
|
||||
nsIContent* aContent,
|
||||
nsISupports* aSubContent) { return NS_OK; }
|
||||
NS_IMETHOD ContentStatesChanged(nsIDocument* aDocument,
|
||||
nsIContent* aContent1,
|
||||
nsIContent* aContent2) { return NS_OK; }
|
||||
// This one we care about; see implementation below.
|
||||
NS_IMETHOD AttributeChanged(nsIDocument *aDocument,
|
||||
nsIContent* aContent,
|
||||
nsIAtom* aAttribute,
|
||||
PRInt32 aHint);
|
||||
NS_IMETHOD ContentAppended(nsIDocument *aDocument,
|
||||
nsIContent* aContainer,
|
||||
PRInt32 aNewIndexInContainer)
|
||||
{ return NS_OK; }
|
||||
NS_IMETHOD ContentInserted(nsIDocument *aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer) { return NS_OK; }
|
||||
NS_IMETHOD ContentReplaced(nsIDocument *aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aOldChild,
|
||||
nsIContent* aNewChild,
|
||||
PRInt32 aIndexInContainer) { return NS_OK; }
|
||||
NS_IMETHOD ContentRemoved(nsIDocument *aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer) { return NS_OK; }
|
||||
NS_IMETHOD StyleSheetAdded(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet) { return NS_OK; }
|
||||
NS_IMETHOD StyleSheetRemoved(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet) { return NS_OK; }
|
||||
NS_IMETHOD StyleSheetDisabledStateChanged(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
PRBool aDisabled) { return NS_OK; }
|
||||
NS_IMETHOD StyleRuleChanged(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
nsIStyleRule* aStyleRule,
|
||||
PRInt32 aHint) { return NS_OK; }
|
||||
NS_IMETHOD StyleRuleAdded(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
nsIStyleRule* aStyleRule) { return NS_OK; }
|
||||
NS_IMETHOD StyleRuleRemoved(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
nsIStyleRule* aStyleRule) { return NS_OK; }
|
||||
NS_IMETHOD DocumentWillBeDestroyed(nsIDocument *aDocument)
|
||||
{ return NS_OK; }
|
||||
|
||||
// nsPropertiesDialog stuff
|
||||
nsPropertiesDialog( nsIDOMNode *aNode );
|
||||
virtual ~nsPropertiesDialog() {}
|
||||
//void SetWindow( nsIWebShellWindow *aWindow );
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIDOMNode> mNode;
|
||||
//nsCOMPtr<nsIWebShell> mWebShell;
|
||||
//nsCOMPtr<nsIWebShellWindow> mWindow;
|
||||
static nsIAtom *kIdAtom;
|
||||
}; // nsPropertiesDialog
|
||||
|
||||
nsIAtom *nsPropertiesDialog::kIdAtom = 0;
|
||||
|
||||
// Standard implementations of addref/release.
|
||||
NS_IMPL_ADDREF( nsPropertiesDialog );
|
||||
NS_IMPL_RELEASE( nsPropertiesDialog );
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPropertiesDialog::QueryInterface(REFNSIID aIID,void** aInstancePtr)
|
||||
{
|
||||
if (aInstancePtr == NULL) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
// Always NULL result, in case of failure
|
||||
*aInstancePtr = NULL;
|
||||
|
||||
if (aIID.Equals(nsIDocumentObserver::GetIID())) {
|
||||
*aInstancePtr = (void*) ((nsIDocumentObserver*)this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(nsIXULWindowCallbacks::GetIID())) {
|
||||
*aInstancePtr = (void*) ((nsIXULWindowCallbacks*)this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
|
||||
// ctor
|
||||
nsPropertiesDialog::nsPropertiesDialog( nsIDOMNode *aNode )
|
||||
: mNode( nsDontQueryInterface<nsIDOMNode>(aNode) ) {
|
||||
|
||||
// Initialize ref count.
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
// Initialize static atoms.
|
||||
static PRBool initialized = 0;
|
||||
if ( !initialized ) {
|
||||
kIdAtom = NS_NewAtom("id");
|
||||
initialized = 1;
|
||||
}
|
||||
}
|
||||
|
||||
static nsresult setAttribute( nsIWebShell *shell,
|
||||
const char *id,
|
||||
const nsString &name,
|
||||
const nsString &value ) {
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsCOMPtr<nsIContentViewer> cv;
|
||||
rv = shell->GetContentViewer(getter_AddRefs(cv));
|
||||
if ( cv ) {
|
||||
// Up-cast.
|
||||
nsCOMPtr<nsIDocumentViewer> docv(do_QueryInterface(cv));
|
||||
if ( docv ) {
|
||||
// Get the document from the doc viewer.
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
rv = docv->GetDocument(*getter_AddRefs(doc));
|
||||
if ( doc ) {
|
||||
// Up-cast.
|
||||
nsCOMPtr<nsIDOMXULDocument> xulDoc( do_QueryInterface(doc) );
|
||||
if ( xulDoc ) {
|
||||
// Find specified element.
|
||||
nsCOMPtr<nsIDOMElement> elem;
|
||||
rv = xulDoc->GetElementById( id, getter_AddRefs(elem) );
|
||||
if ( elem ) {
|
||||
// Set the text attribute.
|
||||
rv = elem->SetAttribute( name, value );
|
||||
if ( rv != NS_OK ) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Do startup stuff from C++ side.
|
||||
NS_IMETHODIMP
|
||||
nsPropertiesDialog::ConstructBeforeJavaScript(nsIWebShell *aWebShell) {
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// Save web shell pointer.
|
||||
//mWebShell = nsDontQueryInterface<nsIWebShell>( aWebShell );
|
||||
|
||||
// Store attributes of propeties node into dialog's DOM.
|
||||
|
||||
|
||||
nsIDOMNamedNodeMap* map;
|
||||
nsresult result = mNode->GetAttributes(&map);
|
||||
|
||||
if (NS_OK == result) {
|
||||
nsIDOMNode *node;
|
||||
PRUint32 attr_count;
|
||||
|
||||
result = map->GetLength(&attr_count);
|
||||
if (NS_OK == result) {
|
||||
for (PRUint32 ii=0; ii<attr_count; ii++) {
|
||||
result = map->Item(ii,&node);
|
||||
if (NS_OK == result) {
|
||||
nsString name;
|
||||
result = node->GetNodeName(name);
|
||||
if (NS_OK == result) {
|
||||
nsString value;
|
||||
result = node->GetNodeValue(value);
|
||||
if (NS_OK == result) {
|
||||
if (name == "id") {
|
||||
name = "url";
|
||||
}
|
||||
setAttribute( aWebShell, "properties_node", name, value );
|
||||
//cout << "BM Props: " << "name=" << name << " value=" << value << endl;
|
||||
}
|
||||
}
|
||||
NS_RELEASE(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
NS_RELEASE(map);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Add as observer of the xul document.
|
||||
nsCOMPtr<nsIContentViewer> cv;
|
||||
rv = aWebShell->GetContentViewer(getter_AddRefs(cv));
|
||||
if ( cv ) {
|
||||
// Up-cast.
|
||||
nsCOMPtr<nsIDocumentViewer> docv(do_QueryInterface(cv));
|
||||
if ( docv ) {
|
||||
// Get the document from the doc viewer.
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
rv = docv->GetDocument(*getter_AddRefs(doc));
|
||||
if ( doc ) {
|
||||
doc->AddObserver( this );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Trigger dialog startup code.
|
||||
setAttribute( aWebShell, "dialog.start", "ready", "true" );
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Handle attribute changing; we only care about the element "data.execute"
|
||||
// which is used to signal command execution from the UI.
|
||||
NS_IMETHODIMP
|
||||
nsPropertiesDialog::AttributeChanged( nsIDocument *aDocument,
|
||||
nsIContent* aContent,
|
||||
nsIAtom* aAttribute,
|
||||
PRInt32 aHint ) {
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsString id;
|
||||
aContent->GetAttribute( kNameSpaceID_None, kIdAtom, id );
|
||||
if ( id == "properties_node" ) {
|
||||
//cout << "BM properties node changed" << endl;
|
||||
|
||||
nsIDOMNamedNodeMap* map;
|
||||
nsresult result = mNode->GetAttributes(&map);
|
||||
|
||||
if (NS_OK == result) {
|
||||
nsIDOMNode *attr_node;
|
||||
PRUint32 attr_count;
|
||||
|
||||
result = map->GetLength(&attr_count);
|
||||
if (NS_OK == result) {
|
||||
for (PRUint32 ii=0; ii<attr_count; ii++) {
|
||||
result = map->Item(ii,&attr_node);
|
||||
if (NS_OK == result) {
|
||||
nsString name;
|
||||
result = attr_node->GetNodeName(name);
|
||||
if (NS_OK == result && name != "id") {
|
||||
nsString attr;
|
||||
nsIAtom *atom = NS_NewAtom(name);
|
||||
aContent->GetAttribute( kNameSpaceID_None, atom, attr );
|
||||
//cerr << "BM Props: name=" << name << " value=" << attr << " (setting)" << endl;
|
||||
attr_node->SetNodeValue(attr);
|
||||
//attr_node->SetNodeValue("something");
|
||||
NS_RELEASE(atom);
|
||||
}
|
||||
NS_RELEASE(attr_node);
|
||||
}
|
||||
}
|
||||
}
|
||||
NS_RELEASE(map);
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// nsDOMPropsCore
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsDOMPropsCore::nsDOMPropsCore() {
|
||||
|
||||
printf("Created nsDOMPropsCore\n");
|
||||
|
||||
IncInstanceCount();
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
nsDOMPropsCore::~nsDOMPropsCore() {
|
||||
DecInstanceCount();
|
||||
}
|
||||
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsDOMPropsCore, nsBaseAppCore)
|
||||
NS_IMPL_RELEASE_INHERITED(nsDOMPropsCore, nsBaseAppCore)
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMPropsCore::QueryInterface(REFNSIID aIID, void** aInstancePtr) {
|
||||
|
||||
if (aInstancePtr == NULL)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aInstancePtr = NULL;
|
||||
|
||||
if (aIID.Equals(kIDOMPropsCoreIID)) {
|
||||
*aInstancePtr = (void*) ((nsIDOMDOMPropsCore*) this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return nsBaseAppCore::QueryInterface(aIID, aInstancePtr);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMPropsCore::GetScriptObject(nsIScriptContext *aContext, void** aScriptObject) {
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
NS_PRECONDITION(aScriptObject != nsnull, "null arg");
|
||||
if (mScriptObject == nsnull) {
|
||||
nsISupports *core;
|
||||
rv = QueryInterface(kISupportsIID, (void **)&core);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = NS_NewScriptDOMPropsCore(aContext,
|
||||
(nsISupports *) core,
|
||||
nsnull,
|
||||
&mScriptObject);
|
||||
NS_RELEASE(core);
|
||||
}
|
||||
}
|
||||
|
||||
*aScriptObject = mScriptObject;
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMPropsCore::Init(const nsString& aId) {
|
||||
|
||||
nsresult rv;
|
||||
|
||||
nsBaseAppCore::Init(aId);
|
||||
|
||||
nsIDOMBaseAppCore *core;
|
||||
rv = QueryInterface(kIDOMBaseAppCoreIID, (void **)&core);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsAppCoresManager* sdm = new nsAppCoresManager();
|
||||
if (sdm) {
|
||||
sdm->Add(core);
|
||||
delete sdm;
|
||||
return NS_OK;
|
||||
} else
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_RELEASE(core);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMPropsCore::GetNode(nsIDOMNode** aNode) {
|
||||
nsresult err = NS_OK;
|
||||
return err;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMPropsCore::SetNode(nsIDOMNode* aNode) {
|
||||
nsresult err = NS_OK;
|
||||
return err;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMPropsCore::ShowProperties(const nsString& aUrl, nsIDOMWindow* aParent, nsIDOMNode* aNode) {
|
||||
|
||||
nsresult rv;
|
||||
nsIAppShellService *appShell;
|
||||
|
||||
nsCOMPtr<nsIURI> urlObj;
|
||||
#ifndef NECKO
|
||||
rv = NS_NewURL(getter_AddRefs(urlObj), aUrl);
|
||||
#else
|
||||
NS_WITH_SERVICE(nsIIOService, service, kIOServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsIURI *uri = nsnull;
|
||||
char *uriStr = aUrl.ToNewCString();
|
||||
if (!uriStr) return NS_ERROR_OUT_OF_MEMORY;
|
||||
rv = service->NewURI(uriStr, nsnull, &uri);
|
||||
nsCRT::free(uriStr);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = uri->QueryInterface(nsIURI::GetIID(), (void**)&urlObj);
|
||||
NS_RELEASE(uri);
|
||||
#endif // NECKO
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
rv = nsServiceManager::GetService(kAppShellServiceCID, kIAppShellServiceIID,
|
||||
(nsISupports**) &appShell);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
|
||||
nsPropertiesDialog *dialog = new nsPropertiesDialog(aNode);
|
||||
|
||||
nsCOMPtr<nsIWebShellWindow> parent = DOMWindowToWebShellWindow(aParent);
|
||||
|
||||
nsCOMPtr<nsIWebShellWindow> newWindow;
|
||||
rv = appShell->CreateTopLevelWindow(parent, urlObj, PR_TRUE, getter_AddRefs(newWindow),
|
||||
nsnull, dialog, NS_SIZETOCONTENT, NS_SIZETOCONTENT);
|
||||
|
||||
nsServiceManager::ReleaseService(kAppShellServiceCID, appShell);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMPropsCore::Commit() {
|
||||
nsresult rv = NS_OK;
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMPropsCore::Cancel() {
|
||||
nsresult rv = NS_OK;
|
||||
return rv;
|
||||
}
|
||||
|
||||
// horribly complicated routine to simply convert from one to the other
|
||||
nsCOMPtr<nsIWebShellWindow>
|
||||
nsDOMPropsCore::DOMWindowToWebShellWindow(nsIDOMWindow *DOMWindow) const {
|
||||
|
||||
nsCOMPtr<nsIWebShellWindow> webWindow;
|
||||
|
||||
nsCOMPtr<nsIScriptGlobalObject> globalScript(do_QueryInterface(DOMWindow));
|
||||
nsCOMPtr<nsIWebShell> webshell;
|
||||
if (globalScript)
|
||||
globalScript->GetWebShell(getter_AddRefs(webshell));
|
||||
if (webshell) {
|
||||
nsCOMPtr<nsIWebShellContainer> webshellContainer;
|
||||
webshell->GetContainer(*getter_AddRefs(webshellContainer));
|
||||
webWindow = do_QueryInterface(webshellContainer);
|
||||
}
|
||||
return webWindow;
|
||||
}
|
@ -1,469 +0,0 @@
|
||||
/* -*- 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.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/* AUTO-GENERATED. DO NOT EDIT!!! */
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "nsJSUtils.h"
|
||||
#include "nscore.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIJSScriptObject.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMDOMPropsCore.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsIScriptNameSpaceManager.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsDOMCID.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(kINodeIID, NS_IDOMNODE_IID);
|
||||
static NS_DEFINE_IID(kIDOMPropsCoreIID, NS_IDOMDOMPROPSCORE_IID);
|
||||
static NS_DEFINE_IID(kIWindowIID, NS_IDOMWINDOW_IID);
|
||||
|
||||
NS_DEF_PTR(nsIDOMNode);
|
||||
NS_DEF_PTR(nsIDOMDOMPropsCore);
|
||||
NS_DEF_PTR(nsIDOMWindow);
|
||||
|
||||
//
|
||||
// DOMPropsCore property ids
|
||||
//
|
||||
enum DOMPropsCore_slots {
|
||||
DOMPROPSCORE_NODE = -1
|
||||
};
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// DOMPropsCore Properties Getter
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
GetDOMPropsCoreProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
nsIDOMDOMPropsCore *a = (nsIDOMDOMPropsCore*)JS_GetPrivate(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)) {
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case DOMPROPSCORE_NODE:
|
||||
{
|
||||
nsIDOMNode* prop;
|
||||
if (NS_OK == a->GetNode(&prop)) {
|
||||
// get the js object
|
||||
nsJSUtils::nsConvertObjectToJSVal((nsISupports *)prop, cx, vp);
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// DOMPropsCore Properties Setter
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
SetDOMPropsCoreProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
nsIDOMDOMPropsCore *a = (nsIDOMDOMPropsCore*)JS_GetPrivate(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)) {
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case DOMPROPSCORE_NODE:
|
||||
{
|
||||
nsIDOMNode* prop;
|
||||
if (PR_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&prop,
|
||||
kINodeIID, "Node",
|
||||
cx, *vp)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
a->SetNode(prop);
|
||||
NS_IF_RELEASE(prop);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp);
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// DOMPropsCore finalizer
|
||||
//
|
||||
PR_STATIC_CALLBACK(void)
|
||||
FinalizeDOMPropsCore(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
nsJSUtils::nsGenericFinalize(cx, obj);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// DOMPropsCore enumerate
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
EnumerateDOMPropsCore(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
return nsJSUtils::nsGenericEnumerate(cx, obj);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// DOMPropsCore resolve
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
ResolveDOMPropsCore(JSContext *cx, JSObject *obj, jsval id)
|
||||
{
|
||||
return nsJSUtils::nsGenericResolve(cx, obj, id);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method ShowProperties
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
DOMPropsCoreShowProperties(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMDOMPropsCore *nativeThis = (nsIDOMDOMPropsCore*)JS_GetPrivate(cx, obj);
|
||||
nsAutoString b0;
|
||||
nsIDOMWindowPtr b1;
|
||||
nsIDOMNodePtr b2;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (argc >= 3) {
|
||||
|
||||
nsJSUtils::nsConvertJSValToString(b0, cx, argv[0]);
|
||||
|
||||
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b1,
|
||||
kIWindowIID,
|
||||
"Window",
|
||||
cx,
|
||||
argv[1])) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b2,
|
||||
kINodeIID,
|
||||
"Node",
|
||||
cx,
|
||||
argv[2])) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (NS_OK != nativeThis->ShowProperties(b0, b1, b2)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function showProperties requires 3 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method Commit
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
DOMPropsCoreCommit(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMDOMPropsCore *nativeThis = (nsIDOMDOMPropsCore*)JS_GetPrivate(cx, obj);
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (argc >= 0) {
|
||||
|
||||
if (NS_OK != nativeThis->Commit()) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function commit requires 0 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method Cancel
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
DOMPropsCoreCancel(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMDOMPropsCore *nativeThis = (nsIDOMDOMPropsCore*)JS_GetPrivate(cx, obj);
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (argc >= 0) {
|
||||
|
||||
if (NS_OK != nativeThis->Cancel()) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function cancel requires 0 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// class for DOMPropsCore
|
||||
//
|
||||
JSClass DOMPropsCoreClass = {
|
||||
"DOMPropsCore",
|
||||
JSCLASS_HAS_PRIVATE,
|
||||
JS_PropertyStub,
|
||||
JS_PropertyStub,
|
||||
GetDOMPropsCoreProperty,
|
||||
SetDOMPropsCoreProperty,
|
||||
EnumerateDOMPropsCore,
|
||||
ResolveDOMPropsCore,
|
||||
JS_ConvertStub,
|
||||
FinalizeDOMPropsCore
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// DOMPropsCore class properties
|
||||
//
|
||||
static JSPropertySpec DOMPropsCoreProperties[] =
|
||||
{
|
||||
{"node", DOMPROPSCORE_NODE, JSPROP_ENUMERATE},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// DOMPropsCore class methods
|
||||
//
|
||||
static JSFunctionSpec DOMPropsCoreMethods[] =
|
||||
{
|
||||
{"showProperties", DOMPropsCoreShowProperties, 3},
|
||||
{"commit", DOMPropsCoreCommit, 0},
|
||||
{"cancel", DOMPropsCoreCancel, 0},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// DOMPropsCore constructor
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
DOMPropsCore(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsresult result;
|
||||
nsIID classID;
|
||||
nsIScriptContext* context = (nsIScriptContext*)JS_GetContextPrivate(cx);
|
||||
nsIScriptNameSpaceManager* manager;
|
||||
nsIDOMDOMPropsCore *nativeThis;
|
||||
nsIScriptObjectOwner *owner = nsnull;
|
||||
|
||||
static NS_DEFINE_IID(kIDOMDOMPropsCoreIID, NS_IDOMDOMPROPSCORE_IID);
|
||||
|
||||
result = context->GetNameSpaceManager(&manager);
|
||||
if (NS_OK != result) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
result = manager->LookupName("DOMPropsCore", PR_TRUE, classID);
|
||||
NS_RELEASE(manager);
|
||||
if (NS_OK != result) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
result = nsComponentManager::CreateInstance(classID,
|
||||
nsnull,
|
||||
kIDOMDOMPropsCoreIID,
|
||||
(void **)&nativeThis);
|
||||
if (NS_OK != result) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
// XXX We should be calling Init() on the instance
|
||||
|
||||
result = nativeThis->QueryInterface(kIScriptObjectOwnerIID, (void **)&owner);
|
||||
if (NS_OK != result) {
|
||||
NS_RELEASE(nativeThis);
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
owner->SetScriptObject((void *)obj);
|
||||
JS_SetPrivate(cx, obj, nativeThis);
|
||||
|
||||
NS_RELEASE(owner);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
//
|
||||
// DOMPropsCore class initialization
|
||||
//
|
||||
extern "C" NS_DOM nsresult NS_InitDOMPropsCoreClass(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, "DOMPropsCore", &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_InitBaseAppCoreClass(aContext, (void **)&parent_proto)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
proto = JS_InitClass(jscontext, // context
|
||||
global, // global object
|
||||
parent_proto, // parent proto
|
||||
&DOMPropsCoreClass, // JSClass
|
||||
DOMPropsCore, // JSNative ctor
|
||||
0, // ctor args
|
||||
DOMPropsCoreProperties, // proto props
|
||||
DOMPropsCoreMethods, // 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 DOMPropsCore JavaScript object
|
||||
//
|
||||
extern "C" NS_DOM nsresult NS_NewScriptDOMPropsCore(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null argument to NS_NewScriptDOMPropsCore");
|
||||
JSObject *proto;
|
||||
JSObject *parent;
|
||||
nsIScriptObjectOwner *owner;
|
||||
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
|
||||
nsresult result = NS_OK;
|
||||
nsIDOMDOMPropsCore *aDOMPropsCore;
|
||||
|
||||
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_InitDOMPropsCoreClass(aContext, (void **)&proto)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
result = aSupports->QueryInterface(kIDOMPropsCoreIID, (void **)&aDOMPropsCore);
|
||||
if (NS_OK != result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// create a js object for this class
|
||||
*aReturn = JS_NewObject(jscontext, &DOMPropsCoreClass, proto, parent);
|
||||
if (nsnull != *aReturn) {
|
||||
// connect the native object to the js object
|
||||
JS_SetPrivate(jscontext, (JSObject *)*aReturn, aDOMPropsCore);
|
||||
}
|
||||
else {
|
||||
NS_RELEASE(aDOMPropsCore);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
Loading…
Reference in New Issue
Block a user