mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 651984 - Add ability to detect if a page has registered touch event listeners, r=jst
This commit is contained in:
parent
46d7b33a70
commit
c9e2181c9f
@ -558,6 +558,9 @@ nsNodeUtils::CloneAndAdopt(nsINode *aNode, PRBool aClone, PRBool aDeep,
|
||||
window->SetHasAudioAvailableEventListeners();
|
||||
}
|
||||
#endif
|
||||
if (elm->MayHaveTouchEventListener()) {
|
||||
window->SetHasTouchEventListeners();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -56,8 +56,8 @@ class nsCxPusher;
|
||||
* Event listener manager interface.
|
||||
*/
|
||||
#define NS_IEVENTLISTENERMANAGER_IID \
|
||||
{ 0xe86a148b, 0x0563, 0x454f, \
|
||||
{ 0x8c, 0xf2, 0xbd, 0xc4, 0x7c, 0xe6, 0xbe, 0x91 } }
|
||||
{ 0x8e8667ed, 0x10d3, 0x41e8, \
|
||||
{ 0x93, 0xfa, 0xa4, 0xc4, 0xea, 0x16, 0x85, 0xd5 } }
|
||||
|
||||
class nsIEventListenerManager : public nsISupports {
|
||||
|
||||
@ -69,6 +69,7 @@ public:
|
||||
mMayHaveCapturingListeners(PR_FALSE),
|
||||
mMayHaveSystemGroupListeners(PR_FALSE),
|
||||
mMayHaveAudioAvailableEventListener(PR_FALSE),
|
||||
mMayHaveTouchEventListener(PR_FALSE),
|
||||
mNoListenerForEvent(0)
|
||||
{}
|
||||
|
||||
@ -212,14 +213,19 @@ public:
|
||||
*/
|
||||
PRBool MayHaveAudioAvailableEventListener() { return mMayHaveAudioAvailableEventListener; }
|
||||
|
||||
|
||||
/**
|
||||
* Returns PR_TRUE if there may be a touch event listener registered,
|
||||
* PR_FALSE if there definitely isn't.
|
||||
*/
|
||||
PRBool MayHaveTouchEventListener() { return mMayHaveTouchEventListener; }
|
||||
protected:
|
||||
PRUint32 mMayHavePaintEventListener : 1;
|
||||
PRUint32 mMayHaveMutationListeners : 1;
|
||||
PRUint32 mMayHaveCapturingListeners : 1;
|
||||
PRUint32 mMayHaveSystemGroupListeners : 1;
|
||||
PRUint32 mMayHaveAudioAvailableEventListener : 1;
|
||||
PRUint32 mNoListenerForEvent : 27;
|
||||
PRUint32 mMayHaveTouchEventListener : 1;
|
||||
PRUint32 mNoListenerForEvent : 26;
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsIEventListenerManager,
|
||||
|
@ -507,7 +507,14 @@ nsEventListenerManager::AddEventListener(nsIDOMEventListener *aListener,
|
||||
nsPIDOMWindow* window = GetInnerWindowForTarget();
|
||||
if (window)
|
||||
window->SetHasOrientationEventListener();
|
||||
} else if (aType >= NS_MOZTOUCH_DOWN && aType <= NS_MOZTOUCH_UP) {
|
||||
} else if ((aType >= NS_MOZTOUCH_DOWN && aType <= NS_MOZTOUCH_UP) ||
|
||||
(aTypeAtom == nsGkAtoms::ontouchstart ||
|
||||
aTypeAtom == nsGkAtoms::ontouchend ||
|
||||
aTypeAtom == nsGkAtoms::ontouchmove ||
|
||||
aTypeAtom == nsGkAtoms::ontouchenter ||
|
||||
aTypeAtom == nsGkAtoms::ontouchleave ||
|
||||
aTypeAtom == nsGkAtoms::ontouchcancel)) {
|
||||
mMayHaveTouchEventListener = PR_TRUE;
|
||||
nsPIDOMWindow* window = GetInnerWindowForTarget();
|
||||
if (window)
|
||||
window->SetHasTouchEventListeners();
|
||||
|
@ -20,6 +20,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=648573
|
||||
|
||||
/** Test for Bug 648573 **/
|
||||
|
||||
ok(!SpecialPowers.DOMWindowUtils.mayHaveTouchEventListeners,
|
||||
"There shouldn't be any touch event listeners yet.");
|
||||
|
||||
ok("createTouch" in document, "Should have createTouch function");
|
||||
ok("createTouchList" in document, "Should have createTouchList function");
|
||||
ok(document.createEvent("touchevent"), "Should be able to create TouchEvent objects");
|
||||
@ -98,6 +101,9 @@ function runEventTest(type) {
|
||||
for (var i = 0; i < events.length; ++i) {
|
||||
runEventTest(events[i]);
|
||||
}
|
||||
|
||||
ok(SpecialPowers.DOMWindowUtils.mayHaveTouchEventListeners,
|
||||
"There should be touch event listeners.");
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
@ -1861,3 +1861,16 @@ nsDOMWindowUtils::LeafLayersPartitionWindow(PRBool* aResult)
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMWindowUtils::GetMayHaveTouchEventListeners(PRBool* aResult)
|
||||
{
|
||||
if (!IsUniversalXPConnectCapable()) {
|
||||
return NS_ERROR_DOM_SECURITY_ERR;
|
||||
}
|
||||
|
||||
nsPIDOMWindow* innerWindow = mWindow->GetCurrentInnerWindow();
|
||||
*aResult = innerWindow ? innerWindow->HasTouchEventListeners() : PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -78,8 +78,8 @@ class nsIArray;
|
||||
class nsPIWindowRoot;
|
||||
|
||||
#define NS_PIDOMWINDOW_IID \
|
||||
{ 0x8d8be7db, 0xffaa, 0x4962, \
|
||||
{ 0xa7, 0x27, 0xb7, 0x0f, 0xc9, 0xfa, 0xd3, 0x0e } }
|
||||
{ 0xafc4849b, 0x21d3, 0x45ea, \
|
||||
{ 0x8b, 0xfd, 0x61, 0xec, 0x12, 0x5d, 0x38, 0x64 } }
|
||||
|
||||
class nsPIDOMWindow : public nsIDOMWindowInternal
|
||||
{
|
||||
@ -442,6 +442,11 @@ public:
|
||||
MaybeUpdateTouchState();
|
||||
}
|
||||
|
||||
PRBool HasTouchEventListeners()
|
||||
{
|
||||
return mMayHaveTouchEventListener;
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this to check whether some node (this window, its document,
|
||||
* or content in that document) has a MozAudioAvailable event listener.
|
||||
|
@ -66,7 +66,7 @@ interface nsITransferable;
|
||||
interface nsIQueryContentEventResult;
|
||||
interface nsIDOMWindow;
|
||||
|
||||
[scriptable, uuid(3828e648-af61-47e1-b9bc-89ca51bc19f2)]
|
||||
[scriptable, uuid(663e33d7-eca2-42e8-af92-5df6a5e222df)]
|
||||
interface nsIDOMWindowUtils : nsISupports {
|
||||
|
||||
/**
|
||||
@ -881,4 +881,9 @@ interface nsIDOMWindowUtils : nsISupports {
|
||||
* the bounds of the window. Always returns true in non-DEBUG builds.
|
||||
*/
|
||||
boolean leafLayersPartitionWindow();
|
||||
|
||||
/**
|
||||
* true if the (current inner) window may have event listeners for touch events.
|
||||
*/
|
||||
readonly attribute boolean mayHaveTouchEventListeners;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user