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

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: multi_line_ init Created 5 years, 10 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.cc
diff --git a/ui/gfx/render_text.cc b/ui/gfx/render_text.cc
index c4f841dfcf7898f4b590f31839f865e8afbdac74..e395a6e006de38097ea3fe041de046c4c75ed810 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();
@@ -1257,7 +1268,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') | ui/views/controls/label.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698