зеркало из https://github.com/mozilla/gecko-dev.git
Bug 751809 - Fix OSX focus issue with click-to-play. r=josh
This commit is contained in:
Родитель
4b018119c7
Коммит
d5a643b3c3
|
@ -3777,6 +3777,12 @@ void nsPluginInstanceOwner::SetFrame(nsObjectFrame *aFrame)
|
|||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
nsFocusManager* fm = nsFocusManager::GetFocusManager();
|
||||
const nsIContent* content = aFrame->GetContent();
|
||||
if (fm && content) {
|
||||
mContentFocused = (content == fm->GetFocusedContent());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -64,6 +64,7 @@ MOCHITEST_FILES = \
|
|||
test_bug771202.html \
|
||||
file_bug771202.html \
|
||||
test_bug777098.html \
|
||||
test_bug751809.html \
|
||||
test_enumerate.html \
|
||||
test_npruntime_construct.html \
|
||||
307-xo-redirect.sjs \
|
||||
|
|
|
@ -0,0 +1,92 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Bug 751809</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<script type="application/javascript">
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
||||
|
||||
const Ci = Components.interfaces;
|
||||
const utils = window.QueryInterface(Ci.nsIInterfaceRequestor).
|
||||
getInterface(Ci.nsIDOMWindowUtils);
|
||||
|
||||
function waitForCondition(condition, nextTest, errorMsg) {
|
||||
var tries = 0;
|
||||
var interval = setInterval(function() {
|
||||
if (tries >= 30) {
|
||||
ok(false, errorMsg);
|
||||
moveOn();
|
||||
}
|
||||
if (condition()) {
|
||||
moveOn();
|
||||
}
|
||||
tries++;
|
||||
}, 100);
|
||||
var moveOn = function() { clearInterval(interval); nextTest(); };
|
||||
}
|
||||
|
||||
function startFocusTest() {
|
||||
var plugin = document.getElementById('plugin');
|
||||
ok(plugin, "Got plugin element.");
|
||||
|
||||
var condition = function() plugin.getBoundingClientRect().width == 400;
|
||||
waitForCondition(condition, afterPluginInsertion, "Waited too long for plugin to show up in page");
|
||||
}
|
||||
|
||||
function afterPluginInsertion() {
|
||||
var plugin = document.getElementById('plugin');
|
||||
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
|
||||
ok(!objLoadingContent.activated, "plugin should not be activated");
|
||||
|
||||
SimpleTest.waitForFocus(afterWindowFocus);
|
||||
}
|
||||
|
||||
function afterWindowFocus() {
|
||||
var plugin = document.getElementById('plugin');
|
||||
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
|
||||
|
||||
synthesizeMouseAtCenter(plugin, {}, window);
|
||||
var condition = function() objLoadingContent.activated;
|
||||
waitForCondition(condition, afterPluginActivation, "Waited too long for plugin to activate");
|
||||
}
|
||||
|
||||
function afterPluginActivation() {
|
||||
var plugin = document.getElementById('plugin');
|
||||
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
|
||||
ok(objLoadingContent.activated, "plugin should be activated now");
|
||||
try {
|
||||
is(plugin.getMouseUpEventCount(), 0, "Plugin should not have received mouse events yet.");
|
||||
} catch(e) {
|
||||
ok(false, "plugin.getMouseUpEventCount() shouldn't throw");
|
||||
}
|
||||
|
||||
synthesizeMouseAtCenter(plugin, {}, window);
|
||||
var condition = function() plugin.getMouseUpEventCount() > 0;
|
||||
waitForCondition(condition, afterFirstClick, "Waited too long for plugin to receive the mouse click");
|
||||
}
|
||||
|
||||
function afterFirstClick() {
|
||||
var plugin = document.getElementById('plugin');
|
||||
try {
|
||||
is(plugin.getMouseUpEventCount(), 1, "Plugin should have received 1 mouse up event.");
|
||||
} catch(e) {
|
||||
ok(false, "plugin.getMouseUpEventCount() shouldn't throw");
|
||||
}
|
||||
|
||||
SpecialPowers.clearUserPref("plugins.click_to_play");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
SpecialPowers.setBoolPref("plugins.click_to_play", true);
|
||||
document.write('<embed id="plugin" type="application/x-test" width="400" height="400" drawmode="solid" color="FF00FFFF"></embed>');
|
||||
SimpleTest.executeSoon(startFocusTest);
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -163,6 +163,7 @@ static bool setSitesWithData(NPObject* npobj, const NPVariant* args, uint32_t ar
|
|||
static bool setSitesWithDataCapabilities(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
||||
static bool getLastKeyText(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
||||
static bool getNPNVdocumentOrigin(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
||||
static bool getMouseUpEventCount(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
||||
|
||||
static const NPUTF8* sPluginMethodIdentifierNames[] = {
|
||||
"npnEvaluateTest",
|
||||
|
@ -222,7 +223,8 @@ static const NPUTF8* sPluginMethodIdentifierNames[] = {
|
|||
"setSitesWithData",
|
||||
"setSitesWithDataCapabilities",
|
||||
"getLastKeyText",
|
||||
"getNPNVdocumentOrigin"
|
||||
"getNPNVdocumentOrigin",
|
||||
"getMouseUpEventCount"
|
||||
};
|
||||
static NPIdentifier sPluginMethodIdentifiers[ARRAY_LENGTH(sPluginMethodIdentifierNames)];
|
||||
static const ScriptableFunction sPluginMethodFunctions[] = {
|
||||
|
@ -283,7 +285,8 @@ static const ScriptableFunction sPluginMethodFunctions[] = {
|
|||
setSitesWithData,
|
||||
setSitesWithDataCapabilities,
|
||||
getLastKeyText,
|
||||
getNPNVdocumentOrigin
|
||||
getNPNVdocumentOrigin,
|
||||
getMouseUpEventCount
|
||||
};
|
||||
|
||||
STATIC_ASSERT(ARRAY_LENGTH(sPluginMethodIdentifierNames) ==
|
||||
|
@ -777,6 +780,7 @@ NPP_New(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc, char*
|
|||
instanceData->asyncDrawing = AD_NONE;
|
||||
instanceData->frontBuffer = NULL;
|
||||
instanceData->backBuffer = NULL;
|
||||
instanceData->mouseUpEventCount = 0;
|
||||
instance->pdata = instanceData;
|
||||
|
||||
TestNPObject* scriptableObject = (TestNPObject*)NPN_CreateObject(instance, &sNPClass);
|
||||
|
@ -3649,3 +3653,15 @@ bool getNPNVdocumentOrigin(NPObject* npobj, const NPVariant* args, uint32_t argC
|
|||
STRINGZ_TO_NPVARIANT(origin, *result);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool getMouseUpEventCount(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result)
|
||||
{
|
||||
if (argCount != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
NPP npp = static_cast<TestNPObject*>(npobj)->npp;
|
||||
InstanceData* id = static_cast<InstanceData*>(npp->pdata);
|
||||
INT32_TO_NPVARIANT(id->mouseUpEventCount, *result);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -150,6 +150,7 @@ typedef struct InstanceData {
|
|||
AsyncDrawing asyncDrawing;
|
||||
NPAsyncSurface *frontBuffer;
|
||||
NPAsyncSurface *backBuffer;
|
||||
int32_t mouseUpEventCount;
|
||||
} InstanceData;
|
||||
|
||||
void notifyDidPaint(InstanceData* instanceData);
|
||||
|
|
|
@ -254,6 +254,9 @@ ButtonEvent(GtkWidget* widget, GdkEventButton* event,
|
|||
InstanceData* instanceData = static_cast<InstanceData*>(user_data);
|
||||
instanceData->lastMouseX = event->x;
|
||||
instanceData->lastMouseY = event->y;
|
||||
if (event->type == GDK_BUTTON_RELEASE) {
|
||||
instanceData->mouseUpEventCount++;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -418,6 +421,9 @@ pluginHandleEvent(InstanceData* instanceData, void* event)
|
|||
XButtonEvent* button = &nsEvent->xbutton;
|
||||
instanceData->lastMouseX = button->x;
|
||||
instanceData->lastMouseY = button->y;
|
||||
if (nsEvent->type == ButtonRelease) {
|
||||
instanceData->mouseUpEventCount++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
|
@ -276,6 +276,9 @@ pluginHandleEvent(InstanceData* instanceData, void* event)
|
|||
::GetWindowBounds(nativeWindow, kWindowStructureRgn, &globalBounds);
|
||||
instanceData->lastMouseX = carbonEvent->where.h - w->x - globalBounds.left;
|
||||
instanceData->lastMouseY = carbonEvent->where.v - w->y - globalBounds.top;
|
||||
if (carbonEvent->what == mouseUp) {
|
||||
instanceData->mouseUpEventCount++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -299,6 +302,9 @@ pluginHandleEvent(InstanceData* instanceData, void* event)
|
|||
case NPCocoaEventMouseMoved:
|
||||
instanceData->lastMouseX = (int32_t)cocoaEvent->data.mouse.pluginX;
|
||||
instanceData->lastMouseY = (int32_t)cocoaEvent->data.mouse.pluginY;
|
||||
if (cocoaEvent->type == NPCocoaEventMouseUp) {
|
||||
instanceData->mouseUpEventCount++;
|
||||
}
|
||||
break;
|
||||
case NPCocoaEventWindowFocusChanged:
|
||||
instanceData->topLevelWindowActivationState = cocoaEvent->data.focus.hasFocus ?
|
||||
|
|
|
@ -193,6 +193,7 @@ pluginHandleEvent(InstanceData* instanceData, void* event)
|
|||
XButtonEvent* button = &nsEvent->xbutton;
|
||||
instanceData->lastMouseX = button->x;
|
||||
instanceData->lastMouseY = button->y;
|
||||
instanceData->mouseUpEventCount++;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
|
@ -602,6 +602,9 @@ handleEventInternal(InstanceData* instanceData, NPEvent* pe, LRESULT* result)
|
|||
int y = instanceData->hasWidget ? 0 : instanceData->winY;
|
||||
instanceData->lastMouseX = GET_X_LPARAM(pe->lParam) - x;
|
||||
instanceData->lastMouseY = GET_Y_LPARAM(pe->lParam) - y;
|
||||
if ((UINT)pe->event == WM_LBUTTONUP) {
|
||||
instanceData->mouseUpEventCount++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче