#define VERBOSE_LOGGING 0
// #define EXTRA_NOISY_LOGGING 1
#define DEBUG_TOUCH_HANDLES 0
+#if DEBUG_TOUCH_HANDLES
+#define DBG_HANDLE_LOG(format, ...) LOGD("%s " format, __FUNCTION__, __VA_ARGS__)
+#else
+#define DBG_HANDLE_LOG(...)
+#endif
// TextRunIterator has been copied verbatim from GraphicsContext.cpp
namespace WebCore {
// from the drawable itself
#define CONTROL_HEIGHT 47
#define CONTROL_WIDTH 26
+#define CONTROL_SLOP 5
#define STROKE_WIDTH 1.0f
#define STROKE_OUTSET 3.5f
#define STROKE_I_OUTSET 4 // (int) ceil(STROKE_OUTSET)
SelectText::SelectText()
: m_controlWidth(CONTROL_WIDTH)
, m_controlHeight(CONTROL_HEIGHT)
+ , m_controlSlop(CONTROL_SLOP)
{
m_picture = 0;
reset();
#if DEBUG_TOUCH_HANDLES
SkRect touchHandleRect;
- paint.setColor(SkColorSetARGB(0xA0, 0xFF, 0x00, 0x00));
+ paint.setColor(SkColorSetARGB(0x60, 0xFF, 0x00, 0x00));
touchHandleRect.set(0, m_selStart.fBottom, m_selStart.fLeft, 0);
touchHandleRect.fBottom = touchHandleRect.fTop + m_controlHeight;
touchHandleRect.fLeft = touchHandleRect.fRight - m_controlWidth;
canvas->drawRect(touchHandleRect, paint);
+ touchHandleRect.inset(-m_controlSlop, -m_controlSlop);
+ canvas->drawRect(touchHandleRect, paint);
touchHandleRect.set(m_selEnd.fRight, m_selEnd.fBottom, 0, 0);
touchHandleRect.fBottom = touchHandleRect.fTop + m_controlHeight;
touchHandleRect.fRight = touchHandleRect.fLeft + m_controlWidth;
canvas->drawRect(touchHandleRect, paint);
+ touchHandleRect.inset(-m_controlSlop, -m_controlSlop);
+ canvas->drawRect(touchHandleRect, paint);
#endif
SkIRect a = diff.getBounds();
{
SkIRect test;
test.set(cx, cy, cx + m_controlWidth, cy + m_controlHeight);
+ test.inset(-m_controlSlop, -m_controlSlop);
+ DBG_HANDLE_LOG("checking if %dx%d,%d-%d contains %dx%d",
+ cx, cy, m_controlWidth, m_controlHeight, x, y);
return test.contains(x, y);
}
return m_selRegion.contains(x, y);
}
+void SelectText::getSelectionHandles(int* handles)
+{
+ handles[0] = m_selStart.fLeft;
+ handles[1] = m_selStart.fBottom;
+ handles[2] = m_selEnd.fRight;
+ handles[3] = m_selEnd.fBottom;
+}
+
void SelectText::moveSelection(const IntRect& vis, int x, int y)
{
if (!m_picture)
{
m_controlHeight = CONTROL_HEIGHT * handleScale;
m_controlWidth = CONTROL_WIDTH * handleScale;
+ m_controlSlop = CONTROL_SLOP * handleScale;
}
/* selects the word at (x, y)
m_selectText.getSelectionRegion(getVisibleRect(), region, compositeRoot());
}
+void getTextSelectionHandles(int* handles)
+{
+ m_selectText.getSelectionHandles(handles);
+}
+
void replaceBaseContent(PictureSet* set)
{
if (!m_baseLayer)
registerPageSwapCallback);
}
-static void nativeGetTextSelectionRegion(JNIEnv *env, jobject obj, jobject region)
+static void nativeGetTextSelectionRegion(JNIEnv *env, jobject obj, jint view,
+ jobject region)
{
if (!region)
return;
SkRegion* nregion = GraphicsJNI::getNativeRegion(env, region);
- GET_NATIVE_VIEW(env, obj)->getTextSelectionRegion(nregion);
+ ((WebView*)view)->getTextSelectionRegion(nregion);
+}
+
+static void nativeGetSelectionHandles(JNIEnv *env, jobject obj, jint view,
+ jintArray arr)
+{
+ int handles[4];
+ ((WebView*)view)->getTextSelectionHandles(handles);
+ env->SetIntArrayRegion(arr, 0, 4, handles);
+ checkException(env);
}
static BaseLayerAndroid* nativeGetBaseLayer(JNIEnv *env, jobject obj)
(void*) nativeSetHeightCanMeasure },
{ "nativeSetBaseLayer", "(ILandroid/graphics/Region;ZZZ)V",
(void*) nativeSetBaseLayer },
- { "nativeGetTextSelectionRegion", "(Landroid/graphics/Region;)V",
+ { "nativeGetTextSelectionRegion", "(ILandroid/graphics/Region;)V",
(void*) nativeGetTextSelectionRegion },
+ { "nativeGetSelectionHandles", "(I[I)V",
+ (void*) nativeGetSelectionHandles },
{ "nativeGetBaseLayer", "()I",
(void*) nativeGetBaseLayer },
{ "nativeReplaceBaseContent", "(I)V",