From 41258a73c8673221dc99884672b8643987e1747e Mon Sep 17 00:00:00 2001 From: Derek Sollenberger Date: Fri, 7 Aug 2009 11:17:15 -0400 Subject: [PATCH] enabling plugin surfaces to manually scale based on the zoom level. --- WebKit/android/plugins/ANPSurfaceInterface.cpp | 4 ++-- WebKit/android/plugins/PluginWidgetAndroid.cpp | 16 +++------------- WebKit/android/plugins/PluginWidgetAndroid.h | 7 +++++-- WebKit/android/plugins/android_npapi.h | 9 +-------- 4 files changed, 11 insertions(+), 25 deletions(-) diff --git a/WebKit/android/plugins/ANPSurfaceInterface.cpp b/WebKit/android/plugins/ANPSurfaceInterface.cpp index 835f45a2f..20df7f821 100644 --- a/WebKit/android/plugins/ANPSurfaceInterface.cpp +++ b/WebKit/android/plugins/ANPSurfaceInterface.cpp @@ -33,11 +33,11 @@ using namespace WebCore; -static ANPSurface* anp_newSurface(NPP instance, ANPSurfaceType type) { +static ANPSurface* anp_newSurface(NPP instance, ANPSurfaceType type, bool fixedSize) { if (instance && instance->ndata) { PluginView* view = static_cast(instance->ndata); PluginWidgetAndroid* widget = view->platformPluginWidget(); - return widget->createSurface(type); + return widget->createSurface(type, fixedSize); } return NULL; } diff --git a/WebKit/android/plugins/PluginWidgetAndroid.cpp b/WebKit/android/plugins/PluginWidgetAndroid.cpp index 6e0536011..f1f0a15e2 100644 --- a/WebKit/android/plugins/PluginWidgetAndroid.cpp +++ b/WebKit/android/plugins/PluginWidgetAndroid.cpp @@ -210,11 +210,11 @@ bool PluginWidgetAndroid::isAcceptingEvent(ANPEventFlag flag) { return m_eventFlags & flag; } -ANPSurface* PluginWidgetAndroid::createSurface(ANPSurfaceType ignored) { +ANPSurface* PluginWidgetAndroid::createSurface(ANPSurfaceType ignored, bool fixedSize) { if (m_drawingModel != kSurface_ANPDrawingModel) { return NULL; } - m_surface.set(new android::PluginSurface(this, !isAcceptingEvent(kZoom_ANPEventFlag))); + m_surface.set(new android::PluginSurface(this, fixedSize)); ANPSurface* surface = new ANPSurface; surface->data = m_surface.get(); surface->type = ignored; @@ -223,17 +223,7 @@ ANPSurface* PluginWidgetAndroid::createSurface(ANPSurfaceType ignored) { void PluginWidgetAndroid::setVisibleScreen(const ANPRectI& visibleDocRect, float zoom) { - //send an event to the plugin that communicates the zoom - if (isAcceptingEvent(kZoom_ANPEventFlag) && m_zoomLevel != zoom) { - //store the local zoom level - m_zoomLevel = zoom; - - //trigger the event - ANPEvent event; - SkANP::InitEvent(&event, kZoomLevel_ANPEventType); - event.data.zoomLevel = zoom; - sendEvent(event); - } + // TODO update the bitmap size based on the zoom? (for kBitmap_ANPDrawingModel) int oldScreenW = m_visibleDocRect.width(); int oldScreenH = m_visibleDocRect.height(); diff --git a/WebKit/android/plugins/PluginWidgetAndroid.h b/WebKit/android/plugins/PluginWidgetAndroid.h index 151d6eff8..72e666032 100644 --- a/WebKit/android/plugins/PluginWidgetAndroid.h +++ b/WebKit/android/plugins/PluginWidgetAndroid.h @@ -112,9 +112,12 @@ struct PluginWidgetAndroid { /* Create an ANPSurface that the plugin may draw in to. The drawing model must be kSurface_ANPDrawingModel for this call to succeed. The type - specifies what kind of pixel access will be available. + specifies what kind of pixel access will be available. If true the + fixedSize param signals that the browser will auto-scale the surface for + the plugin (e.g. in the case of zooming). If false the surface will be + resized when zoomed and the plugin must manually scale to the new size. */ - ANPSurface* createSurface(ANPSurfaceType type); + ANPSurface* createSurface(ANPSurfaceType type, bool fixedSize); /* Notify the plugin of the currently visible screen coordinates (document space) and the current zoom level. diff --git a/WebKit/android/plugins/android_npapi.h b/WebKit/android/plugins/android_npapi.h index f67d0748a..71890ea5d 100644 --- a/WebKit/android/plugins/android_npapi.h +++ b/WebKit/android/plugins/android_npapi.h @@ -165,7 +165,6 @@ typedef int32_t ANPDrawingModel; enum ANPEventFlag { kKey_ANPEventFlag = 0x01, kTouch_ANPEventFlag = 0x02, - kZoom_ANPEventFlag = 0x04, // triggers zoom & surface changed events }; typedef uint32_t ANPEventFlags; @@ -218,7 +217,7 @@ struct ANPSurfaceInterfaceV0 : ANPInterface { /** Creates a new surface handle based on the given surface type. If the given surface type is not supported then NULL is returned. */ - ANPSurface* (*newSurface)(NPP instance, ANPSurfaceType); + ANPSurface* (*newSurface)(NPP instance, ANPSurfaceType, bool fixedSize); /** Given a valid surface handle (i.e. one created by calling newSurface) the underlying surface is removed and the pointer is set to NULL. */ @@ -756,11 +755,6 @@ enum ANPEventTypes { kDraw_ANPEventType = 4, kLifecycle_ANPEventType = 5, kSurface_ANPEventType = 6, - /** Reports the current zoom level of the page. The event is only received - if the plugin has specified that it wants to handle scaling the surface, - by setting the kDynamicSurface_ANPEventFlag. - */ - kZoomLevel_ANPEventType = 7, }; typedef int32_t ANPEventType; @@ -877,7 +871,6 @@ struct ANPEvent { } changed; } data; } surface; - float zoomLevel; int32_t other[8]; } data; }; -- 2.11.0