diff options
author | John Reck <jreck@google.com> | 2011-09-01 08:43:25 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-09-01 08:43:25 -0700 |
commit | ed544a3dc0117e0f1e554b44016cd6031dbc2fb5 (patch) | |
tree | e578f99b7972c9322133b57ca3238ee0473b1fde /Source | |
parent | 192378c6d8e50b07babbe3bd14d304b70e0aea4d (diff) | |
parent | 8111ace8860f79c6b7ece2c408a3f80a0762b09b (diff) | |
download | external_webkit-ed544a3dc0117e0f1e554b44016cd6031dbc2fb5.zip external_webkit-ed544a3dc0117e0f1e554b44016cd6031dbc2fb5.tar.gz external_webkit-ed544a3dc0117e0f1e554b44016cd6031dbc2fb5.tar.bz2 |
Merge "Allow native to query selection region"
Diffstat (limited to 'Source')
-rw-r--r-- | Source/WebKit/android/nav/SelectText.cpp | 10 | ||||
-rw-r--r-- | Source/WebKit/android/nav/SelectText.h | 1 | ||||
-rw-r--r-- | Source/WebKit/android/nav/WebView.cpp | 15 |
3 files changed, 26 insertions, 0 deletions
diff --git a/Source/WebKit/android/nav/SelectText.cpp b/Source/WebKit/android/nav/SelectText.cpp index c56c53c..7d18d5d 100644 --- a/Source/WebKit/android/nav/SelectText.cpp +++ b/Source/WebKit/android/nav/SelectText.cpp @@ -1475,6 +1475,16 @@ static void addEnd(SkRegion* diff, const SkIRect& rect) diff->op(bounds, SkRegion::kUnion_Op); } +void SelectText::getSelectionRegion(const IntRect& vis, SkRegion *region) +{ + SkIRect ivisBounds = vis; + ivisBounds.join(m_selStart); + ivisBounds.join(m_selEnd); + region->setEmpty(); + buildSelection(*m_picture, ivisBounds, m_selStart, m_startBase, + m_selEnd, m_endBase, region); +} + void SelectText::drawSelectionRegion(SkCanvas* canvas, IntRect* inval) { if (!m_picture) diff --git a/Source/WebKit/android/nav/SelectText.h b/Source/WebKit/android/nav/SelectText.h index de577ac..272cfd1 100644 --- a/Source/WebKit/android/nav/SelectText.h +++ b/Source/WebKit/android/nav/SelectText.h @@ -57,6 +57,7 @@ public: void setExtendSelection(bool extend) { m_extendSelection = extend; } bool startSelection(const CachedRoot* , const IntRect& vis, int x, int y); bool wordSelection(const CachedRoot* , const IntRect& vis, int x, int y); + void getSelectionRegion(const IntRect& vis, SkRegion *region); public: float m_inverseScale; // inverse scale, x, y used for drawing select path int m_selectX; diff --git a/Source/WebKit/android/nav/WebView.cpp b/Source/WebKit/android/nav/WebView.cpp index 945a785..5cf9953 100644 --- a/Source/WebKit/android/nav/WebView.cpp +++ b/Source/WebKit/android/nav/WebView.cpp @@ -1482,6 +1482,11 @@ void setBaseLayer(BaseLayerAndroid* layer, SkRegion& inval, bool showVisualIndic root->setRootLayer(compositeRoot()); } +void getTextSelectionRegion(SkRegion *region) +{ + m_selectText.getSelectionRegion(getVisibleRect(), region); +} + void replaceBaseContent(PictureSet* set) { if (!m_baseLayer) @@ -1910,6 +1915,14 @@ static void nativeSetBaseLayer(JNIEnv *env, jobject obj, jint layer, jobject inv registerPageSwapCallback); } +static void nativeGetTextSelectionRegion(JNIEnv *env, jobject obj, jobject region) +{ + if (!region) + return; + SkRegion* nregion = GraphicsJNI::getNativeRegion(env, region); + GET_NATIVE_VIEW(env, obj)->getTextSelectionRegion(nregion); +} + static BaseLayerAndroid* nativeGetBaseLayer(JNIEnv *env, jobject obj) { return GET_NATIVE_VIEW(env, obj)->getBaseLayer(); @@ -2794,6 +2807,8 @@ static JNINativeMethod gJavaWebViewMethods[] = { (void*) nativeSetHeightCanMeasure }, { "nativeSetBaseLayer", "(ILandroid/graphics/Region;ZZZ)V", (void*) nativeSetBaseLayer }, + { "nativeGetTextSelectionRegion", "(Landroid/graphics/Region;)V", + (void*) nativeGetTextSelectionRegion }, { "nativeGetBaseLayer", "()I", (void*) nativeGetBaseLayer }, { "nativeReplaceBaseContent", "(I)V", |