summaryrefslogtreecommitdiffstats
path: root/Source/WebKit/android/nav/SelectText.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebKit/android/nav/SelectText.cpp')
-rw-r--r--Source/WebKit/android/nav/SelectText.cpp25
1 files changed, 24 insertions, 1 deletions
diff --git a/Source/WebKit/android/nav/SelectText.cpp b/Source/WebKit/android/nav/SelectText.cpp
index 98ec574..4a6b509 100644
--- a/Source/WebKit/android/nav/SelectText.cpp
+++ b/Source/WebKit/android/nav/SelectText.cpp
@@ -51,6 +51,11 @@
#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 {
@@ -1311,6 +1316,7 @@ static WTF::String text(const SkPicture& picture, const SkIRect& area,
// 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)
@@ -1321,6 +1327,7 @@ static WTF::String text(const SkPicture& picture, const SkIRect& area,
SelectText::SelectText()
: m_controlWidth(CONTROL_WIDTH)
, m_controlHeight(CONTROL_HEIGHT)
+ , m_controlSlop(CONTROL_SLOP)
{
m_picture = 0;
reset();
@@ -1538,15 +1545,19 @@ void SelectText::drawSelectionRegion(SkCanvas* canvas, IntRect* inval)
#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();
@@ -1789,6 +1800,9 @@ bool SelectText::hitCorner(int cx, int cy, int x, int y) const
{
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);
}
@@ -1815,6 +1829,14 @@ bool SelectText::hitSelection(int x, int y) const
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)
@@ -1953,6 +1975,7 @@ void SelectText::updateHandleScale(float handleScale)
{
m_controlHeight = CONTROL_HEIGHT * handleScale;
m_controlWidth = CONTROL_WIDTH * handleScale;
+ m_controlSlop = CONTROL_SLOP * handleScale;
}
/* selects the word at (x, y)