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

Side by Side Diff: ui/gfx/render_text_mac.cc

Issue 968923004: Use GetDisplayText() instead of text() for rendering text. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: another fix 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/gfx/render_text_mac.h" 5 #include "ui/gfx/render_text_mac.h"
6 6
7 #include <ApplicationServices/ApplicationServices.h> 7 #include <ApplicationServices/ApplicationServices.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 return Range(); 87 return Range();
88 } 88 }
89 89
90 std::vector<Rect> RenderTextMac::GetSubstringBounds(const Range& range) { 90 std::vector<Rect> RenderTextMac::GetSubstringBounds(const Range& range) {
91 // TODO(asvitkine): Implement this. http://crbug.com/131618 91 // TODO(asvitkine): Implement this. http://crbug.com/131618
92 return std::vector<Rect>(); 92 return std::vector<Rect>();
93 } 93 }
94 94
95 size_t RenderTextMac::TextIndexToDisplayIndex(size_t index) { 95 size_t RenderTextMac::TextIndexToDisplayIndex(size_t index) {
96 // TODO(asvitkine): Implement this. http://crbug.com/131618 96 // TODO(asvitkine): Implement this. http://crbug.com/131618
97 return index; 97 return std::min(index, GetDisplayText().size());
98 } 98 }
99 99
100 size_t RenderTextMac::DisplayIndexToTextIndex(size_t index) { 100 size_t RenderTextMac::DisplayIndexToTextIndex(size_t index) {
101 // TODO(asvitkine): Implement this. http://crbug.com/131618 101 // TODO(asvitkine): Implement this. http://crbug.com/131618
102 return index; 102 return index;
103 } 103 }
104 104
105 bool RenderTextMac::IsValidCursorIndex(size_t index) { 105 bool RenderTextMac::IsValidCursorIndex(size_t index) {
106 // TODO(asvitkine): Implement this. http://crbug.com/131618 106 // TODO(asvitkine): Implement this. http://crbug.com/131618
107 return IsValidLogicalIndex(index); 107 return IsValidLogicalIndex(index);
108 } 108 }
109 109
110 void RenderTextMac::OnLayoutTextAttributeChanged(bool text_changed) { 110 void RenderTextMac::OnLayoutTextAttributeChanged(bool text_changed) {
111 DCHECK(!multiline()) << "RenderTextMac does not support multi line"; 111 DCHECK(!multiline()) << "RenderTextMac does not support multi line";
112 if (text_changed) { 112 if (text_changed) {
113 if (elide_behavior() != NO_ELIDE && 113 if (elide_behavior() != NO_ELIDE &&
114 elide_behavior() != FADE_TAIL && 114 elide_behavior() != FADE_TAIL &&
115 !layout_text().empty()) { 115 !layout_text().empty()) {
116 UpdateDisplayText(GetContentWidth()); 116 UpdateDisplayText(GetContentWidth());
tapted 2015/03/03 08:11:21 Gosh this is hard to explain :/ But, I think the
Jun Mukai 2015/03/03 08:34:00 I believe this is not a problem, it looks like cyc
tapted 2015/03/03 09:30:32 I think it is cyclic. But feels like it isn't beca
Jun Mukai 2015/03/04 08:33:23 You're right! Sorry for my previous comment. So, G
oshima 2015/03/04 10:17:21 FYI: This is cyclic by nature because you use the
Jun Mukai 2015/03/05 00:33:52 The latest patchset does that thing -- separating
117 } else { 117 } else {
118 UpdateDisplayText(0); 118 UpdateDisplayText(0);
119 } 119 }
120 } 120 }
121 line_.reset(); 121 line_.reset();
122 attributes_.reset(); 122 attributes_.reset();
123 runs_.clear(); 123 runs_.clear();
124 runs_valid_ = false; 124 runs_valid_ = false;
125 } 125 }
126 126
(...skipping 14 matching lines...) Expand all
141 const void* values[] = { ct_font }; 141 const void* values[] = { ct_font };
142 base::ScopedCFTypeRef<CFDictionaryRef> attributes( 142 base::ScopedCFTypeRef<CFDictionaryRef> attributes(
143 CFDictionaryCreate(NULL, 143 CFDictionaryCreate(NULL,
144 keys, 144 keys,
145 values, 145 values,
146 arraysize(keys), 146 arraysize(keys),
147 NULL, 147 NULL,
148 &kCFTypeDictionaryValueCallBacks)); 148 &kCFTypeDictionaryValueCallBacks));
149 149
150 base::ScopedCFTypeRef<CFStringRef> cf_text( 150 base::ScopedCFTypeRef<CFStringRef> cf_text(
151 base::SysUTF16ToCFStringRef(text())); 151 base::SysUTF16ToCFStringRef(GetDisplayText()));
152 base::ScopedCFTypeRef<CFAttributedStringRef> attr_text( 152 base::ScopedCFTypeRef<CFAttributedStringRef> attr_text(
153 CFAttributedStringCreate(NULL, cf_text, attributes)); 153 CFAttributedStringCreate(NULL, cf_text, attributes));
154 base::ScopedCFTypeRef<CFMutableAttributedStringRef> attr_text_mutable( 154 base::ScopedCFTypeRef<CFMutableAttributedStringRef> attr_text_mutable(
155 CFAttributedStringCreateMutableCopy(NULL, 0, attr_text)); 155 CFAttributedStringCreateMutableCopy(NULL, 0, attr_text));
156 156
157 // TODO(asvitkine|msw): Respect GetTextDirection(), which may not match the 157 // TODO(asvitkine|msw): Respect GetTextDirection(), which may not match the
158 // natural text direction. See kCTTypesetterOptionForcedEmbeddingLevel, etc. 158 // natural text direction. See kCTTypesetterOptionForcedEmbeddingLevel, etc.
159 159
160 ApplyStyles(attr_text_mutable, ct_font); 160 ApplyStyles(attr_text_mutable, ct_font);
161 line_.reset(CTLineCreateWithAttributedString(attr_text_mutable)); 161 line_.reset(CTLineCreateWithAttributedString(attr_text_mutable));
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 CTUnderlineStyle value = kCTUnderlineStyleNone; 358 CTUnderlineStyle value = kCTUnderlineStyleNone;
359 if (underline && CFNumberGetValue(underline, kCFNumberSInt32Type, &value)) 359 if (underline && CFNumberGetValue(underline, kCFNumberSInt32Type, &value))
360 run->underline = (value == kCTUnderlineStyleSingle); 360 run->underline = (value == kCTUnderlineStyleSingle);
361 361
362 run_origin.offset(run_width, 0); 362 run_origin.offset(run_width, 0);
363 } 363 }
364 runs_valid_ = true; 364 runs_valid_ = true;
365 } 365 }
366 366
367 } // namespace gfx 367 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698