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

Side by Side Diff: ui/views/cocoa/bridged_content_view.mm

Issue 2271653006: base::mac::IsOSSierra() -> base::mac::IsOS10_12(), etc. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Nits Created 4 years, 3 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
« no previous file with comments | « ui/native_theme/native_theme_mac_unittest.cc ('k') | ui/views/cocoa/bridged_native_widget.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #import "ui/views/cocoa/bridged_content_view.h" 5 #import "ui/views/cocoa/bridged_content_view.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #import "base/mac/mac_util.h" 8 #import "base/mac/mac_util.h"
9 #import "base/mac/scoped_nsobject.h" 9 #import "base/mac/scoped_nsobject.h"
10 #include "base/strings/sys_string_conversions.h" 10 #include "base/strings/sys_string_conversions.h"
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 DCHECK(newTooltipText.empty()); 338 DCHECK(newTooltipText.empty());
339 } 339 }
340 if (newTooltipText != lastTooltipText_) { 340 if (newTooltipText != lastTooltipText_) {
341 std::swap(newTooltipText, lastTooltipText_); 341 std::swap(newTooltipText, lastTooltipText_);
342 [self setToolTipAtMousePoint:base::SysUTF16ToNSString(lastTooltipText_)]; 342 [self setToolTipAtMousePoint:base::SysUTF16ToNSString(lastTooltipText_)];
343 } 343 }
344 } 344 }
345 345
346 - (void)updateWindowMask { 346 - (void)updateWindowMask {
347 DCHECK(![self inLiveResize]); 347 DCHECK(![self inLiveResize]);
348 DCHECK(base::mac::IsOSMavericks()); 348 DCHECK(base::mac::IsOS10_9());
349 DCHECK(hostedView_); 349 DCHECK(hostedView_);
350 350
351 views::Widget* widget = hostedView_->GetWidget(); 351 views::Widget* widget = hostedView_->GetWidget();
352 if (!widget->non_client_view()) 352 if (!widget->non_client_view())
353 return; 353 return;
354 354
355 const NSRect frameRect = [self bounds]; 355 const NSRect frameRect = [self bounds];
356 gfx::Path mask; 356 gfx::Path mask;
357 widget->non_client_view()->GetWindowMask(gfx::Size(frameRect.size), &mask); 357 widget->non_client_view()->GetWindowMask(gfx::Size(frameRect.size), &mask);
358 if (mask.isEmpty()) 358 if (mask.isEmpty())
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 599
600 hostedView_->SetSize(gfx::Size(newSize.width, newSize.height)); 600 hostedView_->SetSize(gfx::Size(newSize.width, newSize.height));
601 } 601 }
602 602
603 - (void)viewDidEndLiveResize { 603 - (void)viewDidEndLiveResize {
604 [super viewDidEndLiveResize]; 604 [super viewDidEndLiveResize];
605 605
606 // We prevent updating the window mask and clipping the border around the 606 // We prevent updating the window mask and clipping the border around the
607 // view, during a live resize. Hence update the window mask and redraw the 607 // view, during a live resize. Hence update the window mask and redraw the
608 // view after resize has completed. 608 // view after resize has completed.
609 if (base::mac::IsOSMavericks()) { 609 if (base::mac::IsOS10_9()) {
610 [self updateWindowMask]; 610 [self updateWindowMask];
611 [self setNeedsDisplay:YES]; 611 [self setNeedsDisplay:YES];
612 } 612 }
613 } 613 }
614 614
615 - (void)drawRect:(NSRect)dirtyRect { 615 - (void)drawRect:(NSRect)dirtyRect {
616 // Note that BridgedNativeWidget uses -[NSWindow setAutodisplay:NO] to 616 // Note that BridgedNativeWidget uses -[NSWindow setAutodisplay:NO] to
617 // suppress calls to this when the window is known to be hidden. 617 // suppress calls to this when the window is known to be hidden.
618 if (!hostedView_) 618 if (!hostedView_)
619 return; 619 return;
620 620
621 if (drawMenuBackgroundForBlur_) { 621 if (drawMenuBackgroundForBlur_) {
622 const CGFloat radius = views::MenuConfig::instance().corner_radius; 622 const CGFloat radius = views::MenuConfig::instance().corner_radius;
623 [skia::SkColorToSRGBNSColor(0x01000000) set]; 623 [skia::SkColorToSRGBNSColor(0x01000000) set];
624 [[NSBezierPath bezierPathWithRoundedRect:[self bounds] 624 [[NSBezierPath bezierPathWithRoundedRect:[self bounds]
625 xRadius:radius 625 xRadius:radius
626 yRadius:radius] fill]; 626 yRadius:radius] fill];
627 } 627 }
628 628
629 // On OS versions earlier than Yosemite, to generate a drop shadow, we set an 629 // On OS versions earlier than Yosemite, to generate a drop shadow, we set an
630 // opaque background. This causes windows with non rectangular shapes to have 630 // opaque background. This causes windows with non rectangular shapes to have
631 // square corners. To get around this, fill the path outside the window 631 // square corners. To get around this, fill the path outside the window
632 // boundary with clearColor and tell Cococa to regenerate drop shadow. See 632 // boundary with clearColor and tell Cococa to regenerate drop shadow. See
633 // crbug.com/543671. 633 // crbug.com/543671.
634 if (windowMask_ && ![self inLiveResize] && 634 if (windowMask_ && ![self inLiveResize] &&
635 !IsRectInsidePath(dirtyRect, windowMask_)) { 635 !IsRectInsidePath(dirtyRect, windowMask_)) {
636 DCHECK(base::mac::IsOSMavericks()); 636 DCHECK(base::mac::IsOS10_9());
637 gfx::ScopedNSGraphicsContextSaveGState state; 637 gfx::ScopedNSGraphicsContextSaveGState state;
638 638
639 // The outer rectangular path corresponding to the window. 639 // The outer rectangular path corresponding to the window.
640 NSBezierPath* outerPath = [NSBezierPath bezierPathWithRect:[self bounds]]; 640 NSBezierPath* outerPath = [NSBezierPath bezierPathWithRect:[self bounds]];
641 641
642 [outerPath appendBezierPath:windowMask_]; 642 [outerPath appendBezierPath:windowMask_];
643 [outerPath setWindingRule:NSEvenOddWindingRule]; 643 [outerPath setWindingRule:NSEvenOddWindingRule];
644 [[NSGraphicsContext currentContext] 644 [[NSGraphicsContext currentContext]
645 setCompositingOperation:NSCompositeCopy]; 645 setCompositingOperation:NSCompositeCopy];
646 [[NSColor clearColor] set]; 646 [[NSColor clearColor] set];
(...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after
1356 } 1356 }
1357 1357
1358 return [super accessibilityAttributeValue:attribute]; 1358 return [super accessibilityAttributeValue:attribute];
1359 } 1359 }
1360 1360
1361 - (id)accessibilityHitTest:(NSPoint)point { 1361 - (id)accessibilityHitTest:(NSPoint)point {
1362 return [hostedView_->GetNativeViewAccessible() accessibilityHitTest:point]; 1362 return [hostedView_->GetNativeViewAccessible() accessibilityHitTest:point];
1363 } 1363 }
1364 1364
1365 @end 1365 @end
OLDNEW
« no previous file with comments | « ui/native_theme/native_theme_mac_unittest.cc ('k') | ui/views/cocoa/bridged_native_widget.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698