From cced55dfb5d64a48ba5dcef9a61fff24eb464cc3 Mon Sep 17 00:00:00 2001 From: Fernando Jimenez Moreno Date: Fri, 9 Jan 2015 09:55:18 +0100 Subject: [PATCH] Bug 1101029 - Overlay iframe on top of front-most app. r=roc, sicking --- dom/apps/PermissionsTable.jsm | 6 ++++ dom/base/nsFrameLoader.cpp | 14 ++++++++++ dom/base/nsFrameLoader.h | 3 ++ dom/ipc/TabChild.cpp | 15 ++++++++++ layout/base/nsPresContext.h | 3 +- layout/base/tests/chrome/chrome.ini | 2 ++ .../passpointerevents_dynamically_window.html | 28 +++++++++++++++++++ .../test_passpointerevents_dynamic.html | 21 ++++++++++++++ layout/generic/nsSubDocumentFrame.cpp | 13 +++++++-- 9 files changed, 102 insertions(+), 3 deletions(-) create mode 100644 layout/base/tests/chrome/passpointerevents_dynamically_window.html create mode 100644 layout/base/tests/chrome/test_passpointerevents_dynamic.html diff --git a/dom/apps/PermissionsTable.jsm b/dom/apps/PermissionsTable.jsm index a2033c68134..079da1c8255 100644 --- a/dom/apps/PermissionsTable.jsm +++ b/dom/apps/PermissionsTable.jsm @@ -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, diff --git a/dom/base/nsFrameLoader.cpp b/dom/base/nsFrameLoader.cpp index 6fea812ac9b..bf7525d54c6 100644 --- a/dom/base/nsFrameLoader.cpp +++ b/dom/base/nsFrameLoader.cpp @@ -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, diff --git a/dom/base/nsFrameLoader.h b/dom/base/nsFrameLoader.h index a8a0a7baebe..515fe883f50 100644 --- a/dom/base/nsFrameLoader.h +++ b/dom/base/nsFrameLoader.h @@ -224,6 +224,9 @@ public: void GetURL(nsString& aURL); + void ActivateUpdateHitRegion(); + void DeactivateUpdateHitRegion(); + private: void SetOwnerContent(mozilla::dom::Element* aContent); diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index 46448393b18..d79b9d5db86 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -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 document(GetDocument()); + NS_ENSURE_TRUE(document, true); + nsCOMPtr presShell = document->GetShell(); + NS_ENSURE_TRUE(presShell, true); + nsRefPtr presContext = presShell->GetPresContext(); + NS_ENSURE_TRUE(presContext, true); + presContext->InvalidatePaintedLayers(); + return true; } diff --git a/layout/base/nsPresContext.h b/layout/base/nsPresContext.h index 95fc3967e05..760b69d8d2f 100644 --- a/layout/base/nsPresContext.h +++ b/layout/base/nsPresContext.h @@ -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() { diff --git a/layout/base/tests/chrome/chrome.ini b/layout/base/tests/chrome/chrome.ini index c0158409e0d..99bc0e21d15 100644 --- a/layout/base/tests/chrome/chrome.ini +++ b/layout/base/tests/chrome/chrome.ini @@ -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] diff --git a/layout/base/tests/chrome/passpointerevents_dynamically_window.html b/layout/base/tests/chrome/passpointerevents_dynamically_window.html new file mode 100644 index 00000000000..5cb05fee0cb --- /dev/null +++ b/layout/base/tests/chrome/passpointerevents_dynamically_window.html @@ -0,0 +1,28 @@ + + + + Test that mozpasspointerevents works after setting it dynamically + + + + + + + diff --git a/layout/base/tests/chrome/test_passpointerevents_dynamic.html b/layout/base/tests/chrome/test_passpointerevents_dynamic.html new file mode 100644 index 00000000000..400602c3a54 --- /dev/null +++ b/layout/base/tests/chrome/test_passpointerevents_dynamic.html @@ -0,0 +1,21 @@ + + + + Test that mozpasspointerevents works after setting it dynamically + + + + + + +
+
+
+ + diff --git a/layout/generic/nsSubDocumentFrame.cpp b/layout/generic/nsSubDocumentFrame.cpp index 4df1b4a3f7e..6b0fcfb7081 100644 --- a/layout/generic/nsSubDocumentFrame.cpp +++ b/layout/generic/nsSubDocumentFrame.cpp @@ -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 frameloader = FrameLoader(); + if (frameloader) { + if (aModType == nsIDOMMutationEvent::ADDITION) { + frameloader->ActivateUpdateHitRegion(); + } else if (aModType == nsIDOMMutationEvent::REMOVAL) { + frameloader->DeactivateUpdateHitRegion(); + } + } + } return NS_OK; }