diff options
| author | Derek Sollenberger <djsollen@google.com> | 2011-01-05 09:40:04 -0500 |
|---|---|---|
| committer | Derek Sollenberger <djsollen@google.com> | 2011-01-05 10:46:27 -0500 |
| commit | 1f7eee5350a1e078daa31e06b09a911f3fc6cb37 (patch) | |
| tree | 8dd3bc8bd149254ff162fef08ab56772d9663f23 /WebKit | |
| parent | 6e57d42a665c4991895ef38776269e59fa164308 (diff) | |
| download | external_webkit-1f7eee5350a1e078daa31e06b09a911f3fc6cb37.zip external_webkit-1f7eee5350a1e078daa31e06b09a911f3fc6cb37.tar.gz external_webkit-1f7eee5350a1e078daa31e06b09a911f3fc6cb37.tar.bz2 | |
Plugin API to report the onscreen visibility of the plugin.
bug: 3324143
Change-Id: I4ad5837b4d79ee63bf53ce974a634d357130930e
Diffstat (limited to 'WebKit')
| -rw-r--r-- | WebKit/android/plugins/ANPWindowInterface.cpp | 14 | ||||
| -rw-r--r-- | WebKit/android/plugins/PluginWidgetAndroid.cpp | 18 | ||||
| -rw-r--r-- | WebKit/android/plugins/PluginWidgetAndroid.h | 6 | ||||
| -rw-r--r-- | WebKit/android/plugins/android_npapi.h | 9 |
4 files changed, 47 insertions, 0 deletions
diff --git a/WebKit/android/plugins/ANPWindowInterface.cpp b/WebKit/android/plugins/ANPWindowInterface.cpp index f086b44..a74616c 100644 --- a/WebKit/android/plugins/ANPWindowInterface.cpp +++ b/WebKit/android/plugins/ANPWindowInterface.cpp @@ -73,6 +73,12 @@ static void anp_requestCenterFitZoom(NPP instance) { pluginWidget->requestCenterFitZoom(); } +static ANPRectI anp_visibleRect(NPP instance) { + PluginView* pluginView = pluginViewForInstance(instance); + PluginWidgetAndroid* pluginWidget = pluginView->platformPluginWidget(); + return pluginWidget->visibleRect(); +} + /////////////////////////////////////////////////////////////////////////////// #define ASSIGN(obj, name) (obj)->name = anp_##name @@ -87,3 +93,11 @@ void ANPWindowInterfaceV0_Init(ANPInterface* value) { ASSIGN(i, exitFullScreen); ASSIGN(i, requestCenterFitZoom); } + +void ANPWindowInterfaceV1_Init(ANPInterface* value) { + // initialize the functions from the previous interface + ANPWindowInterfaceV0_Init(value); + // add any new functions or override existing functions + ANPWindowInterfaceV1* i = reinterpret_cast<ANPWindowInterfaceV1*>(value); + ASSIGN(i, visibleRect); +} diff --git a/WebKit/android/plugins/PluginWidgetAndroid.cpp b/WebKit/android/plugins/PluginWidgetAndroid.cpp index 925f823..de3d944 100644 --- a/WebKit/android/plugins/PluginWidgetAndroid.cpp +++ b/WebKit/android/plugins/PluginWidgetAndroid.cpp @@ -415,6 +415,24 @@ void PluginWidgetAndroid::setVisibleScreen(const ANPRectI& visibleDocRect, float } } +ANPRectI PluginWidgetAndroid::visibleRect() { + + SkIRect visibleRect; + visibleRect.setEmpty(); + + // compute the interesection of the visible screen and the plugin + bool visible = visibleRect.intersect(m_visibleDocRect, m_pluginBounds); + if (visible) { + // convert from absolute coordinates to the plugin's relative coordinates + visibleRect.offset(-m_pluginBounds.fLeft, -m_pluginBounds.fTop); + } + + // convert from SkRect to ANPRect + ANPRectI result; + memcpy(&result, &visibleRect, sizeof(ANPRectI)); + return result; +} + void PluginWidgetAndroid::setVisibleRects(const ANPRectI rects[], int32_t count) { #if DEBUG_VISIBLE_RECTS PLUGIN_LOG("%s count=%d", __FUNCTION__, count); diff --git a/WebKit/android/plugins/PluginWidgetAndroid.h b/WebKit/android/plugins/PluginWidgetAndroid.h index 974fbf0..36b7acd 100644 --- a/WebKit/android/plugins/PluginWidgetAndroid.h +++ b/WebKit/android/plugins/PluginWidgetAndroid.h @@ -117,6 +117,12 @@ struct PluginWidgetAndroid { */ void setVisibleScreen(const ANPRectI& visibleScreenRect, float zoom); + /** Returns a rectangle representing the visible area of the plugin on + screen. The coordinates are relative to the size of the plugin in the + document and will not be negative or exceed the plugin's size. + */ + ANPRectI visibleRect(); + /** Registers a set of rectangles that the plugin would like to keep on screen. The rectangles are listed in order of priority with the highest priority rectangle in location rects[0]. The browser will attempt to keep diff --git a/WebKit/android/plugins/android_npapi.h b/WebKit/android/plugins/android_npapi.h index a99666e..2431985 100644 --- a/WebKit/android/plugins/android_npapi.h +++ b/WebKit/android/plugins/android_npapi.h @@ -122,6 +122,7 @@ typedef uint32_t ANPMatrixFlag; #define kAudioTrackInterfaceV1_ANPGetValue ((NPNVariable)1012) #define kOpenGLInterfaceV0_ANPGetValue ((NPNVariable)1013) +#define kWindowInterfaceV1_ANPGetValue ((NPNVariable)1014) /** queries for the drawing models supported on this device. @@ -682,6 +683,14 @@ struct ANPWindowInterfaceV0 : ANPInterface { void (*requestCenterFitZoom)(NPP instance); }; +struct ANPWindowInterfaceV1 : ANPWindowInterfaceV0 { + /** Returns a rectangle representing the visible area of the plugin on + screen. The coordinates are relative to the size of the plugin in the + document and therefore will never be negative or exceed the plugin's size. + */ + ANPRectI (*visibleRect)(NPP instance); +}; + /////////////////////////////////////////////////////////////////////////////// enum ANPSampleFormats { |
