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