Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 13ae2d6

Browse files
ahrimagreenblatt
authored andcommitted
Mac: Use CAST_CEF_WINDOW_HANDLE_TO_NSVIEW macro to fix build errors (fixes issue chromiumembedded#340).
1 parent 467f8fc commit 13ae2d6

File tree

1 file changed

+30
-20
lines changed

1 file changed

+30
-20
lines changed

native/util_mac.mm

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ + (void)setVisibility:(SetVisibilityParams*)params;
7070
// Java provides an NSApplicationAWT implementation that we can't access or
7171
// override directly. Therefore add the necessary CefAppProtocol
7272
// functionality to NSApplication using categories and swizzling.
73-
@interface NSApplication (JCEFApplication)<CefAppProtocol>
73+
@interface NSApplication (JCEFApplication) <CefAppProtocol>
7474

7575
- (BOOL)isHandlingSendEvent;
7676
- (void)setHandlingSendEvent:(BOOL)handlingSendEvent;
@@ -109,10 +109,9 @@ + (void)load {
109109
NSMouseEnteredMask |
110110
NSMouseExitedMask)
111111
handler:^(NSEvent* evt) {
112-
113112
// Get corresponding CefWindowHandle of
114113
// Java-Canvas
115-
CefWindowHandle browser = NULL;
114+
NSView* browser = NULL;
116115
NSPoint absPos = [evt locationInWindow];
117116
NSWindow* evtWin = [evt window];
118117
g_browsers_lock_.Lock();
@@ -123,12 +122,15 @@ + (void)load {
123122
std::set<CefWindowHandle>::iterator it;
124123
for (it = browsers.begin();
125124
it != browsers.end(); ++it) {
126-
NSPoint relPos = [*it convertPoint:absPos
127-
fromView:nil];
128-
if (evtWin == [*it window] &&
129-
[*it mouse:relPos
130-
inRect:[*it frame]]) {
131-
browser = *it;
125+
NSView* wh =
126+
CAST_CEF_WINDOW_HANDLE_TO_NSVIEW(
127+
*it);
128+
NSPoint relPos = [wh convertPoint:absPos
129+
fromView:nil];
130+
if (evtWin == [wh window] &&
131+
[wh mouse:relPos
132+
inRect:[wh frame]]) {
133+
browser = wh;
132134
break;
133135
}
134136
}
@@ -235,11 +237,12 @@ + (void)doMessageLoopWork {
235237

236238
+ (void)setVisibility:(SetVisibilityParams*)params {
237239
if (g_client_app_) {
238-
bool isHidden = [params->handle_ isHidden];
240+
NSView* wh = CAST_CEF_WINDOW_HANDLE_TO_NSVIEW(params->handle_);
241+
bool isHidden = [wh isHidden];
239242
if (isHidden == params->isVisible_) {
240-
[params->handle_ setHidden:!params->isVisible_];
241-
[params->handle_ needsDisplay];
242-
[[params->handle_ superview] display];
243+
[wh setHidden:!params->isVisible_];
244+
[wh needsDisplay];
245+
[[wh superview] display];
243246
}
244247
}
245248
[params release];
@@ -392,7 +395,7 @@ bool IsNSView(void* ptr) {
392395
}
393396

394397
CefWindowHandle CreateBrowserContentView(NSWindow* window, CefRect& orig) {
395-
NSView* mainView = (CefWindowHandle)[window contentView];
398+
NSView* mainView = CAST_CEF_WINDOW_HANDLE_TO_NSVIEW([window contentView]);
396399
TranslateRect(mainView, orig);
397400
NSRect frame = {{orig.x, orig.y}, {orig.width, orig.height}};
398401

@@ -419,7 +422,8 @@ CefWindowHandle CreateBrowserContentView(NSWindow* window, CefRect& orig) {
419422

420423
// translate java's window origin to Obj-C's window origin
421424
void TranslateRect(CefWindowHandle view, CefRect& orig) {
422-
NSRect bounds = [[[view window] contentView] bounds];
425+
NSRect bounds =
426+
[[[CAST_CEF_WINDOW_HANDLE_TO_NSVIEW(view) window] contentView] bounds];
423427
orig.y = bounds.size.height - orig.height - orig.y;
424428
}
425429

@@ -467,7 +471,9 @@ void UpdateView(CefWindowHandle handle,
467471
CefRect contentRect,
468472
CefRect browserRect) {
469473
util_mac::TranslateRect(handle, contentRect);
470-
CefBrowserContentView* browser = (CefBrowserContentView*)[handle superview];
474+
CefBrowserContentView* browser =
475+
(CefBrowserContentView*)[CAST_CEF_WINDOW_HANDLE_TO_NSVIEW(handle)
476+
superview];
471477
browserRect.y = contentRect.height - browserRect.height - browserRect.y;
472478

473479
// Only update the view if nobody is currently resizing the main window.
@@ -502,14 +508,16 @@ void AddCefBrowser(CefRefPtr<CefBrowser> browser) {
502508
g_browsers_.insert(handle);
503509
g_browsers_lock_.Unlock();
504510
CefBrowserContentView* browserImpl =
505-
(CefBrowserContentView*)[handle superview];
511+
(CefBrowserContentView*)[CAST_CEF_WINDOW_HANDLE_TO_NSVIEW(handle)
512+
superview];
506513
[browserImpl addCefBrowser:browser];
507514
}
508515

509516
void DestroyCefBrowser(CefRefPtr<CefBrowser> browser) {
510517
if (!browser.get())
511518
return;
512-
CefWindowHandle handle = browser->GetHost()->GetWindowHandle();
519+
NSView* handle =
520+
CAST_CEF_WINDOW_HANDLE_TO_NSVIEW(browser->GetHost()->GetWindowHandle());
513521
g_browsers_lock_.Lock();
514522
g_browsers_.erase(handle);
515523
g_browsers_lock_.Unlock();
@@ -531,7 +539,8 @@ void SetParent(CefWindowHandle handle,
531539
base::Closure* pCallback = new base::Closure(callback);
532540
dispatch_async(dispatch_get_main_queue(), ^{
533541
CefBrowserContentView* browser_view =
534-
(CefBrowserContentView*)[handle superview];
542+
(CefBrowserContentView*)[CAST_CEF_WINDOW_HANDLE_TO_NSVIEW(handle)
543+
superview];
535544
[browser_view retain];
536545
[browser_view removeFromSuperview];
537546

@@ -540,7 +549,8 @@ void SetParent(CefWindowHandle handle,
540549
NSWindow* window = (NSWindow*)parentHandle;
541550
contentView = [window contentView];
542551
} else {
543-
contentView = TempWindow::GetWindowHandle();
552+
contentView =
553+
CAST_CEF_WINDOW_HANDLE_TO_NSVIEW(TempWindow::GetWindowHandle());
544554
}
545555
[contentView addSubview:browser_view];
546556
[browser_view release];

0 commit comments

Comments
 (0)