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

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

Issue 1020853018: DNCI [RenderText] Added font size options in RenderText. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed some debug code Created 5 years, 8 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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 ApplyCompositionAndSelectionStyles(); 248 ApplyCompositionAndSelectionStyles();
249 249
250 // Note: CFAttributedStringSetAttribute() does not appear to retain the values 250 // Note: CFAttributedStringSetAttribute() does not appear to retain the values
251 // passed in, as can be verified via CFGetRetainCount(). To ensure the 251 // passed in, as can be verified via CFGetRetainCount(). To ensure the
252 // attribute objects do not leak, they are saved to |attributes_|. 252 // attribute objects do not leak, they are saved to |attributes_|.
253 // Clear the attributes storage. 253 // Clear the attributes storage.
254 base::ScopedCFTypeRef<CFMutableArrayRef> attributes( 254 base::ScopedCFTypeRef<CFMutableArrayRef> attributes(
255 CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks)); 255 CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks));
256 256
257 // https://developer.apple.com/library/mac/#documentation/Carbon/Reference/Cor eText_StringAttributes_Ref/Reference/reference.html 257 // https://developer.apple.com/library/mac/#documentation/Carbon/Reference/Cor eText_StringAttributes_Ref/Reference/reference.html
258 internal::StyleIterator style(colors(), baselines(), styles()); 258 internal::StyleIterator style(font_sizes(), colors(), baselines(), styles());
259 const size_t layout_text_length = CFAttributedStringGetLength(attr_string); 259 const size_t layout_text_length = CFAttributedStringGetLength(attr_string);
260 for (size_t i = 0, end = 0; i < layout_text_length; i = end) { 260 for (size_t i = 0, end = 0; i < layout_text_length; i = end) {
261 end = TextIndexToGivenTextIndex(text, style.GetRange().end()); 261 end = TextIndexToGivenTextIndex(text, style.GetRange().end());
262 const CFRange range = CFRangeMake(i, end - i); 262 const CFRange range = CFRangeMake(i, end - i);
263 base::ScopedCFTypeRef<CGColorRef> foreground( 263 base::ScopedCFTypeRef<CGColorRef> foreground(
264 CGColorCreateFromSkColor(style.color())); 264 CGColorCreateFromSkColor(style.color()));
265 CFAttributedStringSetAttribute(attr_string, range, 265 CFAttributedStringSetAttribute(attr_string, range,
266 kCTForegroundColorAttributeName, foreground); 266 kCTForegroundColorAttributeName, foreground);
267 CFArrayAppendValue(attributes, foreground); 267 CFArrayAppendValue(attributes, foreground);
268 268
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 CTUnderlineStyle value = kCTUnderlineStyleNone; 385 CTUnderlineStyle value = kCTUnderlineStyleNone;
386 if (underline && CFNumberGetValue(underline, kCFNumberSInt32Type, &value)) 386 if (underline && CFNumberGetValue(underline, kCFNumberSInt32Type, &value))
387 run->underline = (value == kCTUnderlineStyleSingle); 387 run->underline = (value == kCTUnderlineStyleSingle);
388 388
389 run_origin.offset(run_width, 0); 389 run_origin.offset(run_width, 0);
390 } 390 }
391 runs_valid_ = true; 391 runs_valid_ = true;
392 } 392 }
393 393
394 } // namespace gfx 394 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698