summaryrefslogtreecommitdiffstats
path: root/WebKit/android/plugins/PluginWidgetAndroid.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebKit/android/plugins/PluginWidgetAndroid.cpp')
-rw-r--r--WebKit/android/plugins/PluginWidgetAndroid.cpp69
1 files changed, 38 insertions, 31 deletions
diff --git a/WebKit/android/plugins/PluginWidgetAndroid.cpp b/WebKit/android/plugins/PluginWidgetAndroid.cpp
index 7c779c1..293c994 100644
--- a/WebKit/android/plugins/PluginWidgetAndroid.cpp
+++ b/WebKit/android/plugins/PluginWidgetAndroid.cpp
@@ -129,7 +129,9 @@ void PluginWidgetAndroid::setWindow(NPWindow* window, bool isTransparent) {
m_pluginBounds.fLeft, m_pluginBounds.fTop,
m_pluginBounds.fRight, m_pluginBounds.fBottom);
- layoutSurface(m_pluginBounds != oldPluginBounds);
+ const bool boundsChanged = m_pluginBounds != oldPluginBounds;
+ sendSizeAndVisibilityEvents(boundsChanged);
+ layoutSurface(boundsChanged);
if (m_drawingModel != kSurface_ANPDrawingModel) {
m_flipPixelRef->safeUnref();
@@ -354,30 +356,53 @@ bool PluginWidgetAndroid::isAcceptingEvent(ANPEventFlag flag) {
return m_eventFlags & flag;
}
-void PluginWidgetAndroid::setVisibleScreen(const ANPRectI& visibleDocRect, float zoom) {
-#if DEBUG_VISIBLE_RECTS
- PLUGIN_LOG("%s (%d,%d,%d,%d)[%f]", __FUNCTION__, visibleDocRect.left,
- visibleDocRect.top, visibleDocRect.right,
- visibleDocRect.bottom, zoom);
-#endif
+void PluginWidgetAndroid::sendSizeAndVisibilityEvents(const bool updateDimensions) {
// TODO update the bitmap size based on the zoom? (for kBitmap_ANPDrawingModel)
// notify the plugin of the new size
- // TODO what if the plugin changes sizes?
- if (m_drawingModel == kOpenGL_ANPDrawingModel && m_zoomLevel != zoom) {
+ if (m_drawingModel == kOpenGL_ANPDrawingModel && updateDimensions) {
PLUGIN_LOG("%s (%d,%d)[%f]", __FUNCTION__, m_pluginWindow->width,
- m_pluginWindow->height, zoom);
+ m_pluginWindow->height, m_zoomLevel);
ANPEvent event;
SkANP::InitEvent(&event, kDraw_ANPEventType);
event.data.draw.model = kOpenGL_ANPDrawingModel;
- event.data.draw.data.surface.width = m_pluginWindow->width * zoom;
- event.data.draw.data.surface.height = m_pluginWindow->height * zoom;
+ event.data.draw.data.surface.width = m_pluginWindow->width * m_zoomLevel;
+ event.data.draw.data.surface.height = m_pluginWindow->height * m_zoomLevel;
sendEvent(event);
}
+ bool visible = SkIRect::Intersects(m_visibleDocRect, m_pluginBounds);
+ if(m_visible != visible) {
+
+#if DEBUG_VISIBLE_RECTS
+ PLUGIN_LOG("%p changeVisiblity[%d] pluginBounds(%d,%d,%d,%d)",
+ m_pluginView->instance(), visible,
+ m_pluginBounds.fLeft, m_pluginBounds.fTop,
+ m_pluginBounds.fRight, m_pluginBounds.fBottom);
+#endif
+
+ // change the visibility
+ m_visible = visible;
+ // send the event
+ ANPEvent event;
+ SkANP::InitEvent(&event, kLifecycle_ANPEventType);
+ event.data.lifecycle.action = visible ? kOnScreen_ANPLifecycleAction
+ : kOffScreen_ANPLifecycleAction;
+ sendEvent(event);
+ }
+}
+
+void PluginWidgetAndroid::setVisibleScreen(const ANPRectI& visibleDocRect, float zoom) {
+#if DEBUG_VISIBLE_RECTS
+ PLUGIN_LOG("%s (%d,%d,%d,%d)[%f]", __FUNCTION__, visibleDocRect.left,
+ visibleDocRect.top, visibleDocRect.right,
+ visibleDocRect.bottom, zoom);
+#endif
int oldScreenW = m_visibleDocRect.width();
int oldScreenH = m_visibleDocRect.height();
+ const bool zoomChanged = m_zoomLevel != zoom;
+
// make local copies of the parameters
m_zoomLevel = zoom;
m_visibleDocRect.set(visibleDocRect.left,
@@ -396,25 +421,7 @@ void PluginWidgetAndroid::setVisibleScreen(const ANPRectI& visibleDocRect, float
computeVisiblePluginRect();
}
- bool visible = SkIRect::Intersects(m_visibleDocRect, m_pluginBounds);
- if(m_visible != visible) {
-
-#if DEBUG_VISIBLE_RECTS
- PLUGIN_LOG("%p changeVisiblity[%d] pluginBounds(%d,%d,%d,%d)",
- m_pluginView->instance(), visible,
- m_pluginBounds.fLeft, m_pluginBounds.fTop,
- m_pluginBounds.fRight, m_pluginBounds.fBottom);
-#endif
-
- // change the visibility
- m_visible = visible;
- // send the event
- ANPEvent event;
- SkANP::InitEvent(&event, kLifecycle_ANPEventType);
- event.data.lifecycle.action = visible ? kOnScreen_ANPLifecycleAction
- : kOffScreen_ANPLifecycleAction;
- sendEvent(event);
- }
+ sendSizeAndVisibilityEvents(zoomChanged);
}
ANPRectI PluginWidgetAndroid::visibleRect() {