Permalink
Browse files

Landing the split window work, bug 296639. This change doesn't have f…

…ull reviews yet, bzbarsky@mit.edu and shaver@mozilla.org have done partial reviews, but there's still more to look at. Given the current time constraint this is landed with reviews and followup changes that result to come after the initial checkin. a=drivers
  • Loading branch information...
jst%mozilla.jstenback.com
jst%mozilla.jstenback.com committed Jul 30, 2005
1 parent afdb1c6 commit 8c2bc6fcb8925d74b5e7bd6f978417494fc629a4
Showing with 2,054 additions and 690 deletions.
  1. +4 −3 content/base/public/nsIDocument.h
  2. +12 −3 content/base/src/nsDocument.cpp
  3. +5 −1 content/base/src/nsDocument.h
  4. +3 −3 content/base/src/nsScriptLoader.cpp
  5. +3 −0 content/events/public/nsIEventListenerManager.h
  6. +36 −26 content/events/src/nsEventListenerManager.cpp
  7. +6 −2 content/events/src/nsEventListenerManager.h
  8. +77 −33 content/events/src/nsEventStateManager.cpp
  9. +8 −2 content/html/content/src/nsGenericHTMLElement.cpp
  10. +3 −2 content/html/content/src/nsHTMLScriptElement.cpp
  11. +1 −1 content/xbl/src/nsBindingManager.cpp
  12. +13 −5 content/xbl/src/nsXBLBinding.cpp
  13. +7 −0 content/xbl/src/nsXBLDocumentInfo.cpp
  14. +13 −2 content/xbl/src/nsXBLProtoImpl.cpp
  15. +12 −2 content/xbl/src/nsXBLProtoImplMethod.cpp
  16. +13 −1 content/xbl/src/nsXBLProtoImplProperty.cpp
  17. +7 −2 content/xbl/src/nsXBLPrototypeBinding.cpp
  18. +7 −8 content/xbl/src/nsXBLPrototypeHandler.cpp
  19. +0 −1 content/xbl/src/nsXBLWindowKeyHandler.cpp
  20. +3 −1 content/xul/document/src/nsXULDocument.cpp
  21. +7 −0 content/xul/document/src/nsXULPrototypeDocument.cpp
  22. +4 −3 content/xul/templates/src/nsXULTemplateBuilder.cpp
  23. +6 −6 docshell/base/nsDocShell.cpp
  24. +94 −14 dom/public/base/nsPIDOMWindow.h
  25. +2 −6 dom/public/nsIDOMScriptObjectFactory.h
  26. +15 −2 dom/public/nsIJSEventListener.h
  27. +15 −0 dom/public/nsIScriptContext.h
  28. +7 −0 dom/public/nsIScriptGlobalObject.h
  29. +475 −99 dom/src/base/nsDOMClassInfo.cpp
  30. +42 −9 dom/src/base/nsDOMClassInfo.h
  31. +4 −12 dom/src/base/nsDOMScriptObjectFactory.cpp
  32. +0 −4 dom/src/base/nsDOMScriptObjectFactory.h
  33. +49 −38 dom/src/base/nsFocusController.cpp
  34. +2 −1 dom/src/base/nsFocusController.h
  35. +786 −276 dom/src/base/nsGlobalWindow.cpp
  36. +71 −18 dom/src/base/nsGlobalWindow.h
  37. +23 −10 dom/src/base/nsJSEnvironment.cpp
  38. +17 −9 dom/src/base/nsJSEnvironment.h
  39. +10 −9 dom/src/events/nsJSEventListener.cpp
  40. +2 −6 dom/src/events/nsJSEventListener.h
  41. +22 −27 embedding/components/windowwatcher/src/nsWindowWatcher.cpp
  42. +8 −2 js/src/jsapi.h
  43. +16 −1 js/src/jsinterp.c
  44. +20 −2 js/src/jsobj.c
  45. +2 −0 js/src/jsxml.c
  46. +9 −1 js/src/xpconnect/idl/nsIXPCScriptable.idl
  47. +1 −1 js/src/xpconnect/idl/xpccomponents.idl
  48. +24 −0 js/src/xpconnect/public/xpc_map_end.h
  49. +3 −1 js/src/xpconnect/src/xpcprivate.h
  50. +62 −11 js/src/xpconnect/src/xpcwrappednativejsops.cpp
  51. +13 −20 layout/base/nsDocumentViewer.cpp
  52. +1 −1 layout/base/nsPresContext.h
  53. +9 −3 layout/base/nsPresShell.cpp
@@ -461,9 +461,10 @@ class nsIDocument : public nsISupports
virtual nsIHTMLCSSStyleSheet* GetInlineStyleSheet() const = 0;
/**
* Set the object from which a document can get a script context.
* This is the context within which all scripts (during document
* creation and during event handling) will run.
* Get/set the object from which a document can get a script context
* and scope. This is the context within which all scripts (during
* document creation and during event handling) will run. Note that
* this is the *inner* window object.
*/
virtual nsIScriptGlobalObject* GetScriptGlobalObject() const = 0;
virtual void SetScriptGlobalObject(nsIScriptGlobalObject* aGlobalObject) = 0;
@@ -96,6 +96,7 @@
#include "nsIPrivateDOMImplementation.h"
#include "nsIDOMWindowInternal.h"
#include "nsPIDOMWindow.h"
#include "nsIDOMElement.h"
#include "nsIBoxObject.h"
@@ -2914,11 +2915,19 @@ nsDocument::CreateTreeWalker(nsIDOMNode *aRoot,
NS_IMETHODIMP
nsDocument::GetDefaultView(nsIDOMAbstractView** aDefaultView)
{
if (mScriptGlobalObject) {
return CallQueryInterface(mScriptGlobalObject, aDefaultView);
*aDefaultView = nsnull;
nsCOMPtr<nsPIDOMWindow> win(do_QueryInterface(mScriptGlobalObject));
if (win) {
// The default view is our outer window.
if (!win->IsInnerWindow()) {
return NS_ERROR_UNEXPECTED;
}
return CallQueryInterface(win->GetOuterWindow(), aDefaultView);
}
*aDefaultView = nsnull;
return NS_OK;
}
@@ -172,7 +172,6 @@ class nsDOMStyleSheetList : public nsIDOMStyleSheetList,
protected:
PRInt32 mLength;
nsIDocument* mDocument;
void* mScriptObject;
};
class nsOnloadBlocker : public nsIRequest
@@ -616,7 +615,12 @@ class nsDocument : public nsIDocument,
// Basically always has at least 1 entry
nsAutoVoidArray mObservers;
// The document's script global object, the object from which the
// document can get its script context and scope. This is the
// *inner* window object.
nsCOMPtr<nsIScriptGlobalObject> mScriptGlobalObject;
nsCOMPtr<nsIEventListenerManager> mListenerManager;
nsCOMPtr<nsIDOMStyleSheetList> mDOMStyleSheets;
nsCOMPtr<nsIScriptLoader> mScriptLoader;
@@ -749,9 +749,9 @@ nsScriptLoader::EvaluateScript(nsScriptLoadRequest* aRequest,
mCurrentScript = aRequest->mElement;
PRBool isUndefined;
context->EvaluateString(aScript, nsnull, principal, url.get(),
aRequest->mLineNo, aRequest->mJSVersion, nsnull,
&isUndefined);
context->EvaluateString(aScript, globalObject->GetGlobalJSObject(),
principal, url.get(), aRequest->mLineNo,
aRequest->mJSVersion, nsnull, &isUndefined);
// Put the old script back in case it wants to do anything else.
mCurrentScript = oldCurrent;
@@ -48,6 +48,7 @@ class nsIScriptContext;
class nsIDOMEventTarget;
class nsIDOMEventGroup;
class nsIAtom;
struct JSObject;
/*
* Event listener manager interface.
@@ -115,6 +116,7 @@ class nsIEventListenerManager : public nsISupports {
* @param the name of an event listener
*/
NS_IMETHOD RegisterScriptEventListener(nsIScriptContext *aContext,
JSObject *aScopeObject,
nsISupports *aObject,
nsIAtom* aName) = 0;
@@ -123,6 +125,7 @@ class nsIEventListenerManager : public nsISupports {
* script object for a given event type.
* @param an event listener */
NS_IMETHOD CompileScriptEventListener(nsIScriptContext *aContext,
JSObject *aScopeObject,
nsISupports *aObject,
nsIAtom* aName,
PRBool *aDidCompile) = 0;
@@ -88,7 +88,6 @@
#include "nsIPresShell.h"
#include "nsMutationEvent.h"
#include "nsIXPConnect.h"
#include "nsIDOMScriptObjectFactory.h"
#include "nsDOMCID.h"
#include "nsIScriptObjectOwner.h" // for nsIScriptEventHandlerOwner
#include "nsIClassInfo.h"
@@ -1102,7 +1101,8 @@ nsEventListenerManager::FindJSEventListener(EventArrayType aType)
}
nsresult
nsEventListenerManager::SetJSEventListener(nsIScriptContext *aContext,
nsEventListenerManager::SetJSEventListener(nsIScriptContext *aContext,
JSObject *aScopeObject,
nsISupports *aObject,
nsIAtom* aName,
PRBool aIsString,
@@ -1121,13 +1121,9 @@ nsEventListenerManager::SetJSEventListener(nsIScriptContext *aContext,
if (nsnull == ls) {
// If we didn't find a script listener or no listeners existed
// create and add a new one.
nsCOMPtr<nsIDOMScriptObjectFactory> factory =
do_GetService(kDOMScriptObjectFactoryCID);
NS_ENSURE_TRUE(factory, NS_ERROR_FAILURE);
nsCOMPtr<nsIDOMEventListener> scriptListener;
rv = factory->NewJSEventListener(aContext, aObject,
getter_AddRefs(scriptListener));
rv = NS_NewJSEventListener(aContext, aScopeObject, aObject,
getter_AddRefs(scriptListener));
if (NS_SUCCEEDED(rv)) {
AddEventListener(scriptListener, arrayType, NS_EVENT_BITS_NONE, nsnull,
NS_EVENT_FLAG_BUBBLE | NS_PRIV_EVENT_FLAG_SCRIPT, nsnull);
@@ -1172,13 +1168,16 @@ nsEventListenerManager::AddScriptEventListener(nsISupports *aObject,
nsISupports *objiSupp = aObject;
JSObject *scope = nsnull;
if (content) {
// Try to get context from doc
doc = content->GetOwnerDoc();
nsIScriptGlobalObject *global;
if (doc && (global = doc->GetScriptGlobalObject())) {
context = global->GetContext();
scope = global->GetGlobalJSObject();
}
} else {
nsCOMPtr<nsIDOMWindow> win(do_QueryInterface(aObject));
@@ -1199,11 +1198,13 @@ nsEventListenerManager::AddScriptEventListener(nsISupports *aObject,
}
if (global) {
context = global->GetContext();
scope = global->GetGlobalJSObject();
}
}
if (!context) {
// Get JSContext from stack.
// Get JSContext from stack, or use the safe context (and hidden
// window global) if no JS is running.
nsCOMPtr<nsIThreadJSContextStack> stack =
do_GetService("@mozilla.org/js/xpc/ContextStack;1");
NS_ENSURE_TRUE(stack, NS_ERROR_FAILURE);
@@ -1216,6 +1217,13 @@ nsEventListenerManager::AddScriptEventListener(nsISupports *aObject,
context = nsJSUtils::GetDynamicScriptContext(cx);
NS_ENSURE_TRUE(context, NS_ERROR_FAILURE);
scope = ::JS_GetGlobalObject(cx);
} else if (!scope) {
NS_ERROR("Context reachable, but no scope reachable in "
"AddScriptEventListener()!");
return NS_ERROR_NOT_AVAILABLE;
}
nsresult rv;
@@ -1224,8 +1232,7 @@ nsEventListenerManager::AddScriptEventListener(nsISupports *aObject,
JSContext *cx = (JSContext *)context->GetNativeContext();
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
rv = nsContentUtils::XPConnect()->WrapNative(cx, ::JS_GetGlobalObject(cx),
aObject,
rv = nsContentUtils::XPConnect()->WrapNative(cx, scope, aObject,
NS_GET_IID(nsISupports),
getter_AddRefs(holder));
NS_ENSURE_SUCCESS(rv, rv);
@@ -1297,7 +1304,7 @@ nsEventListenerManager::AddScriptEventListener(nsISupports *aObject,
}
}
return SetJSEventListener(context, objiSupp, aName, aDeferCompilation,
return SetJSEventListener(context, scope, objiSupp, aName, aDeferCompilation,
aPermitUntrustedEvents);
}
@@ -1335,6 +1342,7 @@ nsEventListenerManager::sAddListenerID = JSVAL_VOID;
NS_IMETHODIMP
nsEventListenerManager::RegisterScriptEventListener(nsIScriptContext *aContext,
JSObject *aScopeObject,
nsISupports *aObject,
nsIAtom *aName)
{
@@ -1357,8 +1365,8 @@ nsEventListenerManager::RegisterScriptEventListener(nsIScriptContext *aContext,
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
rv = nsContentUtils::XPConnect()->
WrapNative(current_cx, ::JS_GetGlobalObject(current_cx), aObject,
NS_GET_IID(nsISupports), getter_AddRefs(holder));
WrapNative(current_cx, aScopeObject, aObject, NS_GET_IID(nsISupports),
getter_AddRefs(holder));
NS_ENSURE_SUCCESS(rv, rv);
// Since JSEventListeners only have a raw nsISupports pointer, it's
@@ -1372,11 +1380,11 @@ nsEventListenerManager::RegisterScriptEventListener(nsIScriptContext *aContext,
rv = holder->GetJSObject(&jsobj);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIClassInfo> classInfo = do_QueryInterface(aObject);
if (sAddListenerID == JSVAL_VOID && cx) {
sAddListenerID =
STRING_TO_JSVAL(::JS_InternString(cx, "addEventListener"));
if (cx) {
if (sAddListenerID == JSVAL_VOID) {
sAddListenerID =
STRING_TO_JSVAL(::JS_InternString(cx, "addEventListener"));
}
rv = nsContentUtils::GetSecurityManager()->
CheckPropertyAccess(cx, jsobj,
@@ -1391,12 +1399,13 @@ nsEventListenerManager::RegisterScriptEventListener(nsIScriptContext *aContext,
// Untrusted events are always permitted for non-chrome script
// handlers.
return SetJSEventListener(aContext, wrapper->Native(), aName, PR_FALSE,
!nsContentUtils::IsCallerChrome());
return SetJSEventListener(aContext, aScopeObject, wrapper->Native(), aName,
PR_FALSE, !nsContentUtils::IsCallerChrome());
}
nsresult
nsEventListenerManager::CompileScriptEventListener(nsIScriptContext *aContext,
JSObject *aScopeObject,
nsISupports *aObject,
nsIAtom *aName,
PRBool *aDidCompile)
@@ -1419,7 +1428,8 @@ nsEventListenerManager::CompileScriptEventListener(nsIScriptContext *aContext,
}
if (ls->mHandlerIsString & subType) {
rv = CompileEventHandlerInternal(aContext, aObject, aName, ls, /*XXX fixme*/nsnull, subType);
rv = CompileEventHandlerInternal(aContext, aScopeObject, aObject, aName,
ls, /*XXX fixme*/nsnull, subType);
}
// Set *aDidCompile to true even if we didn't really compile
@@ -1434,6 +1444,7 @@ nsEventListenerManager::CompileScriptEventListener(nsIScriptContext *aContext,
nsresult
nsEventListenerManager::CompileEventHandlerInternal(nsIScriptContext *aContext,
JSObject *aScopeObject,
nsISupports *aObject,
nsIAtom *aName,
nsListenerStruct *aListenerStruct,
@@ -1445,9 +1456,7 @@ nsEventListenerManager::CompileEventHandlerInternal(nsIScriptContext *aContext,
JSContext *cx = (JSContext *)aContext->GetNativeContext();
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
result = nsContentUtils::XPConnect()->WrapNative(cx,
::JS_GetGlobalObject(cx),
aObject,
result = nsContentUtils::XPConnect()->WrapNative(cx, aScopeObject, aObject,
NS_GET_IID(nsISupports),
getter_AddRefs(holder));
NS_ENSURE_SUCCESS(result, result);
@@ -1561,6 +1570,7 @@ nsEventListenerManager::HandleEventSubType(nsListenerStruct* aListenerStruct,
nsCOMPtr<nsIAtom> atom = do_GetAtom(NS_LITERAL_STRING("on") + eventString);
result = CompileEventHandlerInternal(jslistener->GetEventContext(),
jslistener->GetEventScope(),
jslistener->GetEventTarget(),
atom, aListenerStruct,
aCurrentTarget,
@@ -2141,7 +2151,7 @@ nsEventListenerManager::FixContextMenuEvent(nsPresContext* aPresContext,
currentTarget = do_QueryInterface(currentFocus);
nsCOMPtr<nsIPrivateDOMEvent> pEvent(do_QueryInterface(*aDOMEvent));
pEvent->SetTarget (currentTarget);
pEvent->SetTarget(currentTarget);
}
}
@@ -130,10 +130,12 @@ class nsEventListenerManager : public nsIEventListenerManager,
PRBool aDeferCompilation,
PRBool aPermitUntrustedEvents);
NS_IMETHOD RegisterScriptEventListener(nsIScriptContext *aContext,
JSObject *aScopeObject,
nsISupports *aObject,
nsIAtom* aName);
NS_IMETHOD RemoveScriptEventListener(nsIAtom *aName);
NS_IMETHOD CompileScriptEventListener(nsIScriptContext *aContext,
JSObject *aScopeObject,
nsISupports *aObject,
nsIAtom* aName, PRBool *aDidCompile);
@@ -195,15 +197,17 @@ class nsEventListenerManager : public nsIEventListenerManager,
PRUint32 aSubType,
PRUint32 aPhaseFlags);
nsresult CompileEventHandlerInternal(nsIScriptContext *aContext,
JSObject *aScopeObject,
nsISupports *aObject,
nsIAtom *aName,
nsListenerStruct *aListenerStruct,
nsIDOMEventTarget* aCurrentTarget,
PRUint32 aSubType);
nsListenerStruct* FindJSEventListener(EventArrayType aType);
nsresult SetJSEventListener(nsIScriptContext *aContext,
nsISupports *aObject, nsIAtom* aName,
PRBool aIsString, PRBool aPermitUntrustedEvents);
JSObject *aScopeObject, nsISupports *aObject,
nsIAtom* aName, PRBool aIsString,
PRBool aPermitUntrustedEvents);
nsresult AddEventListener(nsIDOMEventListener *aListener,
EventArrayType aType,
PRInt32 aSubType,
Oops, something went wrong.

0 comments on commit 8c2bc6f

Please sign in to comment.