Bug 454235 - IME events not fired when clicking on text input box, adds IsOffScreenBrowser property to DocShell r=smaug sr=bz

This commit is contained in:
Brad Lassey 2008-09-19 12:57:56 -04:00
parent be30cbf4ef
commit 4aa13cc558
6 changed files with 100 additions and 3 deletions

View File

@ -299,6 +299,7 @@ nsDocShell::nsDocShell():
mIsBeingDestroyed(PR_FALSE),
mIsExecutingOnLoadHandler(PR_FALSE),
mIsPrintingOrPP(PR_FALSE),
mIsOffScreenBrowser(PR_FALSE),
mSavingOldViewer(PR_FALSE),
mAppType(nsIDocShell::APP_TYPE_UNKNOWN),
mChildOffset(0),
@ -3928,7 +3929,8 @@ nsDocShell::GetVisibility(PRBool * aVisibility)
}
// otherwise, we must walk up the document and view trees checking
// for a hidden view.
// for a hidden view, unless we're an off screen browser, which
// would make this test meaningless.
nsCOMPtr<nsIDocShellTreeItem> treeItem = this;
nsCOMPtr<nsIDocShellTreeItem> parentItem;
@ -3953,7 +3955,9 @@ nsDocShell::GetVisibility(PRBool * aVisibility)
NS_ASSERTION(shellContent, "subshell not in the map");
nsIFrame* frame = pPresShell->GetPrimaryFrameFor(shellContent);
if (frame && !frame->AreAncestorViewsVisible()) {
PRBool isDocShellOffScreen = PR_FALSE;
docShell->GetIsOffScreenBrowser(&isDocShellOffScreen);
if (frame && !frame->AreAncestorViewsVisible() && !isDocShellOffScreen) {
*aVisibility = PR_FALSE;
return NS_OK;
}
@ -3974,6 +3978,20 @@ nsDocShell::GetVisibility(PRBool * aVisibility)
return treeOwnerAsWin->GetVisibility(aVisibility);
}
NS_IMETHODIMP
nsDocShell::SetIsOffScreenBrowser(PRBool aIsOffScreen)
{
mIsOffScreenBrowser = aIsOffScreen;
return NS_OK;
}
NS_IMETHODIMP
nsDocShell::GetIsOffScreenBrowser(PRBool *aIsOffScreen)
{
*aIsOffScreen = mIsOffScreenBrowser;
return NS_OK;
}
NS_IMETHODIMP
nsDocShell::SetVisibility(PRBool aVisibility)
{

View File

@ -562,6 +562,7 @@ protected:
PRPackedBool mObserveErrorPages;
PRPackedBool mAllowAuth;
PRPackedBool mAllowKeywordFixup;
PRPackedBool mIsOffScreenBrowser;
// This boolean is set to true right before we fire pagehide and generally
// unset when we embed a new content viewer. While it's true no navigation

View File

@ -68,7 +68,7 @@ interface nsILayoutHistoryState;
interface nsISecureBrowserUI;
interface nsIDOMStorage;
[scriptable, uuid(7d1cf6b9-daa3-476d-8f9f-9eb2a971a95c)]
[scriptable, uuid(dc4daea1-b43d-406f-bd62-c2ee879192ad)]
interface nsIDocShell : nsISupports
{
/**
@ -463,5 +463,12 @@ interface nsIDocShell : nsISupports
* editor data in the open document's session history entry.
*/
[noscript, notxpcom] void DetachEditorFromWindow();
/**
* If true, this browser is not visible in the traditional sense, but
* is actively being rendered to the screen (ex. painted on a canvas)
* and should be treated accordingly.
**/
attribute boolean isOffScreenBrowser;
};

View File

@ -51,6 +51,8 @@ _TEST_FILES = \
test_bug396519.xul \
bug396519_window.xul \
test_bug428288.html \
test_bug454235.xul \
bug454235-subframe.xul \
$(NULL)
libs:: $(_TEST_FILES)

View File

@ -0,0 +1,7 @@
<window title="Mozilla Bug 454235 SubFrame"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<deck flex="1">
<browser id="topBrowser" src="about:mozilla"/>
<browser id="burriedBrowser" src="about:mozilla"/>
</deck>
</window>

View File

@ -0,0 +1,62 @@
<?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"?>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=454235
-->
<window title="Mozilla Bug 454235"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<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>
<!-- test results are displayed in the html:body -->
<body xmlns="http://www.w3.org/1999/xhtml">
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=454235"
target="_blank">Mozilla Bug 454235</a>
</body>
<!-- test code goes here -->
<script type="application/javascript"><![CDATA[
/** Test for Bug 454235 **/
SimpleTest.waitForExplicitFinish();
addLoadEvent(doTest);
function doTest() {
var shownBrowser = document.getElementById("shownBrowser");
var hiddenBrowser = document.getElementById("hiddenBrowser");
var offScreenBrowser = document.getElementById("offScreenBrowser");
var offScreenSubBrowser = offScreenBrowser.contentDocument.getElementById("topBrowser");
var offScreenBurriedBrowser = offScreenBrowser.contentDocument.getElementById("burriedBrowser");
shownBrowser.contentWindow.focus();
ok(shownBrowser.contentDocument.hasFocus(), "visible browser is not visible");
hiddenBrowser.contentWindow.focus();
ok(!hiddenBrowser.contentDocument.hasFocus(),"hidden browser is visible");
offScreenBrowser.docShell.isOffScreenBrowser = true;
offScreenBrowser.contentWindow.focus();
ok(offScreenBrowser.contentDocument.hasFocus(),"offscreen browser is not visible");
offScreenSubBrowser.wrappedJSObject.contentWindow.focus();
todo(offScreenSubBrowser.wrappedJSObject.contentDocument.hasFocus(),"visible browser in offscreen browser is not visible");
offScreenBurriedBrowser.wrappedJSObject.contentWindow.focus();
ok(!offScreenBurriedBrowser.wrappedJSObject.contentDocument.hasFocus(),"hidden browser in offscreen browser is visible");
SimpleTest.finish();
}
]]></script>
<deck flex="1" style="border:5px black solid">
<browser style="border:5px green solid" id="shownBrowser" src="bug454235-subframe.xul"/>
<browser style="border:5px blue solid" id="hiddenBrowser" src="bug454235-subframe.xul"/>
<browser style="border:5px yellow solid" id="offScreenBrowser" src="bug454235-subframe.xul"/>
</deck>
</window>