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

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

Issue 924543004: adding baseline options for super/sub scripting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: added rough bounds checking that is not yet correct 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 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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698