OLD | NEW |
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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 // TODO(asvitkine): Implement this. http://crbug.com/131618 | 110 // TODO(asvitkine): Implement this. http://crbug.com/131618 |
111 return IsValidLogicalIndex(index); | 111 return IsValidLogicalIndex(index); |
112 } | 112 } |
113 | 113 |
114 void RenderTextMac::OnLayoutTextAttributeChanged(bool text_changed) { | 114 void RenderTextMac::OnLayoutTextAttributeChanged(bool text_changed) { |
115 //DCHECK(!multiline()) << "RenderTextMac does not support multi line"; | 115 //DCHECK(!multiline()) << "RenderTextMac does not support multi line"; |
116 if (text_changed) { | 116 if (text_changed) { |
117 if (elide_behavior() != NO_ELIDE && | 117 if (elide_behavior() != NO_ELIDE && |
118 elide_behavior() != FADE_TAIL && | 118 elide_behavior() != FADE_TAIL && |
119 !layout_text().empty()) { | 119 !layout_text().empty()) { |
| 120 DLOG(INFO) << "UPDATE DISP: " << GetContentWidth(); |
120 UpdateDisplayText(GetContentWidth()); | 121 UpdateDisplayText(GetContentWidth()); |
121 } else { | 122 } else { |
122 UpdateDisplayText(0); | 123 UpdateDisplayText(0); |
123 } | 124 } |
124 } | 125 } |
125 line_.reset(); | 126 line_.reset(); |
126 attributes_.reset(); | 127 attributes_.reset(); |
127 runs_.clear(); | 128 runs_.clear(); |
128 runs_valid_ = false; | 129 runs_valid_ = false; |
129 } | 130 } |
130 | 131 |
131 void RenderTextMac::OnDisplayTextAttributeChanged() { | 132 void RenderTextMac::OnDisplayTextAttributeChanged() { |
132 OnLayoutTextAttributeChanged(true); | 133 OnLayoutTextAttributeChanged(true); |
133 } | 134 } |
134 | 135 |
135 void RenderTextMac::EnsureLayout() { | 136 void RenderTextMac::EnsureLayout() { |
136 if (line_.get()) | 137 if (line_.get()) |
137 return; | 138 return; |
| 139 |
| 140 DLOG(INFO) << "EnsureLayout based on: " << GetDisplayText() << " elided=" << t
ext_elided(); |
138 runs_.clear(); | 141 runs_.clear(); |
139 runs_valid_ = false; | 142 runs_valid_ = false; |
140 | 143 |
141 CTFontRef ct_font = base::mac::NSToCFCast( | 144 CTFontRef ct_font = base::mac::NSToCFCast( |
142 font_list().GetPrimaryFont().GetNativeFont()); | 145 font_list().GetPrimaryFont().GetNativeFont()); |
143 | 146 |
144 const void* keys[] = { kCTFontAttributeName }; | 147 const void* keys[] = { kCTFontAttributeName }; |
145 const void* values[] = { ct_font }; | 148 const void* values[] = { ct_font }; |
146 base::ScopedCFTypeRef<CFDictionaryRef> attributes( | 149 base::ScopedCFTypeRef<CFDictionaryRef> attributes( |
147 CFDictionaryCreate(NULL, | 150 CFDictionaryCreate(NULL, |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 CTUnderlineStyle value = kCTUnderlineStyleNone; | 365 CTUnderlineStyle value = kCTUnderlineStyleNone; |
363 if (underline && CFNumberGetValue(underline, kCFNumberSInt32Type, &value)) | 366 if (underline && CFNumberGetValue(underline, kCFNumberSInt32Type, &value)) |
364 run->underline = (value == kCTUnderlineStyleSingle); | 367 run->underline = (value == kCTUnderlineStyleSingle); |
365 | 368 |
366 run_origin.offset(run_width, 0); | 369 run_origin.offset(run_width, 0); |
367 } | 370 } |
368 runs_valid_ = true; | 371 runs_valid_ = true; |
369 } | 372 } |
370 | 373 |
371 } // namespace gfx | 374 } // namespace gfx |
OLD | NEW |