Bug 564991. Part 37: Add test plugin API to make the plugin invalidate itself during each paint. r=josh

This commit is contained in:
Robert O'Callahan 2010-07-16 09:08:11 +12:00
Родитель e78d0ab3cd
Коммит 9c297da773
3 изменённых файлов: 34 добавлений и 0 удалений

Просмотреть файл

@ -171,6 +171,10 @@ window.
* getWidthAtLastPaint()
Returns the window width that was current when the plugin last painted.
* setInvalidateDuringPaint(value)
When value is true, every time the plugin paints, it will invalidate
itself *during the paint* using NPN_Invalidate.
== Plugin geometry ==
The test plugin supports the following scriptable methods:

Просмотреть файл

@ -142,6 +142,7 @@ static bool getLastMouseX(NPObject* npobj, const NPVariant* args, uint32_t argCo
static bool getLastMouseY(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
static bool getPaintCount(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
static bool getWidthAtLastPaint(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
static bool setInvalidateDuringPaint(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
static bool getError(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
static bool doInternalConsistencyCheck(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
static bool setColor(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
@ -192,6 +193,7 @@ static const NPUTF8* sPluginMethodIdentifierNames[] = {
"getLastMouseY",
"getPaintCount",
"getWidthAtLastPaint",
"setInvalidateDuringPaint",
"getError",
"doInternalConsistencyCheck",
"setColor",
@ -243,6 +245,7 @@ static const ScriptableFunction sPluginMethodFunctions[] = {
getLastMouseY,
getPaintCount,
getWidthAtLastPaint,
setInvalidateDuringPaint,
getError,
doInternalConsistencyCheck,
setColor,
@ -689,6 +692,7 @@ NPP_New(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc, char*
instanceData->testrange = NULL;
instanceData->hasWidget = false;
instanceData->npnNewStream = false;
instanceData->invalidateDuringPaint = false;
instanceData->writeCount = 0;
instanceData->writeReadyCount = 0;
memset(&instanceData->window, 0, sizeof(instanceData->window));
@ -2127,6 +2131,22 @@ getWidthAtLastPaint(NPObject* npobj, const NPVariant* args, uint32_t argCount, N
return true;
}
static bool
setInvalidateDuringPaint(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result)
{
if (argCount != 1)
return false;
if (!NPVARIANT_IS_BOOLEAN(args[0]))
return false;
bool doInvalidate = NPVARIANT_TO_BOOLEAN(args[0]);
NPP npp = static_cast<TestNPObject*>(npobj)->npp;
InstanceData* id = static_cast<InstanceData*>(npp->pdata);
id->invalidateDuringPaint = doInvalidate;
return true;
}
static bool
getError(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result)
{
@ -2338,6 +2358,15 @@ void notifyDidPaint(InstanceData* instanceData)
{
++instanceData->paintCount;
instanceData->widthAtLastPaint = instanceData->window.width;
if (instanceData->invalidateDuringPaint) {
NPRect r;
r.left = 0;
r.top = 0;
r.right = instanceData->window.width;
r.bottom = instanceData->window.height;
NPN_InvalidateRect(instanceData->npp, &r);
}
}
static const NPClass kTestSharedNPClass = {

Просмотреть файл

@ -102,6 +102,7 @@ typedef struct InstanceData {
uint32_t timerID[2];
bool timerTestResult;
bool asyncCallbackResult;
bool invalidateDuringPaint;
int32_t winX;
int32_t winY;
int32_t lastMouseX;