From 243869ecee2d4b5ab0f796fcc6692ece5b03c15e Mon Sep 17 00:00:00 2001 From: Derek Sollenberger Date: Wed, 5 Aug 2009 11:53:29 -0400 Subject: [PATCH] first cut at adding zoom support for plugins. --- WebKit/android/plugins/PluginWidgetAndroid.cpp | 13 ++++++++++++- WebKit/android/plugins/PluginWidgetAndroid.h | 1 + WebKit/android/plugins/android_npapi.h | 22 ++++++++++++++++------ 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/WebKit/android/plugins/PluginWidgetAndroid.cpp b/WebKit/android/plugins/PluginWidgetAndroid.cpp index 72714b4bb..c947b3b87 100644 --- a/WebKit/android/plugins/PluginWidgetAndroid.cpp +++ b/WebKit/android/plugins/PluginWidgetAndroid.cpp @@ -48,6 +48,7 @@ PluginWidgetAndroid::PluginWidgetAndroid(WebCore::PluginView* view) m_requestedFrameRect.setEmpty(); m_visibleDocRect.setEmpty(); m_hasFocus = false; + m_zoomLevel = 0; } PluginWidgetAndroid::~PluginWidgetAndroid() { @@ -222,7 +223,17 @@ ANPSurface* PluginWidgetAndroid::createSurface(ANPSurfaceType ignored) { void PluginWidgetAndroid::setVisibleScreen(const ANPRectI& visibleDocRect, float zoom) { - //TODO send an event to the plugin that communicates the 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); + } 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 c278ffb4b..151d6eff8 100644 --- a/WebKit/android/plugins/PluginWidgetAndroid.h +++ b/WebKit/android/plugins/PluginWidgetAndroid.h @@ -147,6 +147,7 @@ private: SkIRect m_requestedFrameRect; OwnPtr m_surface; bool m_hasFocus; + float m_zoomLevel; /* We limit the number of rectangles to minimize storage and ensure adequate speed. diff --git a/WebKit/android/plugins/android_npapi.h b/WebKit/android/plugins/android_npapi.h index 47a7494a5..f67d0748a 100644 --- a/WebKit/android/plugins/android_npapi.h +++ b/WebKit/android/plugins/android_npapi.h @@ -150,21 +150,22 @@ enum ANPDrawingModels { }; typedef int32_t ANPDrawingModel; -/** Request to receive/disable events. If the pointer is NULL then all input will - be disabled. Otherwise, the input type will be enabled iff its corresponding +/** Request to receive/disable events. If the pointer is NULL then all flags will + be disabled. Otherwise, the event type will be enabled iff its corresponding bit in the EventFlags bit field is set. NPN_SetValue(inst, ANPAcceptEvents, (void*)EventFlags) */ #define kAcceptEvents_ANPSetValue ((NPPVariable)1001) -/* The EventFlags are a set of bits used to determine which types of input the +/* The EventFlags are a set of bits used to determine which types of events the plugin wishes to receive. For example, if the value is 0x03 then both key and touch events will be provided to the plugin. */ enum ANPEventFlag { - kKey_ANPEventFlag = 0x01, - kTouch_ANPEventFlag = 0x02, + kKey_ANPEventFlag = 0x01, + kTouch_ANPEventFlag = 0x02, + kZoom_ANPEventFlag = 0x04, // triggers zoom & surface changed events }; typedef uint32_t ANPEventFlags; @@ -755,6 +756,11 @@ 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; @@ -794,6 +800,9 @@ enum ANPLifecycleActions { kGainFocus_ANPLifecycleAction = 2, kLoseFocus_ANPLifecycleAction = 3, kFreeMemory_ANPLifecycleAction = 4, + /** The page has finished loading. This happens when the page's top level + frame reports that it has completed loading. + */ kOnLoad_ANPLifecycleAction = 5, }; typedef uint32_t ANPLifecycleAction; @@ -868,7 +877,8 @@ struct ANPEvent { } changed; } data; } surface; - int32_t other[8]; + float zoomLevel; + int32_t other[8]; } data; }; -- 2.11.0