2
* Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
4
* Redistribution and use in source and binary forms, with or without
5
* modification, are permitted provided that the following conditions
7
* 1. Redistributions of source code must retain the above copyright
8
* notice, this list of conditions and the following disclaimer.
9
* 2. Redistributions in binary form must reproduce the above copyright
10
* notice, this list of conditions and the following disclaimer in the
11
* documentation and/or other materials provided with the distribution.
13
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
17
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
#include "PluginObject.h"
28
#include "PluginTest.h"
35
#include <X11/Xutil.h>
38
#if !defined(NP_NO_CARBON) && defined(QD_HEADERS_ARE_PRIVATE) && QD_HEADERS_ARE_PRIVATE
39
extern "C" void GlobalToLocal(Point*);
44
#define CRASH() do { \
45
*(int *)(uintptr_t)0xbbadbeef = 0; \
46
((void(*)())0)(); /* More reliable, but doesn't say BBADBEEF */ \
49
static bool getEntryPointsWasCalled;
50
static bool initializeWasCalled;
53
#define STDCALL __stdcall
55
static inline int strcasecmp(const char* s1, const char* s2)
57
return _stricmp(s1, s2);
65
NPError STDCALL NP_GetEntryPoints(NPPluginFuncs *pluginFuncs);
70
NPError STDCALL NP_Initialize(NPNetscapeFuncs *browserFuncs
72
, NPPluginFuncs *pluginFuncs
76
initializeWasCalled = true;
79
// Simulate Flash and QuickTime's behavior of crashing when NP_Initialize is called before NP_GetEntryPoints.
80
if (!getEntryPointsWasCalled)
84
browser = browserFuncs;
87
return NP_GetEntryPoints(pluginFuncs);
89
return NPERR_NO_ERROR;
94
NPError STDCALL NP_GetEntryPoints(NPPluginFuncs *pluginFuncs)
96
getEntryPointsWasCalled = true;
99
// Simulate Silverlight's behavior of crashing when NP_GetEntryPoints is called before NP_Initialize.
100
if (!initializeWasCalled)
104
pluginFunctions = pluginFuncs;
106
pluginFuncs->version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR;
107
pluginFuncs->size = sizeof(pluginFuncs);
108
pluginFuncs->newp = NPP_New;
109
pluginFuncs->destroy = NPP_Destroy;
110
pluginFuncs->setwindow = NPP_SetWindow;
111
pluginFuncs->newstream = NPP_NewStream;
112
pluginFuncs->destroystream = NPP_DestroyStream;
113
pluginFuncs->asfile = NPP_StreamAsFile;
114
pluginFuncs->writeready = NPP_WriteReady;
115
pluginFuncs->write = (NPP_WriteProcPtr)NPP_Write;
116
pluginFuncs->print = NPP_Print;
117
pluginFuncs->event = NPP_HandleEvent;
118
pluginFuncs->urlnotify = NPP_URLNotify;
119
pluginFuncs->getvalue = NPP_GetValue;
120
pluginFuncs->setvalue = NPP_SetValue;
122
return NPERR_NO_ERROR;
126
void STDCALL NP_Shutdown(void)
128
PluginTest::NP_Shutdown();
131
static void executeScript(const PluginObject* obj, const char* script);
133
NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc, char *argn[], char *argv[], NPSavedData *saved)
136
NPEventModel eventModel;
138
// Always turn on the CG model
139
NPBool supportsCoreGraphics;
140
if (browser->getvalue(instance, NPNVsupportsCoreGraphicsBool, &supportsCoreGraphics) != NPERR_NO_ERROR)
141
supportsCoreGraphics = false;
143
if (!supportsCoreGraphics)
144
return NPERR_INCOMPATIBLE_VERSION_ERROR;
146
NPDrawingModel drawingModelToUse = NPDrawingModelCoreGraphics;
148
NPBool supportsCoreAnimation;
149
if (browser->getvalue(instance, NPNVsupportsCoreAnimationBool, &supportsCoreAnimation) != NPERR_NO_ERROR)
150
supportsCoreAnimation = false;
153
NPBool supportsCarbon = false;
155
NPBool supportsCocoa = false;
158
// A browser that doesn't know about NPNVsupportsCarbonBool is one that only supports Carbon event model.
159
if (browser->getvalue(instance, NPNVsupportsCarbonBool, &supportsCarbon) != NPERR_NO_ERROR)
160
supportsCarbon = true;
163
if (browser->getvalue(instance, NPNVsupportsCocoaBool, &supportsCocoa) != NPERR_NO_ERROR)
164
supportsCocoa = false;
167
eventModel = NPEventModelCocoa;
169
} else if (supportsCarbon) {
170
eventModel = NPEventModelCarbon;
173
return NPERR_INCOMPATIBLE_VERSION_ERROR;
176
browser->setvalue(instance, NPPVpluginEventModel, (void *)eventModel);
179
PluginObject* obj = (PluginObject*)browser->createobject(instance, getPluginClass());
180
instance->pdata = obj;
183
obj->eventModel = eventModel;
184
obj->coreAnimationLayer = 0;
187
string testIdentifier;
188
const char* onNewScript = 0;
190
for (int i = 0; i < argc; i++) {
191
if (strcasecmp(argn[i], "test") == 0)
192
testIdentifier = argv[i];
193
if (strcasecmp(argn[i], "onstreamload") == 0 && !obj->onStreamLoad)
194
obj->onStreamLoad = strdup(argv[i]);
195
else if (strcasecmp(argn[i], "onStreamDestroy") == 0 && !obj->onStreamDestroy)
196
obj->onStreamDestroy = strdup(argv[i]);
197
else if (strcasecmp(argn[i], "onURLNotify") == 0 && !obj->onURLNotify)
198
obj->onURLNotify = strdup(argv[i]);
199
else if (strcasecmp(argn[i], "src") == 0 &&
200
strcasecmp(argv[i], "data:application/x-webkit-test-netscape,returnerrorfromnewstream") == 0)
201
obj->returnErrorFromNewStream = TRUE;
202
else if (strcasecmp(argn[i], "src") == 0 &&
203
strcasecmp(argv[i], "data:application/x-webkit-test-netscape,alertwhenloaded") == 0)
204
executeScript(obj, "alert('Plugin Loaded!')");
205
else if (strcasecmp(argn[i], "src") == 0 &&
206
strcasecmp(argv[i], "data:application/x-webkit-test-netscape,logifloaded") == 0) {
207
for (int j = 0; j < argc; j++) {
208
if (strcasecmp(argn[j], "log") == 0) {
209
int length = 26 + strlen(argv[j]) + 1;
210
char* buffer = (char*) malloc(length);
211
snprintf(buffer, length, "xWebkitTestNetscapeLog('%s')", argv[j]);
212
executeScript(obj, buffer);
216
} else if (strcasecmp(argn[i], "onSetWindow") == 0 && !obj->onSetWindow)
217
obj->onSetWindow = strdup(argv[i]);
218
else if (strcasecmp(argn[i], "onNew") == 0 && !onNewScript)
219
onNewScript = argv[i];
220
else if (strcasecmp(argn[i], "onPaintEvent") == 0 && !obj->onPaintEvent)
221
obj->onPaintEvent = strdup(argv[i]);
222
else if (strcasecmp(argn[i], "logfirstsetwindow") == 0)
223
obj->logSetWindow = TRUE;
224
else if (strcasecmp(argn[i], "testnpruntime") == 0)
225
testNPRuntime(instance);
226
else if (strcasecmp(argn[i], "logSrc") == 0) {
227
for (int i = 0; i < argc; i++)
228
if (strcasecmp(argn[i], "src") == 0)
229
pluginLog(instance, "src: %s", argv[i]);
230
} else if (strcasecmp(argn[i], "cleardocumentduringnew") == 0)
231
executeScript(obj, "document.body.innerHTML = ''");
232
else if (!strcasecmp(argn[i], "ondestroy"))
233
obj->onDestroy = strdup(argv[i]);
234
else if (strcasecmp(argn[i], "testwindowopen") == 0)
235
obj->testWindowOpen = TRUE;
236
else if (strcasecmp(argn[i], "drawingmodel") == 0) {
238
const char* value = argv[i];
239
if (strcasecmp(value, "coreanimation") == 0) {
240
if (supportsCoreAnimation)
241
drawingModelToUse = NPDrawingModelCoreAnimation;
243
return NPERR_INCOMPATIBLE_VERSION_ERROR;
244
} else if (strcasecmp(value, "coregraphics") == 0) {
245
if (supportsCoreGraphics)
246
drawingModelToUse = NPDrawingModelCoreGraphics;
248
return NPERR_INCOMPATIBLE_VERSION_ERROR;
250
return NPERR_INCOMPATIBLE_VERSION_ERROR;
252
} else if (strcasecmp(argn[i], "testGetURLOnDestroy") == 0) {
254
// FIXME: When https://bugs.webkit.org/show_bug.cgi?id=41831 is fixed, this #ifdef can be removed.
255
obj->testGetURLOnDestroy = TRUE;
257
} else if (!strcasecmp(argn[i], "src") && strstr(argv[i], "plugin-document-has-focus.pl"))
258
obj->testKeyboardFocusForPlugins = TRUE;
259
else if (!strcasecmp(argn[i], "evaluatescript")) {
260
char* script = argv[i];
261
if (script == strstr(script, "mouse::")) {
262
obj->mouseDownForEvaluateScript = true;
263
obj->evaluateScriptOnMouseDownOrKeyDown = strdup(script + sizeof("mouse::") - 1);
264
} else if (script == strstr(script, "key::")) {
265
obj->evaluateScriptOnMouseDownOrKeyDown = strdup(script + sizeof("key::") - 1);
267
// When testing evaluate script on mouse-down or key-down, allow event logging to handle events.
268
if (obj->evaluateScriptOnMouseDownOrKeyDown)
269
obj->eventLogging = true;
270
} else if (!strcasecmp(argn[i], "windowedPlugin")) {
272
if (!strcasecmp(argv[i], "false") || !strcasecmp(argv[i], "0"))
274
else if (!strcasecmp(argv[i], "true") || !strcasecmp(argv[i], "1"))
275
windowed = reinterpret_cast<void*>(1);
278
browser->setvalue(instance, NPPVpluginWindowBool, windowed);
283
browser->setvalue(instance, NPPVpluginDrawingModel, (void *)drawingModelToUse);
284
if (drawingModelToUse == NPDrawingModelCoreAnimation)
285
obj->coreAnimationLayer = createCoreAnimationLayer();
288
obj->pluginTest = PluginTest::create(instance, testIdentifier);
290
if (!obj->pluginTest) {
291
pluginLog(instance, "NPP_New: Could not find a test named \"%s\", maybe its .cpp file wasn't added to the build system?", testIdentifier.c_str());
292
return NPERR_GENERIC_ERROR;
296
executeScript(obj, onNewScript);
298
return obj->pluginTest->NPP_New(pluginType, mode, argc, argn, argv, saved);
301
NPError NPP_Destroy(NPP instance, NPSavedData **save)
303
PluginObject* obj = static_cast<PluginObject*>(instance->pdata);
305
if (obj->testGetURLOnDestroy)
306
browser->geturlnotify(obj->npp, "about:blank", "", 0);
308
if (obj->onDestroy) {
309
executeScript(obj, obj->onDestroy);
310
free(obj->onDestroy);
313
if (obj->onStreamLoad)
314
free(obj->onStreamLoad);
316
if (obj->onStreamDestroy)
317
free(obj->onStreamDestroy);
319
if (obj->onURLNotify)
320
free(obj->onURLNotify);
322
if (obj->onSetWindow)
323
free(obj->onSetWindow);
325
if (obj->onPaintEvent)
326
free(obj->onPaintEvent);
329
pluginLog(instance, "NPP_Destroy");
332
if (obj->coreAnimationLayer)
333
CFRelease(obj->coreAnimationLayer);
337
obj->pluginTest->NPP_Destroy(save);
339
browser->releaseobject(&obj->header);
341
return NPERR_NO_ERROR;
344
NPError NPP_SetWindow(NPP instance, NPWindow *window)
346
PluginObject* obj = static_cast<PluginObject*>(instance->pdata);
349
obj->lastWindow = *window;
351
if (obj->logSetWindow) {
352
pluginLog(instance, "NPP_SetWindow: %d %d", (int)window->width, (int)window->height);
353
obj->logSetWindow = FALSE;
356
if (obj->onSetWindow)
357
executeScript(obj, obj->onSetWindow);
359
if (obj->testWindowOpen) {
360
testWindowOpen(instance);
361
obj->testWindowOpen = FALSE;
364
if (obj->testKeyboardFocusForPlugins) {
365
obj->eventLogging = true;
366
executeScript(obj, "eventSender.keyDown('A');");
370
return obj->pluginTest->NPP_SetWindow(window);
373
static void executeScript(const PluginObject* obj, const char* script)
375
NPObject *windowScriptObject;
376
browser->getvalue(obj->npp, NPNVWindowNPObject, &windowScriptObject);
379
npScript.UTF8Characters = script;
380
npScript.UTF8Length = strlen(script);
382
NPVariant browserResult;
383
browser->evaluate(obj->npp, windowScriptObject, &npScript, &browserResult);
384
browser->releasevariantvalue(&browserResult);
387
NPError NPP_NewStream(NPP instance, NPMIMEType type, NPStream *stream, NPBool seekable, uint16_t *stype)
389
PluginObject* obj = static_cast<PluginObject*>(instance->pdata);
390
obj->stream = stream;
393
if (obj->returnErrorFromNewStream)
394
return NPERR_GENERIC_ERROR;
396
if (browser->version >= NPVERS_HAS_RESPONSE_HEADERS)
397
notifyStream(obj, stream->url, stream->headers);
399
if (obj->onStreamLoad)
400
executeScript(obj, obj->onStreamLoad);
402
return obj->pluginTest->NPP_NewStream(type, stream, seekable, stype);
405
NPError NPP_DestroyStream(NPP instance, NPStream *stream, NPReason reason)
407
PluginObject* obj = (PluginObject*)instance->pdata;
409
if (obj->onStreamDestroy) {
410
NPObject* windowObject = 0;
411
NPError error = browser->getvalue(instance, NPNVWindowNPObject, &windowObject);
413
if (error == NPERR_NO_ERROR) {
414
NPVariant onStreamDestroyVariant;
415
if (browser->getproperty(instance, windowObject, browser->getstringidentifier(obj->onStreamDestroy), &onStreamDestroyVariant)) {
416
if (NPVARIANT_IS_OBJECT(onStreamDestroyVariant)) {
417
NPObject* onStreamDestroyFunction = NPVARIANT_TO_OBJECT(onStreamDestroyVariant);
419
NPVariant reasonVariant;
420
INT32_TO_NPVARIANT(reason, reasonVariant);
423
browser->invokeDefault(instance, onStreamDestroyFunction, &reasonVariant, 1, &result);
424
browser->releasevariantvalue(&result);
426
browser->releasevariantvalue(&onStreamDestroyVariant);
428
browser->releaseobject(windowObject);
432
return obj->pluginTest->NPP_DestroyStream(stream, reason);
435
int32_t NPP_WriteReady(NPP instance, NPStream *stream)
437
PluginObject* obj = (PluginObject*)instance->pdata;
438
return obj->pluginTest->NPP_WriteReady(stream);
441
int32_t NPP_Write(NPP instance, NPStream *stream, int32_t offset, int32_t len, void *buffer)
443
PluginObject* obj = (PluginObject*)instance->pdata;
445
if (obj->returnNegativeOneFromWrite)
448
return obj->pluginTest->NPP_Write(stream, offset, len, buffer);
451
void NPP_StreamAsFile(NPP instance, NPStream *stream, const char *fname)
455
void NPP_Print(NPP instance, NPPrint *platformPrint)
461
static int16_t handleEventCarbon(NPP instance, PluginObject* obj, EventRecord* event)
463
Point pt = { event->where.v, event->where.h };
465
switch (event->what) {
467
// these are delivered non-deterministically, don't log.
470
if (obj->eventLogging) {
472
#pragma clang diagnostic push
473
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
477
#pragma clang diagnostic pop
479
pluginLog(instance, "mouseDown at (%d, %d)", pt.h, pt.v);
481
if (obj->evaluateScriptOnMouseDownOrKeyDown && obj->mouseDownForEvaluateScript)
482
executeScript(obj, obj->evaluateScriptOnMouseDownOrKeyDown);
485
if (obj->eventLogging) {
487
#pragma clang diagnostic push
488
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
492
#pragma clang diagnostic pop
494
pluginLog(instance, "mouseUp at (%d, %d)", pt.h, pt.v);
498
if (obj->eventLogging)
499
pluginLog(instance, "keyDown '%c'", (char)(event->message & 0xFF));
500
if (obj->evaluateScriptOnMouseDownOrKeyDown && !obj->mouseDownForEvaluateScript)
501
executeScript(obj, obj->evaluateScriptOnMouseDownOrKeyDown);
504
if (obj->eventLogging)
505
pluginLog(instance, "keyUp '%c'", (char)(event->message & 0xFF));
506
if (obj->testKeyboardFocusForPlugins) {
507
obj->eventLogging = false;
508
obj->testKeyboardFocusForPlugins = FALSE;
509
executeScript(obj, "testRunner.notifyDone();");
513
if (obj->eventLogging)
514
pluginLog(instance, "autoKey '%c'", (char)(event->message & 0xFF));
517
if (obj->eventLogging)
518
pluginLog(instance, "updateEvt");
521
if (obj->eventLogging)
522
pluginLog(instance, "diskEvt");
525
if (obj->eventLogging)
526
pluginLog(instance, "activateEvt");
529
if (!obj->eventLogging)
531
printf("PLUGIN: osEvt - ");
532
switch ((event->message & 0xFF000000) >> 24) {
533
case suspendResumeMessage:
534
printf("%s\n", (event->message & 0x1) ? "resume" : "suspend");
536
case mouseMovedMessage:
537
printf("mouseMoved\n");
540
printf("%08lX\n", event->message);
543
case kHighLevelEvent:
544
if (obj->eventLogging)
545
pluginLog(instance, "kHighLevelEvent");
548
case NPEventType_GetFocusEvent:
549
if (obj->eventLogging)
550
pluginLog(instance, "getFocusEvent");
552
case NPEventType_LoseFocusEvent:
553
if (obj->eventLogging)
554
pluginLog(instance, "loseFocusEvent");
556
case NPEventType_AdjustCursorEvent:
557
if (obj->eventLogging)
558
pluginLog(instance, "adjustCursorEvent");
561
if (obj->eventLogging)
562
pluginLog(instance, "event %d", event->what);
569
static int16_t handleEventCocoa(NPP instance, PluginObject* obj, NPCocoaEvent* event)
571
switch (event->type) {
572
case NPCocoaEventWindowFocusChanged:
574
case NPCocoaEventFocusChanged:
575
if (obj->eventLogging) {
576
if (event->data.focus.hasFocus)
577
pluginLog(instance, "getFocusEvent");
579
pluginLog(instance, "loseFocusEvent");
583
case NPCocoaEventDrawRect: {
584
if (obj->onPaintEvent)
585
executeScript(obj, obj->onPaintEvent);
589
case NPCocoaEventKeyDown:
590
if (obj->eventLogging && event->data.key.characters)
591
pluginLog(instance, "keyDown '%c'", CFStringGetCharacterAtIndex(reinterpret_cast<CFStringRef>(event->data.key.characters), 0));
592
if (obj->evaluateScriptOnMouseDownOrKeyDown && !obj->mouseDownForEvaluateScript)
593
executeScript(obj, obj->evaluateScriptOnMouseDownOrKeyDown);
596
case NPCocoaEventKeyUp:
597
if (obj->eventLogging && event->data.key.characters) {
598
pluginLog(instance, "keyUp '%c'", CFStringGetCharacterAtIndex(reinterpret_cast<CFStringRef>(event->data.key.characters), 0));
599
if (obj->testKeyboardFocusForPlugins) {
600
obj->eventLogging = false;
601
obj->testKeyboardFocusForPlugins = FALSE;
602
executeScript(obj, "testRunner.notifyDone();");
607
case NPCocoaEventFlagsChanged:
610
case NPCocoaEventMouseDown:
611
if (obj->eventLogging) {
612
pluginLog(instance, "mouseDown at (%d, %d)",
613
(int)event->data.mouse.pluginX,
614
(int)event->data.mouse.pluginY);
616
if (obj->evaluateScriptOnMouseDownOrKeyDown && obj->mouseDownForEvaluateScript)
617
executeScript(obj, obj->evaluateScriptOnMouseDownOrKeyDown);
619
case NPCocoaEventMouseUp:
620
if (obj->eventLogging) {
621
pluginLog(instance, "mouseUp at (%d, %d)",
622
(int)event->data.mouse.pluginX,
623
(int)event->data.mouse.pluginY);
627
case NPCocoaEventMouseMoved:
628
case NPCocoaEventMouseEntered:
629
case NPCocoaEventMouseExited:
630
case NPCocoaEventMouseDragged:
631
case NPCocoaEventScrollWheel:
632
case NPCocoaEventTextInput:
643
static char keyEventToChar(XKeyEvent* event)
646
XLookupString(event, &c, sizeof(c), 0, 0);
650
static int16_t handleEventX11(NPP instance, PluginObject* obj, XEvent* event)
652
switch (event->type) {
654
if (obj->eventLogging)
655
pluginLog(instance, "mouseDown at (%d, %d)", event->xbutton.x, event->xbutton.y);
656
if (obj->evaluateScriptOnMouseDownOrKeyDown && obj->mouseDownForEvaluateScript)
657
executeScript(obj, obj->evaluateScriptOnMouseDownOrKeyDown);
660
if (obj->eventLogging)
661
pluginLog(instance, "mouseUp at (%d, %d)", event->xbutton.x, event->xbutton.y);
664
// FIXME: extract key code
665
if (obj->eventLogging)
666
pluginLog(instance, "keyDown '%c'", keyEventToChar(&event->xkey));
667
if (obj->evaluateScriptOnMouseDownOrKeyDown && !obj->mouseDownForEvaluateScript)
668
executeScript(obj, obj->evaluateScriptOnMouseDownOrKeyDown);
671
// FIXME: extract key code
672
if (obj->eventLogging)
673
pluginLog(instance, "keyUp '%c'", keyEventToChar(&event->xkey));
674
if (obj->testKeyboardFocusForPlugins) {
675
obj->eventLogging = false;
676
obj->testKeyboardFocusForPlugins = FALSE;
677
executeScript(obj, "testRunner.notifyDone();");
681
if (obj->eventLogging)
682
pluginLog(instance, "updateEvt");
683
if (obj->onPaintEvent)
684
executeScript(obj, obj->onPaintEvent);
688
if (obj->eventLogging)
689
pluginLog(instance, "getFocusEvent");
692
if (obj->eventLogging)
693
pluginLog(instance, "loseFocusEvent");
700
if (obj->eventLogging)
701
pluginLog(instance, "event %d", event->type);
710
static int16_t handleEventWin(NPP instance, PluginObject* obj, NPEvent* event)
712
switch (event->event) {
714
if (obj->onPaintEvent)
715
executeScript(obj, obj->onPaintEvent);
718
if (obj->eventLogging)
719
pluginLog(instance, "keyDown '%c'", event->wParam);
720
if (obj->evaluateScriptOnMouseDownOrKeyDown && !obj->mouseDownForEvaluateScript)
721
executeScript(obj, obj->evaluateScriptOnMouseDownOrKeyDown);
726
if (obj->eventLogging)
727
pluginLog(instance, "keyUp '%c'", event->wParam);
728
if (obj->testKeyboardFocusForPlugins) {
729
obj->eventLogging = false;
730
obj->testKeyboardFocusForPlugins = FALSE;
731
executeScript(obj, "testRunner.notifyDone();");
737
if (obj->eventLogging)
738
pluginLog(instance, "mouseDown at (%d, %d)", LOWORD(event->lParam), HIWORD(event->lParam));
739
if (obj->evaluateScriptOnMouseDownOrKeyDown && obj->mouseDownForEvaluateScript)
740
executeScript(obj, obj->evaluateScriptOnMouseDownOrKeyDown);
745
if (obj->eventLogging)
746
pluginLog(instance, "mouseUp at (%d, %d)", LOWORD(event->lParam), HIWORD(event->lParam));
749
if (obj->eventLogging)
750
pluginLog(instance, "getFocusEvent");
753
if (obj->eventLogging)
754
pluginLog(instance, "loseFocusEvent");
761
int16_t NPP_HandleEvent(NPP instance, void *event)
763
PluginObject* obj = static_cast<PluginObject*>(instance->pdata);
765
if (obj->pluginTest->NPP_HandleEvent(event) == 1)
770
if (obj->eventModel == NPEventModelCarbon)
771
return handleEventCarbon(instance, obj, static_cast<EventRecord*>(event));
774
assert(obj->eventModel == NPEventModelCocoa);
775
return handleEventCocoa(instance, obj, static_cast<NPCocoaEvent*>(event));
776
#elif defined(XP_UNIX)
777
return handleEventX11(instance, obj, static_cast<XEvent*>(event));
778
#elif defined(XP_WIN)
779
return handleEventWin(instance, obj, static_cast<NPEvent*>(event));
781
// FIXME: Implement for other platforms.
786
void NPP_URLNotify(NPP instance, const char *url, NPReason reason, void *notifyData)
788
PluginObject* obj = static_cast<PluginObject*>(instance->pdata);
789
if (obj->pluginTest->NPP_URLNotify(url, reason, notifyData))
792
if (obj->onURLNotify)
793
executeScript(obj, obj->onURLNotify);
795
handleCallback(obj, url, reason, notifyData);
798
NPError NPP_GetValue(NPP instance, NPPVariable variable, void *value)
801
if (variable == NPPVpluginNameString) {
802
*((char **)value) = const_cast<char*>("WebKit Test PlugIn");
803
return NPERR_NO_ERROR;
805
if (variable == NPPVpluginDescriptionString) {
806
*((char **)value) = const_cast<char*>("Simple Netscape® plug-in that handles test content for WebKit");
807
return NPERR_NO_ERROR;
809
if (variable == NPPVpluginNeedsXEmbed) {
810
*((NPBool *)value) = TRUE;
811
return NPERR_NO_ERROR;
816
return NPERR_GENERIC_ERROR;
817
PluginObject* obj = static_cast<PluginObject*>(instance->pdata);
819
// First, check if the PluginTest object supports getting this value.
820
if (obj->pluginTest->NPP_GetValue(variable, value) == NPERR_NO_ERROR)
821
return NPERR_NO_ERROR;
823
if (variable == NPPVpluginScriptableNPObject) {
824
void **v = (void **)value;
825
// Return value is expected to be retained
826
browser->retainobject((NPObject *)obj);
828
return NPERR_NO_ERROR;
832
if (variable == NPPVpluginCoreAnimationLayer) {
833
if (!obj->coreAnimationLayer)
834
return NPERR_GENERIC_ERROR;
836
void **v = (void **)value;
837
*v = (void*)CFRetain(obj->coreAnimationLayer);
838
return NPERR_NO_ERROR;
842
return NPERR_GENERIC_ERROR;
845
NPError NPP_SetValue(NPP instance, NPNVariable variable, void *value)
847
PluginObject* obj = static_cast<PluginObject*>(instance->pdata);
848
return obj->pluginTest->NPP_SetValue(variable, value);
853
const char* NP_GetMIMEDescription(void)
855
return "application/x-webkit-test-netscape:testnetscape:test netscape content;image/png:png:PNG image";
859
NPError NP_GetValue(NPP instance, NPPVariable variable, void* value)
861
return NPP_GetValue(instance, variable, value);