Fix for bug 43902. The DOM glue now streamlines the Get/SetProperty methods for the window class. Window.location and title and document.title are now part of the idlc interfaces, rather than special-cased. r=jst@netscape.com

This commit is contained in:
vidur%netscape.com 2000-08-29 00:14:23 +00:00
Родитель 81333540aa
Коммит a6fa8885ba
24 изменённых файлов: 2085 добавлений и 461 удалений

Просмотреть файл

@ -2414,6 +2414,30 @@ nsDocument::GetAnonymousNodes(nsIDOMElement* aElement, nsIDOMNodeList** aResult)
return NS_OK;
}
NS_IMETHODIMP
nsDocument::GetLocation(jsval* aLocation)
{
if (mScriptGlobalObject) {
nsCOMPtr<nsIDOMWindow> window(do_QueryInterface(mScriptGlobalObject));
if(window) {
return window->GetLocation(aLocation);
}
}
return NS_OK;
}
NS_IMETHODIMP
nsDocument::SetLocation(jsval aLocation)
{
if (mScriptGlobalObject) {
nsCOMPtr<nsIDOMWindow> window(do_QueryInterface(mScriptGlobalObject));
if(window) {
return window->SetLocation(aLocation);
}
}
return NS_OK;
}
NS_IMETHODIMP
nsDocument::CreateRange(nsIDOMRange** aReturn)
{
@ -3129,22 +3153,7 @@ PRBool nsDocument::DeleteProperty(JSContext *aContext, JSObject *aObj, jsval
PRBool nsDocument::GetProperty(JSContext *aContext, JSObject *aObj, jsval aID, jsval *aVp)
{
PRBool result = PR_TRUE;
if (JSVAL_IS_STRING(aID) &&
PL_strcmp("location", JS_GetStringBytes(JS_ValueToString(aContext, aID))) == 0) {
if (mScriptGlobalObject) {
nsCOMPtr<nsIJSScriptObject> window(do_QueryInterface(mScriptGlobalObject));
if(window) {
result = window->GetProperty(aContext, aObj, aID, aVp);
}
else {
result = PR_FALSE;
}
}
}
return result;
return PR_TRUE;
}
PRBool nsDocument::SetProperty(JSContext *aContext, JSObject *aObj, jsval aID, jsval *aVp)
@ -3237,18 +3246,6 @@ PRBool nsDocument::SetProperty(JSContext *aContext, JSObject *aObj, jsval aID
NS_IF_RELEASE(mManager);
}
}
else if (JSVAL_IS_STRING(aID) &&
PL_strcmp("location", JS_GetStringBytes(JS_ValueToString(aContext, aID))) == 0) {
if (mScriptGlobalObject) {
nsCOMPtr<nsIJSScriptObject> window(do_QueryInterface(mScriptGlobalObject));
if(window) {
result = window->SetProperty(aContext, aObj, aID, aVp);
}
else {
result = PR_FALSE;
}
}
}
return result;
}

Просмотреть файл

@ -397,6 +397,8 @@ public:
NS_IMETHOD CreateElementWithNameSpace(const nsAReadableString& aTagName,
const nsAReadableString& aNameSpace,
nsIDOMElement** aReturn);
NS_IMETHOD GetLocation(jsval* aLocation);
NS_IMETHOD SetLocation(jsval aLocation);
NS_IMETHOD CreateRange(nsIDOMRange** aReturn);
NS_IMETHOD Load (const nsAReadableString& aUrl);
NS_IMETHOD GetPlugins(nsIDOMPluginArray** aPlugins);

Просмотреть файл

@ -3085,6 +3085,30 @@ nsXULDocument::GetAnonymousNodes(nsIDOMElement* aElement,
return NS_OK;
}
NS_IMETHODIMP
nsXULDocument::GetLocation(jsval* aLocation)
{
if (mScriptGlobalObject) {
nsCOMPtr<nsIDOMWindow> window(do_QueryInterface(mScriptGlobalObject));
if(window) {
return window->GetLocation(aLocation);
}
}
return NS_OK;
}
NS_IMETHODIMP
nsXULDocument::SetLocation(jsval aLocation)
{
if (mScriptGlobalObject) {
nsCOMPtr<nsIDOMWindow> window(do_QueryInterface(mScriptGlobalObject));
if(window) {
return window->SetLocation(aLocation);
}
}
return NS_OK;
}
NS_IMETHODIMP
nsXULDocument::Load(const nsAReadableString& aUrl)
{
@ -3754,19 +3778,6 @@ nsXULDocument::DeleteProperty(JSContext *aContext, JSObject *aObj, jsval aID, js
PRBool
nsXULDocument::GetProperty(JSContext *aContext, JSObject *aObj, jsval aID, jsval *aVp)
{
if (JSVAL_IS_STRING(aID)) {
JSString *jsString = JS_ValueToString(aContext, aID);
if (!jsString)
return PR_FALSE;
if (PL_strcmp("location", JS_GetStringBytes(jsString)) == 0) {
nsCOMPtr<nsIJSScriptObject> window = do_QueryInterface(mScriptGlobalObject);
if (nsnull != window) {
return window->GetProperty(aContext, aObj, aID, aVp);
}
}
}
return PR_TRUE;
}
@ -3802,10 +3813,6 @@ nsXULDocument::SetProperty(JSContext *aContext, JSObject *aObj, jsval aID, jsval
if (NS_FAILED(rv)) return PR_FALSE;
}
}
else if (PL_strcmp("location", s) == 0) {
NS_NOTYETIMPLEMENTED("write me");
return PR_FALSE;
}
}
return PR_TRUE;
}

Просмотреть файл

@ -39,3 +39,4 @@ nsIDOMCrypto.h
nsIDOMCRMFObject.h
nsIDOMPkcs11.h
nsIDOMViewCSS.h
nsIDOMWindowEventOwner.h

Просмотреть файл

@ -48,6 +48,7 @@ EXPORTS = \
nsIDOMCRMFObject.h \
nsIDOMCrypto.h \
nsIDOMPkcs11.h \
nsIDOMWindowEventOwner.h \
$(NULL)
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))

Просмотреть файл

@ -28,7 +28,8 @@ EXPORTS=nsIDOMWindow.h nsIDOMNavigator.h nsIDOMLocation.h nsIDOMNSLocation.h \
nsIDOMMimeType.h nsIDOMMimeTypeArray.h \
nsIDOMPlugin.h nsIDOMPluginArray.h nsIDOMBarProp.h \
nsIDOMDOMException.h nsPIDOMWindow.h nsIDOMAbstractView.h \
nsIDOMViewCSS.h nsIDOMCRMFObject.h nsIDOMCrypto.h nsIDOMPkcs11.h
nsIDOMViewCSS.h nsIDOMCRMFObject.h nsIDOMCrypto.h nsIDOMPkcs11.h \
nsIDOMWindowEventOwner.h
MODULE=dom

Просмотреть файл

@ -110,6 +110,12 @@ public:
NS_IMETHOD GetName(nsAWritableString& aName)=0;
NS_IMETHOD SetName(const nsAReadableString& aName)=0;
NS_IMETHOD GetLocation(jsval* aLocation)=0;
NS_IMETHOD SetLocation(jsval aLocation)=0;
NS_IMETHOD GetTitle(nsAWritableString& aTitle)=0;
NS_IMETHOD SetTitle(const nsAReadableString& aTitle)=0;
NS_IMETHOD GetInnerWidth(PRInt32* aInnerWidth)=0;
NS_IMETHOD SetInnerWidth(PRInt32 aInnerWidth)=0;
@ -250,6 +256,10 @@ public:
NS_IMETHOD SetDefaultStatus(const nsAReadableString& aDefaultStatus); \
NS_IMETHOD GetName(nsAWritableString& aName); \
NS_IMETHOD SetName(const nsAReadableString& aName); \
NS_IMETHOD GetLocation(jsval* aLocation); \
NS_IMETHOD SetLocation(jsval aLocation); \
NS_IMETHOD GetTitle(nsAWritableString& aTitle); \
NS_IMETHOD SetTitle(const nsAReadableString& aTitle); \
NS_IMETHOD GetInnerWidth(PRInt32* aInnerWidth); \
NS_IMETHOD SetInnerWidth(PRInt32 aInnerWidth); \
NS_IMETHOD GetInnerHeight(PRInt32* aInnerHeight); \
@ -342,6 +352,10 @@ public:
NS_IMETHOD SetDefaultStatus(const nsAReadableString& aDefaultStatus) { return _to SetDefaultStatus(aDefaultStatus); } \
NS_IMETHOD GetName(nsAWritableString& aName) { return _to GetName(aName); } \
NS_IMETHOD SetName(const nsAReadableString& aName) { return _to SetName(aName); } \
NS_IMETHOD GetLocation(jsval* aLocation) { return _to GetLocation(aLocation); } \
NS_IMETHOD SetLocation(jsval aLocation) { return _to SetLocation(aLocation); } \
NS_IMETHOD GetTitle(nsAWritableString& aTitle) { return _to GetTitle(aTitle); } \
NS_IMETHOD SetTitle(const nsAReadableString& aTitle) { return _to SetTitle(aTitle); } \
NS_IMETHOD GetInnerWidth(PRInt32* aInnerWidth) { return _to GetInnerWidth(aInnerWidth); } \
NS_IMETHOD SetInnerWidth(PRInt32 aInnerWidth) { return _to SetInnerWidth(aInnerWidth); } \
NS_IMETHOD GetInnerHeight(PRInt32* aInnerHeight) { return _to GetInnerHeight(aInnerHeight); } \

Просмотреть файл

@ -0,0 +1,218 @@
/* -*- 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 nsIDOMWindowEventOwner_h__
#define nsIDOMWindowEventOwner_h__
#include "nsISupports.h"
#include "nsString.h"
#include "nsIScriptContext.h"
#include "jsapi.h"
#define NS_IDOMWINDOWEVENTOWNER_IID \
{ 0xef1876f0, 0x7881, 0x11d4, \
{ 0x9a, 0x80, 0x00, 0x00, 0x64, 0x65, 0x73, 0x74 } }
class nsIDOMWindowEventOwner : public nsISupports {
public:
static const nsIID& GetIID() { static nsIID iid = NS_IDOMWINDOWEVENTOWNER_IID; return iid; }
NS_IMETHOD GetOnmousedown(jsval* aOnmousedown)=0;
NS_IMETHOD SetOnmousedown(jsval aOnmousedown)=0;
NS_IMETHOD GetOnmouseup(jsval* aOnmouseup)=0;
NS_IMETHOD SetOnmouseup(jsval aOnmouseup)=0;
NS_IMETHOD GetOnclick(jsval* aOnclick)=0;
NS_IMETHOD SetOnclick(jsval aOnclick)=0;
NS_IMETHOD GetOnmouseover(jsval* aOnmouseover)=0;
NS_IMETHOD SetOnmouseover(jsval aOnmouseover)=0;
NS_IMETHOD GetOnmouseout(jsval* aOnmouseout)=0;
NS_IMETHOD SetOnmouseout(jsval aOnmouseout)=0;
NS_IMETHOD GetOnkeydown(jsval* aOnkeydown)=0;
NS_IMETHOD SetOnkeydown(jsval aOnkeydown)=0;
NS_IMETHOD GetOnkeyup(jsval* aOnkeyup)=0;
NS_IMETHOD SetOnkeyup(jsval aOnkeyup)=0;
NS_IMETHOD GetOnkeypress(jsval* aOnkeypress)=0;
NS_IMETHOD SetOnkeypress(jsval aOnkeypress)=0;
NS_IMETHOD GetOnmousemove(jsval* aOnmousemove)=0;
NS_IMETHOD SetOnmousemove(jsval aOnmousemove)=0;
NS_IMETHOD GetOnfocus(jsval* aOnfocus)=0;
NS_IMETHOD SetOnfocus(jsval aOnfocus)=0;
NS_IMETHOD GetOnblur(jsval* aOnblur)=0;
NS_IMETHOD SetOnblur(jsval aOnblur)=0;
NS_IMETHOD GetOnsubmit(jsval* aOnsubmit)=0;
NS_IMETHOD SetOnsubmit(jsval aOnsubmit)=0;
NS_IMETHOD GetOnreset(jsval* aOnreset)=0;
NS_IMETHOD SetOnreset(jsval aOnreset)=0;
NS_IMETHOD GetOnchange(jsval* aOnchange)=0;
NS_IMETHOD SetOnchange(jsval aOnchange)=0;
NS_IMETHOD GetOnselect(jsval* aOnselect)=0;
NS_IMETHOD SetOnselect(jsval aOnselect)=0;
NS_IMETHOD GetOnload(jsval* aOnload)=0;
NS_IMETHOD SetOnload(jsval aOnload)=0;
NS_IMETHOD GetOnunload(jsval* aOnunload)=0;
NS_IMETHOD SetOnunload(jsval aOnunload)=0;
NS_IMETHOD GetOnclose(jsval* aOnclose)=0;
NS_IMETHOD SetOnclose(jsval aOnclose)=0;
NS_IMETHOD GetOnabort(jsval* aOnabort)=0;
NS_IMETHOD SetOnabort(jsval aOnabort)=0;
NS_IMETHOD GetOnerror(jsval* aOnerror)=0;
NS_IMETHOD SetOnerror(jsval aOnerror)=0;
NS_IMETHOD GetOnpaint(jsval* aOnpaint)=0;
NS_IMETHOD SetOnpaint(jsval aOnpaint)=0;
NS_IMETHOD GetOndragdrop(jsval* aOndragdrop)=0;
NS_IMETHOD SetOndragdrop(jsval aOndragdrop)=0;
NS_IMETHOD GetOnresize(jsval* aOnresize)=0;
NS_IMETHOD SetOnresize(jsval aOnresize)=0;
NS_IMETHOD GetOnscroll(jsval* aOnscroll)=0;
NS_IMETHOD SetOnscroll(jsval aOnscroll)=0;
};
#define NS_DECL_IDOMWINDOWEVENTOWNER \
NS_IMETHOD GetOnmousedown(jsval* aOnmousedown); \
NS_IMETHOD SetOnmousedown(jsval aOnmousedown); \
NS_IMETHOD GetOnmouseup(jsval* aOnmouseup); \
NS_IMETHOD SetOnmouseup(jsval aOnmouseup); \
NS_IMETHOD GetOnclick(jsval* aOnclick); \
NS_IMETHOD SetOnclick(jsval aOnclick); \
NS_IMETHOD GetOnmouseover(jsval* aOnmouseover); \
NS_IMETHOD SetOnmouseover(jsval aOnmouseover); \
NS_IMETHOD GetOnmouseout(jsval* aOnmouseout); \
NS_IMETHOD SetOnmouseout(jsval aOnmouseout); \
NS_IMETHOD GetOnkeydown(jsval* aOnkeydown); \
NS_IMETHOD SetOnkeydown(jsval aOnkeydown); \
NS_IMETHOD GetOnkeyup(jsval* aOnkeyup); \
NS_IMETHOD SetOnkeyup(jsval aOnkeyup); \
NS_IMETHOD GetOnkeypress(jsval* aOnkeypress); \
NS_IMETHOD SetOnkeypress(jsval aOnkeypress); \
NS_IMETHOD GetOnmousemove(jsval* aOnmousemove); \
NS_IMETHOD SetOnmousemove(jsval aOnmousemove); \
NS_IMETHOD GetOnfocus(jsval* aOnfocus); \
NS_IMETHOD SetOnfocus(jsval aOnfocus); \
NS_IMETHOD GetOnblur(jsval* aOnblur); \
NS_IMETHOD SetOnblur(jsval aOnblur); \
NS_IMETHOD GetOnsubmit(jsval* aOnsubmit); \
NS_IMETHOD SetOnsubmit(jsval aOnsubmit); \
NS_IMETHOD GetOnreset(jsval* aOnreset); \
NS_IMETHOD SetOnreset(jsval aOnreset); \
NS_IMETHOD GetOnchange(jsval* aOnchange); \
NS_IMETHOD SetOnchange(jsval aOnchange); \
NS_IMETHOD GetOnselect(jsval* aOnselect); \
NS_IMETHOD SetOnselect(jsval aOnselect); \
NS_IMETHOD GetOnload(jsval* aOnload); \
NS_IMETHOD SetOnload(jsval aOnload); \
NS_IMETHOD GetOnunload(jsval* aOnunload); \
NS_IMETHOD SetOnunload(jsval aOnunload); \
NS_IMETHOD GetOnclose(jsval* aOnclose); \
NS_IMETHOD SetOnclose(jsval aOnclose); \
NS_IMETHOD GetOnabort(jsval* aOnabort); \
NS_IMETHOD SetOnabort(jsval aOnabort); \
NS_IMETHOD GetOnerror(jsval* aOnerror); \
NS_IMETHOD SetOnerror(jsval aOnerror); \
NS_IMETHOD GetOnpaint(jsval* aOnpaint); \
NS_IMETHOD SetOnpaint(jsval aOnpaint); \
NS_IMETHOD GetOndragdrop(jsval* aOndragdrop); \
NS_IMETHOD SetOndragdrop(jsval aOndragdrop); \
NS_IMETHOD GetOnresize(jsval* aOnresize); \
NS_IMETHOD SetOnresize(jsval aOnresize); \
NS_IMETHOD GetOnscroll(jsval* aOnscroll); \
NS_IMETHOD SetOnscroll(jsval aOnscroll); \
#define NS_FORWARD_IDOMWINDOWEVENTOWNER(_to) \
NS_IMETHOD GetOnmousedown(jsval* aOnmousedown) { return _to GetOnmousedown(aOnmousedown); } \
NS_IMETHOD SetOnmousedown(jsval aOnmousedown) { return _to SetOnmousedown(aOnmousedown); } \
NS_IMETHOD GetOnmouseup(jsval* aOnmouseup) { return _to GetOnmouseup(aOnmouseup); } \
NS_IMETHOD SetOnmouseup(jsval aOnmouseup) { return _to SetOnmouseup(aOnmouseup); } \
NS_IMETHOD GetOnclick(jsval* aOnclick) { return _to GetOnclick(aOnclick); } \
NS_IMETHOD SetOnclick(jsval aOnclick) { return _to SetOnclick(aOnclick); } \
NS_IMETHOD GetOnmouseover(jsval* aOnmouseover) { return _to GetOnmouseover(aOnmouseover); } \
NS_IMETHOD SetOnmouseover(jsval aOnmouseover) { return _to SetOnmouseover(aOnmouseover); } \
NS_IMETHOD GetOnmouseout(jsval* aOnmouseout) { return _to GetOnmouseout(aOnmouseout); } \
NS_IMETHOD SetOnmouseout(jsval aOnmouseout) { return _to SetOnmouseout(aOnmouseout); } \
NS_IMETHOD GetOnkeydown(jsval* aOnkeydown) { return _to GetOnkeydown(aOnkeydown); } \
NS_IMETHOD SetOnkeydown(jsval aOnkeydown) { return _to SetOnkeydown(aOnkeydown); } \
NS_IMETHOD GetOnkeyup(jsval* aOnkeyup) { return _to GetOnkeyup(aOnkeyup); } \
NS_IMETHOD SetOnkeyup(jsval aOnkeyup) { return _to SetOnkeyup(aOnkeyup); } \
NS_IMETHOD GetOnkeypress(jsval* aOnkeypress) { return _to GetOnkeypress(aOnkeypress); } \
NS_IMETHOD SetOnkeypress(jsval aOnkeypress) { return _to SetOnkeypress(aOnkeypress); } \
NS_IMETHOD GetOnmousemove(jsval* aOnmousemove) { return _to GetOnmousemove(aOnmousemove); } \
NS_IMETHOD SetOnmousemove(jsval aOnmousemove) { return _to SetOnmousemove(aOnmousemove); } \
NS_IMETHOD GetOnfocus(jsval* aOnfocus) { return _to GetOnfocus(aOnfocus); } \
NS_IMETHOD SetOnfocus(jsval aOnfocus) { return _to SetOnfocus(aOnfocus); } \
NS_IMETHOD GetOnblur(jsval* aOnblur) { return _to GetOnblur(aOnblur); } \
NS_IMETHOD SetOnblur(jsval aOnblur) { return _to SetOnblur(aOnblur); } \
NS_IMETHOD GetOnsubmit(jsval* aOnsubmit) { return _to GetOnsubmit(aOnsubmit); } \
NS_IMETHOD SetOnsubmit(jsval aOnsubmit) { return _to SetOnsubmit(aOnsubmit); } \
NS_IMETHOD GetOnreset(jsval* aOnreset) { return _to GetOnreset(aOnreset); } \
NS_IMETHOD SetOnreset(jsval aOnreset) { return _to SetOnreset(aOnreset); } \
NS_IMETHOD GetOnchange(jsval* aOnchange) { return _to GetOnchange(aOnchange); } \
NS_IMETHOD SetOnchange(jsval aOnchange) { return _to SetOnchange(aOnchange); } \
NS_IMETHOD GetOnselect(jsval* aOnselect) { return _to GetOnselect(aOnselect); } \
NS_IMETHOD SetOnselect(jsval aOnselect) { return _to SetOnselect(aOnselect); } \
NS_IMETHOD GetOnload(jsval* aOnload) { return _to GetOnload(aOnload); } \
NS_IMETHOD SetOnload(jsval aOnload) { return _to SetOnload(aOnload); } \
NS_IMETHOD GetOnunload(jsval* aOnunload) { return _to GetOnunload(aOnunload); } \
NS_IMETHOD SetOnunload(jsval aOnunload) { return _to SetOnunload(aOnunload); } \
NS_IMETHOD GetOnclose(jsval* aOnclose) { return _to GetOnclose(aOnclose); } \
NS_IMETHOD SetOnclose(jsval aOnclose) { return _to SetOnclose(aOnclose); } \
NS_IMETHOD GetOnabort(jsval* aOnabort) { return _to GetOnabort(aOnabort); } \
NS_IMETHOD SetOnabort(jsval aOnabort) { return _to SetOnabort(aOnabort); } \
NS_IMETHOD GetOnerror(jsval* aOnerror) { return _to GetOnerror(aOnerror); } \
NS_IMETHOD SetOnerror(jsval aOnerror) { return _to SetOnerror(aOnerror); } \
NS_IMETHOD GetOnpaint(jsval* aOnpaint) { return _to GetOnpaint(aOnpaint); } \
NS_IMETHOD SetOnpaint(jsval aOnpaint) { return _to SetOnpaint(aOnpaint); } \
NS_IMETHOD GetOndragdrop(jsval* aOndragdrop) { return _to GetOndragdrop(aOndragdrop); } \
NS_IMETHOD SetOndragdrop(jsval aOndragdrop) { return _to SetOndragdrop(aOndragdrop); } \
NS_IMETHOD GetOnresize(jsval* aOnresize) { return _to GetOnresize(aOnresize); } \
NS_IMETHOD SetOnresize(jsval aOnresize) { return _to SetOnresize(aOnresize); } \
NS_IMETHOD GetOnscroll(jsval* aOnscroll) { return _to GetOnscroll(aOnscroll); } \
NS_IMETHOD SetOnscroll(jsval aOnscroll) { return _to SetOnscroll(aOnscroll); } \
#endif // nsIDOMWindowEventOwner_h__

Просмотреть файл

@ -27,6 +27,7 @@
#include "nsISupports.h"
#include "nsString.h"
#include "nsIScriptContext.h"
#include "jsapi.h"
class nsIDOMElement;
class nsIDOMPluginArray;
@ -44,6 +45,9 @@ public:
NS_IMETHOD GetPlugins(nsIDOMPluginArray** aPlugins)=0;
NS_IMETHOD GetLocation(jsval* aLocation)=0;
NS_IMETHOD SetLocation(jsval aLocation)=0;
NS_IMETHOD CreateElementWithNameSpace(const nsAReadableString& aTagName, const nsAReadableString& aNameSpace, nsIDOMElement** aReturn)=0;
NS_IMETHOD CreateRange(nsIDOMRange** aReturn)=0;
@ -55,6 +59,8 @@ public:
#define NS_DECL_IDOMNSDOCUMENT \
NS_IMETHOD GetCharacterSet(nsAWritableString& aCharacterSet); \
NS_IMETHOD GetPlugins(nsIDOMPluginArray** aPlugins); \
NS_IMETHOD GetLocation(jsval* aLocation); \
NS_IMETHOD SetLocation(jsval aLocation); \
NS_IMETHOD CreateElementWithNameSpace(const nsAReadableString& aTagName, const nsAReadableString& aNameSpace, nsIDOMElement** aReturn); \
NS_IMETHOD CreateRange(nsIDOMRange** aReturn); \
NS_IMETHOD Load(const nsAReadableString& aUrl); \
@ -64,6 +70,8 @@ public:
#define NS_FORWARD_IDOMNSDOCUMENT(_to) \
NS_IMETHOD GetCharacterSet(nsAWritableString& aCharacterSet) { return _to GetCharacterSet(aCharacterSet); } \
NS_IMETHOD GetPlugins(nsIDOMPluginArray** aPlugins) { return _to GetPlugins(aPlugins); } \
NS_IMETHOD GetLocation(jsval* aLocation) { return _to GetLocation(aLocation); } \
NS_IMETHOD SetLocation(jsval aLocation) { return _to SetLocation(aLocation); } \
NS_IMETHOD CreateElementWithNameSpace(const nsAReadableString& aTagName, const nsAReadableString& aNameSpace, nsIDOMElement** aReturn) { return _to CreateElementWithNameSpace(aTagName, aNameSpace, aReturn); } \
NS_IMETHOD CreateRange(nsIDOMRange** aReturn) { return _to CreateRange(aReturn); } \
NS_IMETHOD Load(const nsAReadableString& aUrl) { return _to Load(aUrl); } \

Просмотреть файл

@ -30,6 +30,8 @@ interface Window {
attribute wstring status;
attribute wstring defaultStatus;
attribute wstring name;
attribute jsval location;
replaceable attribute DOMString title;
attribute long innerWidth;
attribute long innerHeight;
attribute long outerWidth;
@ -89,16 +91,46 @@ interface Window {
DOMString escape(in DOMString str);
DOMString unescape(in DOMString str);
Selection getSelection();
};
interface WindowEventOwner {
/* IID: { 0xef1876f0, 0x7881, 0x11d4, \
{ 0x9a, 0x80, 0x00, 0x00, 0x64, 0x65, 0x73, 0x74 } } */
attribute jsval onmousedown;
attribute jsval onmouseup;
attribute jsval onclick;
attribute jsval onmouseover;
attribute jsval onmouseout;
attribute jsval onkeydown;
attribute jsval onkeyup;
attribute jsval onkeypress;
attribute jsval onmousemove;
attribute jsval onfocus;
attribute jsval onblur;
attribute jsval onsubmit;
attribute jsval onreset;
attribute jsval onchange;
attribute jsval onselect;
attribute jsval onload;
attribute jsval onunload;
attribute jsval onclose;
attribute jsval onabort;
attribute jsval onerror;
attribute jsval onpaint;
attribute jsval ondragdrop;
attribute jsval onresize;
attribute jsval onscroll;
};
interface EventTarget {
/* IID: { 0x1c773b30, 0xd1cf, 0x11d2, \
{ 0xbd, 0x95, 0x00, 0x80, 0x5f, 0x8a, 0xe3, 0xf4 } } */
void addEventListener(in DOMString type, in function EventListener listener, in boolean useCapture);
void removeEventListener(in DOMString type, in function EventListener listener, in boolean useCapture);
void dispatchEvent(in Event evt);
void addEventListener(in DOMString type, in function EventListener listener, in boolean useCapture);
void removeEventListener(in DOMString type, in function EventListener listener, in boolean useCapture);
void dispatchEvent(in Event evt);
};
// Introduced in DOM Level 2:

Просмотреть файл

@ -89,6 +89,7 @@ interface NSDocument {
readonly attribute DOMString characterSet;
readonly attribute PluginArray plugins;
attribute jsval location;
// XXX This should be removed, the new createElementNS should be used in stead
Element createElementWithNameSpace(in DOMString tagName,
in DOMString nameSpace)

Просмотреть файл

@ -757,6 +757,7 @@ enum nsDOMProp {
NS_DOM_PROP_NSDOCUMENT_CREATEELEMENTWITHNAMESPACE,
NS_DOM_PROP_NSDOCUMENT_CREATERANGE,
NS_DOM_PROP_NSDOCUMENT_LOAD,
NS_DOM_PROP_NSDOCUMENT_LOCATION,
NS_DOM_PROP_NSDOCUMENT_PLUGINS,
NS_DOM_PROP_NSHTMLANCHORELEMENT_HASH,
NS_DOM_PROP_NSHTMLANCHORELEMENT_HOST,
@ -960,6 +961,7 @@ enum nsDOMProp {
NS_DOM_PROP_WINDOW_INNERHEIGHT,
NS_DOM_PROP_WINDOW_INNERWIDTH,
NS_DOM_PROP_WINDOW_LENGTH,
NS_DOM_PROP_WINDOW_LOCATION,
NS_DOM_PROP_WINDOW_LOCATIONBAR,
NS_DOM_PROP_WINDOW_MENUBAR,
NS_DOM_PROP_WINDOW_MOVEBY,
@ -1002,6 +1004,7 @@ enum nsDOMProp {
NS_DOM_PROP_WINDOW_STATUS,
NS_DOM_PROP_WINDOW_STATUSBAR,
NS_DOM_PROP_WINDOW_STOP,
NS_DOM_PROP_WINDOW_TITLE,
NS_DOM_PROP_WINDOW_TOOLBAR,
NS_DOM_PROP_WINDOW_TOP,
NS_DOM_PROP_WINDOW_UNESCAPE,
@ -1010,6 +1013,30 @@ enum nsDOMProp {
NS_DOM_PROP_WINDOWCOLLECTION_ITEM,
NS_DOM_PROP_WINDOWCOLLECTION_LENGTH,
NS_DOM_PROP_WINDOWCOLLECTION_NAMEDITEM,
NS_DOM_PROP_WINDOWEVENTOWNER_ONABORT,
NS_DOM_PROP_WINDOWEVENTOWNER_ONBLUR,
NS_DOM_PROP_WINDOWEVENTOWNER_ONCHANGE,
NS_DOM_PROP_WINDOWEVENTOWNER_ONCLICK,
NS_DOM_PROP_WINDOWEVENTOWNER_ONCLOSE,
NS_DOM_PROP_WINDOWEVENTOWNER_ONDRAGDROP,
NS_DOM_PROP_WINDOWEVENTOWNER_ONERROR,
NS_DOM_PROP_WINDOWEVENTOWNER_ONFOCUS,
NS_DOM_PROP_WINDOWEVENTOWNER_ONKEYDOWN,
NS_DOM_PROP_WINDOWEVENTOWNER_ONKEYPRESS,
NS_DOM_PROP_WINDOWEVENTOWNER_ONKEYUP,
NS_DOM_PROP_WINDOWEVENTOWNER_ONLOAD,
NS_DOM_PROP_WINDOWEVENTOWNER_ONMOUSEDOWN,
NS_DOM_PROP_WINDOWEVENTOWNER_ONMOUSEMOVE,
NS_DOM_PROP_WINDOWEVENTOWNER_ONMOUSEOUT,
NS_DOM_PROP_WINDOWEVENTOWNER_ONMOUSEOVER,
NS_DOM_PROP_WINDOWEVENTOWNER_ONMOUSEUP,
NS_DOM_PROP_WINDOWEVENTOWNER_ONPAINT,
NS_DOM_PROP_WINDOWEVENTOWNER_ONRESET,
NS_DOM_PROP_WINDOWEVENTOWNER_ONRESIZE,
NS_DOM_PROP_WINDOWEVENTOWNER_ONSCROLL,
NS_DOM_PROP_WINDOWEVENTOWNER_ONSELECT,
NS_DOM_PROP_WINDOWEVENTOWNER_ONSUBMIT,
NS_DOM_PROP_WINDOWEVENTOWNER_ONUNLOAD,
NS_DOM_PROP_XULBROWSERELEMENT_WEBBROWSER,
NS_DOM_PROP_XULCOMMANDDISPATCHER_ACTIVE,
NS_DOM_PROP_XULCOMMANDDISPATCHER_ADDCOMMANDUPDATER,

Просмотреть файл

@ -755,6 +755,7 @@
"nsdocument.createelementwithnamespace", \
"nsdocument.createrange", \
"nsdocument.load", \
"nsdocument.location", \
"nsdocument.plugins", \
"nshtmlanchorelement.hash", \
"nshtmlanchorelement.host", \
@ -958,6 +959,7 @@
"window.innerheight", \
"window.innerwidth", \
"window.length", \
"window.location", \
"window.locationbar", \
"window.menubar", \
"window.moveby", \
@ -1000,6 +1002,7 @@
"window.status", \
"window.statusbar", \
"window.stop", \
"window.title", \
"window.toolbar", \
"window.top", \
"window.unescape", \
@ -1008,6 +1011,30 @@
"windowcollection.item", \
"windowcollection.length", \
"windowcollection.nameditem", \
"windoweventowner.onabort", \
"windoweventowner.onblur", \
"windoweventowner.onchange", \
"windoweventowner.onclick", \
"windoweventowner.onclose", \
"windoweventowner.ondragdrop", \
"windoweventowner.onerror", \
"windoweventowner.onfocus", \
"windoweventowner.onkeydown", \
"windoweventowner.onkeypress", \
"windoweventowner.onkeyup", \
"windoweventowner.onload", \
"windoweventowner.onmousedown", \
"windoweventowner.onmousemove", \
"windoweventowner.onmouseout", \
"windoweventowner.onmouseover", \
"windoweventowner.onmouseup", \
"windoweventowner.onpaint", \
"windoweventowner.onreset", \
"windoweventowner.onresize", \
"windoweventowner.onscroll", \
"windoweventowner.onselect", \
"windoweventowner.onsubmit", \
"windoweventowner.onunload", \
"xulbrowserelement.webbrowser", \
"xulcommanddispatcher.active", \
"xulcommanddispatcher.addcommandupdater", \

Просмотреть файл

@ -914,6 +914,98 @@ NS_IMETHODIMP GlobalWindowImpl::SetName(const nsAReadableString& aName)
return result;
}
NS_IMETHODIMP
GlobalWindowImpl::GetLocation(jsval* aLocation)
{
nsCOMPtr<nsIThreadJSContextStack> stack(do_GetService("nsThreadJSContextStack"));
NS_ENSURE_TRUE(stack, NS_ERROR_FAILURE);
JSContext* cx;
NS_ENSURE_SUCCESS(stack->Peek(&cx), NS_ERROR_FAILURE);
NS_ENSURE_TRUE(cx, NS_ERROR_FAILURE);
nsCOMPtr<nsIDOMLocation> location;
*aLocation = JSVAL_NULL;
GetLocation(getter_AddRefs(location));
if(location) {
nsCOMPtr<nsIScriptObjectOwner> owner(do_QueryInterface(location));
if(owner) {
JSObject *object = nsnull;
nsCOMPtr<nsIScriptContext> scriptCX;
nsJSUtils::nsGetDynamicScriptContext(cx, getter_AddRefs(scriptCX));
if(scriptCX &&
(NS_SUCCEEDED(owner->GetScriptObject(scriptCX, (void**)&object)))) {
// set the return value
*aLocation = OBJECT_TO_JSVAL(object);
}
}
}
return NS_OK;
}
NS_IMETHODIMP
GlobalWindowImpl::SetLocation(jsval aLocation)
{
nsresult result;
if (mLocation) {
nsCOMPtr<nsIThreadJSContextStack> stack(do_GetService("nsThreadJSContextStack"));
NS_ENSURE_TRUE(stack, NS_ERROR_FAILURE);
JSContext* cx;
NS_ENSURE_SUCCESS(stack->Peek(&cx), NS_ERROR_FAILURE);
NS_ENSURE_TRUE(cx, NS_ERROR_FAILURE);
result = mLocation->SetHrefWithContext(cx, aLocation);
if (NS_FAILED(result)) return result;
}
return NS_OK;
}
NS_IMETHODIMP
GlobalWindowImpl::GetTitle(nsAWritableString& aTitle)
{
aTitle.Truncate();
if (mDocShell) {
// See if we're a chrome shell.
PRInt32 type;
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(mDocShell));
docShellAsItem->GetItemType(&type);
if(type == nsIDocShellTreeItem::typeChrome) {
nsCOMPtr<nsIBaseWindow> docShellAsWin(do_QueryInterface(mDocShell));
if(docShellAsWin) {
nsXPIDLString title;
docShellAsWin->GetTitle(getter_Copies(title));
aTitle.Assign(title);
}
}
}
return NS_OK;
}
NS_IMETHODIMP
GlobalWindowImpl::SetTitle(const nsAReadableString& aTitle)
{
if(mDocShell) {
// See if we're a chrome shell.
PRInt32 type;
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(mDocShell));
docShellAsItem->GetItemType(&type);
if(type == nsIDocShellTreeItem::typeChrome) {
nsCOMPtr<nsIBaseWindow> docShellAsWin(do_QueryInterface(mDocShell));
if(docShellAsWin) {
docShellAsWin->SetTitle(nsPromiseFlatString(aTitle));
}
}
}
return NS_OK;
}
NS_IMETHODIMP GlobalWindowImpl::GetInnerWidth(PRInt32* aInnerWidth)
{
nsCOMPtr<nsIDOMWindow> parent;
@ -2077,19 +2169,6 @@ NS_IMETHODIMP GlobalWindowImpl::GetSelection(nsIDOMSelection** aSelection)
PRBool GlobalWindowImpl::AddProperty(JSContext* aContext, JSObject* aObj,
jsval aID, jsval* aVp)
{
if (JSVAL_IS_STRING(aID) &&
::JS_TypeOfValue(aContext, *aVp) == JSTYPE_FUNCTION) {
JSString *str = JSVAL_TO_STRING(aID);
if (::JS_GetStringLength(str) > 2) {
const jschar *chars = ::JS_GetStringChars(str);
if (chars[0] == 'o' && chars[1] == 'n') {
nsAutoString propName;
propName.Assign(NS_REINTERPRET_CAST(const PRUnichar *, chars));
return CheckForEventListener(aContext, propName);
}
}
}
return PR_TRUE;
}
@ -2102,135 +2181,13 @@ PRBool GlobalWindowImpl::DeleteProperty(JSContext* aContext, JSObject* aObj,
PRBool GlobalWindowImpl::GetProperty(JSContext* aContext, JSObject* aObj,
jsval aID, jsval* aVp)
{
if (JSVAL_IS_STRING(aID)) {
char *bytes = ::JS_GetStringBytes(JSVAL_TO_STRING(aID));
if (PL_strcmp("location", bytes) == 0) {
nsCOMPtr<nsIDOMLocation> location;
if (NS_OK == GetLocation(getter_AddRefs(location))) {
if (location) {
nsCOMPtr<nsIScriptObjectOwner>
owner(do_QueryInterface(location));
if (owner) {
JSObject *object = nsnull;
nsCOMPtr<nsIScriptContext> scriptCX;
nsJSUtils::nsGetDynamicScriptContext(aContext,
getter_AddRefs(scriptCX));
if (scriptCX &&
NS_SUCCEEDED(owner->GetScriptObject(scriptCX, (void **) &object))) {
// set the return value
*aVp = OBJECT_TO_JSVAL(object);
}
}
}
else
*aVp = JSVAL_NULL;
}
else
return PR_FALSE;
}
else if (PL_strcmp("title", bytes) == 0) {
if (mDocShell) {
// See if we're a chrome shell.
PRInt32 type;
nsCOMPtr<nsIDocShellTreeItem>
docShellAsItem(do_QueryInterface(mDocShell));
docShellAsItem->GetItemType(&type);
if (type == nsIDocShellTreeItem::typeChrome) {
nsCOMPtr<nsIBaseWindow> docShellAsWin(do_QueryInterface(mDocShell));
if (docShellAsWin) {
nsXPIDLString title;
docShellAsWin->GetTitle(getter_Copies(title));
const PRUnichar *uniTitle = NS_STATIC_CAST(const PRUnichar*, title);
JSString *valstr =
::JS_NewUCStringCopyZ(aContext,
NS_REINTERPRET_CAST(const jschar *,
uniTitle));
if (!valstr)
return PR_FALSE;
*aVp = STRING_TO_JSVAL(valstr);
}
}
}
}
else {
nsIScriptSecurityManager *
securityManager = nsJSUtils::nsGetSecurityManager(aContext, aObj);
if (NS_FAILED(securityManager->CheckScriptAccess(aContext, aObj,
NS_DOM_PROP_WINDOW_SCRIPTGLOBALS,
PR_FALSE))) {
return PR_FALSE;
}
}
}
return PR_TRUE;
}
PRBool GlobalWindowImpl::SetProperty(JSContext* aContext, JSObject* aObj,
jsval aID, jsval* aVp)
{
PRBool result = PR_TRUE;
if (JSVAL_IS_STRING(aID)) {
JSString *str = JSVAL_TO_STRING(aID);
if (::JS_TypeOfValue(aContext, *aVp) == JSTYPE_FUNCTION) {
if (::JS_GetStringLength(str) > 2) {
const jschar *chars = ::JS_GetStringChars(str);
if (chars[0] == 'o' && chars[1] == 'n') {
nsAutoString propName;
propName.Assign(NS_REINTERPRET_CAST(const PRUnichar *, chars));
result = CheckForEventListener(aContext, propName);
}
}
}
else {
char *bytes = ::JS_GetStringBytes(str);
if (PL_strcmp("location", bytes) == 0) {
nsCOMPtr<nsIDOMLocation> location;
if (NS_OK == GetLocation(getter_AddRefs(location))) {
nsCOMPtr<nsIJSScriptObject> scriptObj = do_QueryInterface(location);
str = ::JS_NewStringCopyZ(aContext, "href");
if (scriptObj && str)
result =
scriptObj->SetProperty(aContext, aObj, STRING_TO_JSVAL(str), aVp);
}
else
result = PR_FALSE;
}
else if (PL_strcmp("title", bytes) == 0) {
if (mDocShell) {
// See if we're a chrome shell.
PRInt32 type;
nsCOMPtr<nsIDocShellTreeItem>
docShellAsItem(do_QueryInterface(mDocShell));
docShellAsItem->GetItemType(&type);
if (type == nsIDocShellTreeItem::typeChrome) {
nsCOMPtr<nsIBaseWindow> docShellAsWin(do_QueryInterface(mDocShell));
if (docShellAsWin) {
JSString *valstr = ::JS_ValueToString(aContext, *aVp);
if (!valstr) {
result = PR_FALSE;
}
else {
const PRUnichar *uniTitle =
NS_REINTERPRET_CAST(const PRUnichar *,
::JS_GetStringChars(valstr));
docShellAsWin->SetTitle(uniTitle);
}
}
}
}
}
}
}
return result;
return PR_TRUE;
}
PRBool GlobalWindowImpl::EnumerateProperty(JSContext* aContext, JSObject* aObj)
@ -2243,7 +2200,6 @@ PRBool GlobalWindowImpl::Resolve(JSContext* aContext, JSObject* aObj, jsval aID)
if (JSVAL_IS_STRING(aID)) {
JSBool resolved;
JSString *str;
const char *bytes;
if (!::JS_ResolveStandardClass(aContext, aObj, aID, &resolved))
return PR_FALSE;
@ -2251,12 +2207,7 @@ PRBool GlobalWindowImpl::Resolve(JSContext* aContext, JSObject* aObj, jsval aID)
return PR_TRUE;
str = JSVAL_TO_STRING(aID);
bytes = ::JS_GetStringBytes(str);
if (PL_strcmp("location", bytes) == 0) {
::JS_DefineProperty(aContext, (JSObject *) mScriptObject, "location",
JSVAL_NULL, nsnull, nsnull, 0);
}
else if (mDocShell) {
if (mDocShell) {
nsCOMPtr<nsIDocShellTreeNode>
docShellAsNode(do_QueryInterface(mDocShell));
PRInt32 count;
@ -4022,174 +3973,6 @@ GlobalWindowImpl::GetScrollInfo(nsIScrollableView **aScrollableView,
return NS_OK;
}
PRBool GlobalWindowImpl::CheckForEventListener(JSContext *aContext,
nsString& aPropName)
{
nsCOMPtr<nsIEventListenerManager> manager;
nsCOMPtr<nsIAtom> atom(getter_AddRefs(NS_NewAtom(aPropName)));
// XXX Comparisons should really be atom based
if (aPropName.EqualsWithConversion("onmousedown")
|| aPropName.EqualsWithConversion("onmouseup")
|| aPropName.EqualsWithConversion("onclick")
|| aPropName.EqualsWithConversion("onmouseover")
|| aPropName.EqualsWithConversion("onmouseout")) {
if (NS_OK == GetListenerManager(getter_AddRefs(manager))) {
nsCOMPtr<nsIScriptContext> scriptCX;
nsJSUtils::nsGetDynamicScriptContext(aContext,
getter_AddRefs(scriptCX));
if (!scriptCX ||
NS_FAILED(manager->RegisterScriptEventListener(scriptCX, this, atom,
NS_GET_IID
(nsIDOMMouseListener))))
{
return PR_FALSE;
}
}
}
else if (aPropName.EqualsWithConversion("onkeydown")
|| aPropName.EqualsWithConversion("onkeyup")
|| aPropName.EqualsWithConversion("onkeypress")) {
if (NS_OK == GetListenerManager(getter_AddRefs(manager))) {
nsCOMPtr<nsIScriptContext> scriptCX;
nsJSUtils::nsGetDynamicScriptContext(aContext,
getter_AddRefs(scriptCX));
if (!scriptCX ||
NS_FAILED(manager->RegisterScriptEventListener(scriptCX, this, atom,
NS_GET_IID
(nsIDOMKeyListener))))
{
return PR_FALSE;
}
}
}
else if (aPropName.EqualsWithConversion("onmousemove")) {
if (NS_OK == GetListenerManager(getter_AddRefs(manager))) {
nsCOMPtr<nsIScriptContext> scriptCX;
nsJSUtils::nsGetDynamicScriptContext(aContext,
getter_AddRefs(scriptCX));
if (!scriptCX ||
NS_FAILED(manager->RegisterScriptEventListener(scriptCX, this, atom,
NS_GET_IID
(nsIDOMMouseMotionListener))))
{
return PR_FALSE;
}
}
}
else if (aPropName.EqualsWithConversion("onfocus")
|| aPropName.EqualsWithConversion("onblur")) {
if (NS_OK == GetListenerManager(getter_AddRefs(manager))) {
nsCOMPtr<nsIScriptContext> scriptCX;
nsJSUtils::nsGetDynamicScriptContext(aContext,
getter_AddRefs(scriptCX));
if (!scriptCX ||
NS_FAILED(manager->RegisterScriptEventListener(scriptCX, this, atom,
NS_GET_IID
(nsIDOMFocusListener))))
{
return PR_FALSE;
}
}
}
else if (aPropName.EqualsWithConversion("onsubmit")
|| aPropName.EqualsWithConversion("onreset")
|| aPropName.EqualsWithConversion("onchange")
|| aPropName.EqualsWithConversion("onselect")) {
if (NS_OK == GetListenerManager(getter_AddRefs(manager))) {
nsCOMPtr<nsIScriptContext> scriptCX;
nsJSUtils::nsGetDynamicScriptContext(aContext,
getter_AddRefs(scriptCX));
if (!scriptCX ||
NS_FAILED(manager->RegisterScriptEventListener(scriptCX, this, atom,
NS_GET_IID
(nsIDOMFormListener))))
{
return PR_FALSE;
}
}
}
else if (aPropName.EqualsWithConversion("onload")
|| aPropName.EqualsWithConversion("onunload")
|| aPropName.EqualsWithConversion("onclose")
|| aPropName.EqualsWithConversion("onabort")
|| aPropName.EqualsWithConversion("onerror")) {
if (NS_OK == GetListenerManager(getter_AddRefs(manager))) {
nsCOMPtr<nsIScriptContext> scriptCX;
nsJSUtils::nsGetDynamicScriptContext(aContext,
getter_AddRefs(scriptCX));
if (!scriptCX ||
NS_FAILED(manager->RegisterScriptEventListener(scriptCX, this, atom,
NS_GET_IID
(nsIDOMLoadListener))))
{
return PR_FALSE;
}
}
}
else if (aPropName.EqualsWithConversion("onpaint")) {
if (NS_OK == GetListenerManager(getter_AddRefs(manager))) {
nsCOMPtr<nsIScriptContext> scriptCX;
nsJSUtils::nsGetDynamicScriptContext(aContext,
getter_AddRefs(scriptCX));
if (!scriptCX ||
NS_FAILED(manager->RegisterScriptEventListener(scriptCX, this, atom,
NS_GET_IID
(nsIDOMPaintListener))))
{
return PR_FALSE;
}
}
}
else if (aPropName.EqualsWithConversion("ondragdrop")) {
if (NS_OK == GetListenerManager(getter_AddRefs(manager))) {
nsCOMPtr<nsIScriptContext> scriptCX;
nsJSUtils::nsGetDynamicScriptContext(aContext,
getter_AddRefs(scriptCX));
if (!scriptCX ||
NS_FAILED(manager->RegisterScriptEventListener(scriptCX, this, atom,
NS_GET_IID
(nsIDOMDragListener))))
{
return PR_FALSE;
}
}
}
else if (aPropName.EqualsWithConversion("onresize")) {
if (NS_OK == GetListenerManager(getter_AddRefs(manager))) {
nsCOMPtr<nsIScriptContext> scriptCX;
nsJSUtils::nsGetDynamicScriptContext(aContext,
getter_AddRefs(scriptCX));
if (!scriptCX ||
NS_FAILED(manager->RegisterScriptEventListener(scriptCX, this, atom,
NS_GET_IID
(nsIDOMPaintListener))))
{
return PR_FALSE;
}
}
}
else if (aPropName.EqualsWithConversion("onscroll")) {
if (NS_OK == GetListenerManager(getter_AddRefs(manager))) {
nsCOMPtr<nsIScriptContext> scriptCX;
nsJSUtils::nsGetDynamicScriptContext(aContext,
getter_AddRefs(scriptCX));
if (!scriptCX ||
NS_FAILED(manager->RegisterScriptEventListener(scriptCX, this, atom,
NS_GET_IID
(nsIDOMPaintListener))))
{
return PR_FALSE;
}
}
}
return PR_TRUE;
}
void GlobalWindowImpl::FlushPendingNotifications()
{
if (mDocument) {
@ -4199,6 +3982,301 @@ void GlobalWindowImpl::FlushPendingNotifications()
}
}
nsresult
GlobalWindowImpl::RegisterEventListener(const char* aEventName,
REFNSIID aIID)
{
nsCOMPtr<nsIAtom> eventName = dont_AddRef(NS_NewAtom(aEventName));
// This should only happen from JS
nsCOMPtr<nsIThreadJSContextStack> stack(do_GetService("nsThreadJSContextStack"));
NS_ENSURE_TRUE(stack, NS_ERROR_FAILURE);
JSContext* cx;
NS_ENSURE_SUCCESS(stack->Peek(&cx), NS_ERROR_FAILURE);
NS_ENSURE_TRUE(cx, NS_ERROR_FAILURE);
nsCOMPtr<nsIEventListenerManager> manager;
if (NS_OK == GetListenerManager(getter_AddRefs(manager))) {
nsCOMPtr<nsIScriptContext> scriptCX;
nsJSUtils::nsGetDynamicScriptContext(cx, getter_AddRefs(scriptCX));
if (!scriptCX ||
NS_FAILED(manager->RegisterScriptEventListener(scriptCX, this,
eventName,
aIID))) {
return NS_ERROR_FAILURE;
}
}
return NS_OK;
}
NS_IMETHODIMP
GlobalWindowImpl::GetOnmousedown(jsval* aOnmousedown)
{
return NS_OK;
}
NS_IMETHODIMP
GlobalWindowImpl::SetOnmousedown(jsval aOnmousedown)
{
return RegisterEventListener("onmousedown", NS_GET_IID(nsIDOMMouseListener));
}
NS_IMETHODIMP
GlobalWindowImpl::GetOnmouseup(jsval* aOnmouseup)
{
return NS_OK;
}
NS_IMETHODIMP
GlobalWindowImpl::SetOnmouseup(jsval aOnmouseup)
{
return RegisterEventListener("onmouseup", NS_GET_IID(nsIDOMMouseListener));
}
NS_IMETHODIMP
GlobalWindowImpl::GetOnclick(jsval* aOnclick)
{
return NS_OK;
}
NS_IMETHODIMP
GlobalWindowImpl::SetOnclick(jsval aOnclick)
{
return RegisterEventListener("onclick", NS_GET_IID(nsIDOMMouseListener));
}
NS_IMETHODIMP
GlobalWindowImpl::GetOnmouseover(jsval* aOnmouseover)
{
return NS_OK;
}
NS_IMETHODIMP
GlobalWindowImpl::SetOnmouseover(jsval aOnmouseover)
{
return RegisterEventListener("onmouseover", NS_GET_IID(nsIDOMMouseListener));
}
NS_IMETHODIMP
GlobalWindowImpl::GetOnmouseout(jsval* aOnmouseout)
{
return NS_OK;
}
NS_IMETHODIMP
GlobalWindowImpl::SetOnmouseout(jsval aOnmouseout)
{
return RegisterEventListener("onmouseout", NS_GET_IID(nsIDOMMouseListener));
}
NS_IMETHODIMP
GlobalWindowImpl::GetOnkeydown(jsval* aOnkeydown)
{
return NS_OK;
}
NS_IMETHODIMP
GlobalWindowImpl::SetOnkeydown(jsval aOnkeydown)
{
return RegisterEventListener("onkeydown", NS_GET_IID(nsIDOMKeyListener));
}
NS_IMETHODIMP
GlobalWindowImpl::GetOnkeyup(jsval* aOnkeyup)
{
return NS_OK;
}
NS_IMETHODIMP
GlobalWindowImpl::SetOnkeyup(jsval aOnkeyup)
{
return RegisterEventListener("onkeyup", NS_GET_IID(nsIDOMKeyListener));
}
NS_IMETHODIMP
GlobalWindowImpl::GetOnkeypress(jsval* aOnkeypress)
{
return NS_OK;
}
NS_IMETHODIMP
GlobalWindowImpl::SetOnkeypress(jsval aOnkeypress)
{
return RegisterEventListener("onkeypress", NS_GET_IID(nsIDOMKeyListener));
}
NS_IMETHODIMP
GlobalWindowImpl::GetOnmousemove(jsval* aOnmousemove)
{
return NS_OK;
}
NS_IMETHODIMP
GlobalWindowImpl::SetOnmousemove(jsval aOnmousemove)
{
return RegisterEventListener("onkeypress", NS_GET_IID(nsIDOMMouseMotionListener));
}
NS_IMETHODIMP
GlobalWindowImpl::GetOnfocus(jsval* aOnfocus)
{
return NS_OK;
}
NS_IMETHODIMP
GlobalWindowImpl::SetOnfocus(jsval aOnfocus)
{
return RegisterEventListener("onfocus", NS_GET_IID(nsIDOMFocusListener));
}
NS_IMETHODIMP
GlobalWindowImpl::GetOnblur(jsval* aOnblur)
{
return NS_OK;
}
NS_IMETHODIMP
GlobalWindowImpl::SetOnblur(jsval aOnblur)
{
return RegisterEventListener("onblur", NS_GET_IID(nsIDOMFocusListener));
}
NS_IMETHODIMP
GlobalWindowImpl::GetOnsubmit(jsval* aOnsubmit)
{
return NS_OK;
}
NS_IMETHODIMP
GlobalWindowImpl::SetOnsubmit(jsval aOnsubmit)
{
return RegisterEventListener("onsubmit", NS_GET_IID(nsIDOMFormListener));
}
NS_IMETHODIMP
GlobalWindowImpl::GetOnreset(jsval* aOnreset)
{
return NS_OK;
}
NS_IMETHODIMP
GlobalWindowImpl::SetOnreset(jsval aOnreset)
{
return RegisterEventListener("onreset", NS_GET_IID(nsIDOMFormListener));
}
NS_IMETHODIMP
GlobalWindowImpl::GetOnchange(jsval* aOnchange)
{
return NS_OK;
}
NS_IMETHODIMP
GlobalWindowImpl::SetOnchange(jsval aOnchange)
{
return RegisterEventListener("onchange", NS_GET_IID(nsIDOMFormListener));
}
NS_IMETHODIMP
GlobalWindowImpl::GetOnselect(jsval* aOnselect)
{
return NS_OK;
}
NS_IMETHODIMP
GlobalWindowImpl::SetOnselect(jsval aOnselect)
{
return RegisterEventListener("onselect", NS_GET_IID(nsIDOMFormListener));
}
NS_IMETHODIMP
GlobalWindowImpl::GetOnload(jsval* aOnload)
{
return NS_OK;
}
NS_IMETHODIMP
GlobalWindowImpl::SetOnload(jsval aOnload)
{
return RegisterEventListener("onload", NS_GET_IID(nsIDOMLoadListener));
}
NS_IMETHODIMP
GlobalWindowImpl::GetOnunload(jsval* aOnunload)
{
return NS_OK;
}
NS_IMETHODIMP
GlobalWindowImpl::SetOnunload(jsval aOnunload)
{
return RegisterEventListener("onunload", NS_GET_IID(nsIDOMLoadListener));
}
NS_IMETHODIMP
GlobalWindowImpl::GetOnclose(jsval* aOnclose)
{
return NS_OK;
}
NS_IMETHODIMP
GlobalWindowImpl::SetOnclose(jsval aOnclose)
{
return RegisterEventListener("onclose", NS_GET_IID(nsIDOMLoadListener));
}
NS_IMETHODIMP
GlobalWindowImpl::GetOnabort(jsval* aOnabort)
{
return NS_OK;
}
NS_IMETHODIMP
GlobalWindowImpl::SetOnabort(jsval aOnabort)
{
return RegisterEventListener("onabort", NS_GET_IID(nsIDOMLoadListener));
}
NS_IMETHODIMP
GlobalWindowImpl::GetOnerror(jsval* aOnerror)
{
return NS_OK;
}
NS_IMETHODIMP
GlobalWindowImpl::SetOnerror(jsval aOnerror)
{
return RegisterEventListener("onerror", NS_GET_IID(nsIDOMLoadListener));
}
NS_IMETHODIMP
GlobalWindowImpl::GetOnpaint(jsval* aOnpaint)
{
return NS_OK;
}
NS_IMETHODIMP
GlobalWindowImpl::SetOnpaint(jsval aOnpaint)
{
return RegisterEventListener("onpaint", NS_GET_IID(nsIDOMPaintListener));
}
NS_IMETHODIMP
GlobalWindowImpl::GetOndragdrop(jsval* aOndragdrop)
{
return NS_OK;
}
NS_IMETHODIMP
GlobalWindowImpl::SetOndragdrop(jsval aOndragdrop)
{
return RegisterEventListener("ondragdrop", NS_GET_IID(nsIDOMDragListener));
}
NS_IMETHODIMP
GlobalWindowImpl::GetOnresize(jsval* aOnresize)
{
return NS_OK;
}
NS_IMETHODIMP
GlobalWindowImpl::SetOnresize(jsval aOnresize)
{
return RegisterEventListener("onresize", NS_GET_IID(nsIDOMPaintListener));
}
NS_IMETHODIMP
GlobalWindowImpl::GetOnscroll(jsval* aOnscroll)
{
return NS_OK;
}
NS_IMETHODIMP
GlobalWindowImpl::SetOnscroll(jsval aOnscroll)
{
return RegisterEventListener("onscroll", NS_GET_IID(nsIDOMPaintListener));
}
//*****************************************************************************
// GlobalWindowImpl: Creator Function (This should go away)
//*****************************************************************************

Просмотреть файл

@ -41,6 +41,7 @@
#include "nsIDOMNavigator.h"
#include "nsIDOMNSLocation.h"
#include "nsIDOMWindow.h"
#include "nsIDOMWindowEventOwner.h"
#include "nsIJSScriptObject.h"
#include "nsIScriptGlobalObject.h"
#include "nsITimer.h"
@ -168,6 +169,9 @@ public:
// nsIDOMAbstractView
NS_DECL_IDOMABSTRACTVIEW
// nsIDOMWindowEventOwner
NS_DECL_IDOMWINDOWEVENTOWNER
public:
// Object Management
GlobalWindowImpl();
@ -208,7 +212,8 @@ protected:
NS_IMETHOD GetWebBrowserChrome(nsIWebBrowserChrome** aBrowserChrome);
NS_IMETHOD GetScrollInfo(nsIScrollableView** aScrollableView, float* aP2T,
float* aT2P);
PRBool CheckForEventListener(JSContext* aContext, nsString& aPropName);
nsresult RegisterEventListener(const char* aEventName,
REFNSIID aIID);
void FlushPendingNotifications();
nsresult CheckSecurityWidthAndHeight(PRInt32* width, PRInt32* height);
nsresult CheckSecurityLeftAndTop(PRInt32* left, PRInt32* top);
@ -355,6 +360,8 @@ public:
virtual PRBool Convert(JSContext *aContext, JSObject *aObj, jsval aID);
virtual void Finalize(JSContext *aContext, JSObject *aObj);
nsresult SetHrefWithContext(JSContext* cx, jsval val);
protected:
nsresult SetURL(nsIURI* aURL);
nsresult SetHrefWithBase(const nsAReadableString& aHref,

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -366,6 +366,25 @@ LocationImpl::SetHref(const nsAReadableString& aHref)
return result;
}
nsresult
LocationImpl::SetHrefWithContext(JSContext* cx, jsval val)
{
nsCOMPtr<nsIURI> base;
nsAutoString href;
// Get the parameter passed in
nsJSUtils::nsConvertJSValToString(href, cx, val);
// Get the source of the caller
nsresult result = GetSourceURL(cx, getter_AddRefs(base));
if (NS_FAILED(result)) {
return result;
}
return SetHrefWithBase(href, base, PR_FALSE);
}
nsresult
LocationImpl::SetHrefWithBase(const nsAReadableString& aHref,
nsIURI* aBase,

Просмотреть файл

@ -100,7 +100,8 @@ enum Document_slots {
DOCUMENTSTYLE_STYLESHEETS = -4,
DOCUMENTVIEW_DEFAULTVIEW = -5,
NSDOCUMENT_CHARACTERSET = -6,
NSDOCUMENT_PLUGINS = -7
NSDOCUMENT_PLUGINS = -7,
NSDOCUMENT_LOCATION = -8
};
/***********************************************************************/
@ -241,6 +242,21 @@ GetDocumentProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
}
break;
}
case NSDOCUMENT_LOCATION:
{
rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_NSDOCUMENT_LOCATION, PR_FALSE);
if (NS_SUCCEEDED(rv)) {
nsIDOMNSDocument* b;
if (NS_OK == a->QueryInterface(kINSDocumentIID, (void **)&b)) {
rv = b->GetLocation(vp);
NS_RELEASE(b);
}
else {
rv = NS_ERROR_DOM_WRONG_TYPE_ERR;
}
}
break;
}
default:
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, obj, id, vp);
}
@ -274,7 +290,26 @@ SetDocumentProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
if (!secMan)
return PR_FALSE;
switch(JSVAL_TO_INT(id)) {
case 0:
case NSDOCUMENT_LOCATION:
{
rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_NSDOCUMENT_LOCATION, PR_TRUE);
if (NS_SUCCEEDED(rv)) {
jsval prop;
prop = *vp;
nsIDOMNSDocument *b;
if (NS_OK == a->QueryInterface(kINSDocumentIID, (void **)&b)) {
b->SetLocation(prop);
NS_RELEASE(b);
}
else {
rv = NS_ERROR_DOM_WRONG_TYPE_ERR;
}
}
break;
}
default:
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, obj, id, vp);
}
@ -1396,6 +1431,7 @@ static JSPropertySpec DocumentProperties[] =
{"defaultView", DOCUMENTVIEW_DEFAULTVIEW, JSPROP_ENUMERATE | JSPROP_READONLY},
{"characterSet", NSDOCUMENT_CHARACTERSET, JSPROP_ENUMERATE | JSPROP_READONLY},
{"plugins", NSDOCUMENT_PLUGINS, JSPROP_ENUMERATE | JSPROP_READONLY},
{"location", NSDOCUMENT_LOCATION, JSPROP_ENUMERATE},
{0}
};

Просмотреть файл

@ -321,6 +321,16 @@ static const char kPropFuncBeginStr[] = "\n"
" }\n"
"\n";
static const char kGlobalPropFuncBeginStr[] = "\n"
"/***********************************************************************/\n"
"//\n"
"// %s Properties %ster\n"
"//\n"
"PR_STATIC_CALLBACK(JSBool)\n"
"%s%sProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)\n"
"{\n"
"\n";
static const char kIntCaseStr[] =
" nsresult rv = NS_OK;\n"
" if (JSVAL_IS_INT(id)) {\n"
@ -329,6 +339,22 @@ static const char kIntCaseStr[] =
" return PR_FALSE;\n"
" switch(JSVAL_TO_INT(id)) {\n";
static const char kGlobalIntCaseStr[] =
" nsresult rv = NS_OK;\n"
" if (JSVAL_IS_INT(id)) {\n"
" nsIDOM%s *a = (nsIDOM%s*)nsJSUtils::nsGetNativeThis(cx, obj);\n"
"\n"
" // If there's no private data, this must be the prototype, so ignore\n"
" if (nsnull == a) {\n"
" return JS_TRUE;\n"
" }\n"
"\n"
" nsIScriptSecurityManager *secMan = nsJSUtils::nsGetSecurityManager(cx, obj);\n"
" if (!secMan)\n"
" return PR_FALSE;\n"
" switch(JSVAL_TO_INT(id)) {\n";
static const char kIntCaseNamedItemStr[] =
" PRBool checkNamedItem = PR_TRUE;\n"
" nsresult rv = NS_OK;\n"
@ -345,6 +371,20 @@ static const char kPropFuncDefaultStr[] =
" }\n"
" }\n";
static const char kGlobalPropFuncDefaultStr[] =
" default:\n"
" {\n"
" JSObject* global = JS_GetGlobalObject(cx);\n"
" if (global != obj) {\n"
" nsIScriptSecurityManager *secMan = nsJSUtils::nsGetSecurityManager(cx, obj);\n"
" rv = secMan->CheckScriptAccess(cx, obj,\n"
" NS_DOM_PROP_WINDOW_SCRIPTGLOBALS,\n"
" %s);\n"
" }\n"
" }\n"
" }\n"
" }\n";
static const char kPropFuncDefaultNamedItemStr[] =
" default:\n"
" checkNamedItem = PR_TRUE;\n"
@ -419,6 +459,22 @@ static const char kPropFuncEndStr[] =
" return PR_TRUE;\n"
"}\n";
static const char kGlobalPropFuncEndStr[] =
" else {\n"
" JSObject* global = JS_GetGlobalObject(cx);\n"
" if (global != obj) {\n"
" nsIScriptSecurityManager *secMan = nsJSUtils::nsGetSecurityManager(cx, obj);\n"
" rv = secMan->CheckScriptAccess(cx, obj,\n"
" NS_DOM_PROP_WINDOW_SCRIPTGLOBALS,\n"
" %s);\n"
" }\n"
" }\n"
"\n"
" if (NS_FAILED(rv))\n"
" return nsJSUtils::nsReportError(cx, obj, rv);\n"
" return PR_TRUE;\n"
"}\n";
static const char kPropFuncNamedItemStr[] =
"\n"
" if (checkNamedItem) {\n"
@ -511,12 +567,18 @@ static const char kPropFuncNamedItemEllipsisNonPrimaryStr[] =
#define JSGEN_GENERATE_PROPFUNCBEGIN(buffer, op, className) \
sprintf(buffer, kPropFuncBeginStr, className, op, op, className, className, className)
#define JSGEN_GENERATE_GLOBALPROPFUNCBEGIN(buffer, op, className) \
sprintf(buffer, kGlobalPropFuncBeginStr, className, op, op, className)
#define JSGEN_GENERATE_PROPFUNCEND(buffer, op) \
sprintf(buffer, kPropFuncEndStr, op)
#define JSGEN_GENERATE_PROPFUNCDEFAULT(buffer, op) \
sprintf(buffer, kPropFuncDefaultStr, op)
#define JSGEN_GENERATE_GLOBALINTCASE(buffer, className) \
sprintf(buffer, kGlobalIntCaseStr, className, className)
static const char kPropCaseBeginStr[] =
" case %s_%s:\n"
" {\n"
@ -539,7 +601,22 @@ JSStubGen::GeneratePropertyFunc(IdlSpecification &aSpec, PRBool aIsGetter)
IdlInterface *primary_iface = aSpec.GetInterfaceAt(0);
PRBool any = PR_FALSE;
JSGEN_GENERATE_PROPFUNCBEGIN(buf, aIsGetter ? "Get" : "Set", primary_iface->GetName());
if (aIsGetter) {
if (mIsGlobal) {
JSGEN_GENERATE_GLOBALPROPFUNCBEGIN(buf, "Get", primary_iface->GetName());
}
else {
JSGEN_GENERATE_PROPFUNCBEGIN(buf, "Get", primary_iface->GetName());
}
}
else {
if (mIsGlobal) {
JSGEN_GENERATE_GLOBALPROPFUNCBEGIN(buf, "Set", primary_iface->GetName());
}
else {
JSGEN_GENERATE_PROPFUNCBEGIN(buf, "Set", primary_iface->GetName());
}
}
*file << buf;
IdlFunction *item_func = NULL;
@ -571,7 +648,13 @@ JSStubGen::GeneratePropertyFunc(IdlSpecification &aSpec, PRBool aIsGetter)
}
if (NULL == named_item_func) {
*file << kIntCaseStr;
if (mIsGlobal) {
JSGEN_GENERATE_GLOBALINTCASE(buf, primary_iface->GetName());
*file << buf;
}
else {
*file << kIntCaseStr;
}
}
else {
*file << kIntCaseNamedItemStr;
@ -648,14 +731,24 @@ JSStubGen::GeneratePropertyFunc(IdlSpecification &aSpec, PRBool aIsGetter)
else if (NULL != named_item_func) {
*file << kPropFuncDefaultNamedItemStr;
}
else if (mIsGlobal) {
sprintf(buf, kGlobalPropFuncDefaultStr, "PR_FALSE");
*file << buf;
}
else {
JSGEN_GENERATE_PROPFUNCDEFAULT(buf, aIsGetter ? "Get" : "Set");
JSGEN_GENERATE_PROPFUNCDEFAULT(buf, "Get");
*file << buf;
}
}
else {
JSGEN_GENERATE_PROPFUNCDEFAULT(buf, aIsGetter ? "Get" : "Set");
*file << buf;
if (mIsGlobal) {
sprintf(buf, kGlobalPropFuncDefaultStr, "PR_TRUE");
*file << buf;
}
else {
JSGEN_GENERATE_PROPFUNCDEFAULT(buf, "Set");
*file << buf;
}
}
if (aIsGetter && (NULL != named_item_func)) {
@ -673,10 +766,20 @@ JSStubGen::GeneratePropertyFunc(IdlSpecification &aSpec, PRBool aIsGetter)
}
if (aIsGetter) {
JSGEN_GENERATE_PROPFUNCEND(buf, "Get");
if (mIsGlobal) {
sprintf(buf, kGlobalPropFuncEndStr, "PR_FALSE");
}
else {
JSGEN_GENERATE_PROPFUNCEND(buf, "Get");
}
}
else {
JSGEN_GENERATE_PROPFUNCEND(buf, "Set");
if (mIsGlobal) {
sprintf(buf, kGlobalPropFuncEndStr, "PR_TRUE");
}
else {
JSGEN_GENERATE_PROPFUNCEND(buf, "Set");
}
}
*file << buf;
}
@ -732,7 +835,17 @@ static const char kBoolGetCaseStr[] =
" *vp = BOOLEAN_TO_JSVAL(prop);\n";
static const char kJSValGetCaseStr[] =
" *vp = prop;\n";
" rv = a->Get%s(vp);\n";
static const char kJSValGetCaseNonPrimaryStr[] =
" nsIDOM%s* b;\n"
" if (NS_OK == a->QueryInterface(kI%sIID, (void **)&b)) {\n"
" rv = b->Get%s(vp);\n"
" NS_RELEASE(b);\n"
" }\n"
" else {\n"
" rv = NS_ERROR_DOM_WRONG_TYPE_ERR;\n"
" }\n";
void
JSStubGen::GeneratePropGetter(ofstream *file,
@ -771,9 +884,6 @@ JSStubGen::GeneratePropGetter(ofstream *file,
case TYPE_FLOAT:
case_str = kFloatGetCaseStr;
break;
case TYPE_JSVAL:
case_str = kJSValGetCaseStr;
break;
case TYPE_STRING:
case_str = kStringGetCaseStr;
break;
@ -790,16 +900,28 @@ JSStubGen::GeneratePropGetter(ofstream *file,
}
if (JSSTUBGEN_PRIMARY == aType) {
sprintf(buf, kGetCaseStr, attr_type, attr_name,
aAttribute.GetType() == TYPE_STRING ? "" : "&",
case_str);
if (aAttribute.GetType() == TYPE_JSVAL) {
sprintf(buf, kJSValGetCaseStr, attr_name);
}
else {
sprintf(buf, kGetCaseStr, attr_type, attr_name,
aAttribute.GetType() == TYPE_STRING ? "" : "&",
case_str);
}
}
else if (JSSTUBGEN_NONPRIMARY == aType) {
sprintf(buf, kGetCaseNonPrimaryStr, attr_type,
aInterface.GetName(), aInterface.GetName(),
attr_name,
aAttribute.GetType() == TYPE_STRING ? "" : "&",
case_str);
if (aAttribute.GetType() == TYPE_JSVAL) {
sprintf(buf, kJSValGetCaseNonPrimaryStr,
aInterface.GetName(), aInterface.GetName(),
attr_name);
}
else {
sprintf(buf, kGetCaseNonPrimaryStr, attr_type,
aInterface.GetName(), aInterface.GetName(),
attr_name,
aAttribute.GetType() == TYPE_STRING ? "" : "&",
case_str);
}
}
else if (JSSTUBGEN_DEFAULT == aType) {
char upr_iface_name[128];

Просмотреть файл

@ -177,15 +177,29 @@ XPCOMGen::GenerateIncludes(IdlInterface &aInterface)
*file << buf;
}
int m, mcount = aInterface.FunctionCount();
for (m = 0; m < mcount; m++) {
IdlFunction *func = aInterface.GetFunctionAt(m);
if (func->GetHasEllipsis()) {
PRBool includedJSAPI = 0;
int a, acount = aInterface.AttributeCount();
for (a = 0; a < acount; a++) {
IdlAttribute *attr = aInterface.GetAttributeAt(a);
if (attr->GetType() == TYPE_JSVAL) {
*file << kIncludeJSStr;
includedJSAPI = 1;
break;
}
}
if (!includedJSAPI) {
int m, mcount = aInterface.FunctionCount();
for (m = 0; m < mcount; m++) {
IdlFunction *func = aInterface.GetFunctionAt(m);
if (func->GetHasEllipsis()) {
*file << kIncludeJSStr;
break;
}
}
}
*file << "\n";
}

Просмотреть файл

@ -2414,6 +2414,30 @@ nsDocument::GetAnonymousNodes(nsIDOMElement* aElement, nsIDOMNodeList** aResult)
return NS_OK;
}
NS_IMETHODIMP
nsDocument::GetLocation(jsval* aLocation)
{
if (mScriptGlobalObject) {
nsCOMPtr<nsIDOMWindow> window(do_QueryInterface(mScriptGlobalObject));
if(window) {
return window->GetLocation(aLocation);
}
}
return NS_OK;
}
NS_IMETHODIMP
nsDocument::SetLocation(jsval aLocation)
{
if (mScriptGlobalObject) {
nsCOMPtr<nsIDOMWindow> window(do_QueryInterface(mScriptGlobalObject));
if(window) {
return window->SetLocation(aLocation);
}
}
return NS_OK;
}
NS_IMETHODIMP
nsDocument::CreateRange(nsIDOMRange** aReturn)
{
@ -3129,22 +3153,7 @@ PRBool nsDocument::DeleteProperty(JSContext *aContext, JSObject *aObj, jsval
PRBool nsDocument::GetProperty(JSContext *aContext, JSObject *aObj, jsval aID, jsval *aVp)
{
PRBool result = PR_TRUE;
if (JSVAL_IS_STRING(aID) &&
PL_strcmp("location", JS_GetStringBytes(JS_ValueToString(aContext, aID))) == 0) {
if (mScriptGlobalObject) {
nsCOMPtr<nsIJSScriptObject> window(do_QueryInterface(mScriptGlobalObject));
if(window) {
result = window->GetProperty(aContext, aObj, aID, aVp);
}
else {
result = PR_FALSE;
}
}
}
return result;
return PR_TRUE;
}
PRBool nsDocument::SetProperty(JSContext *aContext, JSObject *aObj, jsval aID, jsval *aVp)
@ -3237,18 +3246,6 @@ PRBool nsDocument::SetProperty(JSContext *aContext, JSObject *aObj, jsval aID
NS_IF_RELEASE(mManager);
}
}
else if (JSVAL_IS_STRING(aID) &&
PL_strcmp("location", JS_GetStringBytes(JS_ValueToString(aContext, aID))) == 0) {
if (mScriptGlobalObject) {
nsCOMPtr<nsIJSScriptObject> window(do_QueryInterface(mScriptGlobalObject));
if(window) {
result = window->SetProperty(aContext, aObj, aID, aVp);
}
else {
result = PR_FALSE;
}
}
}
return result;
}

Просмотреть файл

@ -397,6 +397,8 @@ public:
NS_IMETHOD CreateElementWithNameSpace(const nsAReadableString& aTagName,
const nsAReadableString& aNameSpace,
nsIDOMElement** aReturn);
NS_IMETHOD GetLocation(jsval* aLocation);
NS_IMETHOD SetLocation(jsval aLocation);
NS_IMETHOD CreateRange(nsIDOMRange** aReturn);
NS_IMETHOD Load (const nsAReadableString& aUrl);
NS_IMETHOD GetPlugins(nsIDOMPluginArray** aPlugins);

Просмотреть файл

@ -189,6 +189,8 @@ pref("capability.policy.default.history.item.read", "UniversalBrowserRead");
pref("capability.policy.default.navigator.preference.read", "UniversalPreferencesRead");
pref("capability.policy.default.navigator.preference.write", "UniversalPreferencesWrite");
pref("capability.policy.default.window.location.write", "allAccess");
localDefPref("ghist.expires.pos", 4);
localDefPref("ghist.expires.width", 1400);

Просмотреть файл

@ -3085,6 +3085,30 @@ nsXULDocument::GetAnonymousNodes(nsIDOMElement* aElement,
return NS_OK;
}
NS_IMETHODIMP
nsXULDocument::GetLocation(jsval* aLocation)
{
if (mScriptGlobalObject) {
nsCOMPtr<nsIDOMWindow> window(do_QueryInterface(mScriptGlobalObject));
if(window) {
return window->GetLocation(aLocation);
}
}
return NS_OK;
}
NS_IMETHODIMP
nsXULDocument::SetLocation(jsval aLocation)
{
if (mScriptGlobalObject) {
nsCOMPtr<nsIDOMWindow> window(do_QueryInterface(mScriptGlobalObject));
if(window) {
return window->SetLocation(aLocation);
}
}
return NS_OK;
}
NS_IMETHODIMP
nsXULDocument::Load(const nsAReadableString& aUrl)
{
@ -3754,19 +3778,6 @@ nsXULDocument::DeleteProperty(JSContext *aContext, JSObject *aObj, jsval aID, js
PRBool
nsXULDocument::GetProperty(JSContext *aContext, JSObject *aObj, jsval aID, jsval *aVp)
{
if (JSVAL_IS_STRING(aID)) {
JSString *jsString = JS_ValueToString(aContext, aID);
if (!jsString)
return PR_FALSE;
if (PL_strcmp("location", JS_GetStringBytes(jsString)) == 0) {
nsCOMPtr<nsIJSScriptObject> window = do_QueryInterface(mScriptGlobalObject);
if (nsnull != window) {
return window->GetProperty(aContext, aObj, aID, aVp);
}
}
}
return PR_TRUE;
}
@ -3802,10 +3813,6 @@ nsXULDocument::SetProperty(JSContext *aContext, JSObject *aObj, jsval aID, jsval
if (NS_FAILED(rv)) return PR_FALSE;
}
}
else if (PL_strcmp("location", s) == 0) {
NS_NOTYETIMPLEMENTED("write me");
return PR_FALSE;
}
}
return PR_TRUE;
}