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

Unified Diff: ui/gfx/render_text.cc

Issue 867003002: Cache gfx::RenderText instances in views::Label. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 9 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 | « ui/gfx/render_text.h ('k') | ui/gfx/render_text_harfbuzz.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/render_text.cc
diff --git a/ui/gfx/render_text.cc b/ui/gfx/render_text.cc
index 5a3541f7dd927b7178b4f76995f4991a714695a0..e6a4d2f8d6178aa0ac1578ae442244f59d4d55da 100644
--- a/ui/gfx/render_text.cc
+++ b/ui/gfx/render_text.cc
@@ -402,6 +402,7 @@ void ApplyRenderParams(const FontRenderParams& params,
RenderText::~RenderText() {
}
+// static
RenderText* RenderText::CreateInstance() {
#if defined(OS_MACOSX)
static const bool use_native =
@@ -413,6 +414,7 @@ RenderText* RenderText::CreateInstance() {
return new RenderTextHarfBuzz;
}
+// static
RenderText* RenderText::CreateInstanceForEditing() {
return new RenderTextHarfBuzz;
}
@@ -503,6 +505,14 @@ void RenderText::SetMultiline(bool multiline) {
}
}
+void RenderText::SetReplaceNewlineCharsWithSymbols(bool replace) {
+ if (replace_newline_chars_with_symbols_ == replace)
+ return;
+ replace_newline_chars_with_symbols_ = replace;
+ cached_bounds_and_offset_valid_ = false;
+ OnTextAttributeChanged();
+}
+
void RenderText::SetMinLineHeight(int line_height) {
if (min_line_height_ == line_height)
return;
@@ -919,6 +929,7 @@ RenderText::RenderText()
text_elided_(false),
min_line_height_(0),
multiline_(false),
+ replace_newline_chars_with_symbols_(true),
subpixel_rendering_suppressed_(false),
clip_to_display_rect_(true),
baseline_(kInvalidBaseline),
@@ -1093,7 +1104,7 @@ HorizontalAlignment RenderText::GetCurrentHorizontalAlignment() {
Vector2d RenderText::GetAlignmentOffset(size_t line_number) {
// TODO(ckocagil): Enable |lines_| usage on RenderTextMac.
- if (multiline_)
+ if (MultilineSupported() && multiline_)
DCHECK_LT(line_number, lines_.size());
Vector2d offset;
HorizontalAlignment horizontal_alignment = GetCurrentHorizontalAlignment();
@@ -1268,7 +1279,7 @@ void RenderText::OnTextAttributeChanged() {
}
static const base::char16 kNewline[] = { '\n', 0 };
static const base::char16 kNewlineSymbol[] = { 0x2424, 0 };
- if (!multiline_)
+ if (!multiline_ && replace_newline_chars_with_symbols_)
base::ReplaceChars(layout_text_, kNewline, kNewlineSymbol, &layout_text_);
OnLayoutTextAttributeChanged(true);
« no previous file with comments | « ui/gfx/render_text.h ('k') | ui/gfx/render_text_harfbuzz.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698