mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-30 10:12:59 +00:00
Adding changes to DOM window object to allow window.screen and window.history
This commit is contained in:
parent
437c6358ab
commit
ab06020c2a
@ -27,6 +27,8 @@
|
||||
|
||||
class nsIDOMNavigator;
|
||||
class nsIDOMDocument;
|
||||
class nsIDOMScreen;
|
||||
class nsIDOMHistory;
|
||||
class nsIDOMWindowCollection;
|
||||
class nsIDOMWindow;
|
||||
|
||||
@ -46,6 +48,10 @@ public:
|
||||
|
||||
NS_IMETHOD GetNavigator(nsIDOMNavigator** aNavigator)=0;
|
||||
|
||||
NS_IMETHOD GetScreen(nsIDOMScreen** aScreen)=0;
|
||||
|
||||
NS_IMETHOD GetHistory(nsIDOMHistory** aHistory)=0;
|
||||
|
||||
NS_IMETHOD GetParent(nsIDOMWindow** aParent)=0;
|
||||
|
||||
NS_IMETHOD GetTop(nsIDOMWindow** aTop)=0;
|
||||
@ -139,6 +145,8 @@ public:
|
||||
NS_IMETHOD GetSelf(nsIDOMWindow** aSelf); \
|
||||
NS_IMETHOD GetDocument(nsIDOMDocument** aDocument); \
|
||||
NS_IMETHOD GetNavigator(nsIDOMNavigator** aNavigator); \
|
||||
NS_IMETHOD GetScreen(nsIDOMScreen** aScreen); \
|
||||
NS_IMETHOD GetHistory(nsIDOMHistory** aHistory); \
|
||||
NS_IMETHOD GetParent(nsIDOMWindow** aParent); \
|
||||
NS_IMETHOD GetTop(nsIDOMWindow** aTop); \
|
||||
NS_IMETHOD GetClosed(PRBool* aClosed); \
|
||||
@ -196,6 +204,8 @@ public:
|
||||
NS_IMETHOD GetSelf(nsIDOMWindow** aSelf) { return _to##GetSelf(aSelf); } \
|
||||
NS_IMETHOD GetDocument(nsIDOMDocument** aDocument) { return _to##GetDocument(aDocument); } \
|
||||
NS_IMETHOD GetNavigator(nsIDOMNavigator** aNavigator) { return _to##GetNavigator(aNavigator); } \
|
||||
NS_IMETHOD GetScreen(nsIDOMScreen** aScreen) { return _to##GetScreen(aScreen); } \
|
||||
NS_IMETHOD GetHistory(nsIDOMHistory** aHistory) { return _to##GetHistory(aHistory); } \
|
||||
NS_IMETHOD GetParent(nsIDOMWindow** aParent) { return _to##GetParent(aParent); } \
|
||||
NS_IMETHOD GetTop(nsIDOMWindow** aTop) { return _to##GetTop(aTop); } \
|
||||
NS_IMETHOD GetClosed(PRBool* aClosed) { return _to##GetClosed(aClosed); } \
|
||||
|
@ -41,6 +41,10 @@ CPPSRCS = \
|
||||
nsFrameList.cpp \
|
||||
nsJSSecurityManager.cpp \
|
||||
nsJSUtils.cpp \
|
||||
nsScreen.cpp \
|
||||
nsJSScreen.cpp \
|
||||
nsHistory.cpp \
|
||||
nsJSHistory.cpp \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = nsJSUtils.h
|
||||
|
@ -33,6 +33,10 @@ CPPSRCS = \
|
||||
nsFrameList.cpp \
|
||||
nsJSSecurityManager.cpp \
|
||||
nsJSUtils.cpp \
|
||||
nsScreen.cpp \
|
||||
nsJSScreen.cpp \
|
||||
nsHistory.cpp \
|
||||
nsJSHistory.cpp \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS=nsJSUtils.h
|
||||
@ -52,6 +56,10 @@ CPP_OBJS= \
|
||||
.\$(OBJDIR)\nsJSWindowCollection.obj \
|
||||
.\$(OBJDIR)\nsJSSecurityManager.obj \
|
||||
.\$(OBJDIR)\nsJSUtils.obj \
|
||||
.\$(OBJDIR)\nsScreen.obj \
|
||||
.\$(OBJDIR)\nsJSScreen.obj \
|
||||
.\$(OBJDIR)\nsHistory.obj \
|
||||
.\$(OBJDIR)\nsJSHistory.obj \
|
||||
$(NULL)
|
||||
|
||||
LINCS=-I$(XPDIST)\public\xpcom -I$(XPDIST)\public\raptor \
|
||||
|
@ -52,6 +52,8 @@
|
||||
#include "nsRect.h"
|
||||
#include "nsINetSupport.h"
|
||||
#include "nsIContentViewer.h"
|
||||
#include "nsScreen.h"
|
||||
#include "nsHistory.h"
|
||||
|
||||
#include "jsapi.h"
|
||||
|
||||
@ -88,6 +90,8 @@ GlobalWindowImpl::GlobalWindowImpl()
|
||||
mScriptObject = nsnull;
|
||||
mDocument = nsnull;
|
||||
mNavigator = nsnull;
|
||||
mScreen = nsnull;
|
||||
mHistory = nsnull;
|
||||
mLocation = nsnull;
|
||||
mFrames = nsnull;
|
||||
mOpener = nsnull;
|
||||
@ -109,6 +113,8 @@ GlobalWindowImpl::~GlobalWindowImpl()
|
||||
NS_IF_RELEASE(mContext);
|
||||
NS_IF_RELEASE(mDocument);
|
||||
NS_IF_RELEASE(mNavigator);
|
||||
NS_IF_RELEASE(mScreen);
|
||||
NS_IF_RELEASE(mHistory);
|
||||
NS_IF_RELEASE(mLocation);
|
||||
NS_IF_RELEASE(mFrames);
|
||||
NS_IF_RELEASE(mOpener);
|
||||
@ -234,6 +240,9 @@ GlobalWindowImpl::SetWebShell(nsIWebShell *aWebShell)
|
||||
if (nsnull != mLocation) {
|
||||
mLocation->SetWebShell(aWebShell);
|
||||
}
|
||||
if (nsnull != mHistory) {
|
||||
mHistory->SetWebShell(aWebShell);
|
||||
}
|
||||
if (nsnull != mFrames) {
|
||||
mFrames->SetWebShell(aWebShell);
|
||||
}
|
||||
@ -288,6 +297,37 @@ GlobalWindowImpl::GetNavigator(nsIDOMNavigator** aNavigator)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
GlobalWindowImpl::GetScreen(nsIDOMScreen** aScreen)
|
||||
{
|
||||
if (nsnull == mScreen) {
|
||||
mScreen = new ScreenImpl();
|
||||
NS_IF_ADDREF(mScreen);
|
||||
}
|
||||
|
||||
*aScreen = mScreen;
|
||||
NS_IF_ADDREF(mScreen);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
GlobalWindowImpl::GetHistory(nsIDOMHistory** aHistory)
|
||||
{
|
||||
if (nsnull == mHistory) {
|
||||
mHistory = new HistoryImpl();
|
||||
if (nsnull != mHistory) {
|
||||
NS_ADDREF(mHistory);
|
||||
mHistory->SetWebShell(mWebShell);
|
||||
}
|
||||
}
|
||||
|
||||
*aHistory = mHistory;
|
||||
NS_IF_ADDREF(mHistory);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
GlobalWindowImpl::GetOpener(nsIDOMWindow** aOpener)
|
||||
{
|
||||
@ -723,19 +763,27 @@ GlobalWindowImpl::Close()
|
||||
NS_IMETHODIMP
|
||||
GlobalWindowImpl::Forward()
|
||||
{
|
||||
if (NS_OK == mWebShell->CanForward())
|
||||
mWebShell->Forward();
|
||||
nsIBrowserWindow *mBrowser;
|
||||
|
||||
if (NS_OK == GetBrowserWindowInterface(mBrowser)) {
|
||||
//XXX tbi
|
||||
//mBrowser->Forward();
|
||||
NS_RELEASE(mBrowser);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
GlobalWindowImpl::Back()
|
||||
{
|
||||
if (NS_OK == mWebShell->CanBack())
|
||||
mWebShell->Back();
|
||||
|
||||
return NS_OK;
|
||||
nsIBrowserWindow *mBrowser;
|
||||
|
||||
if (NS_OK == GetBrowserWindowInterface(mBrowser)) {
|
||||
//XXX tbi
|
||||
//mBrowser->Back();
|
||||
NS_RELEASE(mBrowser);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsIDOMNavigator.h"
|
||||
#include "nsIDOMLocation.h"
|
||||
#include "nsIDOMScreen.h"
|
||||
#include "nsITimer.h"
|
||||
#include "nsIJSScriptObject.h"
|
||||
#include "nsIDOMEventCapturer.h"
|
||||
@ -45,6 +46,8 @@ typedef struct nsTimeoutImpl nsTimeoutImpl;
|
||||
|
||||
class LocationImpl;
|
||||
class NavigatorImpl;
|
||||
class ScreenImpl;
|
||||
class HistoryImpl;
|
||||
|
||||
// Global object for scripting
|
||||
class GlobalWindowImpl : public nsIScriptObjectOwner, public nsIScriptGlobalObject, public nsIDOMWindow,
|
||||
@ -68,6 +71,8 @@ public:
|
||||
NS_IMETHOD GetSelf(nsIDOMWindow** aSelf);
|
||||
NS_IMETHOD GetDocument(nsIDOMDocument** aDocument);
|
||||
NS_IMETHOD GetNavigator(nsIDOMNavigator** aNavigator);
|
||||
NS_IMETHOD GetScreen(nsIDOMScreen** aScreen);
|
||||
NS_IMETHOD GetHistory(nsIDOMHistory** aHistory);
|
||||
NS_IMETHOD GetLocation(nsIDOMLocation** aLocation);
|
||||
NS_IMETHOD GetParent(nsIDOMWindow** aOpener);
|
||||
NS_IMETHOD GetTop(nsIDOMWindow** aTop);
|
||||
@ -185,6 +190,8 @@ protected:
|
||||
nsIDOMDocument *mDocument;
|
||||
NavigatorImpl *mNavigator;
|
||||
LocationImpl *mLocation;
|
||||
ScreenImpl *mScreen;
|
||||
HistoryImpl *mHistory;
|
||||
nsIWebShell *mWebShell;
|
||||
nsIDOMWindow *mOpener;
|
||||
|
||||
|
@ -28,6 +28,8 @@
|
||||
#include "nsString.h"
|
||||
#include "nsIDOMNavigator.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMScreen.h"
|
||||
#include "nsIDOMHistory.h"
|
||||
#include "nsIDOMWindowCollection.h"
|
||||
#include "nsIDOMEventCapturer.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
@ -38,12 +40,16 @@ static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID);
|
||||
static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID);
|
||||
static NS_DEFINE_IID(kINavigatorIID, NS_IDOMNAVIGATOR_IID);
|
||||
static NS_DEFINE_IID(kIDocumentIID, NS_IDOMDOCUMENT_IID);
|
||||
static NS_DEFINE_IID(kIScreenIID, NS_IDOMSCREEN_IID);
|
||||
static NS_DEFINE_IID(kIHistoryIID, NS_IDOMHISTORY_IID);
|
||||
static NS_DEFINE_IID(kIWindowCollectionIID, NS_IDOMWINDOWCOLLECTION_IID);
|
||||
static NS_DEFINE_IID(kIEventCapturerIID, NS_IDOMEVENTCAPTURER_IID);
|
||||
static NS_DEFINE_IID(kIWindowIID, NS_IDOMWINDOW_IID);
|
||||
|
||||
NS_DEF_PTR(nsIDOMNavigator);
|
||||
NS_DEF_PTR(nsIDOMDocument);
|
||||
NS_DEF_PTR(nsIDOMScreen);
|
||||
NS_DEF_PTR(nsIDOMHistory);
|
||||
NS_DEF_PTR(nsIDOMWindowCollection);
|
||||
NS_DEF_PTR(nsIDOMEventCapturer);
|
||||
NS_DEF_PTR(nsIDOMWindow);
|
||||
@ -56,22 +62,24 @@ enum Window_slots {
|
||||
WINDOW_SELF = -2,
|
||||
WINDOW_DOCUMENT = -3,
|
||||
WINDOW_NAVIGATOR = -4,
|
||||
WINDOW_PARENT = -5,
|
||||
WINDOW_TOP = -6,
|
||||
WINDOW_CLOSED = -7,
|
||||
WINDOW_FRAMES = -8,
|
||||
WINDOW_OPENER = -9,
|
||||
WINDOW_STATUS = -10,
|
||||
WINDOW_DEFAULTSTATUS = -11,
|
||||
WINDOW_NAME = -12,
|
||||
WINDOW_INNERWIDTH = -13,
|
||||
WINDOW_INNERHEIGHT = -14,
|
||||
WINDOW_OUTERWIDTH = -15,
|
||||
WINDOW_OUTERHEIGHT = -16,
|
||||
WINDOW_SCREENX = -17,
|
||||
WINDOW_SCREENY = -18,
|
||||
WINDOW_PAGEXOFFSET = -19,
|
||||
WINDOW_PAGEYOFFSET = -20
|
||||
WINDOW_SCREEN = -5,
|
||||
WINDOW_HISTORY = -6,
|
||||
WINDOW_PARENT = -7,
|
||||
WINDOW_TOP = -8,
|
||||
WINDOW_CLOSED = -9,
|
||||
WINDOW_FRAMES = -10,
|
||||
WINDOW_OPENER = -11,
|
||||
WINDOW_STATUS = -12,
|
||||
WINDOW_DEFAULTSTATUS = -13,
|
||||
WINDOW_NAME = -14,
|
||||
WINDOW_INNERWIDTH = -15,
|
||||
WINDOW_INNERHEIGHT = -16,
|
||||
WINDOW_OUTERWIDTH = -17,
|
||||
WINDOW_OUTERHEIGHT = -18,
|
||||
WINDOW_SCREENX = -19,
|
||||
WINDOW_SCREENY = -20,
|
||||
WINDOW_PAGEXOFFSET = -21,
|
||||
WINDOW_PAGEYOFFSET = -22
|
||||
};
|
||||
|
||||
/***********************************************************************/
|
||||
@ -138,6 +146,30 @@ GetWindowProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
}
|
||||
break;
|
||||
}
|
||||
case WINDOW_SCREEN:
|
||||
{
|
||||
nsIDOMScreen* prop;
|
||||
if (NS_OK == a->GetScreen(&prop)) {
|
||||
// get the js object
|
||||
nsJSUtils::nsConvertObjectToJSVal((nsISupports *)prop, cx, vp);
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case WINDOW_HISTORY:
|
||||
{
|
||||
nsIDOMHistory* prop;
|
||||
if (NS_OK == a->GetHistory(&prop)) {
|
||||
// get the js object
|
||||
nsJSUtils::nsConvertObjectToJSVal((nsISupports *)prop, cx, vp);
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case WINDOW_PARENT:
|
||||
{
|
||||
nsIDOMWindow* prop;
|
||||
@ -1451,6 +1483,8 @@ static JSPropertySpec WindowProperties[] =
|
||||
{"self", WINDOW_SELF, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||
{"document", WINDOW_DOCUMENT, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||
{"navigator", WINDOW_NAVIGATOR, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||
{"screen", WINDOW_SCREEN, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||
{"history", WINDOW_HISTORY, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||
{"parent", WINDOW_PARENT, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||
{"top", WINDOW_TOP, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||
{"closed", WINDOW_CLOSED, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||
|
Loading…
x
Reference in New Issue
Block a user