summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--WebCore/platform/PlatformTouchEvent.h2
-rw-r--r--WebCore/platform/PlatformTouchPoint.h2
-rw-r--r--WebCore/platform/android/PlatformTouchEventAndroid.cpp10
-rw-r--r--WebCore/platform/android/PlatformTouchPointAndroid.cpp6
-rw-r--r--WebCore/plugins/PluginView.cpp7
-rw-r--r--WebCore/plugins/PluginView.h2
-rw-r--r--WebCore/plugins/android/PluginViewAndroid.cpp49
-rw-r--r--WebKit/android/jni/WebViewCore.cpp6
-rw-r--r--WebKit/android/plugins/PluginWidgetAndroid.cpp87
-rw-r--r--WebKit/android/plugins/PluginWidgetAndroid.h21
10 files changed, 85 insertions, 107 deletions
diff --git a/WebCore/platform/PlatformTouchEvent.h b/WebCore/platform/PlatformTouchEvent.h
index 78de894..5371a40 100644
--- a/WebCore/platform/PlatformTouchEvent.h
+++ b/WebCore/platform/PlatformTouchEvent.h
@@ -60,7 +60,7 @@ public:
#if PLATFORM(QT)
PlatformTouchEvent(QTouchEvent*);
#elif PLATFORM(ANDROID)
- PlatformTouchEvent(const IntPoint&, const IntPoint&, TouchEventType, PlatformTouchPoint::State);
+ PlatformTouchEvent(const IntPoint& absolutePagePos, TouchEventType, PlatformTouchPoint::State);
#endif
TouchEventType type() const { return m_type; }
diff --git a/WebCore/platform/PlatformTouchPoint.h b/WebCore/platform/PlatformTouchPoint.h
index 339fe73..53bd8ae 100644
--- a/WebCore/platform/PlatformTouchPoint.h
+++ b/WebCore/platform/PlatformTouchPoint.h
@@ -47,7 +47,7 @@ public:
#if PLATFORM(QT)
PlatformTouchPoint(const QTouchEvent::TouchPoint&);
#elif PLATFORM(ANDROID)
- PlatformTouchPoint(const IntPoint&, const IntPoint&, State);
+ PlatformTouchPoint(const IntPoint& absolutePagePos, State);
#endif
int id() const { return m_id; }
diff --git a/WebCore/platform/android/PlatformTouchEventAndroid.cpp b/WebCore/platform/android/PlatformTouchEventAndroid.cpp
index 46d5c6f..e4af8a3 100644
--- a/WebCore/platform/android/PlatformTouchEventAndroid.cpp
+++ b/WebCore/platform/android/PlatformTouchEventAndroid.cpp
@@ -30,8 +30,14 @@
namespace WebCore {
-PlatformTouchEvent::PlatformTouchEvent(const IntPoint& pos, const IntPoint& globalPos, TouchEventType type, PlatformTouchPoint::State state) : m_type(type) {
- m_touchPoints.append(PlatformTouchPoint(pos, globalPos, state));
+PlatformTouchEvent::PlatformTouchEvent(const IntPoint& absolutePagePos, TouchEventType type, PlatformTouchPoint::State state)
+ : m_type(type)
+ , m_ctrlKey(false)
+ , m_altKey(false)
+ , m_shiftKey(false)
+ , m_metaKey(false)
+{
+ m_touchPoints.append(PlatformTouchPoint(absolutePagePos, state));
}
}
diff --git a/WebCore/platform/android/PlatformTouchPointAndroid.cpp b/WebCore/platform/android/PlatformTouchPointAndroid.cpp
index cb22f5f..d790855 100644
--- a/WebCore/platform/android/PlatformTouchPointAndroid.cpp
+++ b/WebCore/platform/android/PlatformTouchPointAndroid.cpp
@@ -30,7 +30,11 @@
namespace WebCore {
-PlatformTouchPoint::PlatformTouchPoint(const IntPoint& pos, const IntPoint& globalPos, State state) :m_id(0), m_state(state), m_screenPos(pos), m_pos(globalPos) {}
+PlatformTouchPoint::PlatformTouchPoint(const IntPoint& absolutePagePos, State state)
+ : m_id(0)
+ , m_state(state)
+ , m_screenPos(absolutePagePos)
+ , m_pos(absolutePagePos) { }
}
diff --git a/WebCore/plugins/PluginView.cpp b/WebCore/plugins/PluginView.cpp
index 129a21c..89713b5 100644
--- a/WebCore/plugins/PluginView.cpp
+++ b/WebCore/plugins/PluginView.cpp
@@ -131,15 +131,8 @@ void PluginView::setFrameRect(const IntRect& rect)
if (m_element->document()->printing())
return;
-#if defined(ANDROID_PLUGINS)
- if (m_isStarted && (rect != frameRect())) {
- Widget::setFrameRect(rect);
- setNPWindowRect(rect); // only call when it changes
- }
-#else
if (rect != frameRect())
Widget::setFrameRect(rect);
-#endif
updatePluginWidget();
diff --git a/WebCore/plugins/PluginView.h b/WebCore/plugins/PluginView.h
index a5618f7..0ce9c7c 100644
--- a/WebCore/plugins/PluginView.h
+++ b/WebCore/plugins/PluginView.h
@@ -373,7 +373,7 @@ public:
private:
-#if defined(XP_UNIX) || defined(Q_WS_X11) || PLATFORM(SYMBIAN)
+#if defined(XP_UNIX) || defined(Q_WS_X11) || PLATFORM(SYMBIAN) || defined(ANDROID_PLUGINS)
void setNPWindowIfNeeded();
#elif defined(XP_MACOSX)
NP_CGContext m_npCgContext;
diff --git a/WebCore/plugins/android/PluginViewAndroid.cpp b/WebCore/plugins/android/PluginViewAndroid.cpp
index 0d02941..72fdf3f 100644
--- a/WebCore/plugins/android/PluginViewAndroid.cpp
+++ b/WebCore/plugins/android/PluginViewAndroid.cpp
@@ -401,21 +401,34 @@ void PluginView::setParent(ScrollView* parent)
}
}
-void PluginView::setNPWindowRect(const IntRect& rect)
+void PluginView::setNPWindowRect(const IntRect&)
{
- if (!m_isStarted)
- return;
+ setNPWindowIfNeeded();
+}
- // the rect is relative to the frameview's (0,0)
- m_npWindow.x = rect.x();
- m_npWindow.y = rect.y();
- m_npWindow.width = rect.width();
- m_npWindow.height = rect.height();
+void PluginView::setNPWindowIfNeeded()
+{
+ if (!m_isStarted || !parent())
+ return;
- m_npWindow.clipRect.left = 0;
- m_npWindow.clipRect.top = 0;
- m_npWindow.clipRect.right = rect.width();
- m_npWindow.clipRect.bottom = rect.height();
+ // in Android, plugin always get the setwindow() in the page coordinate.
+ IntRect pageRect = m_windowRect;
+ ScrollView* top = parent();
+ while (top->parent())
+ top = top->parent();
+ // only the top ScrollView can have the offset
+ pageRect.move(top->scrollOffset());
+
+ // the m_npWindow is relative to the page
+ m_npWindow.x = pageRect.x();
+ m_npWindow.y = pageRect.y();
+ m_npWindow.width = pageRect.width();
+ m_npWindow.height = pageRect.height();
+
+ m_npWindow.clipRect.left = pageRect.x();
+ m_npWindow.clipRect.top = pageRect.y();
+ m_npWindow.clipRect.right = pageRect.x() + pageRect.width();
+ m_npWindow.clipRect.bottom = pageRect.y() + pageRect.height();
if (m_plugin->pluginFuncs()->setwindow) {
#if USE(JSC)
@@ -594,16 +607,22 @@ void PluginView::paint(GraphicsContext* context, const IntRect& rect)
}
m_window->inval(rect, false);
+ context->save();
+ context->translate(frame.x(), frame.y());
m_window->draw(android_gc2canvas(context));
+ context->restore();
}
-// new as of SVN 38068, Nov 5 2008
void PluginView::updatePluginWidget()
{
- // I bet/hope we can move all of setNPWindowRect() into here
FrameView* frameView = static_cast<FrameView*>(parent());
if (frameView) {
- m_windowRect = IntRect(frameView->contentsToWindow(frameRect().location()), frameRect().size());
+ IntRect oldWindowRect = m_windowRect;
+
+ m_windowRect = frameView->contentsToWindow(frameRect());
+
+ if (m_windowRect != oldWindowRect)
+ setNPWindowIfNeeded();
}
}
diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp
index cb73fb1..5ebc8eb 100644
--- a/WebKit/android/jni/WebViewCore.cpp
+++ b/WebKit/android/jni/WebViewCore.cpp
@@ -1389,7 +1389,6 @@ void WebViewCore::drawPlugins()
SkIRect dirty;
if (w->isDirty(&dirty)) {
w->draw();
- w->localToDocumentCoords(&dirty);
inval.op(dirty, SkRegion::kUnion_Op);
}
}
@@ -1968,7 +1967,7 @@ int WebViewCore::handleTouchEvent(int action, int x, int y)
m_lastTouchPoint = pt;
- WebCore::PlatformTouchEvent te(pt, pt, type, touchState);
+ WebCore::PlatformTouchEvent te(pt, type, touchState);
preventDefault = m_mainFrame->eventHandler()->handleTouchEvent(te);
#endif
@@ -2979,7 +2978,8 @@ static void FullScreenPluginHidden(JNIEnv* env, jobject obj, jint npp)
{
WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj);
PluginWidgetAndroid* plugin = viewImpl->getPluginWidget((NPP)npp);
- plugin->exitFullScreen(false);
+ if (plugin)
+ plugin->exitFullScreen(false);
}
static WebCore::IntRect jrect_to_webrect(JNIEnv* env, jobject obj)
diff --git a/WebKit/android/plugins/PluginWidgetAndroid.cpp b/WebKit/android/plugins/PluginWidgetAndroid.cpp
index 5626f33..553b455 100644
--- a/WebKit/android/plugins/PluginWidgetAndroid.cpp
+++ b/WebKit/android/plugins/PluginWidgetAndroid.cpp
@@ -54,7 +54,7 @@ PluginWidgetAndroid::PluginWidgetAndroid(WebCore::PluginView* view)
m_eventFlags = 0;
m_pluginWindow = NULL;
m_requestedVisibleRectCount = 0;
- m_requestedFrameRect.setEmpty();
+ m_requestedDocRect.setEmpty();
m_visibleDocRect.setEmpty();
m_pluginBounds.setEmpty();
m_hasFocus = false;
@@ -71,7 +71,8 @@ PluginWidgetAndroid::~PluginWidgetAndroid() {
m_core->removePlugin(this);
if (m_isFullScreen) {
exitFullScreen(true);
- } else if (m_embeddedView) {
+ }
+ if (m_embeddedView) {
m_core->destroySurface(m_embeddedView);
}
}
@@ -112,12 +113,10 @@ void PluginWidgetAndroid::setWindow(NPWindow* window, bool isTransparent) {
if (m_drawingModel == kSurface_ANPDrawingModel) {
- IntPoint docPoint = frameToDocumentCoords(window->x, window->y);
-
// if the surface exists check for changes and update accordingly
if (m_embeddedView && m_pluginBounds != oldPluginBounds) {
- m_core->updateSurface(m_embeddedView, docPoint.x(), docPoint.y(),
+ m_core->updateSurface(m_embeddedView, window->x, window->y,
window->width, window->height);
// if the surface does not exist then create a new surface
@@ -126,13 +125,12 @@ void PluginWidgetAndroid::setWindow(NPWindow* window, bool isTransparent) {
WebCore::PluginPackage* pkg = m_pluginView->plugin();
NPP instance = m_pluginView->instance();
-
jobject pluginSurface;
pkg->pluginFuncs()->getvalue(instance, kJavaSurface_ANPGetValue,
static_cast<void*>(&pluginSurface));
jobject tempObj = m_core->addSurface(pluginSurface,
- docPoint.x(), docPoint.y(),
+ window->x, window->y,
window->width, window->height);
if (tempObj) {
JNIEnv* env = JSC::Bindings::getJNIEnv();
@@ -140,7 +138,7 @@ void PluginWidgetAndroid::setWindow(NPWindow* window, bool isTransparent) {
}
}
if (m_isFullScreen && m_pluginBounds != oldPluginBounds) {
- m_core->updateFullScreenPlugin(docPoint.x(), docPoint.y(),
+ m_core->updateFullScreenPlugin(window->x, window->y,
window->width, window->height);
}
} else {
@@ -155,14 +153,7 @@ bool PluginWidgetAndroid::setDrawingModel(ANPDrawingModel model) {
return true;
}
-void PluginWidgetAndroid::localToDocumentCoords(SkIRect* rect) const {
- if (m_pluginWindow) {
- IntPoint pluginDocCoords = frameToDocumentCoords(m_pluginWindow->x,
- m_pluginWindow->y);
- rect->offset(pluginDocCoords.x(), pluginDocCoords.y());
- }
-}
-
+// returned rect is in the page coordinate
bool PluginWidgetAndroid::isDirty(SkIRect* rect) const {
// nothing to report if we haven't had setWindow() called yet
if (NULL == m_flipPixelRef) {
@@ -175,6 +166,7 @@ bool PluginWidgetAndroid::isDirty(SkIRect* rect) const {
} else {
if (rect) {
*rect = dirty.getBounds();
+ rect->offset(m_pluginWindow->x, m_pluginWindow->y);
}
return true;
}
@@ -222,8 +214,7 @@ void PluginWidgetAndroid::draw(SkCanvas* canvas) {
if (canvas && m_pluginWindow) {
SkBitmap bm(bitmap);
bm.setPixelRef(m_flipPixelRef);
- canvas->drawBitmap(bm, SkIntToScalar(m_pluginWindow->x),
- SkIntToScalar(m_pluginWindow->y), NULL);
+ canvas->drawBitmap(bm, 0, 0);
}
}
break;
@@ -302,7 +293,7 @@ void PluginWidgetAndroid::setVisibleScreen(const ANPRectI& visibleDocRect, float
int newScreenH = m_visibleDocRect.height();
if (oldScreenW != newScreenW || oldScreenH != newScreenH)
- computeVisibleFrameRect();
+ computeVisibleDocRect();
bool visible = SkIRect::Intersects(m_visibleDocRect, m_pluginBounds);
if(m_visible != visible) {
@@ -347,10 +338,10 @@ void PluginWidgetAndroid::setVisibleRects(const ANPRectI rects[], int32_t count)
}
}
#endif
- computeVisibleFrameRect();
+ computeVisibleDocRect();
}
-void PluginWidgetAndroid::computeVisibleFrameRect() {
+void PluginWidgetAndroid::computeVisibleDocRect() {
// ensure the visibleDocRect has been set (i.e. not equal to zero)
if (m_visibleDocRect.isEmpty() || !m_pluginWindow)
@@ -364,7 +355,7 @@ void PluginWidgetAndroid::computeVisibleFrameRect() {
ANPRectI* rect = &m_requestedVisibleRect[counter];
- // create skia rect for easier manipulation and convert it to frame coordinates
+ // create skia rect for easier manipulation and convert it to page coordinates
SkIRect pluginRect;
pluginRect.set(rect->left, rect->top, rect->right, rect->bottom);
pluginRect.offset(m_pluginWindow->x, m_pluginWindow->y);
@@ -396,35 +387,27 @@ void PluginWidgetAndroid::computeVisibleFrameRect() {
visibleRect = pluginRect;
}
- m_requestedFrameRect = visibleRect;
- scrollToVisibleFrameRect();
+ m_requestedDocRect = visibleRect;
+ scrollToVisibleDocRect();
}
-void PluginWidgetAndroid::scrollToVisibleFrameRect() {
+void PluginWidgetAndroid::scrollToVisibleDocRect() {
- if (!m_hasFocus || m_requestedFrameRect.isEmpty() || m_visibleDocRect.isEmpty()) {
+ if (!m_hasFocus || m_requestedDocRect.isEmpty() || m_visibleDocRect.isEmpty()) {
#if DEBUG_VISIBLE_RECTS
- SkDebugf("%s call m_hasFocus=%d m_requestedFrameRect.isEmpty()=%d"
+ SkDebugf("%s call m_hasFocus=%d m_requestedDocRect.isEmpty()=%d"
" m_visibleDocRect.isEmpty()=%d", __FUNCTION__, m_hasFocus,
- m_requestedFrameRect.isEmpty(), m_visibleDocRect.isEmpty());
+ m_requestedDocRect.isEmpty(), m_visibleDocRect.isEmpty());
#endif
return;
}
- // 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))
+ // if the entire rect is already visible then we don't need to scroll
+ if (m_visibleDocRect.contains(m_requestedDocRect))
return;
// find the center of the visibleRect in document coordinates
- int rectCenterX = requestedDocRect.fLeft + requestedDocRect.width()/2;
- int rectCenterY = requestedDocRect.fTop + requestedDocRect.height()/2;
+ int rectCenterX = m_requestedDocRect.fLeft + m_requestedDocRect.width()/2;
+ int rectCenterY = m_requestedDocRect.fTop + m_requestedDocRect.height()/2;
// find document coordinates for center of the visible screen
int screenCenterX = m_visibleDocRect.fLeft + m_visibleDocRect.width()/2;
@@ -442,24 +425,6 @@ void PluginWidgetAndroid::scrollToVisibleFrameRect() {
core->scrollBy(deltaX, deltaY, true);
}
-IntPoint PluginWidgetAndroid::frameToDocumentCoords(int frameX, int frameY) const {
- IntPoint docPoint = IntPoint(frameX, frameY);
-
- const ScrollView* currentScrollView = m_pluginView->parent();
- if (currentScrollView) {
- const ScrollView* parentScrollView = currentScrollView->parent();
- while (parentScrollView) {
-
- docPoint.move(currentScrollView->x(), currentScrollView->y());
-
- currentScrollView = parentScrollView;
- parentScrollView = parentScrollView->parent();
- }
- }
-
- return docPoint;
-}
-
void PluginWidgetAndroid::requestFullScreen() {
if (m_isFullScreen || !m_embeddedView) {
return;
@@ -475,9 +440,8 @@ void PluginWidgetAndroid::requestFullScreen() {
m_core->destroySurface(m_embeddedView);
// add the full screen view
- IntPoint docPoint = frameToDocumentCoords(m_pluginWindow->x, m_pluginWindow->y);
m_core->showFullScreenPlugin(m_embeddedView, m_pluginView->instance(),
- docPoint.x(), docPoint.y(), m_pluginWindow->width,
+ m_pluginWindow->x, m_pluginWindow->y, m_pluginWindow->width,
m_pluginWindow->height);
m_isFullScreen = true;
}
@@ -493,8 +457,7 @@ void PluginWidgetAndroid::exitFullScreen(bool pluginInitiated) {
}
// add the embedded view back
- IntPoint docPoint = frameToDocumentCoords(m_pluginWindow->x, m_pluginWindow->y);
- m_core->updateSurface(m_embeddedView, docPoint.x(), docPoint.y(),
+ m_core->updateSurface(m_embeddedView, m_pluginWindow->x, m_pluginWindow->y,
m_pluginWindow->width, m_pluginWindow->height);
// send event to notify plugin of full screen change
diff --git a/WebKit/android/plugins/PluginWidgetAndroid.h b/WebKit/android/plugins/PluginWidgetAndroid.h
index a63b162..6633e1b 100644
--- a/WebKit/android/plugins/PluginWidgetAndroid.h
+++ b/WebKit/android/plugins/PluginWidgetAndroid.h
@@ -74,14 +74,8 @@ struct PluginWidgetAndroid {
*/
bool setDrawingModel(ANPDrawingModel);
- /* 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 localToDocumentCoords(SkIRect*) const;
-
- /* Returns true (and optionally updates rect with the dirty bounds) if
- the plugin has invalidate us.
+ /* Returns true (and optionally updates rect with the dirty bounds in the
+ page coordinate) if the plugin has invalidate us.
*/
bool isDirty(SkIRect* dirtyBounds = NULL) const;
/* Called by PluginView to invalidate a portion of the plugin area (in
@@ -142,9 +136,8 @@ struct PluginWidgetAndroid {
bool inFullScreen() { return m_isFullScreen; }
private:
- WebCore::IntPoint frameToDocumentCoords(int frameX, int frameY) const;
- void computeVisibleFrameRect();
- void scrollToVisibleFrameRect();
+ void computeVisibleDocRect();
+ void scrollToVisibleDocRect();
WebCore::PluginView* m_pluginView;
android::WebViewCore* m_core;
@@ -152,9 +145,9 @@ private:
ANPDrawingModel m_drawingModel;
ANPEventFlags m_eventFlags;
NPWindow* m_pluginWindow;
- SkIRect m_pluginBounds;
- SkIRect m_visibleDocRect;
- SkIRect m_requestedFrameRect;
+ SkIRect m_pluginBounds; // relative to the page
+ SkIRect m_visibleDocRect; // relative to the page
+ SkIRect m_requestedDocRect; // relative to the page
bool m_hasFocus;
bool m_isFullScreen;
bool m_visible;