Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(903)

Unified Diff: ui/gfx/render_text.h

Issue 2348143003: MacViews: Implement Force Touch/Mac dictionary lookup for Textfields. (Closed)
Patch Set: --- Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/gfx/render_text.h
diff --git a/ui/gfx/render_text.h b/ui/gfx/render_text.h
index 219cab60eea0a847881b99098dc3e4acf360c370..dee79cfb1bdd961ffb10fbb48b4faeeef424a85c 100644
--- a/ui/gfx/render_text.h
+++ b/ui/gfx/render_text.h
@@ -497,6 +497,18 @@ class GFX_EXPORT RenderText {
// and the display offset.
Vector2d GetLineOffset(size_t line_number);
+ // Retreives the |word| displayed at the given |point|. |point| is in the
+ // view's coordinates. If no word is displayed at the point, returns a nearby
+ // word. |baseline_point| should correspond to the left baseline point of the
+ // leftmost glyph of the |word| in the view's coordinates. Returns false, if
+ // no word can be retreived.
+ bool GetWordAtPoint(const Point& point,
+ NativeStyledString word,
+ Point* baseline_point);
+
+ // Retreives the text in the given |range|.
+ base::string16 GetTextFromRange(Range range) const;
+
protected:
RenderText();
@@ -713,6 +725,20 @@ class GFX_EXPORT RenderText {
// Draw the selection.
void DrawSelection(Canvas* canvas);
+ // Returns the nearest word start boundary for |index|. First searches in
+ // CURSOR_BACKWARD direction, then in CURSOR_FORWARD direction. Returns
+ // text length if no valid boundary is found.
+ size_t GetNearestWordStartBoundary(size_t index) const;
+
+ // Expands |range| to it's nearest word boundaries and returns the resulting
tapted 2016/09/21 04:06:55 nit: it's -> its
karandeepb 2016/09/22 08:17:39 Done.
+ // range. Maintains directionality of |range|.
+ Range ExpandRangeToWordBoundary(const Range& range) const;
+
+ // Returns the styled string corresponding to |range|. Returns false if the
+ // string cannot be retreived, e.g. if the text is obscured.
+ virtual bool GetStyledStringForRange(const Range& range,
tapted 2016/09/21 04:06:55 this should be in protected: - private virtuals do
karandeepb 2016/09/22 08:17:39 Shouldn't private virtual functions be preferred,
+ NativeStyledString str) const = 0;
+
// Logical UTF-16 string data to be drawn.
base::string16 text_;

Powered by Google App Engine
This is Rietveld 408576698