Bug 484488 - MakeFullWindow support for windows mobile. r=olli.pettay, sr=vlad

This commit is contained in:
Doug Turner 2009-07-01 12:01:11 -07:00
parent 4eddd594bc
commit d210ca62c4
18 changed files with 280 additions and 107 deletions

View File

@ -2582,6 +2582,7 @@ SessionStoreService.prototype = {
_getWindowDimension: function sss_getWindowDimension(aWindow, aAttribute) {
if (aAttribute == "sizemode") {
switch (aWindow.windowState) {
case aWindow.STATE_FULLSCREEN:
case aWindow.STATE_MAXIMIZED:
return "maximized";
case aWindow.STATE_MINIMIZED:

View File

@ -148,7 +148,6 @@
#include "nsIContentViewer.h"
#include "nsDOMClassInfo.h"
#include "nsIJSNativeInitializer.h"
#include "nsIFullScreen.h"
#include "nsIScriptError.h"
#include "nsIScriptEventManager.h" // For GetInterface()
#include "nsIConsoleService.h"
@ -603,7 +602,6 @@ nsGlobalWindow::nsGlobalWindow(nsGlobalWindow *aOuterWindow)
: nsPIDOMWindow(aOuterWindow),
mIsFrozen(PR_FALSE),
mDidInitJavaProperties(PR_FALSE),
mFullScreen(PR_FALSE),
mIsClosed(PR_FALSE),
mInClose(PR_FALSE),
mHavePendingClose(PR_FALSE),
@ -2113,29 +2111,6 @@ nsGlobalWindow::SetDocShell(nsIDocShell* aDocShell)
langCtx->ClearScope(mScriptGlobals[NS_STID_INDEX(lang_id)], PR_TRUE);
}
// if we are closing the window while in full screen mode, be sure
// to restore os chrome
if (mFullScreen) {
// only restore OS chrome if the closing window was active
nsIFocusManager* fm = nsFocusManager::GetFocusManager();
if (fm) {
nsCOMPtr<nsIDOMWindow> activeWindow;
fm->GetActiveWindow(getter_AddRefs(activeWindow));
nsCOMPtr<nsIDocShellTreeItem> treeItem = do_QueryInterface(mDocShell);
nsCOMPtr<nsIDocShellTreeItem> rootItem;
treeItem->GetRootTreeItem(getter_AddRefs(rootItem));
nsCOMPtr<nsIDOMWindow> rootWin = do_GetInterface(rootItem);
if (rootWin == activeWindow) {
nsCOMPtr<nsIFullScreen> fullScreen =
do_GetService("@mozilla.org/browser/fullscreen;1");
if (fullScreen)
fullScreen->ShowAllOSChrome();
}
}
}
ClearControllers();
mChromeEventHandler = nsnull; // force release now
@ -3844,8 +3819,6 @@ nsGlobalWindow::SetFullScreen(PRBool aFullScreen)
if (widget)
widget->MakeFullScreen(aFullScreen);
mFullScreen = aFullScreen;
return NS_OK;
}
@ -3867,8 +3840,13 @@ nsGlobalWindow::GetFullScreen(PRBool* aFullScreen)
}
}
// We are the root window, or something went wrong. Return our internal value.
*aFullScreen = mFullScreen;
nsCOMPtr<nsIWidget> widget = GetMainWidget();
PRInt32 mode;
if (!widget)
return NS_ERROR_UNEXPECTED;
widget->GetSizeMode(&mode);
*aFullScreen = mode == nsSizeMode_Fullscreen;
return NS_OK;
}
@ -6591,20 +6569,6 @@ nsGlobalWindow::GetLocation(nsIDOMLocation ** aLocation)
void
nsGlobalWindow::ActivateOrDeactivate(PRBool aActivate)
{
// if the window is deactivated while in full screen mode,
// restore OS chrome, and hide it again upon re-activation
nsGlobalWindow* outer = GetOuterWindowInternal();
if (outer && outer->mFullScreen) {
nsCOMPtr<nsIFullScreen> fullScreen =
do_GetService("@mozilla.org/browser/fullscreen;1");
if (fullScreen) {
if (aActivate)
fullScreen->HideAllOSChrome();
else
fullScreen->ShowAllOSChrome();
}
}
// Set / unset the "active" attribute on the documentElement
// of the top level window
nsCOMPtr<nsIWidget> mainWidget = GetMainWidget();
@ -8767,6 +8731,9 @@ nsGlobalChromeWindow::GetWindowState(PRUint16* aWindowState)
case nsSizeMode_Maximized:
*aWindowState = nsIDOMChromeWindow::STATE_MAXIMIZED;
break;
case nsSizeMode_Fullscreen:
*aWindowState = nsIDOMChromeWindow::STATE_FULLSCREEN;
break;
case nsSizeMode_Normal:
*aWindowState = nsIDOMChromeWindow::STATE_NORMAL;
break;
@ -8797,16 +8764,8 @@ nsGlobalChromeWindow::Minimize()
nsCOMPtr<nsIWidget> widget = GetMainWidget();
nsresult rv = NS_OK;
if (widget) {
// minimize doesn't send deactivate events on windows,
// so we need to forcefully restore the os chrome
nsCOMPtr<nsIFullScreen> fullScreen =
do_GetService("@mozilla.org/browser/fullscreen;1");
if (fullScreen)
fullScreen->ShowAllOSChrome();
if (widget)
rv = widget->SetSizeMode(nsSizeMode_Minimized);
}
return rv;
}

View File

@ -670,7 +670,6 @@ protected:
// These members are only used on outer window objects. Make sure
// you never set any of these on an inner object!
PRPackedBool mFullScreen : 1;
PRPackedBool mIsClosed : 1;
PRPackedBool mInClose : 1;
// mHavePendingClose means we've got a termination function set to

View File

@ -40,12 +40,13 @@
interface nsIBrowserDOMWindow;
[scriptable, uuid(77a20f5a-68ad-41d3-97ac-6ff721512908)]
[scriptable, uuid(09A5E148-2A77-4739-9DD9-3D552F5390EE)]
interface nsIDOMChromeWindow : nsISupports
{
const unsigned short STATE_MAXIMIZED = 1;
const unsigned short STATE_MINIMIZED = 2;
const unsigned short STATE_NORMAL = 3;
const unsigned short STATE_FULLSCREEN = 4;
readonly attribute unsigned short windowState;

View File

@ -44,7 +44,12 @@ relativesrcdir = dom/tests/mochitest/chrome
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
_TEST_FILES = test_domstorage.xul \
_TEST_FILES = \
test_fullscreen.xul \
fullscreen.xul \
test_fullscreen_preventdefault.xul \
fullscreen_preventdefault.xul \
test_domstorage.xul \
domstorage_global.xul \
domstorage_global.js \
test_focus.xul \

View File

@ -0,0 +1,29 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
<!--
Test for fullscreen sizemode in chrome
-->
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
sizemode="fullscreen">
<script type="application/javascript"
src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script>
window.addEventListener("fullscreen", onFullScreen, true);
function onFullScreen()
{
window.opener.wrappedJSObject.done();
}
</script>
<button id="find-button" label="Find"/>
<button id="cancel-button" label="Cancel"/>
</window>

View File

@ -0,0 +1,30 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
<!--
Test for fullscreen sizemode in chrome
-->
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
sizemode="fullscreen">
<script type="application/javascript"
src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script>
window.addEventListener("fullscreen", onFullScreen, true);
function onFullScreen(event)
{
event.preventDefault();
window.opener.wrappedJSObject.done();
}
</script>
<button id="find-button" label="Find"/>
<button id="cancel-button" label="Cancel"/>
</window>

View File

@ -0,0 +1,37 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
<!--
Test for fullscreen sizemode in chrome
-->
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
sizemode="fullscreen">
<script type="application/javascript"
src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script>
SimpleTest.waitForExplicitFinish();
newwindow = window.open("fullscreen.xul", "_blank","chrome,resizable=yes");
function done()
{
setTimeout("complete()", 0);
}
function complete()
{
ok(newwindow.fullScreen, "window.fullScreen is true.");
newwindow.close();
SimpleTest.finish();
}
</script>
<body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
</window>

View File

@ -0,0 +1,39 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
<!--
Test for fullscreen sizemode in chrome
-->
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
sizemode="fullscreen">
<script type="application/javascript"
src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script>
SimpleTest.waitForExplicitFinish();
newwindow = window.open("fullscreen_preventdefault.xul", "_blank","chrome,resizable=yes");
function done()
{
// because we are cancelling the fullscreen event, it
// takes a bit for the fullScreen property to be set
setTimeout("complete()", 0);
}
function complete()
{
ok(!(newwindow.fullScreen), "window.fullScreen is false.");
newwindow.close();
SimpleTest.finish();
}
</script>
<body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
</window>

View File

@ -97,7 +97,6 @@ XPIDLSRCS = \
nsIRollupListener.idl \
nsIBaseWindow.idl \
nsIBidiKeyboard.idl \
nsIFullScreen.idl \
nsIScreen.idl \
nsIScreenManager.idl \
nsIPrintSession.idl \

View File

@ -63,7 +63,8 @@ enum nsEventStatus {
enum nsSizeMode {
nsSizeMode_Normal = 0,
nsSizeMode_Minimized,
nsSizeMode_Maximized
nsSizeMode_Maximized,
nsSizeMode_Fullscreen
};
class nsEvent;

View File

@ -1140,12 +1140,22 @@ NS_METHOD nsWindow::Show(PRBool bState)
if (!wasVisible && mWindowType == eWindowType_toplevel) {
switch (mSizeMode) {
#ifdef WINCE
case nsSizeMode_Fullscreen:
::SetForegroundWindow(mWnd);
::ShowWindow(mWnd, SW_SHOWMAXIMIZED);
MakeFullScreen(TRUE);
break;
case nsSizeMode_Maximized :
::SetForegroundWindow(mWnd);
::ShowWindow(mWnd, SW_SHOWMAXIMIZED);
break;
// use default for nsSizeMode_Minimized on Windows CE
#else
case nsSizeMode_Fullscreen:
::ShowWindow(mWnd, SW_SHOWMAXIMIZED);
break;
case nsSizeMode_Maximized :
::ShowWindow(mWnd, SW_SHOWMAXIMIZED);
break;
@ -1497,6 +1507,10 @@ NS_IMETHODIMP nsWindow::SetSizeMode(PRInt32 aMode) {
int mode;
switch (aMode) {
case nsSizeMode_Fullscreen :
mode = SW_MAXIMIZE;
break;
case nsSizeMode_Maximized :
mode = SW_MAXIMIZE;
break;
@ -2303,6 +2317,27 @@ NS_METHOD nsWindow::Invalidate(const nsIntRect & aRect, PRBool aIsSynchronous)
return NS_OK;
}
NS_IMETHODIMP
nsWindow::MakeFullScreen(PRBool aFullScreen)
{
#if WINCE
RECT rc;
if (aFullScreen) {
SetForegroundWindow(mWnd);
SHFullScreen(mWnd, SHFS_HIDETASKBAR | SHFS_HIDESTARTICON);
SetRect(&rc, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
}
else {
SHFullScreen(mWnd, SHFS_SHOWTASKBAR | SHFS_SHOWSTARTICON);
SystemParametersInfo(SPI_GETWORKAREA, 0, &rc, FALSE);
}
MoveWindow(mWnd, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, TRUE);
return NS_OK;
#else
return nsBaseWidget::MakeFullScreen(aFullScreen);
#endif
}
/**************************************************************
*
* SECTION: nsIWidget::Update
@ -4124,6 +4159,8 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM &wParam, LPARAM &lParam,
#else
*aRetValue = 0;
#endif
if (mSizeMode == nsSizeMode_Fullscreen)
MakeFullScreen(TRUE);
}
}
break;
@ -4283,7 +4320,7 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM &wParam, LPARAM &lParam,
else
event.mSizeMode = nsSizeMode_Normal;
#else
event.mSizeMode = nsSizeMode_Normal;
event.mSizeMode = mSizeMode;
#endif
InitEvent(event);
@ -6456,4 +6493,4 @@ DWORD ChildWindow::WindowStyle()
style |= WS_CHILD; // WS_POPUP and WS_CHILD are mutually exclusive.
VERIFY_WINDOW_STYLE(style);
return style;
}
}

View File

@ -140,6 +140,7 @@ public:
NS_IMETHOD SetCursor(imgIContainer* aCursor,
PRUint32 aHotspotX, PRUint32 aHotspotY);
NS_IMETHOD SetCursor(nsCursor aCursor);
NS_IMETHOD MakeFullScreen(PRBool aFullScreen);
NS_IMETHOD HideWindowChrome(PRBool aShouldHide);
NS_IMETHOD Validate();
NS_IMETHOD Invalidate(PRBool aIsSynchronous);
@ -519,4 +520,4 @@ protected:
virtual DWORD WindowStyle();
};
#endif // Window_h__
#endif // Window_h__

View File

@ -315,7 +315,8 @@ NS_IMETHODIMP nsWindow::SetSizeMode(PRInt32 aMode)
// on windows mobile, dialogs and top level windows are full screen
// This is partly due to the lack of a GetWindowPlacement.
if (mWindowType == eWindowType_dialog || mWindowType == eWindowType_toplevel) {
aMode = nsSizeMode_Maximized;
if (aMode == nsSizeMode_Normal)
aMode = nsSizeMode_Maximized;
}
#endif
@ -325,6 +326,7 @@ NS_IMETHODIMP nsWindow::SetSizeMode(PRInt32 aMode)
int mode;
switch (aMode) {
case nsSizeMode_Fullscreen :
case nsSizeMode_Maximized :
mode = SW_MAXIMIZE;
break;
@ -433,4 +435,4 @@ PRBool nsWindow::OnHotKey(WPARAM wParam, LPARAM lParam)
break;
}
return PR_FALSE;
}
}

View File

@ -41,7 +41,6 @@
#include "nsCOMPtr.h"
#include "nsGfxCIID.h"
#include "nsWidgetsCID.h"
#include "nsIFullScreen.h"
#include "nsServiceManagerUtils.h"
#include "nsIScreenManager.h"
#include "nsAppDirectoryServiceDefs.h"
@ -442,8 +441,11 @@ NS_IMETHODIMP nsBaseWidget::PlaceBehind(nsTopLevelWidgetZPlacement aPlacement,
//-------------------------------------------------------------------------
NS_IMETHODIMP nsBaseWidget::SetSizeMode(PRInt32 aMode) {
if (aMode == nsSizeMode_Normal || aMode == nsSizeMode_Minimized ||
aMode == nsSizeMode_Maximized) {
if (aMode == nsSizeMode_Normal ||
aMode == nsSizeMode_Minimized ||
aMode == nsSizeMode_Maximized ||
aMode == nsSizeMode_Fullscreen) {
mSizeMode = (nsSizeMode) aMode;
return NS_OK;
@ -586,9 +588,9 @@ NS_IMETHODIMP nsBaseWidget::HideWindowChrome(PRBool aShouldHide)
//-------------------------------------------------------------------------
NS_IMETHODIMP nsBaseWidget::MakeFullScreen(PRBool aFullScreen)
{
HideWindowChrome(aFullScreen);
SetSizeMode(aFullScreen ? nsSizeMode_Fullscreen : nsSizeMode_Normal);
nsCOMPtr<nsIFullScreen> fullScreen = do_GetService("@mozilla.org/browser/fullscreen;1");
HideWindowChrome(aFullScreen);
if (aFullScreen) {
if (!mOriginalBounds)
@ -607,12 +609,7 @@ NS_IMETHODIMP nsBaseWidget::MakeFullScreen(PRBool aFullScreen)
if (screen) {
PRInt32 left, top, width, height;
if (NS_SUCCEEDED(screen->GetRect(&left, &top, &width, &height))) {
SetSizeMode(nsSizeMode_Normal);
Resize(left, top, width, height, PR_TRUE);
// Hide all of the OS chrome
if (fullScreen)
fullScreen->HideAllOSChrome();
}
}
}
@ -620,10 +617,6 @@ NS_IMETHODIMP nsBaseWidget::MakeFullScreen(PRBool aFullScreen)
} else if (mOriginalBounds) {
Resize(mOriginalBounds->x, mOriginalBounds->y, mOriginalBounds->width,
mOriginalBounds->height, PR_TRUE);
// Show all of the OS chrome
if (fullScreen)
fullScreen->ShowAllOSChrome();
}
return NS_OK;

View File

@ -347,7 +347,8 @@ nsWebShellWindow::HandleEvent(nsGUIEvent *aEvent)
// normal browser windows. here we just drop a raised window
// to the normal zlevel if it's maximized. we make no provision
// for automatically re-raising it when restored.
if (modeEvent->mSizeMode == nsSizeMode_Maximized) {
if (modeEvent->mSizeMode == nsSizeMode_Maximized ||
modeEvent->mSizeMode == nsSizeMode_Fullscreen) {
PRUint32 zLevel;
eventWindow->GetZLevel(&zLevel);
if (zLevel > nsIXULWindow::normalZ)

View File

@ -95,9 +95,10 @@
#include "nsWebShellWindow.h" // get rid of this one, too...
#define SIZEMODE_NORMAL NS_LITERAL_STRING("normal")
#define SIZEMODE_MAXIMIZED NS_LITERAL_STRING("maximized")
#define SIZEMODE_MINIMIZED NS_LITERAL_STRING("minimized")
#define SIZEMODE_NORMAL NS_LITERAL_STRING("normal")
#define SIZEMODE_MAXIMIZED NS_LITERAL_STRING("maximized")
#define SIZEMODE_MINIMIZED NS_LITERAL_STRING("minimized")
#define SIZEMODE_FULLSCREEN NS_LITERAL_STRING("fullscreen")
#define WINDOWTYPE_ATTRIBUTE NS_LITERAL_STRING("windowtype")
@ -255,7 +256,7 @@ NS_IMETHODIMP nsXULWindow::SetZLevel(PRUint32 aLevel)
PRInt32 sizeMode;
if (mWindow) {
mWindow->GetSizeMode(&sizeMode);
if (sizeMode == nsSizeMode_Maximized)
if (sizeMode == nsSizeMode_Maximized || sizeMode == nsSizeMode_Fullscreen)
return NS_ERROR_FAILURE;
}
}
@ -275,30 +276,7 @@ NS_IMETHODIMP nsXULWindow::SetZLevel(PRUint32 aLevel)
SavePersistentAttributes();
// finally, send a notification DOM event
nsCOMPtr<nsIContentViewer> cv;
mDocShell->GetContentViewer(getter_AddRefs(cv));
nsCOMPtr<nsIDocumentViewer> dv(do_QueryInterface(cv));
if (dv) {
nsCOMPtr<nsIDocument> doc;
dv->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDOMDocumentEvent> docEvent(do_QueryInterface(doc));
if (docEvent) {
nsCOMPtr<nsIDOMEvent> event;
docEvent->CreateEvent(NS_LITERAL_STRING("Events"), getter_AddRefs(event));
if (event) {
event->InitEvent(NS_LITERAL_STRING("windowZLevel"), PR_TRUE, PR_FALSE);
nsCOMPtr<nsIPrivateDOMEvent> privateEvent(do_QueryInterface(event));
privateEvent->SetTrusted(PR_TRUE);
nsCOMPtr<nsIDOMEventTarget> targ(do_QueryInterface(doc));
if (targ) {
PRBool defaultActionEnabled;
targ->DispatchEvent(event, &defaultActionEnabled);
}
}
}
}
DispatchCustomEvent(NS_LITERAL_STRING("windowZLevel"));
return NS_OK;
}
@ -1202,17 +1180,33 @@ PRBool nsXULWindow::LoadMiscPersistentAttributesFromXUL()
if (stateString.Equals(SIZEMODE_MINIMIZED))
sizeMode = nsSizeMode_Minimized;
*/
if (stateString.Equals(SIZEMODE_MAXIMIZED)) {
if (stateString.Equals(SIZEMODE_MAXIMIZED) || stateString.Equals(SIZEMODE_FULLSCREEN)) {
/* Honor request to maximize only if the window is sizable.
An unsizable, unmaximizable, yet maximized window confuses
Windows OS and is something of a travesty, anyway. */
if (mChromeFlags & nsIWebBrowserChrome::CHROME_WINDOW_RESIZE) {
mIntrinsicallySized = PR_FALSE;
sizeMode = nsSizeMode_Maximized;
if (stateString.Equals(SIZEMODE_MAXIMIZED))
sizeMode = nsSizeMode_Maximized;
else
sizeMode = nsSizeMode_Fullscreen;
}
}
// Dispatch fullscreen event
if (sizeMode == nsSizeMode_Fullscreen) {
if (!DispatchCustomEvent(NS_LITERAL_STRING("fullscreen"), PR_TRUE, PR_FALSE)) {
// fullscreen event prevented the default, set the window to
// maximized instead of fullscreen.
sizeMode = nsSizeMode_Maximized;
mWindow->SetSizeMode(sizeMode);
}
}
// the widget had better be able to deal with not becoming visible yet
mWindow->SetSizeMode(sizeMode);
gotState = PR_TRUE;
}
@ -1522,6 +1516,8 @@ NS_IMETHODIMP nsXULWindow::SavePersistentAttributes()
persistString.Find("sizemode") >= 0) {
if (sizeMode == nsSizeMode_Maximized)
sizeString.Assign(SIZEMODE_MAXIMIZED);
else if (sizeMode == nsSizeMode_Fullscreen)
sizeString.Assign(SIZEMODE_FULLSCREEN);
else
sizeString.Assign(SIZEMODE_NORMAL);
docShellElement->SetAttribute(MODE_ATTRIBUTE, sizeString);
@ -2139,6 +2135,48 @@ PRInt32 nsXULWindow::AppUnitsPerDevPixel()
return mAppPerDev;
}
PRBool nsXULWindow::DispatchCustomEvent(const nsAString& eventName, PRBool cancelable, PRBool toDocument)
{
nsCOMPtr<nsIContentViewer> cv;
mDocShell->GetContentViewer(getter_AddRefs(cv));
nsCOMPtr<nsIDocumentViewer> dv(do_QueryInterface(cv));
if (dv) {
nsCOMPtr<nsIDocument> doc;
dv->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDOMDocumentEvent> docEvent(do_QueryInterface(doc));
if (docEvent) {
nsCOMPtr<nsIDOMEvent> event;
docEvent->CreateEvent(NS_LITERAL_STRING("Events"), getter_AddRefs(event));
if (event) {
event->InitEvent(eventName, PR_TRUE, cancelable);
nsCOMPtr<nsIPrivateDOMEvent> privateEvent(do_QueryInterface(event));
privateEvent->SetTrusted(PR_TRUE);
if (toDocument) {
nsCOMPtr<nsIDOMEventTarget> targ(do_QueryInterface(doc));
if (targ) {
PRBool defaultActionEnabled;
targ->DispatchEvent(event, &defaultActionEnabled);
return defaultActionEnabled;
}
} else {
nsCOMPtr<nsIDOMWindowInternal> ourWindow;
GetWindowDOMWindow(getter_AddRefs(ourWindow));
nsCOMPtr<nsIDOMEventTarget> targ(do_QueryInterface(ourWindow));
if (targ) {
PRBool defaultActionEnabled;
targ->DispatchEvent(event, &defaultActionEnabled);
return defaultActionEnabled;
}
}
}
}
}
return PR_TRUE;
}
//*****************************************************************************
//*** nsContentShellInfo: Object Management
//*****************************************************************************

View File

@ -150,6 +150,7 @@ protected:
PRBool GetContentScrollbarVisibility();
void PersistentAttributesDirty(PRUint32 aDirtyFlags);
PRInt32 AppUnitsPerDevPixel();
PRBool DispatchCustomEvent(const nsAString& eventName, PRBool cancelable = PR_FALSE, PRBool toDocument = PR_TRUE);
nsChromeTreeOwner* mChromeTreeOwner;
nsContentTreeOwner* mContentTreeOwner;