1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2/* This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 6#include "nsLookAndFeel.h" 7#include "nsCocoaFeatures.h" 8#include "nsIServiceManager.h" 9#include "nsNativeThemeColors.h" 10#include "nsStyleConsts.h" 11#include "nsCocoaFeatures.h" 12#include "nsIContent.h" 13#include "gfxFont.h" 14#include "gfxFontConstants.h" 15#include "gfxPlatformMac.h" 16#include "mozilla/gfx/2D.h" 17#include "mozilla/widget/WidgetMessageUtils.h" 18 19#import <Cocoa/Cocoa.h> 20 21// This must be included last: 22#include "nsObjCExceptions.h" 23 24enum { 25 mozNSScrollerStyleLegacy = 0, 26 mozNSScrollerStyleOverlay = 1 27}; 28typedef NSInteger mozNSScrollerStyle; 29 30@interface NSScroller(AvailableSinceLion) 31+ (mozNSScrollerStyle)preferredScrollerStyle; 32@end 33 34nsLookAndFeel::nsLookAndFeel() 35 : nsXPLookAndFeel() 36 , mUseOverlayScrollbars(-1) 37 , mUseOverlayScrollbarsCached(false) 38 , mAllowOverlayScrollbarsOverlap(-1) 39 , mAllowOverlayScrollbarsOverlapCached(false) 40 , mHasColorButtonText(false) 41 , mInitialized(false) 42{ 43} 44 45nsLookAndFeel::~nsLookAndFeel() 46{ 47} 48 49static nscolor GetColorFromNSColor(NSColor* aColor) 50{ 51 NSColor* deviceColor = [aColor colorUsingColorSpaceName:NSDeviceRGBColorSpace]; 52 return NS_RGB((unsigned int)([deviceColor redComponent] * 255.0), 53 (unsigned int)([deviceColor greenComponent] * 255.0), 54 (unsigned int)([deviceColor blueComponent] * 255.0)); 55} 56 57static nscolor GetColorFromNSColorWithAlpha(NSColor* aColor, float alpha) 58{ 59 NSColor* deviceColor = [aColor colorUsingColorSpaceName:NSDeviceRGBColorSpace]; 60 return NS_RGBA((unsigned int)([deviceColor redComponent] * 255.0), 61 (unsigned int)([deviceColor greenComponent] * 255.0), 62 (unsigned int)([deviceColor blueComponent] * 255.0), 63 (unsigned int)(alpha * 255.0)); 64} 65 66void 67nsLookAndFeel::NativeInit() 68{ 69 EnsureInit(); 70} 71 72void 73nsLookAndFeel::RefreshImpl() 74{ 75 nsXPLookAndFeel::RefreshImpl(); 76 77 // We should only clear the cache if we're in the main browser process. 78 // Otherwise, we should wait for the parent to inform us of new values 79 // to cache via LookAndFeel::SetIntCache. 80 if (XRE_IsParentProcess()) { 81 mUseOverlayScrollbarsCached = false; 82 mAllowOverlayScrollbarsOverlapCached = false; 83 } 84 85 // Fetch colors next time they are requested. 86 mInitialized = false; 87} 88 89nsresult 90nsLookAndFeel::NativeGetColor(ColorID aID, nscolor &aColor) 91{ 92 EnsureInit(); 93 94 nsresult res = NS_OK; 95 96 switch (aID) { 97 case eColorID_WindowBackground: 98 aColor = NS_RGB(0xff,0xff,0xff); 99 break; 100 case eColorID_WindowForeground: 101 aColor = NS_RGB(0x00,0x00,0x00); 102 break; 103 case eColorID_WidgetBackground: 104 aColor = NS_RGB(0xdd,0xdd,0xdd); 105 break; 106 case eColorID_WidgetForeground: 107 aColor = NS_RGB(0x00,0x00,0x00); 108 break; 109 case eColorID_WidgetSelectBackground: 110 aColor = NS_RGB(0x80,0x80,0x80); 111 break; 112 case eColorID_WidgetSelectForeground: 113 aColor = NS_RGB(0x00,0x00,0x80); 114 break; 115 case eColorID_Widget3DHighlight: 116 aColor = NS_RGB(0xa0,0xa0,0xa0); 117 break; 118 case eColorID_Widget3DShadow: 119 aColor = NS_RGB(0x40,0x40,0x40); 120 break; 121 case eColorID_TextBackground: 122 aColor = NS_RGB(0xff,0xff,0xff); 123 break; 124 case eColorID_TextForeground: 125 aColor = NS_RGB(0x00,0x00,0x00); 126 break; 127 case eColorID_TextSelectBackground: 128 aColor = mColorTextSelectBackground; 129 break; 130 // This is used to gray out the selection when it's not focused. Used with 131 // nsISelectionController::SELECTION_DISABLED. 132 case eColorID_TextSelectBackgroundDisabled: 133 aColor = mColorTextSelectBackgroundDisabled; 134 break; 135 case eColorID_highlight: // CSS2 color 136 aColor = mColorHighlight; 137 break; 138 case eColorID__moz_menuhover: 139 aColor = mColorMenuHover; 140 break; 141 case eColorID_TextSelectForeground: 142 aColor = mColorTextSelectForeground; 143 break; 144 case eColorID_highlighttext: // CSS2 color 145 case eColorID__moz_menuhovertext: 146 aColor = mColorMenuHoverText; 147 break; 148 case eColorID_IMESelectedRawTextBackground: 149 case eColorID_IMESelectedConvertedTextBackground: 150 case eColorID_IMERawInputBackground: 151 case eColorID_IMEConvertedTextBackground: 152 aColor = NS_TRANSPARENT; 153 break; 154 case eColorID_IMESelectedRawTextForeground: 155 case eColorID_IMESelectedConvertedTextForeground: 156 case eColorID_IMERawInputForeground: 157 case eColorID_IMEConvertedTextForeground: 158 aColor = NS_SAME_AS_FOREGROUND_COLOR; 159 break; 160 case eColorID_IMERawInputUnderline: 161 case eColorID_IMEConvertedTextUnderline: 162 aColor = NS_40PERCENT_FOREGROUND_COLOR; 163 break; 164 case eColorID_IMESelectedRawTextUnderline: 165 case eColorID_IMESelectedConvertedTextUnderline: 166 aColor = NS_SAME_AS_FOREGROUND_COLOR; 167 break; 168 case eColorID_SpellCheckerUnderline: 169 aColor = NS_RGB(0xff, 0, 0); 170 break; 171 172 // 173 // css2 system colors http://www.w3.org/TR/REC-CSS2/ui.html#system-colors 174 // 175 // It's really hard to effectively map these to the Appearance Manager properly, 176 // since they are modeled word for word after the win32 system colors and don't have any 177 // real counterparts in the Mac world. I'm sure we'll be tweaking these for 178 // years to come. 179 // 180 // Thanks to mpt26@student.canterbury.ac.nz for the hardcoded values that form the defaults 181 // if querying the Appearance Manager fails ;) 182 // 183 case eColorID__moz_mac_buttonactivetext: 184 case eColorID__moz_mac_defaultbuttontext: 185 if (mHasColorButtonText) { 186 aColor = mColorButtonText; 187 break; 188 } 189 // Otherwise fall through and return the regular button text: 190 MOZ_FALLTHROUGH; 191 case eColorID_buttontext: 192 case eColorID__moz_buttonhovertext: 193 aColor = mColorButtonHoverText; 194 break; 195 case eColorID_captiontext: 196 case eColorID_menutext: 197 case eColorID_infotext: 198 case eColorID__moz_menubartext: 199 aColor = mColorText; 200 break; 201 case eColorID_windowtext: 202 aColor = mColorWindowText; 203 break; 204 case eColorID_activecaption: 205 aColor = mColorActiveCaption; 206 break; 207 case eColorID_activeborder: 208 aColor = mColorActiveBorder; 209 break; 210 case eColorID_appworkspace: 211 aColor = NS_RGB(0xFF,0xFF,0xFF); 212 break; 213 case eColorID_background: 214 aColor = NS_RGB(0x63,0x63,0xCE); 215 break; 216 case eColorID_buttonface: 217 case eColorID__moz_buttonhoverface: 218 aColor = NS_RGB(0xF0,0xF0,0xF0); 219 break; 220 case eColorID_buttonhighlight: 221 aColor = NS_RGB(0xFF,0xFF,0xFF); 222 break; 223 case eColorID_buttonshadow: 224 aColor = NS_RGB(0xDC,0xDC,0xDC); 225 break; 226 case eColorID_graytext: 227 aColor = mColorGrayText; 228 break; 229 case eColorID_inactiveborder: 230 aColor = mColorInactiveBorder; 231 break; 232 case eColorID_inactivecaption: 233 aColor = mColorInactiveCaption; 234 break; 235 case eColorID_inactivecaptiontext: 236 aColor = NS_RGB(0x45,0x45,0x45); 237 break; 238 case eColorID_scrollbar: 239 aColor = mColorScrollbar; 240 break; 241 case eColorID_threeddarkshadow: 242 aColor = NS_RGB(0xDC,0xDC,0xDC); 243 break; 244 case eColorID_threedshadow: 245 aColor = NS_RGB(0xE0,0xE0,0xE0); 246 break; 247 case eColorID_threedface: 248 aColor = NS_RGB(0xF0,0xF0,0xF0); 249 break; 250 case eColorID_threedhighlight: 251 aColor = mColorThreeDHighlight; 252 break; 253 case eColorID_threedlightshadow: 254 aColor = NS_RGB(0xDA,0xDA,0xDA); 255 break; 256 case eColorID_menu: 257 aColor = mColorMenu; 258 break; 259 case eColorID_infobackground: 260 aColor = NS_RGB(0xFF,0xFF,0xC7); 261 break; 262 case eColorID_windowframe: 263 aColor = mColorWindowFrame; 264 break; 265 case eColorID_window: 266 case eColorID__moz_field: 267 case eColorID__moz_combobox: 268 aColor = NS_RGB(0xff,0xff,0xff); 269 break; 270 case eColorID__moz_fieldtext: 271 case eColorID__moz_comboboxtext: 272 aColor = mColorFieldText; 273 break; 274 case eColorID__moz_dialog: 275 aColor = mColorDialog; 276 break; 277 case eColorID__moz_dialogtext: 278 case eColorID__moz_cellhighlighttext: 279 case eColorID__moz_html_cellhighlighttext: 280 aColor = mColorDialogText; 281 break; 282 case eColorID__moz_dragtargetzone: 283 aColor = mColorDragTargetZone; 284 break; 285 case eColorID__moz_mac_chrome_active: 286 aColor = mColorChromeActive; 287 break; 288 case eColorID__moz_mac_chrome_inactive: 289 aColor = mColorChromeInactive; 290 break; 291 case eColorID__moz_mac_focusring: 292 aColor = mColorFocusRing; 293 break; 294 case eColorID__moz_mac_menushadow: 295 aColor = NS_RGB(0xA3,0xA3,0xA3); 296 break; 297 case eColorID__moz_mac_menutextdisable: 298 aColor = NS_RGB(0x98,0x98,0x98); 299 break; 300 case eColorID__moz_mac_menutextselect: 301 aColor = mColorTextSelect; 302 break; 303 case eColorID__moz_mac_disabledtoolbartext: 304 aColor = mColorDisabledToolbarText; 305 break; 306 case eColorID__moz_mac_menuselect: 307 aColor = mColorMenuSelect; 308 break; 309 case eColorID__moz_buttondefault: 310 aColor = NS_RGB(0xDC,0xDC,0xDC); 311 break; 312 case eColorID__moz_cellhighlight: 313 case eColorID__moz_html_cellhighlight: 314 case eColorID__moz_mac_secondaryhighlight: 315 // For inactive list selection 316 aColor = mColorCellHighlight; 317 break; 318 case eColorID__moz_eventreerow: 319 // Background color of even list rows. 320 aColor = mColorEvenTreeRow; 321 break; 322 case eColorID__moz_oddtreerow: 323 // Background color of odd list rows. 324 aColor = mColorOddTreeRow; 325 break; 326 case eColorID__moz_nativehyperlinktext: 327 // There appears to be no available system defined color. HARDCODING to the appropriate color. 328 aColor = NS_RGB(0x14,0x4F,0xAE); 329 break; 330 // The following colors are supposed to be used as font-smoothing background 331 // colors, in the chrome-only -moz-font-smoothing-background-color property. 332 // This property is used for text on "vibrant" -moz-appearances. 333 // The colors have been obtained from the system on 10.12.6 using the 334 // program at https://bugzilla.mozilla.org/attachment.cgi?id=8907533 . 335 // We could obtain them at runtime, but doing so may be expensive and 336 // requires the use of the private API 337 // -[NSVisualEffectView fontSmoothingBackgroundColor]. 338 case eColorID__moz_mac_vibrancy_light: 339 case eColorID__moz_mac_vibrant_titlebar_light: 340 case eColorID__moz_mac_source_list: 341 case eColorID__moz_mac_tooltip: 342 aColor = NS_RGB(0xf7,0xf7,0xf7); 343 break; 344 case eColorID__moz_mac_vibrancy_dark: 345 case eColorID__moz_mac_vibrant_titlebar_dark: 346 aColor = NS_RGB(0x28,0x28,0x28); 347 break; 348 case eColorID__moz_mac_menupopup: 349 case eColorID__moz_mac_menuitem: 350 aColor = NS_RGB(0xe6,0xe6,0xe6); 351 break; 352 case eColorID__moz_mac_source_list_selection: 353 aColor = NS_RGB(0xc8,0xc8,0xc8); 354 break; 355 case eColorID__moz_mac_active_menuitem: 356 case eColorID__moz_mac_active_source_list_selection: 357 aColor = mColorActiveSourceListSelection; 358 break; 359 default: 360 NS_WARNING("Someone asked nsILookAndFeel for a color I don't know about"); 361 aColor = NS_RGB(0xff,0xff,0xff); 362 res = NS_ERROR_FAILURE; 363 break; 364 } 365 366 return res; 367} 368 369nsresult 370nsLookAndFeel::GetIntImpl(IntID aID, int32_t &aResult) 371{ 372 NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT; 373 374 nsresult res = nsXPLookAndFeel::GetIntImpl(aID, aResult); 375 if (NS_SUCCEEDED(res)) 376 return res; 377 res = NS_OK; 378 379 switch (aID) { 380 case eIntID_CaretBlinkTime: 381 aResult = 567; 382 break; 383 case eIntID_CaretWidth: 384 aResult = 1; 385 break; 386 case eIntID_ShowCaretDuringSelection: 387 aResult = 0; 388 break; 389 case eIntID_SelectTextfieldsOnKeyFocus: 390 // Select textfield content when focused by kbd 391 // used by EventStateManager::sTextfieldSelectModel 392 aResult = 1; 393 break; 394 case eIntID_SubmenuDelay: 395 aResult = 200; 396 break; 397 case eIntID_TooltipDelay: 398 aResult = 500; 399 break; 400 case eIntID_MenusCanOverlapOSBar: 401 // xul popups are not allowed to overlap the menubar. 402 aResult = 0; 403 break; 404 case eIntID_SkipNavigatingDisabledMenuItem: 405 aResult = 1; 406 break; 407 case eIntID_DragThresholdX: 408 case eIntID_DragThresholdY: 409 aResult = 4; 410 break; 411 case eIntID_ScrollArrowStyle: 412 aResult = eScrollArrow_None; 413 break; 414 case eIntID_ScrollSliderStyle: 415 aResult = eScrollThumbStyle_Proportional; 416 break; 417 case eIntID_UseOverlayScrollbars: 418 if (!mUseOverlayScrollbarsCached) { 419 mUseOverlayScrollbars = SystemWantsOverlayScrollbars() ? 1 : 0; 420 mUseOverlayScrollbarsCached = true; 421 } 422 aResult = mUseOverlayScrollbars; 423 break; 424 case eIntID_AllowOverlayScrollbarsOverlap: 425 if (!mAllowOverlayScrollbarsOverlapCached) { 426 mAllowOverlayScrollbarsOverlap = AllowOverlayScrollbarsOverlap() ? 1 : 0; 427 mAllowOverlayScrollbarsOverlapCached = true; 428 } 429 aResult = mAllowOverlayScrollbarsOverlap; 430 break; 431 case eIntID_ScrollbarDisplayOnMouseMove: 432 aResult = 0; 433 break; 434 case eIntID_ScrollbarFadeBeginDelay: 435 aResult = 450; 436 break; 437 case eIntID_ScrollbarFadeDuration: 438 aResult = 200; 439 break; 440 case eIntID_TreeOpenDelay: 441 aResult = 1000; 442 break; 443 case eIntID_TreeCloseDelay: 444 aResult = 1000; 445 break; 446 case eIntID_TreeLazyScrollDelay: 447 aResult = 150; 448 break; 449 case eIntID_TreeScrollDelay: 450 aResult = 100; 451 break; 452 case eIntID_TreeScrollLinesMax: 453 aResult = 3; 454 break; 455 case eIntID_DWMCompositor: 456 case eIntID_WindowsClassic: 457 case eIntID_WindowsDefaultTheme: 458 case eIntID_TouchEnabled: 459 case eIntID_WindowsThemeIdentifier: 460 case eIntID_OperatingSystemVersionIdentifier: 461 aResult = 0; 462 res = NS_ERROR_NOT_IMPLEMENTED; 463 break; 464 case eIntID_MacGraphiteTheme: 465 aResult = [NSColor currentControlTint] == NSGraphiteControlTint; 466 break; 467 case eIntID_MacYosemiteTheme: 468 aResult = nsCocoaFeatures::OnYosemiteOrLater(); 469 break; 470 case eIntID_AlertNotificationOrigin: 471 aResult = NS_ALERT_TOP; 472 break; 473 case eIntID_TabFocusModel: 474 aResult = [NSApp isFullKeyboardAccessEnabled] ? 475 nsIContent::eTabFocus_any : nsIContent::eTabFocus_textControlsMask; 476 break; 477 case eIntID_ScrollToClick: 478 { 479 aResult = [[NSUserDefaults standardUserDefaults] boolForKey:@"AppleScrollerPagingBehavior"]; 480 } 481 break; 482 case eIntID_ChosenMenuItemsShouldBlink: 483 aResult = 1; 484 break; 485 case eIntID_IMERawInputUnderlineStyle: 486 case eIntID_IMEConvertedTextUnderlineStyle: 487 case eIntID_IMESelectedRawTextUnderlineStyle: 488 case eIntID_IMESelectedConvertedTextUnderline: 489 aResult = NS_STYLE_TEXT_DECORATION_STYLE_SOLID; 490 break; 491 case eIntID_SpellCheckerUnderlineStyle: 492 aResult = NS_STYLE_TEXT_DECORATION_STYLE_DOTTED; 493 break; 494 case eIntID_ScrollbarButtonAutoRepeatBehavior: 495 aResult = 0; 496 break; 497 case eIntID_SwipeAnimationEnabled: 498 aResult = 0; 499 if ([NSEvent respondsToSelector:@selector( 500 isSwipeTrackingFromScrollEventsEnabled)]) { 501 aResult = [NSEvent isSwipeTrackingFromScrollEventsEnabled] ? 1 : 0; 502 } 503 break; 504 case eIntID_ContextMenuOffsetVertical: 505 aResult = -6; 506 break; 507 case eIntID_ContextMenuOffsetHorizontal: 508 aResult = 1; 509 break; 510 default: 511 aResult = 0; 512 res = NS_ERROR_FAILURE; 513 } 514 return res; 515 516 NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT; 517} 518 519nsresult 520nsLookAndFeel::GetFloatImpl(FloatID aID, float &aResult) 521{ 522 nsresult res = nsXPLookAndFeel::GetFloatImpl(aID, aResult); 523 if (NS_SUCCEEDED(res)) 524 return res; 525 res = NS_OK; 526 527 switch (aID) { 528 case eFloatID_IMEUnderlineRelativeSize: 529 aResult = 2.0f; 530 break; 531 case eFloatID_SpellCheckerUnderlineRelativeSize: 532 aResult = 2.0f; 533 break; 534 default: 535 aResult = -1.0; 536 res = NS_ERROR_FAILURE; 537 } 538 539 return res; 540} 541 542bool nsLookAndFeel::UseOverlayScrollbars() 543{ 544 return GetInt(eIntID_UseOverlayScrollbars) != 0; 545} 546 547bool nsLookAndFeel::SystemWantsOverlayScrollbars() 548{ 549 return ([NSScroller respondsToSelector:@selector(preferredScrollerStyle)] && 550 [NSScroller preferredScrollerStyle] == mozNSScrollerStyleOverlay); 551} 552 553bool nsLookAndFeel::AllowOverlayScrollbarsOverlap() 554{ 555 return (UseOverlayScrollbars()); 556} 557 558bool 559nsLookAndFeel::GetFontImpl(FontID aID, nsString &aFontName, 560 gfxFontStyle &aFontStyle, 561 float aDevPixPerCSSPixel) 562{ 563 NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN; 564 565 // hack for now 566 if (aID == eFont_Window || aID == eFont_Document) { 567 aFontStyle.style = NS_FONT_STYLE_NORMAL; 568 aFontStyle.weight = NS_FONT_WEIGHT_NORMAL; 569 aFontStyle.stretch = NS_FONT_STRETCH_NORMAL; 570 aFontStyle.size = 14 * aDevPixPerCSSPixel; 571 aFontStyle.systemFont = true; 572 573 aFontName.AssignLiteral("sans-serif"); 574 return true; 575 } 576 577 gfxPlatformMac::LookupSystemFont(aID, aFontName, aFontStyle, 578 aDevPixPerCSSPixel); 579 580 return true; 581 582 NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(false); 583} 584 585nsTArray<LookAndFeelInt> 586nsLookAndFeel::GetIntCacheImpl() 587{ 588 nsTArray<LookAndFeelInt> lookAndFeelIntCache = 589 nsXPLookAndFeel::GetIntCacheImpl(); 590 591 LookAndFeelInt useOverlayScrollbars; 592 useOverlayScrollbars.id = eIntID_UseOverlayScrollbars; 593 useOverlayScrollbars.value = GetInt(eIntID_UseOverlayScrollbars); 594 lookAndFeelIntCache.AppendElement(useOverlayScrollbars); 595 596 LookAndFeelInt allowOverlayScrollbarsOverlap; 597 allowOverlayScrollbarsOverlap.id = eIntID_AllowOverlayScrollbarsOverlap; 598 allowOverlayScrollbarsOverlap.value = GetInt(eIntID_AllowOverlayScrollbarsOverlap); 599 lookAndFeelIntCache.AppendElement(allowOverlayScrollbarsOverlap); 600 601 return lookAndFeelIntCache; 602} 603 604void 605nsLookAndFeel::SetIntCacheImpl(const nsTArray<LookAndFeelInt>& aLookAndFeelIntCache) 606{ 607 for (auto entry : aLookAndFeelIntCache) { 608 switch(entry.id) { 609 case eIntID_UseOverlayScrollbars: 610 mUseOverlayScrollbars = entry.value; 611 mUseOverlayScrollbarsCached = true; 612 break; 613 case eIntID_AllowOverlayScrollbarsOverlap: 614 mAllowOverlayScrollbarsOverlap = entry.value; 615 mAllowOverlayScrollbarsOverlapCached = true; 616 break; 617 } 618 } 619} 620 621void 622nsLookAndFeel::EnsureInit() 623{ 624 if (mInitialized) { 625 return; 626 } 627 mInitialized = true; 628 629 NS_OBJC_BEGIN_TRY_ABORT_BLOCK 630 631 nscolor color; 632 633 mColorTextSelectBackground = GetColorFromNSColor( 634 [NSColor selectedTextBackgroundColor]); 635 mColorTextSelectBackgroundDisabled = GetColorFromNSColor( 636 [NSColor secondarySelectedControlColor]); 637 638 mColorHighlight = GetColorFromNSColor([NSColor alternateSelectedControlColor]); 639 mColorMenuHover = GetColorFromNSColor([NSColor alternateSelectedControlColor]); 640 641 GetColor(eColorID_TextSelectBackground, color); 642 if (color == 0x000000) { 643 mColorTextSelectForeground = NS_RGB(0xff,0xff,0xff); 644 } else { 645 mColorTextSelectForeground = NS_DONT_CHANGE_COLOR; 646 } 647 648 mColorMenuHoverText = GetColorFromNSColor( 649 [NSColor alternateSelectedControlTextColor]); 650 651 if (nsCocoaFeatures::OnYosemiteOrLater()) { 652 mColorButtonText = NS_RGB(0xFF,0xFF,0xFF); 653 mHasColorButtonText = true; 654 } 655 656 mColorButtonHoverText = GetColorFromNSColor([NSColor controlTextColor]); 657 mColorText = GetColorFromNSColor([NSColor textColor]); 658 mColorWindowText = GetColorFromNSColor([NSColor windowFrameTextColor]); 659 mColorActiveCaption = GetColorFromNSColor([NSColor gridColor]); 660 mColorActiveBorder = GetColorFromNSColor([NSColor keyboardFocusIndicatorColor]); 661 mColorGrayText = GetColorFromNSColor([NSColor disabledControlTextColor]); 662 mColorInactiveBorder = GetColorFromNSColor([NSColor controlBackgroundColor]); 663 mColorInactiveCaption = GetColorFromNSColor([NSColor controlBackgroundColor]); 664 mColorScrollbar = GetColorFromNSColor([NSColor scrollBarColor]); 665 mColorThreeDHighlight = GetColorFromNSColor([NSColor highlightColor]); 666 mColorMenu = GetColorFromNSColor([NSColor alternateSelectedControlTextColor]); 667 mColorWindowFrame = GetColorFromNSColor([NSColor gridColor]); 668 mColorFieldText = GetColorFromNSColor([NSColor controlTextColor]); 669 mColorDialog = GetColorFromNSColor([NSColor controlHighlightColor]); 670 mColorDialogText = GetColorFromNSColor([NSColor controlTextColor]); 671 mColorDragTargetZone = GetColorFromNSColor([NSColor selectedControlColor]); 672 673 int grey = NativeGreyColorAsInt(toolbarFillGrey, true); 674 mColorChromeActive = NS_RGB(grey, grey, grey); 675 grey = NativeGreyColorAsInt(toolbarFillGrey, false); 676 mColorChromeInactive = NS_RGB(grey, grey, grey); 677 678 mColorFocusRing = GetColorFromNSColorWithAlpha([NSColor keyboardFocusIndicatorColor], 679 0.48); 680 681 mColorTextSelect = GetColorFromNSColor([NSColor selectedMenuItemTextColor]); 682 mColorDisabledToolbarText = GetColorFromNSColor([NSColor disabledControlTextColor]); 683 mColorMenuSelect = GetColorFromNSColor([NSColor alternateSelectedControlColor]); 684 mColorCellHighlight = GetColorFromNSColor([NSColor secondarySelectedControlColor]); 685 mColorEvenTreeRow = GetColorFromNSColor([[NSColor controlAlternatingRowBackgroundColors] 686 objectAtIndex:0]); 687 mColorOddTreeRow = GetColorFromNSColor([[NSColor controlAlternatingRowBackgroundColors] 688 objectAtIndex:1]); 689 690 color = [NSColor currentControlTint]; 691 mColorActiveSourceListSelection = (color == NSGraphiteControlTint) ? 692 NS_RGB(0xa0,0xa0,0xa0) : 693 NS_RGB(0x0a,0x64,0xdc); 694 695 NS_OBJC_END_TRY_ABORT_BLOCK 696} 697