Bug 1101029 - Overlay iframe on top of front-most app. r=roc, sicking

This commit is contained in:
Fernando Jimenez Moreno 2015-01-09 09:55:18 +01:00
parent 50ba16711c
commit cced55dfb5
9 changed files with 102 additions and 3 deletions

View File

@ -215,6 +215,12 @@ this.PermissionsTable = { geolocation: {
privileged: DENY_ACTION,
certified: ALLOW_ACTION
},
"global-clickthrough-overlay": {
app: DENY_ACTION,
trusted: DENY_ACTION,
privileged: ALLOW_ACTION,
certified: ALLOW_ACTION
},
"moz-attention": {
app: DENY_ACTION,
trusted: DENY_ACTION,

View File

@ -2218,6 +2218,20 @@ nsFrameLoader::DeactivateRemoteFrame() {
return NS_ERROR_UNEXPECTED;
}
void
nsFrameLoader::ActivateUpdateHitRegion() {
if (mRemoteBrowser) {
unused << mRemoteBrowser->SendSetUpdateHitRegion(true);
}
}
void
nsFrameLoader::DeactivateUpdateHitRegion() {
if (mRemoteBrowser) {
unused << mRemoteBrowser->SendSetUpdateHitRegion(false);
}
}
NS_IMETHODIMP
nsFrameLoader::SendCrossProcessMouseEvent(const nsAString& aType,
float aX,

View File

@ -224,6 +224,9 @@ public:
void GetURL(nsString& aURL);
void ActivateUpdateHitRegion();
void DeactivateUpdateHitRegion();
private:
void SetOwnerContent(mozilla::dom::Element* aContent);

View File

@ -3043,6 +3043,21 @@ bool
TabChild::RecvSetUpdateHitRegion(const bool& aEnabled)
{
mUpdateHitRegion = aEnabled;
// We need to trigger a repaint of the child frame to ensure that it
// recomputes and sends its region.
if (!mUpdateHitRegion) {
return true;
}
nsCOMPtr<nsIDocument> document(GetDocument());
NS_ENSURE_TRUE(document, true);
nsCOMPtr<nsIPresShell> presShell = document->GetShell();
NS_ENSURE_TRUE(presShell, true);
nsRefPtr<nsPresContext> presContext = presShell->GetPresContext();
NS_ENSURE_TRUE(presContext, true);
presContext->InvalidatePaintedLayers();
return true;
}

View File

@ -1162,11 +1162,12 @@ public:
void StopRestyleLogging() { mRestyleLoggingEnabled = false; }
#endif
void InvalidatePaintedLayers();
protected:
// May be called multiple times (unlink, destructor)
void Destroy();
void InvalidatePaintedLayers();
void AppUnitsPerDevPixelChanged();
void HandleRebuildUserFontSet() {

View File

@ -11,6 +11,7 @@ support-files =
no_clip_iframe_subdoc.html
no_clip_iframe_window.xul
passpointerevents_window.html
passpointerevents_dynamically_window.html
printpreview_bug396024_helper.xul
printpreview_bug482976_helper.xul
printpreview_helper.xul
@ -45,6 +46,7 @@ skip-if = buildapp == 'mulet'
skip-if = (!debug) || (toolkit == "cocoa") # Disabled on Mac because of Bug 748219
[test_no_clip_iframe.xul]
[test_passpointerevents.html]
[test_passpointerevents_dynamic.html]
[test_prerendered_transforms.html]
[test_printpreview.xul]
[test_printpreview_bug396024.xul]

View File

@ -0,0 +1,28 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test that mozpasspointerevents works after setting it dynamically</title>
</head>
<body onload="startTest()">
<iframe id="f" style="border:none; width:200px; height:200px; pointer-events:none"
src="data:text/html,<html style='pointer-events:none'><div style='margin:100px; width:100px; height:100px; background:yellow; pointer-events:auto'>">
</iframe>
<script type="application/javascript">
var SimpleTest = window.opener.SimpleTest;
var is = window.opener.is;
function startTest() {
var f = document.getElementById("f");
f.setAttribute("mozpasspointerevents", true);
var fRect = f.getBoundingClientRect();
var e1 = document.elementFromPoint(fRect.left + 10, fRect.top + 10);
is(e1, document.body, "check point in transparent region of the iframe");
var e2 = document.elementFromPoint(fRect.left + 110, fRect.top + 110);
is(e2, f, "check point in opaque region of the iframe");
window.close();
SimpleTest.finish();
}
</script>
</body>
</html>

View File

@ -0,0 +1,21 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test that mozpasspointerevents works after setting it dynamically</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="chrome://mochikit/content/chrome-harness.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
</head>
<body>
<pre id="test">
<script type="application/javascript">
SimpleTest.waitForExplicitFinish();
var root = getRootDirectory(window.location.href);
window.openDialog(root + "passpointerevents_dynamically_window.html",
"passpointerevents", "chrome,width=400,height=400");
</script>
</pre>
</body>
</html>

View File

@ -38,6 +38,7 @@
#include "nsContentUtils.h"
#include "nsIPermissionManager.h"
#include "nsServiceManagerUtils.h"
#include "nsIDOMMutationEvent.h"
using namespace mozilla;
using mozilla::layout::RenderFrameParent;
@ -309,11 +310,9 @@ nsSubDocumentFrame::PassPointerEventsToChildren()
uint32_t permission = nsIPermissionManager::DENY_ACTION;
permMgr->TestPermissionFromPrincipal(GetContent()->NodePrincipal(),
"embed-apps", &permission);
return permission == nsIPermissionManager::ALLOW_ACTION;
}
}
return false;
}
@ -893,6 +892,16 @@ nsSubDocumentFrame::AttributeChanged(int32_t aNameSpaceID,
if (frameloader)
frameloader->MarginsChanged(margins.width, margins.height);
}
else if (aAttribute == nsGkAtoms::mozpasspointerevents) {
nsRefPtr<nsFrameLoader> frameloader = FrameLoader();
if (frameloader) {
if (aModType == nsIDOMMutationEvent::ADDITION) {
frameloader->ActivateUpdateHitRegion();
} else if (aModType == nsIDOMMutationEvent::REMOVAL) {
frameloader->DeactivateUpdateHitRegion();
}
}
}
return NS_OK;
}