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

Side by Side Diff: third_party/WebKit/Source/platform/scroll/ScrollbarThemeMac.mm

Issue 2426793002: Aura overlay scrollbars adjust color for dark backgrounds (Closed)
Patch Set: fix test Created 4 years, 1 month 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 /* 1 /*
2 * Copyright (C) 2008, 2011 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008, 2011 Apple Inc. All Rights Reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 controlSize:(NSControlSize)scrollbar.controlSize() 280 controlSize:(NSControlSize)scrollbar.controlSize()
281 horizontal:isHorizontal 281 horizontal:isHorizontal
282 replacingScrollerImp:nil] retain]); 282 replacingScrollerImp:nil] retain]);
283 RetainPtr<BlinkScrollbarObserver> observer( 283 RetainPtr<BlinkScrollbarObserver> observer(
284 AdoptNS, 284 AdoptNS,
285 [[BlinkScrollbarObserver alloc] initWithScrollbar:&scrollbar 285 [[BlinkScrollbarObserver alloc] initWithScrollbar:&scrollbar
286 painter:scrollbarPainter]); 286 painter:scrollbarPainter]);
287 287
288 scrollbarPainterMap().add(&scrollbar, observer); 288 scrollbarPainterMap().add(&scrollbar, observer);
289 updateEnabledState(scrollbar); 289 updateEnabledState(scrollbar);
290 updateScrollbarOverlayStyle(scrollbar); 290 updateScrollbarOverlayColorTheme(scrollbar);
291 } 291 }
292 292
293 void ScrollbarThemeMac::unregisterScrollbar(ScrollbarThemeClient& scrollbar) { 293 void ScrollbarThemeMac::unregisterScrollbar(ScrollbarThemeClient& scrollbar) {
294 scrollbarPainterMap().remove(&scrollbar); 294 scrollbarPainterMap().remove(&scrollbar);
295 scrollbarSet().remove(&scrollbar); 295 scrollbarSet().remove(&scrollbar);
296 } 296 }
297 297
298 void ScrollbarThemeMac::setNewPainterForScrollbar( 298 void ScrollbarThemeMac::setNewPainterForScrollbar(
299 ScrollbarThemeClient& scrollbar, 299 ScrollbarThemeClient& scrollbar,
300 ScrollbarPainter newPainter) { 300 ScrollbarPainter newPainter) {
301 RetainPtr<ScrollbarPainter> scrollbarPainter(AdoptNS, [newPainter retain]); 301 RetainPtr<ScrollbarPainter> scrollbarPainter(AdoptNS, [newPainter retain]);
302 RetainPtr<BlinkScrollbarObserver> observer( 302 RetainPtr<BlinkScrollbarObserver> observer(
303 AdoptNS, 303 AdoptNS,
304 [[BlinkScrollbarObserver alloc] initWithScrollbar:&scrollbar 304 [[BlinkScrollbarObserver alloc] initWithScrollbar:&scrollbar
305 painter:scrollbarPainter]); 305 painter:scrollbarPainter]);
306 scrollbarPainterMap().set(&scrollbar, observer); 306 scrollbarPainterMap().set(&scrollbar, observer);
307 updateEnabledState(scrollbar); 307 updateEnabledState(scrollbar);
308 updateScrollbarOverlayStyle(scrollbar); 308 updateScrollbarOverlayColorTheme(scrollbar);
309 } 309 }
310 310
311 ScrollbarPainter ScrollbarThemeMac::painterForScrollbar( 311 ScrollbarPainter ScrollbarThemeMac::painterForScrollbar(
312 const ScrollbarThemeClient& scrollbar) const { 312 const ScrollbarThemeClient& scrollbar) const {
313 return [scrollbarPainterMap() 313 return [scrollbarPainterMap()
314 .get(const_cast<ScrollbarThemeClient*>(&scrollbar)) 314 .get(const_cast<ScrollbarThemeClient*>(&scrollbar))
315 .get() painter]; 315 .get() painter];
316 } 316 }
317 317
318 void ScrollbarThemeMac::paintTrackBackground(GraphicsContext& context, 318 void ScrollbarThemeMac::paintTrackBackground(GraphicsContext& context,
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 int thickness = [scrollbarPainter trackBoxWidth]; 393 int thickness = [scrollbarPainter trackBoxWidth];
394 if (supportsExpandedScrollbars()) 394 if (supportsExpandedScrollbars())
395 [scrollbarPainter setExpanded:wasExpanded]; 395 [scrollbarPainter setExpanded:wasExpanded];
396 return thickness; 396 return thickness;
397 } 397 }
398 398
399 bool ScrollbarThemeMac::usesOverlayScrollbars() const { 399 bool ScrollbarThemeMac::usesOverlayScrollbars() const {
400 return recommendedScrollerStyle() == NSScrollerStyleOverlay; 400 return recommendedScrollerStyle() == NSScrollerStyleOverlay;
401 } 401 }
402 402
403 void ScrollbarThemeMac::updateScrollbarOverlayStyle( 403 void ScrollbarThemeMac::updateScrollbarOverlayColorTheme(
404 const ScrollbarThemeClient& scrollbar) { 404 const ScrollbarThemeClient& scrollbar) {
405 ScrollbarPainter painter = painterForScrollbar(scrollbar); 405 ScrollbarPainter painter = painterForScrollbar(scrollbar);
406 switch (scrollbar.getScrollbarOverlayStyle()) { 406 switch (scrollbar.getScrollbarOverlayColorTheme()) {
407 case ScrollbarOverlayStyleDefault: 407 case ScrollbarOverlayColorThemeDark:
408 [painter setKnobStyle:NSScrollerKnobStyleDefault];
409 break;
410 case ScrollbarOverlayStyleDark:
411 [painter setKnobStyle:NSScrollerKnobStyleDark]; 408 [painter setKnobStyle:NSScrollerKnobStyleDark];
412 break; 409 break;
413 case ScrollbarOverlayStyleLight: 410 case ScrollbarOverlayColorThemeLight:
414 [painter setKnobStyle:NSScrollerKnobStyleLight]; 411 [painter setKnobStyle:NSScrollerKnobStyleLight];
415 break; 412 break;
416 } 413 }
417 } 414 }
418 415
419 WebScrollbarButtonsPlacement ScrollbarThemeMac::buttonsPlacement() const { 416 WebScrollbarButtonsPlacement ScrollbarThemeMac::buttonsPlacement() const {
420 return WebScrollbarButtonsPlacementNone; 417 return WebScrollbarButtonsPlacementNone;
421 } 418 }
422 419
423 bool ScrollbarThemeMac::hasThumb(const ScrollbarThemeClient& scrollbar) { 420 bool ScrollbarThemeMac::hasThumb(const ScrollbarThemeClient& scrollbar) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 } 467 }
471 468
472 // static 469 // static
473 NSScrollerStyle ScrollbarThemeMac::recommendedScrollerStyle() { 470 NSScrollerStyle ScrollbarThemeMac::recommendedScrollerStyle() {
474 if (RuntimeEnabledFeatures::overlayScrollbarsEnabled()) 471 if (RuntimeEnabledFeatures::overlayScrollbarsEnabled())
475 return NSScrollerStyleOverlay; 472 return NSScrollerStyleOverlay;
476 return gPreferredScrollerStyle; 473 return gPreferredScrollerStyle;
477 } 474 }
478 475
479 } // namespace blink 476 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698