diff options
| -rw-r--r-- | WebCore/plugins/android/PluginViewAndroid.cpp | 2 | ||||
| -rw-r--r-- | WebKit/android/nav/CacheBuilder.cpp | 6 | ||||
| -rw-r--r-- | WebKit/android/nav/SelectText.cpp | 22 | ||||
| -rw-r--r-- | WebKit/android/nav/SelectText.h | 2 | ||||
| -rw-r--r-- | WebKit/android/nav/WebView.cpp | 20 | ||||
| -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 |
9 files changed, 96 insertions, 3 deletions
diff --git a/WebCore/plugins/android/PluginViewAndroid.cpp b/WebCore/plugins/android/PluginViewAndroid.cpp index 68fa3d7..912068e 100644 --- a/WebCore/plugins/android/PluginViewAndroid.cpp +++ b/WebCore/plugins/android/PluginViewAndroid.cpp @@ -104,6 +104,7 @@ extern void ANPPathInterfaceV0_Init(ANPInterface* value); extern void ANPSurfaceInterfaceV0_Init(ANPInterface* value); extern void ANPTypefaceInterfaceV0_Init(ANPInterface* value); extern void ANPWindowInterfaceV0_Init(ANPInterface* value); +extern void ANPWindowInterfaceV1_Init(ANPInterface* value); extern void ANPSystemInterfaceV0_Init(ANPInterface* value); extern void ANPOpenGLInterfaceV0_Init(ANPInterface* value); @@ -129,6 +130,7 @@ static const VarProcPair gVarProcs[] = { { VARPROCLINE(SurfaceInterfaceV0) }, { VARPROCLINE(TypefaceInterfaceV0) }, { VARPROCLINE(WindowInterfaceV0) }, + { VARPROCLINE(WindowInterfaceV1) }, { VARPROCLINE(SystemInterfaceV0) }, { VARPROCLINE(OpenGLInterfaceV0) }, }; diff --git a/WebKit/android/nav/CacheBuilder.cpp b/WebKit/android/nav/CacheBuilder.cpp index 48583be..4cb9695 100644 --- a/WebKit/android/nav/CacheBuilder.cpp +++ b/WebKit/android/nav/CacheBuilder.cpp @@ -1030,8 +1030,10 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame, // The frame itself might be composited so we need to track the layer. Do // not track the base frame's layer as the main content is draw as part of // BaseLayerAndroid's picture. - if (frame != root && frame->contentRenderer()->usesCompositing() && node->lastChild()) - TrackLayer(layerTracker, frame->contentRenderer(), node->lastChild(), globalOffsetX, globalOffsetY); + if (frame != root && frame->contentRenderer() + && frame->contentRenderer()->usesCompositing() && node->lastChild()) + TrackLayer(layerTracker, frame->contentRenderer(), node->lastChild(), + globalOffsetX, globalOffsetY); #endif while (walk.mMore || (node = node->traverseNextNode()) != NULL) { #if DUMP_NAV_CACHE diff --git a/WebKit/android/nav/SelectText.cpp b/WebKit/android/nav/SelectText.cpp index 0862284..f2d7521 100644 --- a/WebKit/android/nav/SelectText.cpp +++ b/WebKit/android/nav/SelectText.cpp @@ -486,7 +486,7 @@ public: return false; } - virtual bool onIRectGlyph(const SkIRect& rect, const SkBounder::GlyphRec& ) + virtual bool onIRect(const SkIRect& rect) { SkIRect bounds; bounds.set(rect.fLeft, top(), rect.fRight, bottom()); @@ -1853,6 +1853,25 @@ void SelectText::reset() m_layerId = 0; } +IntPoint SelectText::selectableText(const CachedRoot* root) +{ + int x = 0; + int y = 0; + SkPicture* picture = root->pictureAt(&x, &y, &m_layerId); + if (!picture) { + DBG_NAV_LOG("picture==0"); + return IntPoint(0, 0); + } + int width = picture->width(); + int height = picture->height(); + IntRect vis(0, 0, width, height); + FirstCheck center(width >> 1, height >> 1, vis); + int base; + const SkIRect& closest = findClosest(center, *picture, &base); + return IntPoint((closest.fLeft + closest.fRight) >> 1, + (closest.fTop + closest.fBottom) >> 1); +} + void SelectText::selectAll() { if (!m_picture) @@ -1961,6 +1980,7 @@ bool SelectText::wordSelection(const CachedRoot* root, const IntRect& vis, y = (m_selStart.fTop + m_selStart.fBottom) >> 1; SkIRect clipRect = m_visibleRect; clipRect.fLeft -= m_visibleRect.width() >> 1; + clipRect.fLeft = std::max(clipRect.fLeft, 0); int base; SkIRect left = findLeft(*m_picture, clipRect, x, y, &base); if (!left.isEmpty()) { diff --git a/WebKit/android/nav/SelectText.h b/WebKit/android/nav/SelectText.h index 8f4747f..3b15c0b 100644 --- a/WebKit/android/nav/SelectText.h +++ b/WebKit/android/nav/SelectText.h @@ -27,6 +27,7 @@ #define SELECT_TEXT_H #include "DrawExtra.h" +#include "IntPoint.h" #include "IntRect.h" #include "PlatformString.h" #include "SkPath.h" @@ -48,6 +49,7 @@ public: bool hitSelection(int x, int y) const; void moveSelection(const IntRect& vis, int x, int y); void reset(); + IntPoint selectableText(const CachedRoot* ); void selectAll(); int selectionX() const; int selectionY() const; diff --git a/WebKit/android/nav/WebView.cpp b/WebKit/android/nav/WebView.cpp index fdca064..a022fe1 100644 --- a/WebKit/android/nav/WebView.cpp +++ b/WebKit/android/nav/WebView.cpp @@ -1081,6 +1081,14 @@ void moveSelection(int x, int y) m_selectText.moveSelection(getVisibleRect(), x, y); } +IntPoint selectableText() +{ + const CachedRoot* root = getFrameCache(DontAllowNewer); + if (!root) + return IntPoint(0, 0); + return m_selectText.selectableText(root); +} + void selectAll() { m_selectText.selectAll(); @@ -2113,6 +2121,16 @@ static void nativeResetSelection(JNIEnv *env, jobject obj) return GET_NATIVE_VIEW(env, obj)->resetSelection(); } +static jobject nativeSelectableText(JNIEnv* env, jobject obj) +{ + IntPoint pos = GET_NATIVE_VIEW(env, obj)->selectableText(); + jclass pointClass = env->FindClass("android/graphics/Point"); + jmethodID init = env->GetMethodID(pointClass, "<init>", "(II)V"); + jobject point = env->NewObject(pointClass, init, pos.x(), pos.y()); + env->DeleteLocalRef(pointClass); + return point; +} + static void nativeSelectAll(JNIEnv* env, jobject obj) { GET_NATIVE_VIEW(env, obj)->selectAll(); @@ -2364,6 +2382,8 @@ static JNINativeMethod gJavaWebViewMethods[] = { (void*) nativeRecordButtons }, { "nativeResetSelection", "()V", (void*) nativeResetSelection }, + { "nativeSelectableText", "()Landroid/graphics/Point;", + (void*) nativeSelectableText }, { "nativeSelectAll", "()V", (void*) nativeSelectAll }, { "nativeSelectBestAt", "(Landroid/graphics/Rect;)V", 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 { |
