Merge change Ib16749e2 into eclair-mr2
* changes: Refactoring the logging interface to remove dependence on NPP.
This commit is contained in:
@ -46,7 +46,7 @@ EventPlugin::~EventPlugin() { }
|
|||||||
|
|
||||||
void EventPlugin::drawPlugin(const ANPBitmap& bitmap, const ANPRectI& clip) {
|
void EventPlugin::drawPlugin(const ANPBitmap& bitmap, const ANPRectI& clip) {
|
||||||
|
|
||||||
gLogI.log(inst(), kDebug_ANPLogType, " ------ %p drawing the plugin (%d,%d)",
|
gLogI.log(kDebug_ANPLogType, " ------ %p drawing the plugin (%d,%d)",
|
||||||
inst(), bitmap.width, bitmap.height);
|
inst(), bitmap.width, bitmap.height);
|
||||||
|
|
||||||
// get the plugin's dimensions according to the DOM
|
// get the plugin's dimensions according to the DOM
|
||||||
@ -60,7 +60,7 @@ void EventPlugin::drawPlugin(const ANPBitmap& bitmap, const ANPRectI& clip) {
|
|||||||
|
|
||||||
// check to make sure the zoom level is uniform
|
// check to make sure the zoom level is uniform
|
||||||
if (zoomFactorW + .01 < zoomFactorH && zoomFactorW - .01 > zoomFactorH)
|
if (zoomFactorW + .01 < zoomFactorH && zoomFactorW - .01 > zoomFactorH)
|
||||||
gLogI.log(inst(), kError_ANPLogType, " ------ %p zoom is out of sync (%f,%f)",
|
gLogI.log(kError_ANPLogType, " ------ %p zoom is out of sync (%f,%f)",
|
||||||
inst(), zoomFactorW, zoomFactorH);
|
inst(), zoomFactorW, zoomFactorH);
|
||||||
|
|
||||||
// scale the variables based on the zoom level
|
// scale the variables based on the zoom level
|
||||||
@ -109,7 +109,7 @@ void EventPlugin::printToDiv(const char* text, int length) {
|
|||||||
browser->getvalue(inst(), NPNVWindowNPObject, &windowObject);
|
browser->getvalue(inst(), NPNVWindowNPObject, &windowObject);
|
||||||
|
|
||||||
if (!windowObject)
|
if (!windowObject)
|
||||||
gLogI.log(inst(), kError_ANPLogType, " ------ %p Unable to retrieve DOM Window", inst());
|
gLogI.log(kError_ANPLogType, " ------ %p Unable to retrieve DOM Window", inst());
|
||||||
|
|
||||||
// create a string (JS code) that is stored in memory allocated by the browser
|
// create a string (JS code) that is stored in memory allocated by the browser
|
||||||
const char* jsBegin = "var outputDiv = document.getElementById('eventOutput'); outputDiv.innerHTML += ' ";
|
const char* jsBegin = "var outputDiv = document.getElementById('eventOutput'); outputDiv.innerHTML += ' ";
|
||||||
@ -126,13 +126,13 @@ void EventPlugin::printToDiv(const char* text, int length) {
|
|||||||
memcpy(middleMem, text, length);
|
memcpy(middleMem, text, length);
|
||||||
memcpy(endMem, jsEnd, strlen(jsEnd));
|
memcpy(endMem, jsEnd, strlen(jsEnd));
|
||||||
|
|
||||||
gLogI.log(inst(), kError_ANPLogType, "text: %.*s\n", totalLength, (char*)beginMem);
|
gLogI.log(kDebug_ANPLogType, "text: %.*s\n", totalLength, (char*)beginMem);
|
||||||
|
|
||||||
// execute the javascript in the plugin's DOM object
|
// execute the javascript in the plugin's DOM object
|
||||||
NPString script = { (char*)beginMem, totalLength };
|
NPString script = { (char*)beginMem, totalLength };
|
||||||
NPVariant scriptVariant;
|
NPVariant scriptVariant;
|
||||||
if (!browser->evaluate(inst(), windowObject, &script, &scriptVariant))
|
if (!browser->evaluate(inst(), windowObject, &script, &scriptVariant))
|
||||||
gLogI.log(inst(), kError_ANPLogType, " ------ %p Unable to eval the JS.", inst());
|
gLogI.log(kError_ANPLogType, " ------ %p Unable to eval the JS.", inst());
|
||||||
|
|
||||||
// free the memory allocated within the browser
|
// free the memory allocated within the browser
|
||||||
browser->memfree(beginMem);
|
browser->memfree(beginMem);
|
||||||
@ -170,10 +170,10 @@ int16 EventPlugin::handleEvent(const ANPEvent* evt) {
|
|||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
case kTouch_ANPEventType:
|
case kTouch_ANPEventType:
|
||||||
gLogI.log(inst(), kError_ANPLogType, " ------ %p the plugin did not request touch events", inst());
|
gLogI.log(kError_ANPLogType, " ------ %p the plugin did not request touch events", inst());
|
||||||
break;
|
break;
|
||||||
case kKey_ANPEventType:
|
case kKey_ANPEventType:
|
||||||
gLogI.log(inst(), kError_ANPLogType, " ------ %p the plugin did not request key events", inst());
|
gLogI.log(kError_ANPLogType, " ------ %p the plugin did not request key events", inst());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -134,7 +134,7 @@ NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc,
|
|||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
gLogI.log(instance, kDebug_ANPLogType, "creating plugin");
|
gLogI.log(kDebug_ANPLogType, "creating plugin");
|
||||||
|
|
||||||
PluginObject *obj = NULL;
|
PluginObject *obj = NULL;
|
||||||
|
|
||||||
@ -155,7 +155,7 @@ NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc,
|
|||||||
NPError err = browser->setvalue(instance, kRequestDrawingModel_ANPSetValue,
|
NPError err = browser->setvalue(instance, kRequestDrawingModel_ANPSetValue,
|
||||||
reinterpret_cast<void*>(model));
|
reinterpret_cast<void*>(model));
|
||||||
if (err) {
|
if (err) {
|
||||||
gLogI.log(instance, kError_ANPLogType, "request model %d err %d", model, err);
|
gLogI.log(kError_ANPLogType, "request model %d err %d", model, err);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -220,7 +220,7 @@ int16 NPP_HandleEvent(NPP instance, void* event)
|
|||||||
const ANPEvent* evt = reinterpret_cast<const ANPEvent*>(event);
|
const ANPEvent* evt = reinterpret_cast<const ANPEvent*>(event);
|
||||||
|
|
||||||
if(!obj->subPlugin) {
|
if(!obj->subPlugin) {
|
||||||
gLogI.log(instance, kError_ANPLogType, "the sub-plugin is null.");
|
gLogI.log(kError_ANPLogType, "the sub-plugin is null.");
|
||||||
return 0; // unknown or unhandled event
|
return 0; // unknown or unhandled event
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
Reference in New Issue
Block a user