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

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

Issue 1508893003: Use proper namespace in skia/ext (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years 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 #import <AppKit/AppKit.h> 8 #import <AppKit/AppKit.h>
9 #include <CoreText/CoreText.h> 9 #include <CoreText/CoreText.h>
10 10
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 base::ScopedCFTypeRef<CFMutableArrayRef> attributes( 306 base::ScopedCFTypeRef<CFMutableArrayRef> attributes(
307 CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks)); 307 CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks));
308 308
309 // https://developer.apple.com/library/mac/#documentation/Carbon/Reference/Cor eText_StringAttributes_Ref/Reference/reference.html 309 // https://developer.apple.com/library/mac/#documentation/Carbon/Reference/Cor eText_StringAttributes_Ref/Reference/reference.html
310 internal::StyleIterator style(colors(), baselines(), styles()); 310 internal::StyleIterator style(colors(), baselines(), styles());
311 const size_t layout_text_length = CFAttributedStringGetLength(attr_string); 311 const size_t layout_text_length = CFAttributedStringGetLength(attr_string);
312 for (size_t i = 0, end = 0; i < layout_text_length; i = end) { 312 for (size_t i = 0, end = 0; i < layout_text_length; i = end) {
313 end = TextIndexToGivenTextIndex(text, style.GetRange().end()); 313 end = TextIndexToGivenTextIndex(text, style.GetRange().end());
314 const CFRange range = CFRangeMake(i, end - i); 314 const CFRange range = CFRangeMake(i, end - i);
315 base::ScopedCFTypeRef<CGColorRef> foreground( 315 base::ScopedCFTypeRef<CGColorRef> foreground(
316 CGColorCreateFromSkColor(style.color())); 316 skia::CGColorCreateFromSkColor(style.color()));
317 CFAttributedStringSetAttribute(attr_string, range, 317 CFAttributedStringSetAttribute(attr_string, range,
318 kCTForegroundColorAttributeName, foreground); 318 kCTForegroundColorAttributeName, foreground);
319 CFArrayAppendValue(attributes, foreground); 319 CFArrayAppendValue(attributes, foreground);
320 320
321 if (style.style(UNDERLINE)) { 321 if (style.style(UNDERLINE)) {
322 CTUnderlineStyle value = kCTUnderlineStyleSingle; 322 CTUnderlineStyle value = kCTUnderlineStyleSingle;
323 base::ScopedCFTypeRef<CFNumberRef> underline_value( 323 base::ScopedCFTypeRef<CFNumberRef> underline_value(
324 CFNumberCreate(NULL, kCFNumberSInt32Type, &value)); 324 CFNumberCreate(NULL, kCFNumberSInt32Type, &value));
325 CFAttributedStringSetAttribute( 325 CFAttributedStringSetAttribute(
326 attr_string, range, kCTUnderlineStyleAttributeName, underline_value); 326 attr_string, range, kCTUnderlineStyleAttributeName, underline_value);
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 // TODO(asvitkine): Style boundaries are not necessarily per-run. Handle 410 // TODO(asvitkine): Style boundaries are not necessarily per-run. Handle
411 // this better. Also, support strike and diagonal_strike. 411 // this better. Also, support strike and diagonal_strike.
412 CFDictionaryRef attributes = CTRunGetAttributes(ct_run); 412 CFDictionaryRef attributes = CTRunGetAttributes(ct_run);
413 CTFontRef ct_font = base::mac::GetValueFromDictionary<CTFontRef>( 413 CTFontRef ct_font = base::mac::GetValueFromDictionary<CTFontRef>(
414 attributes, kCTFontAttributeName); 414 attributes, kCTFontAttributeName);
415 run->font = Font(static_cast<NSFont*>(ct_font)); 415 run->font = Font(static_cast<NSFont*>(ct_font));
416 416
417 const CGColorRef foreground = base::mac::GetValueFromDictionary<CGColorRef>( 417 const CGColorRef foreground = base::mac::GetValueFromDictionary<CGColorRef>(
418 attributes, kCTForegroundColorAttributeName); 418 attributes, kCTForegroundColorAttributeName);
419 if (foreground) 419 if (foreground)
420 run->foreground = CGColorRefToSkColor(foreground); 420 run->foreground = skia::CGColorRefToSkColor(foreground);
421 421
422 const CFNumberRef underline = 422 const CFNumberRef underline =
423 base::mac::GetValueFromDictionary<CFNumberRef>( 423 base::mac::GetValueFromDictionary<CFNumberRef>(
424 attributes, kCTUnderlineStyleAttributeName); 424 attributes, kCTUnderlineStyleAttributeName);
425 CTUnderlineStyle value = kCTUnderlineStyleNone; 425 CTUnderlineStyle value = kCTUnderlineStyleNone;
426 if (underline && CFNumberGetValue(underline, kCFNumberSInt32Type, &value)) 426 if (underline && CFNumberGetValue(underline, kCFNumberSInt32Type, &value))
427 run->underline = (value == kCTUnderlineStyleSingle); 427 run->underline = (value == kCTUnderlineStyleSingle);
428 428
429 run_origin.offset(run_width, 0); 429 run_origin.offset(run_width, 0);
430 } 430 }
431 runs_valid_ = true; 431 runs_valid_ = true;
432 } 432 }
433 433
434 void RenderTextMac::InvalidateStyle() { 434 void RenderTextMac::InvalidateStyle() {
435 line_.reset(); 435 line_.reset();
436 attributes_.reset(); 436 attributes_.reset();
437 runs_.clear(); 437 runs_.clear();
438 runs_valid_ = false; 438 runs_valid_ = false;
439 } 439 }
440 440
441 } // namespace gfx 441 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/image/image_unittest_util_mac.mm ('k') | ui/message_center/cocoa/notification_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698