From 0e4d476d76dea59ce44d28486cd7698f819d072e Mon Sep 17 00:00:00 2001 From: Tom Robinson Date: Fri, 12 Mar 2010 17:25:19 -0800 Subject: [PATCH] Add guard div to protect against iframes consuming events during tracking. --- AppKit/Platform/DOM/CPPlatformWindow+DOM.j | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/AppKit/Platform/DOM/CPPlatformWindow+DOM.j b/AppKit/Platform/DOM/CPPlatformWindow+DOM.j index c90ad06c0..971c1f45a 100644 --- a/AppKit/Platform/DOM/CPPlatformWindow+DOM.j +++ b/AppKit/Platform/DOM/CPPlatformWindow+DOM.j @@ -129,6 +129,8 @@ var CPDOMEventGetClickCount, CPDOMEventStop, StopDOMEventPropagation; +var _DOMEventGuard; + //right now we hard code q, w, r and t as keys to propogate //these aren't normal keycodes, they are with modifier key codes //might be mac only, we should investigate futher later. @@ -255,6 +257,19 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop]; // Make sure the pastboard element is blurred. _DOMPasteboardElement.blur(); + + // Create a full screen div to protect against iframes and other elements from consuming events during tracking + // FIXME: multiple windows + _DOMEventGuard = theDocument.createElement("div"); + _DOMEventGuard.style.position = "absolute"; + _DOMEventGuard.style.top = "0px"; + _DOMEventGuard.style.left = "0px"; + _DOMEventGuard.style.width = "100%"; + _DOMEventGuard.style.height = "100%"; + _DOMEventGuard.style.zIndex = "999"; + _DOMEventGuard.style.display = "none"; + _DOMEventGuard.className = "cpdontremove"; + _DOMBodyElement.appendChild(_DOMEventGuard); } - (void)registerDOMWindow @@ -1102,6 +1117,9 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop]; if (StopDOMEventPropagation && (!supportsNativeDragAndDrop || type !== "mousedown" && !isDragging)) CPDOMEventStop(aDOMEvent, self); + // if there are any tracking event listeners then show the event guard so we don't lose events to iframes + _DOMEventGuard.style.display = (CPApp._eventListeners.length === 0) ? "none" : ""; + [[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode]; }