summaryrefslogtreecommitdiffstats
path: root/WebKit
diff options
context:
space:
mode:
authorDerek Sollenberger <djsollen@google.com>2009-08-04 09:28:51 -0400
committerDerek Sollenberger <djsollen@google.com>2009-08-04 09:57:19 -0400
commitdfe318f64605ccd0edac334790a5bce975921f47 (patch)
tree0680cdc01cfb411fc9048a0742d6249b6390dbe8 /WebKit
parent5655832af95b56bf25c0183a2d5d2cd909d6c8f4 (diff)
downloadexternal_webkit-dfe318f64605ccd0edac334790a5bce975921f47.zip
external_webkit-dfe318f64605ccd0edac334790a5bce975921f47.tar.gz
external_webkit-dfe318f64605ccd0edac334790a5bce975921f47.tar.bz2
enhancing visibleRect tracking and making it work within iframes.
Diffstat (limited to 'WebKit')
-rw-r--r--WebKit/android/jni/WebViewCore.cpp2
-rw-r--r--WebKit/android/plugins/PluginWidgetAndroid.cpp43
-rw-r--r--WebKit/android/plugins/PluginWidgetAndroid.h7
3 files changed, 37 insertions, 15 deletions
diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp
index 726f724..43a077f 100644
--- a/WebKit/android/jni/WebViewCore.cpp
+++ b/WebKit/android/jni/WebViewCore.cpp
@@ -1192,7 +1192,7 @@ void WebViewCore::drawPlugins()
SkIRect dirty;
if (w->isDirty(&dirty)) {
w->draw();
- w->localToPageCoords(&dirty);
+ w->localToDocumentCoords(&dirty);
inval.op(dirty, SkRegion::kUnion_Op);
}
}
diff --git a/WebKit/android/plugins/PluginWidgetAndroid.cpp b/WebKit/android/plugins/PluginWidgetAndroid.cpp
index 96aa74b..72714b4 100644
--- a/WebKit/android/plugins/PluginWidgetAndroid.cpp
+++ b/WebKit/android/plugins/PluginWidgetAndroid.cpp
@@ -47,6 +47,7 @@ PluginWidgetAndroid::PluginWidgetAndroid(WebCore::PluginView* view)
m_requestedVisibleRectCount = 0;
m_requestedFrameRect.setEmpty();
m_visibleDocRect.setEmpty();
+ m_hasFocus = false;
}
PluginWidgetAndroid::~PluginWidgetAndroid() {
@@ -71,7 +72,7 @@ void PluginWidgetAndroid::setWindow(NPWindow* window, bool isTransparent) {
if (m_drawingModel == kSurface_ANPDrawingModel) {
if (m_surface) {
- IntPoint docPoint = getDocumentCoordinates(window->x, window->y);
+ IntPoint docPoint = frameToDocumentCoords(window->x, window->y);
m_surface->attach(docPoint.x(), docPoint.y(), window->width, window->height);
}
} else {
@@ -86,9 +87,12 @@ bool PluginWidgetAndroid::setDrawingModel(ANPDrawingModel model) {
return true;
}
-void PluginWidgetAndroid::localToPageCoords(SkIRect* rect) const {
- if (m_pluginWindow)
- rect->offset(m_pluginWindow->x, m_pluginWindow->y);
+void PluginWidgetAndroid::localToDocumentCoords(SkIRect* rect) const {
+ if (m_pluginWindow) {
+ IntPoint pluginDocCoords = frameToDocumentCoords(m_pluginWindow->x,
+ m_pluginWindow->y);
+ rect->offset(pluginDocCoords.x(), pluginDocCoords.y());
+ }
}
bool PluginWidgetAndroid::isDirty(SkIRect* rect) const {
@@ -166,6 +170,15 @@ bool PluginWidgetAndroid::sendEvent(const ANPEvent& evt) {
NPP instance = m_pluginView->instance();
// "missing" plugins won't have these
if (pkg && instance) {
+
+ // keep track of whether or not the plugin currently has focus
+ if (evt.eventType == kLifecycle_ANPEventType) {
+ if (evt.data.lifecycle.action == kLoseFocus_ANPLifecycleAction)
+ m_hasFocus = false;
+ else if (evt.data.lifecycle.action == kGainFocus_ANPLifecycleAction)
+ m_hasFocus = true;
+ }
+
// make a localCopy since the actual plugin may not respect its constness,
// and so we don't want our caller to have its param modified
ANPEvent localCopy = evt;
@@ -286,16 +299,24 @@ void PluginWidgetAndroid::computeVisibleFrameRect() {
void PluginWidgetAndroid::scrollToVisibleFrameRect() {
- if (m_requestedFrameRect.isEmpty() || m_visibleDocRect.isEmpty())
+ if (!m_hasFocus || m_requestedFrameRect.isEmpty() || m_visibleDocRect.isEmpty())
return;
- // TODO if the entire rect is already visible then we don't need to scroll,
- // this requires converting the m_requestedFrameRect from frame to doc coordinates
+ // if the entire rect is already visible then we don't need to scroll, which
+ // requires converting the m_requestedFrameRect from frame to doc coordinates
+ IntPoint pluginDocPoint = frameToDocumentCoords(m_requestedFrameRect.fLeft,
+ m_requestedFrameRect.fTop);
+ SkIRect requestedDocRect;
+ requestedDocRect.set(pluginDocPoint.x(), pluginDocPoint.y(),
+ pluginDocPoint.x() + m_requestedFrameRect.width(),
+ pluginDocPoint.y() + m_requestedFrameRect.height());
+
+ if (m_visibleDocRect.contains(requestedDocRect))
+ return;
// find the center of the visibleRect in document coordinates
- IntPoint pluginDocPoint = getDocumentCoordinates(m_requestedFrameRect.fLeft, m_requestedFrameRect.fTop);
- int rectCenterX = pluginDocPoint.x() + m_requestedFrameRect.width()/2;
- int rectCenterY = pluginDocPoint.y() + m_requestedFrameRect.height()/2;
+ int rectCenterX = requestedDocRect.fLeft + requestedDocRect.width()/2;
+ int rectCenterY = requestedDocRect.fTop + requestedDocRect.height()/2;
// find document coordinates for center of the visible screen
int screenCenterX = m_visibleDocRect.fLeft + m_visibleDocRect.width()/2;
@@ -310,7 +331,7 @@ void PluginWidgetAndroid::scrollToVisibleFrameRect() {
core->scrollBy(deltaX, deltaY, true);
}
-IntPoint PluginWidgetAndroid::getDocumentCoordinates(int frameX, int frameY) {
+IntPoint PluginWidgetAndroid::frameToDocumentCoords(int frameX, int frameY) const {
IntPoint docPoint = IntPoint(frameX, frameY);
const ScrollView* currentScrollView = m_pluginView->parent();
diff --git a/WebKit/android/plugins/PluginWidgetAndroid.h b/WebKit/android/plugins/PluginWidgetAndroid.h
index cc2d206..c278ffb 100644
--- a/WebKit/android/plugins/PluginWidgetAndroid.h
+++ b/WebKit/android/plugins/PluginWidgetAndroid.h
@@ -74,11 +74,11 @@ struct PluginWidgetAndroid {
*/
bool setDrawingModel(ANPDrawingModel);
- /* Utility method to convert from local (plugin) coordinates to docuemnt
+ /* Utility method to convert from local (plugin) coordinates to document
coordinates. Needed (for instance) to convert the dirty rectangle into
document coordinates to inturn inval the screen.
*/
- void localToPageCoords(SkIRect*) const;
+ void localToDocumentCoords(SkIRect*) const;
/* Returns true (and optionally updates rect with the dirty bounds) if
the plugin has invalidate us.
@@ -133,7 +133,7 @@ struct PluginWidgetAndroid {
void setVisibleRects(const ANPRectI rects[], int32_t count);
private:
- WebCore::IntPoint getDocumentCoordinates(int frameX, int frameY);
+ WebCore::IntPoint frameToDocumentCoords(int frameX, int frameY) const;
void computeVisibleFrameRect();
void scrollToVisibleFrameRect();
@@ -146,6 +146,7 @@ private:
SkIRect m_visibleDocRect;
SkIRect m_requestedFrameRect;
OwnPtr<android::PluginSurface> m_surface;
+ bool m_hasFocus;
/* We limit the number of rectangles to minimize storage and ensure adequate
speed.