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

Unified Diff: ui/gfx/render_text.h

Issue 16867016: Windows implementation of multiline RenderText (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: fix ComputeLines and rects Created 7 years, 5 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
« no previous file with comments | « no previous file | ui/gfx/render_text.cc » ('j') | ui/gfx/render_text.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/render_text.h
diff --git a/ui/gfx/render_text.h b/ui/gfx/render_text.h
index c10b8abf3d63c2177ee68269b73a0fc9888312a6..11ee680b6e85ecec05c561973b0c45a1fd7b82ec 100644
--- a/ui/gfx/render_text.h
+++ b/ui/gfx/render_text.h
@@ -13,6 +13,7 @@
#include "base/gtest_prod_util.h"
#include "base/i18n/rtl.h"
+#include "base/memory/scoped_vector.h"
#include "base/strings/string16.h"
#include "skia/ext/refptr.h"
#include "third_party/skia/include/core/SkColor.h"
@@ -111,6 +112,11 @@ class StyleIterator {
DISALLOW_COPY_AND_ASSIGN(StyleIterator);
};
+struct LineSegment {
Alexei Svitkine (slow) 2013/07/09 15:35:13 This should live in the class unless you're planni
msw 2013/07/10 04:01:56 Add a struct comment to describe what this is. (a
msw 2013/07/10 04:01:56 I disagree; SkiaTextRenderer and StyleIterator are
ckocagil 2013/07/13 16:05:10 Keeping it in internal namespace for now.
+ ui::Range x_pos; // x coord, in text coordinates
+ ui::Range char_pos;
+};
+
} // namespace internal
// RenderText represents an abstract model of styled text and its corresponding
@@ -186,6 +192,9 @@ class UI_EXPORT RenderText {
bool obscured() const { return obscured_; }
void SetObscured(bool obscured);
+ bool multiline() const { return multiline_; }
+ void set_multiline(bool multiline) { multiline_ = multiline; }
+
// Makes a char in obscured text at |index| to be revealed. |index| should be
// a UTF16 text index. If there is a previous revealed index, the previous one
// is cleared and only the last set index will be revealed. If |index| is -1
@@ -288,6 +297,8 @@ class UI_EXPORT RenderText {
// the margin area of text shadows.
virtual Size GetStringSize() = 0;
+ virtual Size RenderText::GetMultilineTextSize() = 0;
msw 2013/07/10 04:01:56 Remove "RenderText::" and add a comment (explain t
ckocagil 2013/07/13 16:05:10 Done.
+
// Returns the width of content, which reserves room for the cursor if
// |cursor_enabled_| is true.
int GetContentWidth();
@@ -348,6 +359,27 @@ class UI_EXPORT RenderText {
const BreakList<SkColor>& colors() const { return colors_; }
const std::vector<BreakList<bool> >& styles() const { return styles_; }
+ const std::vector<size_t>& line_breaks() const { return line_breaks_; }
+
+ const std::vector<ScopedVector<internal::LineSegment> >& lines() const {
+ return lines_;
+ }
+ void set_lines(std::vector<ScopedVector<internal::LineSegment> >* lines) {
+ lines_.swap(*lines);
+ }
+
+ bool lines_valid() const { return lines_valid_; }
+ void set_lines_valid(bool lines_valid) {
msw 2013/07/10 04:01:56 nit: rename the param to |valid| to fit this on on
ckocagil 2013/07/13 16:05:10 Actually it fits without renaming.
+ lines_valid_ = lines_valid;
+ }
+
+ int LineWidth(int line) {
Alexei Svitkine (slow) 2013/07/09 15:35:13 This is not a trivial method so the implementation
ckocagil 2013/07/13 16:05:10 Removed since we now have a Line struct that cache
+ int width = 0;
+ for (size_t i = 0; i < lines()[line].size(); ++i)
Alexei Svitkine (slow) 2013/07/09 15:35:13 Add a DCHECK() that |line| is within a valid range
ckocagil 2013/07/13 16:05:10 This method no longer exists.
+ width += lines()[line][i]->x_pos.length();
+ return width;
+ }
+
const Vector2d& GetUpdatedDisplayOffset();
void set_cached_bounds_and_offset_valid(bool valid) {
@@ -412,6 +444,8 @@ class UI_EXPORT RenderText {
// Draw the text.
virtual void DrawVisualText(Canvas* canvas) = 0;
+ virtual void ComputeLines() = 0;
msw 2013/07/10 04:01:56 Add a comment, move this above DrawVisualText (it'
ckocagil 2013/07/13 16:05:10 I moved this to render_text_win since we now call
+
// Returns the text used for layout, which may be |obscured_text_|.
const base::string16& GetLayoutText() const;
@@ -421,16 +455,18 @@ class UI_EXPORT RenderText {
// Returns the text offset from the origin after applying text alignment and
// display offset.
- Vector2d GetTextOffset();
+ Vector2d GetTextOffset(int line_width);
msw 2013/07/10 04:01:56 Comment on what |line_width| is used for here. It'
ckocagil 2013/07/13 16:05:10 I renamed this to |GetLineOffset| and it now takes
msw 2013/07/17 06:47:18 Sounds good.
// Convert points from the text space to the view space and back.
// Handles the display area, display offset, and the application LTR/RTL mode.
Point ToTextPoint(const Point& point);
Point ToViewPoint(const Point& point);
+ std::vector<Rect> RangeToViewRects(const ui::Range& x, int y);
msw 2013/07/10 04:01:56 nit: Comment on what this does and what the args a
ckocagil 2013/07/13 16:05:10 Comment added, |y| removed.
+
// Returns the text offset from the origin, taking into account text alignment
// only.
- Vector2d GetAlignmentOffset();
+ Vector2d GetAlignmentOffset(int line_width);
msw 2013/07/10 04:01:56 Ditto comment from GetTextOffset: Comment and rena
ckocagil 2013/07/13 16:05:10 This method now takes a line number.
// Applies fade effects to |renderer|.
void ApplyFadeEffects(internal::SkiaTextRenderer* renderer);
@@ -545,6 +581,9 @@ class UI_EXPORT RenderText {
// The index at which the char should be revealed in the obscured text.
int obscured_reveal_index_;
+ // Whether we should break the text to multiple lines.
msw 2013/07/10 04:01:56 optional nit: I prefer avoiding "we" in comments.
ckocagil 2013/07/13 16:05:10 Done.
+ bool multiline_;
+
// Fade text head and/or tail, if text doesn't fit into |display_rect_|.
bool fade_head_;
bool fade_tail_;
@@ -572,6 +611,14 @@ class UI_EXPORT RenderText {
// Text shadows to be drawn.
ShadowValues text_shadows_;
+ // Positions at which we can break the line.
+ std::vector<size_t> line_breaks_;
+
+ // Lines computed by ComputeLines().
+ std::vector<ScopedVector<internal::LineSegment> > lines_;
Alexei Svitkine (slow) 2013/07/09 15:35:13 Can you use a regular vector instead of a ScopedVe
msw 2013/07/10 04:01:56 I'm wondering if it might help in the long run to
ckocagil 2013/07/13 16:05:10 I can't, we need pointers as long as we have LineS
ckocagil 2013/07/13 16:05:10 I'm not sure how this would work but I'm adding a
+
+ bool lines_valid_;
Alexei Svitkine (slow) 2013/07/09 15:35:13 Add a comment.
ckocagil 2013/07/13 16:05:10 Done.
+
DISALLOW_COPY_AND_ASSIGN(RenderText);
};
« no previous file with comments | « no previous file | ui/gfx/render_text.cc » ('j') | ui/gfx/render_text.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698