From d2966aa787e0dcc4d26a10b6f0dc9f3a2f51abe4 Mon Sep 17 00:00:00 2001 From: Cary Clark Date: Tue, 14 Dec 2010 08:04:18 -0500 Subject: improve text selection LayerAndroid.* Adjust the hit-test (x,y) by the layer position. Keep track of the adjusted (x,y) and store the best to be returned when the best layer is found. CachedRoot.cpp Remove code that adjusted (x,y) by layer bounds. SelectText.* Detect columns of text and prefer new characters in the same column as the existing selection. Don't extend the selection until the tap point moves past the word anchors. There's more work to do on selecting text in layers. bug:3275625 bug:3271730 bug:3191699 Change-Id: Ib3c2b35e5eebe30c6032f484cf76d388e94293e0 --- WebCore/platform/graphics/android/LayerAndroid.cpp | 20 ++++++++++++++++---- WebCore/platform/graphics/android/LayerAndroid.h | 2 +- 2 files changed, 17 insertions(+), 5 deletions(-) (limited to 'WebCore/platform') diff --git a/WebCore/platform/graphics/android/LayerAndroid.cpp b/WebCore/platform/graphics/android/LayerAndroid.cpp index f02136a..58d8772 100644 --- a/WebCore/platform/graphics/android/LayerAndroid.cpp +++ b/WebCore/platform/graphics/android/LayerAndroid.cpp @@ -255,7 +255,7 @@ protected: virtual bool onIRectGlyph(const SkIRect& , const SkBounder::GlyphRec& ) { - m_drewText = true; + m_drew = m_drewText = true; return false; } @@ -281,6 +281,8 @@ public: FindState(int x, int y) : m_x(x) , m_y(y) + , m_bestX(x) + , m_bestY(y) , m_best(0) { m_bitmap.setConfig(SkBitmap::kARGB_8888_Config, TOUCH_SLOP * 2, @@ -290,6 +292,8 @@ public: } const LayerAndroid* best() const { return m_best; } + int bestX() const { return m_bestX; } + int bestY() const { return m_bestY; } bool drew(SkPicture* picture, const SkRect& localBounds) { m_findCheck.reset(); @@ -301,7 +305,11 @@ public: bool drewText() { return m_findCheck.drewText(); } - void setBest(const LayerAndroid* best) { m_best = best; } + void setBest(const LayerAndroid* best) { + m_best = best; + m_bestX = m_x; + m_bestY = m_y; + } int x() const { return m_x; } int y() const { return m_y; } @@ -313,6 +321,8 @@ public: protected: int m_x; int m_y; + int m_bestX; + int m_bestY; const LayerAndroid* m_best; FindCheck m_findCheck; SkBitmap m_bitmap; @@ -340,14 +350,16 @@ void LayerAndroid::findInner(LayerAndroid::FindState& state) const state.setBest(this); // set last match (presumably on top) } -const LayerAndroid* LayerAndroid::find(int x, int y, SkPicture* root) const +const LayerAndroid* LayerAndroid::find(int* xPtr, int* yPtr, SkPicture* root) const { - FindState state(x, y); + FindState state(*xPtr, *yPtr); SkRect rootBounds; rootBounds.setEmpty(); if (root && state.drew(root, rootBounds) && state.drewText()) return 0; // use the root picture only if it contains the text findInner(state); + *xPtr = state.bestX(); + *yPtr = state.bestY(); return state.best(); } diff --git a/WebCore/platform/graphics/android/LayerAndroid.h b/WebCore/platform/graphics/android/LayerAndroid.h index 510014b..575ada7 100644 --- a/WebCore/platform/graphics/android/LayerAndroid.h +++ b/WebCore/platform/graphics/android/LayerAndroid.h @@ -163,7 +163,7 @@ public: void updatePositions(); void clipArea(SkTDArray* region) const; - const LayerAndroid* find(int x, int y, SkPicture* root) const; + const LayerAndroid* find(int* xPtr, int* yPtr, SkPicture* root) const; const LayerAndroid* findById(int uniqueID) const { return const_cast(this)->findById(uniqueID); } -- cgit v1.1