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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 // Temporarily apply composition underlines and selection colors. | 223 // Temporarily apply composition underlines and selection colors. |
224 ApplyCompositionAndSelectionStyles(); | 224 ApplyCompositionAndSelectionStyles(); |
225 | 225 |
226 // Note: CFAttributedStringSetAttribute() does not appear to retain the values | 226 // Note: CFAttributedStringSetAttribute() does not appear to retain the values |
227 // passed in, as can be verified via CFGetRetainCount(). To ensure the | 227 // passed in, as can be verified via CFGetRetainCount(). To ensure the |
228 // attribute objects do not leak, they are saved to |attributes_|. | 228 // attribute objects do not leak, they are saved to |attributes_|. |
229 // Clear the attributes storage. | 229 // Clear the attributes storage. |
230 attributes_.reset(CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks)); | 230 attributes_.reset(CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks)); |
231 | 231 |
232 // https://developer.apple.com/library/mac/#documentation/Carbon/Reference/Cor
eText_StringAttributes_Ref/Reference/reference.html | 232 // https://developer.apple.com/library/mac/#documentation/Carbon/Reference/Cor
eText_StringAttributes_Ref/Reference/reference.html |
233 internal::StyleIterator style(colors(), styles()); | 233 internal::StyleIterator style(colors(), baselines(), styles()); |
234 const size_t layout_text_length = GetDisplayText().length(); | 234 const size_t layout_text_length = GetDisplayText().length(); |
235 for (size_t i = 0, end = 0; i < layout_text_length; i = end) { | 235 for (size_t i = 0, end = 0; i < layout_text_length; i = end) { |
236 end = TextIndexToDisplayIndex(style.GetRange().end()); | 236 end = TextIndexToDisplayIndex(style.GetRange().end()); |
237 const CFRange range = CFRangeMake(i, end - i); | 237 const CFRange range = CFRangeMake(i, end - i); |
238 base::ScopedCFTypeRef<CGColorRef> foreground( | 238 base::ScopedCFTypeRef<CGColorRef> foreground( |
239 CGColorCreateFromSkColor(style.color())); | 239 CGColorCreateFromSkColor(style.color())); |
240 CFAttributedStringSetAttribute(attr_string, range, | 240 CFAttributedStringSetAttribute(attr_string, range, |
241 kCTForegroundColorAttributeName, foreground); | 241 kCTForegroundColorAttributeName, foreground); |
242 CFArrayAppendValue(attributes_, foreground); | 242 CFArrayAppendValue(attributes_, foreground); |
243 | 243 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
OLD | NEW |