diff options
author | John Reck <jreck@google.com> | 2012-01-25 09:20:19 -0800 |
---|---|---|
committer | John Reck <jreck@google.com> | 2012-01-30 17:26:58 -0800 |
commit | dea0c131566f424923425970fe5621305d136e5a (patch) | |
tree | 0bec1b7dce4e813f367a4952ac9eb3938c3dc163 /Source/WebKit/android/nav/SelectText.h | |
parent | a7b12d27ee68ff4de7d56bb494f31bb9ca7c39a0 (diff) | |
download | external_webkit-dea0c131566f424923425970fe5621305d136e5a.zip external_webkit-dea0c131566f424923425970fe5621305d136e5a.tar.gz external_webkit-dea0c131566f424923425970fe5621305d136e5a.tar.bz2 |
Webkit text selection
Change-Id: I8e2e400940c7c84055aeb2624958aaf47804900b
Diffstat (limited to 'Source/WebKit/android/nav/SelectText.h')
-rw-r--r-- | Source/WebKit/android/nav/SelectText.h | 110 |
1 files changed, 40 insertions, 70 deletions
diff --git a/Source/WebKit/android/nav/SelectText.h b/Source/WebKit/android/nav/SelectText.h index b454b8e..33d9f3f 100644 --- a/Source/WebKit/android/nav/SelectText.h +++ b/Source/WebKit/android/nav/SelectText.h @@ -34,83 +34,53 @@ #include "SkPicture.h" #include "SkRect.h" #include "SkRegion.h" +#include "wtf/Vector.h" namespace android { -class CachedRoot; - class SelectText : public DrawExtra { public: - SelectText(); + enum HandleId { + StartHandle = 0, + EndHandle = 1, + BaseHandle = 2, + ExtentHandle = 3, + }; + + SelectText() {} virtual ~SelectText(); - virtual void draw(SkCanvas* , LayerAndroid* , IntRect* ); - void extendSelection(const IntRect& vis, int x, int y); - const String getSelection(); - 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; - void setDrawPointer(bool drawPointer) { m_drawPointer = drawPointer; } - 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, LayerAndroid* root); - void updateHandleScale(float handleScale); - void getSelectionHandles(int* handles, LayerAndroid* root); -public: - float m_inverseScale; // inverse scale, x, y used for drawing select path - int m_selectX; - int m_selectY; + + SkRegion* getHightlightRegionsForLayer(int layerId) { + return m_highlightRegions.get(layerId); + } + + void setHighlightRegionsForLayer(int layerId, SkRegion* region) { + m_highlightRegions.set(layerId, region); + } + + virtual void draw(SkCanvas*, LayerAndroid*); + virtual void drawGL(GLExtras*, const LayerAndroid*); + + IntRect& caretRect(HandleId id) { return m_caretRects[mapId(id)]; } + void setCaretRect(HandleId id, const IntRect& rect) { m_caretRects[mapId(id)] = rect; } + int caretLayerId(HandleId id) { return m_caretLayerId[mapId(id)]; } + void setCaretLayerId(HandleId id, int layerId) { m_caretLayerId[mapId(id)] = layerId; } + + bool isBaseFirst() const { return m_baseIsFirst; } + void setBaseFirst(bool isFirst) { m_baseIsFirst = isFirst; } + + void setText(const String& text) { m_text = text.threadsafeCopy(); } + String& getText() { return m_text; } + private: - int m_controlWidth; - int m_controlHeight; - int m_controlSlop; - class FirstCheck; - class EdgeCheck; - void drawSelectionPointer(SkCanvas* , IntRect* ); - void drawSelectionRegion(SkCanvas* , IntRect* ); - SkIRect findClosest(FirstCheck& , const SkPicture& , int* base); - SkIRect findEdge(const SkPicture& , const SkIRect& area, - int x, int y, bool left, int* base); - SkIRect findLeft(const SkPicture& picture, const SkIRect& area, - int x, int y, int* base); - SkIRect findRight(const SkPicture& picture, const SkIRect& area, - int x, int y, int* base); - static void getSelectionArrow(SkPath* ); - void getSelectionCaret(SkPath* ); - bool hitCorner(int cx, int cy, int x, int y) const; - bool hitStartHandle(int x, int y) const; - bool hitEndHandle(int x, int y) const; - void setVisibleRect(const IntRect& ); - void swapAsNeeded(); - SkIPoint m_original; // computed start of extend selection - SkIPoint m_startOffset; // difference from global to layer - SkIRect m_selStart; - SkIRect m_selEnd; - SkIRect m_lastStart; - SkIRect m_lastEnd; - SkIRect m_lastDrawnStart; - SkIRect m_lastDrawnEnd; - SkIRect m_wordBounds; - int m_startBase; - int m_endBase; - int m_layerId; - SkIRect m_visibleRect; // constrains picture computations to visible area - SkRegion m_lastSelRegion; - SkRegion m_selRegion; // computed from sel start, end - SkPicture m_startControl; - SkPicture m_endControl; - const SkPicture* m_picture; - bool m_drawPointer; - bool m_extendSelection; // false when trackball is moving pointer - bool m_flipped; - bool m_hitTopLeft; - bool m_startSelection; - bool m_wordSelection; - bool m_outsideWord; + HandleId mapId(HandleId id); + + typedef HashMap<int, SkRegion* > HighlightRegionMap; + HighlightRegionMap m_highlightRegions; + IntRect m_caretRects[2]; + int m_caretLayerId[2]; + bool m_baseIsFirst; + String m_text; }; } |