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

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

Issue 654393002: MacViews: Fix WidgetTest.DesktopNativeWidgetNoPaintAfterCloseTest (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ReadReceivedPaintAndReset Created 6 years, 2 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/views/cocoa/bridged_content_view.h ('k') | ui/views/cocoa/bridged_native_widget_unittest.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/scoped_nsobject.h" 8 #import "base/mac/scoped_nsobject.h"
9 #include "base/strings/sys_string_conversions.h" 9 #include "base/strings/sys_string_conversions.h"
10 #include "ui/base/ime/text_input_client.h" 10 #include "ui/base/ime/text_input_client.h"
(...skipping 12 matching lines...) Expand all
23 // Execute a command on the currently focused TextInputClient. 23 // Execute a command on the currently focused TextInputClient.
24 // |commandId| should be a resource ID from ui_strings.grd. 24 // |commandId| should be a resource ID from ui_strings.grd.
25 - (void)doCommandByID:(int)commandId; 25 - (void)doCommandByID:(int)commandId;
26 26
27 @end 27 @end
28 28
29 @implementation BridgedContentView 29 @implementation BridgedContentView
30 30
31 @synthesize hostedView = hostedView_; 31 @synthesize hostedView = hostedView_;
32 @synthesize textInputClient = textInputClient_; 32 @synthesize textInputClient = textInputClient_;
33 @synthesize willShow = willShow_;
33 34
34 - (id)initWithView:(views::View*)viewToHost { 35 - (id)initWithView:(views::View*)viewToHost {
35 DCHECK(viewToHost); 36 DCHECK(viewToHost);
36 gfx::Rect bounds = viewToHost->bounds(); 37 gfx::Rect bounds = viewToHost->bounds();
37 // To keep things simple, assume the origin is (0, 0) until there exists a use 38 // To keep things simple, assume the origin is (0, 0) until there exists a use
38 // case for something other than that. 39 // case for something other than that.
39 DCHECK(bounds.origin().IsOrigin()); 40 DCHECK(bounds.origin().IsOrigin());
40 NSRect initialFrame = NSMakeRect(0, 0, bounds.width(), bounds.height()); 41 NSRect initialFrame = NSMakeRect(0, 0, bounds.width(), bounds.height());
41 if ((self = [super initWithFrame:initialFrame])) { 42 if ((self = [super initWithFrame:initialFrame])) {
42 hostedView_ = viewToHost; 43 hostedView_ = viewToHost;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 83
83 - (void)setFrameSize:(NSSize)newSize { 84 - (void)setFrameSize:(NSSize)newSize {
84 [super setFrameSize:newSize]; 85 [super setFrameSize:newSize];
85 if (!hostedView_) 86 if (!hostedView_)
86 return; 87 return;
87 88
88 hostedView_->SetSize(gfx::Size(newSize.width, newSize.height)); 89 hostedView_->SetSize(gfx::Size(newSize.width, newSize.height));
89 } 90 }
90 91
91 - (void)drawRect:(NSRect)dirtyRect { 92 - (void)drawRect:(NSRect)dirtyRect {
92 if (!hostedView_) 93 // Note that on a Show, Cocoa calls drawRect: before changing
94 // -[NSWindow isVisible], hence the extra check.
95 if (!hostedView_ || (!willShow_ && ![[self window] isVisible]))
93 return; 96 return;
94 97
95 gfx::CanvasSkiaPaint canvas(dirtyRect, false /* opaque */); 98 gfx::CanvasSkiaPaint canvas(dirtyRect, false /* opaque */);
96 hostedView_->Paint(&canvas, views::CullSet()); 99 hostedView_->GetWidget()->OnNativeWidgetPaint(&canvas);
97 } 100 }
98 101
99 // NSResponder implementation. 102 // NSResponder implementation.
100 103
101 - (void)keyDown:(NSEvent*)theEvent { 104 - (void)keyDown:(NSEvent*)theEvent {
102 if (textInputClient_) 105 if (textInputClient_)
103 [self interpretKeyEvents:@[ theEvent ]]; 106 [self interpretKeyEvents:@[ theEvent ]];
104 else 107 else
105 [super keyDown:theEvent]; 108 [super keyDown:theEvent];
106 } 109 }
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 } 318 }
316 319
317 return [super accessibilityAttributeValue:attribute]; 320 return [super accessibilityAttributeValue:attribute];
318 } 321 }
319 322
320 - (id)accessibilityHitTest:(NSPoint)point { 323 - (id)accessibilityHitTest:(NSPoint)point {
321 return [hostedView_->GetNativeViewAccessible() accessibilityHitTest:point]; 324 return [hostedView_->GetNativeViewAccessible() accessibilityHitTest:point];
322 } 325 }
323 326
324 @end 327 @end
OLDNEW
« no previous file with comments | « ui/views/cocoa/bridged_content_view.h ('k') | ui/views/cocoa/bridged_native_widget_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698