Bug 516727 - Electrolysis+Fennec: forward mouse events from the chrome tiles to the content process

This commit is contained in:
Olli Pettay 2009-11-05 20:21:09 +02:00
parent ca88319903
commit 3d8a76e521
8 changed files with 94 additions and 1 deletions

View File

@ -43,7 +43,7 @@ interface nsIDocShell;
interface nsIURI;
interface nsIFrame;
[scriptable, uuid(897af00a-c907-4311-88dc-f9d12f05b110)]
[scriptable, uuid(8f94788d-ec69-4220-971c-0fd68d47b80f)]
interface nsIFrameLoader : nsISupports
{
/**
@ -88,6 +88,18 @@ interface nsIFrameLoader : nsISupports
* Throws an exception with non-remote frames.
*/
void activateRemoteFrame();
/**
* @see nsIDOMWindowUtils sendMouseEvent.
*/
void sendCrossProcessMouseEvent(in AString aType,
in float aX,
in float aY,
in long aButton,
in long aClickCount,
in long aModifiers,
[optional] in boolean aIgnoreRootScrollFrame);
};
native alreadyAddRefed_nsFrameLoader(already_AddRefed<nsFrameLoader>);

View File

@ -1470,3 +1470,24 @@ nsFrameLoader::ActivateRemoteFrame() {
#endif
return NS_ERROR_UNEXPECTED;
}
NS_IMETHODIMP
nsFrameLoader::SendCrossProcessMouseEvent(const nsAString& aType,
float aX,
float aY,
PRInt32 aButton,
PRInt32 aClickCount,
PRInt32 aModifiers,
PRBool aIgnoreRootScrollFrame)
{
#ifdef MOZ_IPC
if (mChildProcess) {
mChildProcess->SendMouseEvent(aType, aX, aY, aButton,
aClickCount, aModifiers,
aIgnoreRootScrollFrame);
return NS_OK;
}
#endif
return NS_ERROR_FAILURE;
}

View File

@ -75,6 +75,17 @@ child:
*/
activate();
/**
* @see nsIDOMWindowUtils sendMouseEvent.
*/
sendMouseEvent(nsString aType,
PRInt32 aX, //XXX should be float, but ipdl doesn't seem to support that.
PRInt32 aY, //XXX - " -
PRInt32 aButton,
PRInt32 aClickCount,
PRInt32 aModifiers,
bool aIgnoreRootScrollFrame);
PDocumentRenderer(PRInt32 x, PRInt32 y, PRInt32 w, PRInt32 h, nsString bgcolor, PRUint32 flags, bool flush);
parent:

View File

@ -312,6 +312,23 @@ TabChild::Recvactivate()
return true;
}
bool
TabChild::RecvsendMouseEvent(const nsString& aType,
const PRInt32& aX,
const PRInt32& aY,
const PRInt32& aButton,
const PRInt32& aClickCount,
const PRInt32& aModifiers,
const bool& aIgnoreRootScrollFrame)
{
nsCOMPtr<nsPIDOMWindow> window = do_GetInterface(mWebNav);
nsCOMPtr<nsIDOMWindowUtils> utils = do_GetInterface(window);
NS_ENSURE_TRUE(utils, true);
utils->SendMouseEvent(aType, aX, aY, aButton, aClickCount, aModifiers,
aIgnoreRootScrollFrame);
return true;
}
mozilla::ipc::PDocumentRendererChild*
TabChild::AllocPDocumentRenderer(
const PRInt32& x,

View File

@ -75,6 +75,13 @@ public:
const PRUint32& width,
const PRUint32& height);
virtual bool Recvactivate();
virtual bool RecvsendMouseEvent(const nsString& aType,
const PRInt32& aX,
const PRInt32& aY,
const PRInt32& aButton,
const PRInt32& aClickCount,
const PRInt32& aModifiers,
const bool& aIgnoreRootScrollFrame);
virtual mozilla::ipc::PDocumentRendererChild* AllocPDocumentRenderer(
const PRInt32& x,
const PRInt32& y,

View File

@ -124,5 +124,14 @@ TabParent::RecvPDocumentRendererDestructor(PDocumentRendererParent* __a,
return true;
}
void
TabParent::SendMouseEvent(const nsAString& aType, float aX, float aY,
PRInt32 aButton, PRInt32 aClickCount,
PRInt32 aModifiers, PRBool aIgnoreRootScrollFrame)
{
SendsendMouseEvent(nsString(aType), aX, aY, aButton, aClickCount,
aModifiers, aIgnoreRootScrollFrame);
}
} // namespace tabs
} // namespace mozilla

View File

@ -61,6 +61,9 @@ public:
void LoadURL(nsIURI* aURI);
void Move(PRUint32 x, PRUint32 y, PRUint32 width, PRUint32 height);
void Activate();
void SendMouseEvent(const nsAString& aType, float aX, float aY,
PRInt32 aButton, PRInt32 aClickCount,
PRInt32 aModifiers, PRBool aIgnoreRootScrollFrame);
virtual mozilla::ipc::PDocumentRendererParent* AllocPDocumentRenderer(
const PRInt32& x,

View File

@ -13,6 +13,18 @@
function loadURL(url) {
document.getElementById('page').setAttribute('src', url);
}
function randomClick() {
// First focus the remote frame, then dispatch click. This way remote frame gets focus before
// mouse event.
document.getElementById('page').QueryInterface(Components.interfaces.nsIFrameLoaderOwner)
.frameLoader.activateRemoteFrame();
var frameLoader = document.getElementById('page').QueryInterface(Components.interfaces.nsIFrameLoaderOwner).frameLoader;
var x = parseInt(Math.random() * 100);
var y = parseInt(Math.random() * 100);
frameLoader.sendCrossProcessMouseEvent("mousedown", x, y, 0, 1, 0, false);
frameLoader.sendCrossProcessMouseEvent("mouseup", x, y, 0, 1, 0, false);
}
</script>
<toolbar id="controls">
@ -20,6 +32,7 @@
<toolbarbutton label="Forward"/>
<textbox onchange="loadURL(this.value)" flex="1" id="URL"/>
<toolbarbutton onclick="restart()" label="Recover"/>
<toolbarbutton onclick="randomClick()" label="random click"/>
</toolbar>
<browser type="content" src="http://www.google.com/" flex="1" id="page" remote="true"