mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-02-26 08:58:18 +01:00
macOS: Add support for building clients with ARC enabled (fixes issue #2623).
Under ARC (Automatic Reference Counting), assigning to an Objective-C pointer has different semantics than assigning to a void* pointer. This makes it dangerous to treat the same memory address as an Objective-C pointer in some cases and as a "regular C pointer" in other cases. This change removes the conditional type defines and instead uses void* everywhere. Explicit type casting in combination with ARC annotations makes it safe to get typed Objective-C pointers from the void* pointers. This change enables ARC by default in the CEF binary distribution CMake configuration for the cefclient and cefsimple sample applications. It can be disabled by adding `-DOPTION_USE_ARC=Off` to the CMake command line. ARC is not supported when building Chromium due to the substantial number of changes that would be required in the Chromium code base.
This commit is contained in:
parent
491253fa03
commit
019611c764
@ -37,29 +37,37 @@
|
|||||||
#include "include/internal/cef_string.h"
|
#include "include/internal/cef_string.h"
|
||||||
|
|
||||||
// Handle types.
|
// Handle types.
|
||||||
#ifdef __cplusplus
|
// Actually NSCursor*
|
||||||
#ifdef __OBJC__
|
|
||||||
@class NSCursor;
|
|
||||||
@class NSEvent;
|
|
||||||
@class NSView;
|
|
||||||
#else
|
|
||||||
class NSCursor;
|
|
||||||
class NSEvent;
|
|
||||||
struct NSView;
|
|
||||||
#endif
|
|
||||||
#define cef_cursor_handle_t NSCursor*
|
|
||||||
#define cef_event_handle_t NSEvent*
|
|
||||||
#define cef_window_handle_t NSView*
|
|
||||||
#else
|
|
||||||
#define cef_cursor_handle_t void*
|
#define cef_cursor_handle_t void*
|
||||||
|
// Acutally NSEvent*
|
||||||
#define cef_event_handle_t void*
|
#define cef_event_handle_t void*
|
||||||
|
// Actually NSView*
|
||||||
#define cef_window_handle_t void*
|
#define cef_window_handle_t void*
|
||||||
#endif
|
|
||||||
|
|
||||||
#define kNullCursorHandle NULL
|
#define kNullCursorHandle NULL
|
||||||
#define kNullEventHandle NULL
|
#define kNullEventHandle NULL
|
||||||
#define kNullWindowHandle NULL
|
#define kNullWindowHandle NULL
|
||||||
|
|
||||||
|
#ifdef __OBJC__
|
||||||
|
#if __has_feature(objc_arc)
|
||||||
|
#define CAST_CEF_CURSOR_HANDLE_TO_NSCURSOR(handle) ((__bridge NSCursor*)handle)
|
||||||
|
#define CAST_CEF_EVENT_HANDLE_TO_NSEVENT(handle) ((__bridge NSEvent*)handle)
|
||||||
|
#define CAST_CEF_WINDOW_HANDLE_TO_NSVIEW(handle) ((__bridge NSView*)handle)
|
||||||
|
|
||||||
|
#define CAST_NSCURSOR_TO_CEF_CURSOR_HANDLE(cursor) ((__bridge void*)cursor)
|
||||||
|
#define CAST_NSEVENT_TO_CEF_EVENT_HANDLE(event) ((__bridge void*)event)
|
||||||
|
#define CAST_NSVIEW_TO_CEF_WINDOW_HANDLE(view) ((__bridge void*)view)
|
||||||
|
#else // __has_feature(objc_arc)
|
||||||
|
#define CAST_CEF_CURSOR_HANDLE_TO_NSCURSOR(handle) ((NSCursor*)handle)
|
||||||
|
#define CAST_CEF_EVENT_HANDLE_TO_NSEVENT(handle) ((NSEvent*)handle)
|
||||||
|
#define CAST_CEF_WINDOW_HANDLE_TO_NSVIEW(handle) ((NSView*)handle)
|
||||||
|
|
||||||
|
#define CAST_NSCURSOR_TO_CEF_CURSOR_HANDLE(cursor) ((void*)cursor)
|
||||||
|
#define CAST_NSEVENT_TO_CEF_EVENT_HANDLE(event) ((void*)event)
|
||||||
|
#define CAST_NSVIEW_TO_CEF_WINDOW_HANDLE(view) ((void*)view)
|
||||||
|
#endif // __has_feature(objc_arc)
|
||||||
|
#endif // __OBJC__
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
@ -56,7 +56,7 @@
|
|||||||
@end
|
@end
|
||||||
|
|
||||||
// Receives notifications from the browser window. Will delete itself when done.
|
// Receives notifications from the browser window. Will delete itself when done.
|
||||||
@interface CefWindowDelegate : NSObject<NSWindowDelegate> {
|
@interface CefWindowDelegate : NSObject <NSWindowDelegate> {
|
||||||
@private
|
@private
|
||||||
CefBrowserHostImpl* browser_; // weak
|
CefBrowserHostImpl* browser_; // weak
|
||||||
NSWindow* window_;
|
NSWindow* window_;
|
||||||
@ -165,7 +165,8 @@ bool CefBrowserPlatformDelegateNativeMac::CreateHostWindow() {
|
|||||||
|
|
||||||
NSWindow* newWnd = nil;
|
NSWindow* newWnd = nil;
|
||||||
|
|
||||||
NSView* parentView = window_info_.parent_view;
|
NSView* parentView =
|
||||||
|
CAST_CEF_WINDOW_HANDLE_TO_NSVIEW(window_info_.parent_view);
|
||||||
NSRect contentRect = {{window_info_.x, window_info_.y},
|
NSRect contentRect = {{window_info_.x, window_info_.y},
|
||||||
{window_info_.width, window_info_.height}};
|
{window_info_.width, window_info_.height}};
|
||||||
if (parentView == nil) {
|
if (parentView == nil) {
|
||||||
@ -239,11 +240,11 @@ bool CefBrowserPlatformDelegateNativeMac::CreateHostWindow() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserPlatformDelegateNativeMac::CloseHostWindow() {
|
void CefBrowserPlatformDelegateNativeMac::CloseHostWindow() {
|
||||||
if (window_info_.view != nil) {
|
NSView* nsview = CAST_CEF_WINDOW_HANDLE_TO_NSVIEW(window_info_.view);
|
||||||
[[window_info_.view window]
|
if (nsview != nil) {
|
||||||
performSelectorOnMainThread:@selector(performClose:)
|
[[nsview window] performSelectorOnMainThread:@selector(performClose:)
|
||||||
withObject:nil
|
withObject:nil
|
||||||
waitUntilDone:NO];
|
waitUntilDone:NO];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,7 +276,7 @@ gfx::Point CefBrowserPlatformDelegateNativeMac::GetScreenPoint(
|
|||||||
if (windowless_handler_)
|
if (windowless_handler_)
|
||||||
return windowless_handler_->GetParentScreenPoint(view);
|
return windowless_handler_->GetParentScreenPoint(view);
|
||||||
|
|
||||||
NSView* nsview = window_info_.parent_view;
|
NSView* nsview = CAST_CEF_WINDOW_HANDLE_TO_NSVIEW(window_info_.parent_view);
|
||||||
if (nsview) {
|
if (nsview) {
|
||||||
NSRect bounds = [nsview bounds];
|
NSRect bounds = [nsview bounds];
|
||||||
NSPoint view_pt = {view.x(), bounds.size.height - view.y()};
|
NSPoint view_pt = {view.x(), bounds.size.height - view.y()};
|
||||||
@ -336,8 +337,8 @@ void CefBrowserPlatformDelegateNativeMac::TranslateKeyEvent(
|
|||||||
[[[NSString alloc] initWithCharacters:&key_event.unmodified_character
|
[[[NSString alloc] initWithCharacters:&key_event.unmodified_character
|
||||||
length:1] autorelease];
|
length:1] autorelease];
|
||||||
NSString* characters =
|
NSString* characters =
|
||||||
[[[NSString alloc] initWithCharacters:&key_event.character length:1]
|
[[[NSString alloc] initWithCharacters:&key_event.character
|
||||||
autorelease];
|
length:1] autorelease];
|
||||||
|
|
||||||
NSEvent* synthetic_event =
|
NSEvent* synthetic_event =
|
||||||
[NSEvent keyEventWithType:event_type
|
[NSEvent keyEventWithType:event_type
|
||||||
|
@ -387,7 +387,7 @@ void CefFileDialogRunnerMac::Run(CefBrowserHostImpl* browser,
|
|||||||
const FileChooserParams& params,
|
const FileChooserParams& params,
|
||||||
RunFileChooserCallback callback) {
|
RunFileChooserCallback callback) {
|
||||||
int filter_index = params.selected_accept_filter;
|
int filter_index = params.selected_accept_filter;
|
||||||
NSView* owner = browser->GetWindowHandle();
|
NSView* owner = CAST_CEF_WINDOW_HANDLE_TO_NSVIEW(browser->GetWindowHandle());
|
||||||
|
|
||||||
if (params.mode == blink::mojom::FileChooserParams::Mode::kOpen ||
|
if (params.mode == blink::mojom::FileChooserParams::Mode::kOpen ||
|
||||||
params.mode == blink::mojom::FileChooserParams::Mode::kOpenMultiple ||
|
params.mode == blink::mojom::FileChooserParams::Mode::kOpenMultiple ||
|
||||||
|
@ -152,6 +152,16 @@ endif()
|
|||||||
#
|
#
|
||||||
|
|
||||||
if(OS_MACOSX)
|
if(OS_MACOSX)
|
||||||
|
option(OPTION_USE_ARC "Build with ARC (automatic Reference Counting) on macOS." ON)
|
||||||
|
if(OPTION_USE_ARC)
|
||||||
|
list(APPEND CEF_COMPILER_FLAGS
|
||||||
|
-fobjc-arc
|
||||||
|
)
|
||||||
|
set_target_properties(${target} PROPERTIES
|
||||||
|
CLANG_ENABLE_OBJC_ARC "YES"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
# All sources required by the "cefclient" target. Generates an app bundle that
|
# All sources required by the "cefclient" target. Generates an app bundle that
|
||||||
# is used only for the browser process.
|
# is used only for the browser process.
|
||||||
set(CEFCLIENT_SRCS
|
set(CEFCLIENT_SRCS
|
||||||
|
@ -13,6 +13,8 @@
|
|||||||
|
|
||||||
namespace client {
|
namespace client {
|
||||||
|
|
||||||
|
class BrowserWindowOsrMacImpl;
|
||||||
|
|
||||||
// Represents a native child window hosting a single off-screen browser
|
// Represents a native child window hosting a single off-screen browser
|
||||||
// instance. The methods of this class must be called on the main thread unless
|
// instance. The methods of this class must be called on the main thread unless
|
||||||
// otherwise indicated.
|
// otherwise indicated.
|
||||||
@ -88,17 +90,11 @@ class BrowserWindowOsrMac : public BrowserWindow,
|
|||||||
void UpdateAccessibilityLocation(CefRefPtr<CefValue> value) OVERRIDE;
|
void UpdateAccessibilityLocation(CefRefPtr<CefValue> value) OVERRIDE;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Create the NSView.
|
scoped_ptr<BrowserWindowOsrMacImpl> impl_;
|
||||||
void Create(ClientWindowHandle parent_handle, const CefRect& rect);
|
|
||||||
|
|
||||||
// The below members will only be accessed on the main thread which should be
|
|
||||||
// the same as the CEF UI thread.
|
|
||||||
OsrRenderer renderer_;
|
|
||||||
ClientWindowHandle nsview_;
|
|
||||||
bool hidden_;
|
|
||||||
bool painting_popup_;
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(BrowserWindowOsrMac);
|
DISALLOW_COPY_AND_ASSIGN(BrowserWindowOsrMac);
|
||||||
|
|
||||||
|
friend class BrowserWindowOsrMacImpl;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace client
|
} // namespace client
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -52,11 +52,11 @@ void BrowserWindowStdMac::ShowPopup(ClientWindowHandle parent_handle,
|
|||||||
size_t height) {
|
size_t height) {
|
||||||
REQUIRE_MAIN_THREAD();
|
REQUIRE_MAIN_THREAD();
|
||||||
|
|
||||||
NSView* browser_view = GetWindowHandle();
|
NSView* browser_view = CAST_CEF_WINDOW_HANDLE_TO_NSVIEW(GetWindowHandle());
|
||||||
|
|
||||||
// Re-parent |browser_view| to |parent_handle|.
|
// Re-parent |browser_view| to |parent_handle|.
|
||||||
[browser_view removeFromSuperview];
|
[browser_view removeFromSuperview];
|
||||||
[parent_handle addSubview:browser_view];
|
[CAST_CEF_WINDOW_HANDLE_TO_NSVIEW(parent_handle) addSubview:browser_view];
|
||||||
|
|
||||||
NSSize size = NSMakeSize(static_cast<int>(width), static_cast<int>(height));
|
NSSize size = NSMakeSize(static_cast<int>(width), static_cast<int>(height));
|
||||||
[browser_view setFrameSize:size];
|
[browser_view setFrameSize:size];
|
||||||
|
@ -18,15 +18,12 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(OS_MACOSX)
|
#if defined(OS_MACOSX)
|
||||||
// Forward declaration of ObjC types used by cefclient and not provided by
|
#define ClientNativeMacWindow void*
|
||||||
// include/internal/cef_types_mac.h.
|
|
||||||
#ifdef __cplusplus
|
|
||||||
#ifdef __OBJC__
|
#ifdef __OBJC__
|
||||||
@class NSWindow;
|
#define CAST_CLIENT_NATIVE_MAC_WINDOW_TO_NSWINDOW(native) \
|
||||||
#else
|
(__bridge NSWindow*)native
|
||||||
class NSWindow;
|
#define CAST_NSWINDOW_TO_CLIENT_NATIVE_MAC_WINDOW(window) (__bridge void*)window
|
||||||
#endif
|
#endif // __OBJC__
|
||||||
#endif
|
|
||||||
#endif // defined OS_MACOSX
|
#endif // defined OS_MACOSX
|
||||||
|
|
||||||
#endif // CEF_TESTS_CEFCLIENT_BROWSER_CLIENT_TYPES_H_
|
#endif // CEF_TESTS_CEFCLIENT_BROWSER_CLIENT_TYPES_H_
|
||||||
|
@ -11,12 +11,19 @@
|
|||||||
#include "include/cef_browser.h"
|
#include "include/cef_browser.h"
|
||||||
|
|
||||||
#if defined(OS_MACOSX)
|
#if defined(OS_MACOSX)
|
||||||
#ifdef __OBJC__
|
typedef void CefNativeAccessible;
|
||||||
@class NSObject;
|
#if __OBJC__
|
||||||
#else
|
#if __has_feature(objc_arc)
|
||||||
class NSObject;
|
#define CAST_CEF_NATIVE_ACCESSIBLE_TO_NSOBJECT(accessible) \
|
||||||
#endif
|
(__bridge NSObject*)accessible
|
||||||
typedef NSObject CefNativeAccessible;
|
#define CAST_NSOBJECT_TO_CEF_NATIVE_ACCESSIBLE(object) \
|
||||||
|
(__bridge CefNativeAccessible*)object
|
||||||
|
#else // __has_feature(objc_arc)
|
||||||
|
#define CAST_CEF_NATIVE_ACCESSIBLE_TO_NSOBJECT(accessible) (NSObject*)accessible
|
||||||
|
#define CAST_NSOBJECT_TO_CEF_NATIVE_ACCESSIBLE(object) \
|
||||||
|
(__bridge CefNativeAccessible*)object
|
||||||
|
#endif // __has_feature(objc_arc)
|
||||||
|
#endif // __OBJC__
|
||||||
#elif defined(OS_WIN)
|
#elif defined(OS_WIN)
|
||||||
struct IAccessible;
|
struct IAccessible;
|
||||||
typedef IAccessible CefNativeAccessible;
|
typedef IAccessible CefNativeAccessible;
|
||||||
|
@ -320,7 +320,9 @@ inline int MiddleY(const CefRect& rect) {
|
|||||||
NSMutableArray* kids = [NSMutableArray arrayWithCapacity:numChilds];
|
NSMutableArray* kids = [NSMutableArray arrayWithCapacity:numChilds];
|
||||||
for (int index = 0; index < numChilds; index++) {
|
for (int index = 0; index < numChilds; index++) {
|
||||||
client::OsrAXNode* child = node_->ChildAtIndex(index);
|
client::OsrAXNode* child = node_->ChildAtIndex(index);
|
||||||
[kids addObject:child ? child->GetNativeAccessibleObject(node_) : nil];
|
[kids addObject:child ? CAST_CEF_NATIVE_ACCESSIBLE_TO_NSOBJECT(
|
||||||
|
child->GetNativeAccessibleObject(node_))
|
||||||
|
: nil];
|
||||||
}
|
}
|
||||||
return kids;
|
return kids;
|
||||||
}
|
}
|
||||||
@ -332,7 +334,7 @@ inline int MiddleY(const CefRect& rect) {
|
|||||||
NSPoint origin = NSMakePoint(cef_rect.x, cef_rect.y);
|
NSPoint origin = NSMakePoint(cef_rect.x, cef_rect.y);
|
||||||
NSSize size = NSMakeSize(cef_rect.width, cef_rect.height);
|
NSSize size = NSMakeSize(cef_rect.width, cef_rect.height);
|
||||||
|
|
||||||
NSView* view = node_->GetWindowHandle();
|
NSView* view = CAST_CEF_WINDOW_HANDLE_TO_NSVIEW(node_->GetWindowHandle());
|
||||||
origin.y = NSHeight([view bounds]) - origin.y;
|
origin.y = NSHeight([view bounds]) - origin.y;
|
||||||
NSPoint originInWindow = [view convertPoint:origin toView:nil];
|
NSPoint originInWindow = [view convertPoint:origin toView:nil];
|
||||||
|
|
||||||
@ -348,7 +350,7 @@ inline int MiddleY(const CefRect& rect) {
|
|||||||
CefRect cef_rect = node_->AxLocation();
|
CefRect cef_rect = node_->AxLocation();
|
||||||
NSRect rect =
|
NSRect rect =
|
||||||
NSMakeRect(cef_rect.x, cef_rect.y, cef_rect.width, cef_rect.height);
|
NSMakeRect(cef_rect.x, cef_rect.y, cef_rect.width, cef_rect.height);
|
||||||
NSView* view = node_->GetWindowHandle();
|
NSView* view = CAST_CEF_WINDOW_HANDLE_TO_NSVIEW(node_->GetWindowHandle());
|
||||||
rect = [[view window] convertRectToScreen:rect];
|
rect = [[view window] convertRectToScreen:rect];
|
||||||
return rect.size;
|
return rect.size;
|
||||||
}
|
}
|
||||||
@ -384,6 +386,7 @@ inline int MiddleY(const CefRect& rect) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (id)accessibilityAttributeValue:(NSString*)attribute {
|
- (id)accessibilityAttributeValue:(NSString*)attribute {
|
||||||
|
NSObject* typed_parent = CAST_CEF_NATIVE_ACCESSIBLE_TO_NSOBJECT(parent_);
|
||||||
if (!node_)
|
if (!node_)
|
||||||
return nil;
|
return nil;
|
||||||
if ([attribute isEqualToString:NSAccessibilityRoleAttribute]) {
|
if ([attribute isEqualToString:NSAccessibilityRoleAttribute]) {
|
||||||
@ -397,16 +400,17 @@ inline int MiddleY(const CefRect& rect) {
|
|||||||
accessibilityAttributeValue:NSAccessibilityFocusedUIElementAttribute];
|
accessibilityAttributeValue:NSAccessibilityFocusedUIElementAttribute];
|
||||||
return [NSNumber numberWithBool:[focusedElement isEqual:self]];
|
return [NSNumber numberWithBool:[focusedElement isEqual:self]];
|
||||||
} else if ([attribute isEqualToString:NSAccessibilityParentAttribute]) {
|
} else if ([attribute isEqualToString:NSAccessibilityParentAttribute]) {
|
||||||
return NSAccessibilityUnignoredAncestor(parent_);
|
return NSAccessibilityUnignoredAncestor(typed_parent);
|
||||||
} else if ([attribute isEqualToString:NSAccessibilityChildrenAttribute]) {
|
} else if ([attribute isEqualToString:NSAccessibilityChildrenAttribute]) {
|
||||||
return NSAccessibilityUnignoredChildren([self getKids]);
|
return NSAccessibilityUnignoredChildren([self getKids]);
|
||||||
} else if ([attribute isEqualToString:NSAccessibilityWindowAttribute]) {
|
} else if ([attribute isEqualToString:NSAccessibilityWindowAttribute]) {
|
||||||
// We're in the same window as our parent.
|
// We're in the same window as our parent.
|
||||||
return [parent_ accessibilityAttributeValue:NSAccessibilityWindowAttribute];
|
return [typed_parent
|
||||||
|
accessibilityAttributeValue:NSAccessibilityWindowAttribute];
|
||||||
} else if ([attribute
|
} else if ([attribute
|
||||||
isEqualToString:NSAccessibilityTopLevelUIElementAttribute]) {
|
isEqualToString:NSAccessibilityTopLevelUIElementAttribute]) {
|
||||||
// We're in the same top level element as our parent.
|
// We're in the same top level element as our parent.
|
||||||
return [parent_
|
return [typed_parent
|
||||||
accessibilityAttributeValue:NSAccessibilityTopLevelUIElementAttribute];
|
accessibilityAttributeValue:NSAccessibilityTopLevelUIElementAttribute];
|
||||||
} else if ([attribute isEqualToString:NSAccessibilityPositionAttribute]) {
|
} else if ([attribute isEqualToString:NSAccessibilityPositionAttribute]) {
|
||||||
return [NSValue valueWithPoint:[self position]];
|
return [NSValue valueWithPoint:[self position]];
|
||||||
@ -460,17 +464,18 @@ inline int MiddleY(const CefRect& rect) {
|
|||||||
namespace client {
|
namespace client {
|
||||||
|
|
||||||
void OsrAXNode::NotifyAccessibilityEvent(std::string event_type) const {
|
void OsrAXNode::NotifyAccessibilityEvent(std::string event_type) const {
|
||||||
|
NSView* view = CAST_CEF_WINDOW_HANDLE_TO_NSVIEW(GetWindowHandle());
|
||||||
if (event_type == "focus") {
|
if (event_type == "focus") {
|
||||||
NSAccessibilityPostNotification(
|
NSAccessibilityPostNotification(
|
||||||
GetWindowHandle(), NSAccessibilityFocusedUIElementChangedNotification);
|
view, NSAccessibilityFocusedUIElementChangedNotification);
|
||||||
} else if (event_type == "textChanged") {
|
} else if (event_type == "textChanged") {
|
||||||
NSAccessibilityPostNotification(GetWindowHandle(),
|
NSAccessibilityPostNotification(view,
|
||||||
NSAccessibilityTitleChangedNotification);
|
NSAccessibilityTitleChangedNotification);
|
||||||
} else if (event_type == "valueChanged") {
|
} else if (event_type == "valueChanged") {
|
||||||
NSAccessibilityPostNotification(GetWindowHandle(),
|
NSAccessibilityPostNotification(view,
|
||||||
NSAccessibilityValueChangedNotification);
|
NSAccessibilityValueChangedNotification);
|
||||||
} else if (event_type == "textSelectionChanged") {
|
} else if (event_type == "textSelectionChanged") {
|
||||||
NSAccessibilityPostNotification(GetWindowHandle(),
|
NSAccessibilityPostNotification(view,
|
||||||
NSAccessibilityValueChangedNotification);
|
NSAccessibilityValueChangedNotification);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -478,7 +483,8 @@ void OsrAXNode::NotifyAccessibilityEvent(std::string event_type) const {
|
|||||||
void OsrAXNode::Destroy() {
|
void OsrAXNode::Destroy() {
|
||||||
if (platform_accessibility_) {
|
if (platform_accessibility_) {
|
||||||
NSAccessibilityPostNotification(
|
NSAccessibilityPostNotification(
|
||||||
platform_accessibility_, NSAccessibilityUIElementDestroyedNotification);
|
CAST_CEF_NATIVE_ACCESSIBLE_TO_NSOBJECT(platform_accessibility_),
|
||||||
|
NSAccessibilityUIElementDestroyedNotification);
|
||||||
}
|
}
|
||||||
|
|
||||||
delete this;
|
delete this;
|
||||||
@ -488,7 +494,8 @@ void OsrAXNode::Destroy() {
|
|||||||
CefNativeAccessible* OsrAXNode::GetNativeAccessibleObject(
|
CefNativeAccessible* OsrAXNode::GetNativeAccessibleObject(
|
||||||
client::OsrAXNode* parent) {
|
client::OsrAXNode* parent) {
|
||||||
if (!platform_accessibility_) {
|
if (!platform_accessibility_) {
|
||||||
platform_accessibility_ = [OsrAXNodeObject elementWithNode:this];
|
platform_accessibility_ = CAST_NSOBJECT_TO_CEF_NATIVE_ACCESSIBLE(
|
||||||
|
[OsrAXNodeObject elementWithNode:this]);
|
||||||
SetParent(parent);
|
SetParent(parent);
|
||||||
}
|
}
|
||||||
return platform_accessibility_;
|
return platform_accessibility_;
|
||||||
|
@ -17,6 +17,10 @@
|
|||||||
#include "tests/cefclient/browser/image_cache.h"
|
#include "tests/cefclient/browser/image_cache.h"
|
||||||
#include "tests/shared/browser/main_message_loop.h"
|
#include "tests/shared/browser/main_message_loop.h"
|
||||||
|
|
||||||
|
#if defined(OS_MACOSX) && __OBJC__
|
||||||
|
@class NSWindow;
|
||||||
|
#endif // defined(OS_MACOSX) && __OBJC__
|
||||||
|
|
||||||
namespace client {
|
namespace client {
|
||||||
|
|
||||||
// Used to configure how a RootWindow is created.
|
// Used to configure how a RootWindow is created.
|
||||||
@ -117,7 +121,7 @@ class RootWindow
|
|||||||
// called on the main thread.
|
// called on the main thread.
|
||||||
static scoped_refptr<RootWindow> GetForBrowser(int browser_id);
|
static scoped_refptr<RootWindow> GetForBrowser(int browser_id);
|
||||||
|
|
||||||
#if defined(OS_MACOSX)
|
#if defined(OS_MACOSX) && __OBJC__
|
||||||
// Returns the RootWindow associated with the specified |window|. Must be
|
// Returns the RootWindow associated with the specified |window|. Must be
|
||||||
// called on the main thread.
|
// called on the main thread.
|
||||||
static scoped_refptr<RootWindow> GetForNSWindow(NSWindow* window);
|
static scoped_refptr<RootWindow> GetForNSWindow(NSWindow* window);
|
||||||
|
@ -12,18 +12,10 @@
|
|||||||
#include "tests/cefclient/browser/browser_window.h"
|
#include "tests/cefclient/browser/browser_window.h"
|
||||||
#include "tests/cefclient/browser/root_window.h"
|
#include "tests/cefclient/browser/root_window.h"
|
||||||
|
|
||||||
#ifdef __OBJC__
|
|
||||||
@class NSWindow;
|
|
||||||
@class NSButton;
|
|
||||||
@class NSTextField;
|
|
||||||
#else
|
|
||||||
class NSWindow;
|
|
||||||
class NSButton;
|
|
||||||
class NSTextField;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace client {
|
namespace client {
|
||||||
|
|
||||||
|
class RootWindowMacImpl;
|
||||||
|
|
||||||
// OS X implementation of a top-level native window in the browser process.
|
// OS X implementation of a top-level native window in the browser process.
|
||||||
// The methods of this class must be called on the main thread unless otherwise
|
// The methods of this class must be called on the main thread unless otherwise
|
||||||
// indicated.
|
// indicated.
|
||||||
@ -33,6 +25,9 @@ class RootWindowMac : public RootWindow, public BrowserWindow::Delegate {
|
|||||||
RootWindowMac();
|
RootWindowMac();
|
||||||
~RootWindowMac();
|
~RootWindowMac();
|
||||||
|
|
||||||
|
BrowserWindow* browser_window() const;
|
||||||
|
RootWindow::Delegate* delegate() const;
|
||||||
|
|
||||||
// RootWindow methods.
|
// RootWindow methods.
|
||||||
void Init(RootWindow::Delegate* delegate,
|
void Init(RootWindow::Delegate* delegate,
|
||||||
const RootWindowConfig& config,
|
const RootWindowConfig& config,
|
||||||
@ -55,18 +50,6 @@ class RootWindowMac : public RootWindow, public BrowserWindow::Delegate {
|
|||||||
bool WithWindowlessRendering() const OVERRIDE;
|
bool WithWindowlessRendering() const OVERRIDE;
|
||||||
bool WithExtension() const OVERRIDE;
|
bool WithExtension() const OVERRIDE;
|
||||||
|
|
||||||
// Called by RootWindowDelegate after the associated NSWindow has been
|
|
||||||
// destroyed.
|
|
||||||
void WindowDestroyed();
|
|
||||||
|
|
||||||
BrowserWindow* browser_window() const { return browser_window_.get(); }
|
|
||||||
RootWindow::Delegate* delegate() const { return delegate_; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
void CreateBrowserWindow(const std::string& startup_url);
|
|
||||||
void CreateRootWindow(const CefBrowserSettings& settings,
|
|
||||||
bool initially_hidden);
|
|
||||||
|
|
||||||
// BrowserWindow::Delegate methods.
|
// BrowserWindow::Delegate methods.
|
||||||
void OnBrowserCreated(CefRefPtr<CefBrowser> browser) OVERRIDE;
|
void OnBrowserCreated(CefRefPtr<CefBrowser> browser) OVERRIDE;
|
||||||
void OnBrowserWindowDestroyed() OVERRIDE;
|
void OnBrowserWindowDestroyed() OVERRIDE;
|
||||||
@ -80,34 +63,14 @@ class RootWindowMac : public RootWindow, public BrowserWindow::Delegate {
|
|||||||
void OnSetDraggableRegions(
|
void OnSetDraggableRegions(
|
||||||
const std::vector<CefDraggableRegion>& regions) OVERRIDE;
|
const std::vector<CefDraggableRegion>& regions) OVERRIDE;
|
||||||
|
|
||||||
void NotifyDestroyedIfDone();
|
void OnNativeWindowClosed();
|
||||||
|
|
||||||
// After initialization all members are only accessed on the main thread.
|
private:
|
||||||
// Members set during initialization.
|
CefRefPtr<RootWindowMacImpl> impl_;
|
||||||
bool with_controls_;
|
|
||||||
bool with_osr_;
|
|
||||||
bool with_extension_;
|
|
||||||
bool is_popup_;
|
|
||||||
CefRect start_rect_;
|
|
||||||
scoped_ptr<BrowserWindow> browser_window_;
|
|
||||||
bool initialized_;
|
|
||||||
|
|
||||||
// Main window.
|
|
||||||
NSWindow* window_;
|
|
||||||
|
|
||||||
// Buttons.
|
|
||||||
NSButton* back_button_;
|
|
||||||
NSButton* forward_button_;
|
|
||||||
NSButton* reload_button_;
|
|
||||||
NSButton* stop_button_;
|
|
||||||
|
|
||||||
// URL text field.
|
|
||||||
NSTextField* url_textfield_;
|
|
||||||
|
|
||||||
bool window_destroyed_;
|
|
||||||
bool browser_destroyed_;
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(RootWindowMac);
|
DISALLOW_COPY_AND_ASSIGN(RootWindowMac);
|
||||||
|
|
||||||
|
friend class RootWindowMacImpl;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace client
|
} // namespace client
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -10,6 +10,8 @@
|
|||||||
|
|
||||||
namespace client {
|
namespace client {
|
||||||
|
|
||||||
|
class TempWindowMacImpl;
|
||||||
|
|
||||||
// Represents a singleton hidden window that acts as a temporary parent for
|
// Represents a singleton hidden window that acts as a temporary parent for
|
||||||
// popup browsers. Only accessed on the UI thread.
|
// popup browsers. Only accessed on the UI thread.
|
||||||
class TempWindowMac {
|
class TempWindowMac {
|
||||||
@ -26,7 +28,7 @@ class TempWindowMac {
|
|||||||
TempWindowMac();
|
TempWindowMac();
|
||||||
~TempWindowMac();
|
~TempWindowMac();
|
||||||
|
|
||||||
NSWindow* window_;
|
scoped_ptr<TempWindowMacImpl> impl_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(TempWindowMac);
|
DISALLOW_COPY_AND_ASSIGN(TempWindowMac);
|
||||||
};
|
};
|
||||||
|
@ -17,29 +17,43 @@ TempWindowMac* g_temp_window = NULL;
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
TempWindowMac::TempWindowMac() : window_(nil) {
|
class TempWindowMacImpl {
|
||||||
DCHECK(!g_temp_window);
|
public:
|
||||||
g_temp_window = this;
|
TempWindowMacImpl() {
|
||||||
|
// Create a borderless non-visible 1x1 window.
|
||||||
|
window_ = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 1, 1)
|
||||||
|
styleMask:NSBorderlessWindowMask
|
||||||
|
backing:NSBackingStoreBuffered
|
||||||
|
defer:NO];
|
||||||
|
CHECK(window_);
|
||||||
|
}
|
||||||
|
~TempWindowMacImpl() {
|
||||||
|
DCHECK(window_);
|
||||||
|
[window_ close];
|
||||||
|
}
|
||||||
|
|
||||||
// Create a borderless non-visible 1x1 window.
|
private:
|
||||||
window_ = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 1, 1)
|
NSWindow* window_;
|
||||||
styleMask:NSBorderlessWindowMask
|
|
||||||
backing:NSBackingStoreBuffered
|
friend class TempWindowMac;
|
||||||
defer:NO];
|
};
|
||||||
CHECK(window_);
|
|
||||||
|
TempWindowMac::TempWindowMac() {
|
||||||
|
DCHECK(!g_temp_window);
|
||||||
|
impl_.reset(new TempWindowMacImpl);
|
||||||
|
g_temp_window = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
TempWindowMac::~TempWindowMac() {
|
TempWindowMac::~TempWindowMac() {
|
||||||
|
impl_.reset();
|
||||||
g_temp_window = NULL;
|
g_temp_window = NULL;
|
||||||
DCHECK(window_);
|
|
||||||
|
|
||||||
[window_ close];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
CefWindowHandle TempWindowMac::GetWindowHandle() {
|
CefWindowHandle TempWindowMac::GetWindowHandle() {
|
||||||
DCHECK(g_temp_window);
|
DCHECK(g_temp_window);
|
||||||
return [g_temp_window->window_ contentView];
|
return CAST_NSVIEW_TO_CEF_WINDOW_HANDLE(
|
||||||
|
g_temp_window->impl_->window_.contentView);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace client
|
} // namespace client
|
||||||
|
@ -15,7 +15,8 @@ namespace window_test {
|
|||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
NSWindow* GetWindow(CefRefPtr<CefBrowser> browser) {
|
NSWindow* GetWindow(CefRefPtr<CefBrowser> browser) {
|
||||||
NSView* view = (NSView*)browser->GetHost()->GetWindowHandle();
|
NSView* view =
|
||||||
|
CAST_CEF_WINDOW_HANDLE_TO_NSVIEW(browser->GetHost()->GetWindowHandle());
|
||||||
return [view window];
|
return [view window];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -355,71 +355,77 @@ int RunMain(int argc, char* argv[]) {
|
|||||||
if (!library_loader.LoadInMain())
|
if (!library_loader.LoadInMain())
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
int result = -1;
|
||||||
|
|
||||||
CefMainArgs main_args(argc, argv);
|
CefMainArgs main_args(argc, argv);
|
||||||
|
|
||||||
// Initialize the AutoRelease pool.
|
@autoreleasepool {
|
||||||
NSAutoreleasePool* autopool = [[NSAutoreleasePool alloc] init];
|
// Initialize the ClientApplication instance.
|
||||||
|
[ClientApplication sharedApplication];
|
||||||
|
|
||||||
// Initialize the ClientApplication instance.
|
// Parse command-line arguments.
|
||||||
[ClientApplication sharedApplication];
|
CefRefPtr<CefCommandLine> command_line =
|
||||||
|
CefCommandLine::CreateCommandLine();
|
||||||
|
command_line->InitFromArgv(argc, argv);
|
||||||
|
|
||||||
// Parse command-line arguments.
|
// Create a ClientApp of the correct type.
|
||||||
CefRefPtr<CefCommandLine> command_line = CefCommandLine::CreateCommandLine();
|
CefRefPtr<CefApp> app;
|
||||||
command_line->InitFromArgv(argc, argv);
|
ClientApp::ProcessType process_type =
|
||||||
|
ClientApp::GetProcessType(command_line);
|
||||||
|
if (process_type == ClientApp::BrowserProcess)
|
||||||
|
app = new ClientAppBrowser();
|
||||||
|
|
||||||
// Create a ClientApp of the correct type.
|
// Create the main context object.
|
||||||
CefRefPtr<CefApp> app;
|
scoped_ptr<MainContextImpl> context(
|
||||||
ClientApp::ProcessType process_type = ClientApp::GetProcessType(command_line);
|
new MainContextImpl(command_line, true));
|
||||||
if (process_type == ClientApp::BrowserProcess)
|
|
||||||
app = new ClientAppBrowser();
|
|
||||||
|
|
||||||
// Create the main context object.
|
CefSettings settings;
|
||||||
scoped_ptr<MainContextImpl> context(new MainContextImpl(command_line, true));
|
|
||||||
|
|
||||||
CefSettings settings;
|
|
||||||
|
|
||||||
// When generating projects with CMake the CEF_USE_SANDBOX value will be defined
|
// When generating projects with CMake the CEF_USE_SANDBOX value will be defined
|
||||||
// automatically. Pass -DUSE_SANDBOX=OFF to the CMake command-line to disable
|
// automatically. Pass -DUSE_SANDBOX=OFF to the CMake command-line to disable
|
||||||
// use of the sandbox.
|
// use of the sandbox.
|
||||||
#if !defined(CEF_USE_SANDBOX)
|
#if !defined(CEF_USE_SANDBOX)
|
||||||
settings.no_sandbox = true;
|
settings.no_sandbox = true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Populate the settings based on command line arguments.
|
// Populate the settings based on command line arguments.
|
||||||
context->PopulateSettings(&settings);
|
context->PopulateSettings(&settings);
|
||||||
|
|
||||||
// Create the main message loop object.
|
// Create the main message loop object.
|
||||||
scoped_ptr<MainMessageLoop> message_loop;
|
scoped_ptr<MainMessageLoop> message_loop;
|
||||||
if (settings.external_message_pump)
|
if (settings.external_message_pump)
|
||||||
message_loop = MainMessageLoopExternalPump::Create();
|
message_loop = MainMessageLoopExternalPump::Create();
|
||||||
else
|
else
|
||||||
message_loop.reset(new MainMessageLoopStd);
|
message_loop.reset(new MainMessageLoopStd);
|
||||||
|
|
||||||
// Initialize CEF.
|
// Initialize CEF.
|
||||||
context->Initialize(main_args, settings, app, NULL);
|
context->Initialize(main_args, settings, app, NULL);
|
||||||
|
|
||||||
// Register scheme handlers.
|
// Register scheme handlers.
|
||||||
test_runner::RegisterSchemeHandlers();
|
test_runner::RegisterSchemeHandlers();
|
||||||
|
|
||||||
// Create the application delegate and window.
|
// Create the application delegate and window.
|
||||||
ClientAppDelegate* delegate = [[ClientAppDelegate alloc]
|
ClientAppDelegate* delegate = [[ClientAppDelegate alloc]
|
||||||
initWithControls:!command_line->HasSwitch(switches::kHideControls)
|
initWithControls:!command_line->HasSwitch(switches::kHideControls)
|
||||||
andOsr:settings.windowless_rendering_enabled ? true : false];
|
andOsr:settings.windowless_rendering_enabled ? true : false];
|
||||||
[delegate performSelectorOnMainThread:@selector(createApplication:)
|
[delegate performSelectorOnMainThread:@selector(createApplication:)
|
||||||
withObject:nil
|
withObject:nil
|
||||||
waitUntilDone:NO];
|
waitUntilDone:NO];
|
||||||
|
|
||||||
// Run the message loop. This will block until Quit() is called.
|
// Run the message loop. This will block until Quit() is called.
|
||||||
int result = message_loop->Run();
|
result = message_loop->Run();
|
||||||
|
|
||||||
// Shut down CEF.
|
// Shut down CEF.
|
||||||
context->Shutdown();
|
context->Shutdown();
|
||||||
|
|
||||||
// Release objects in reverse order of creation.
|
// Release objects in reverse order of creation.
|
||||||
[delegate release];
|
#if !__has_feature(objc_arc)
|
||||||
message_loop.reset();
|
[delegate release];
|
||||||
context.reset();
|
#endif // !__has_feature(objc_arc)
|
||||||
[autopool release];
|
delegate = nil;
|
||||||
|
message_loop.reset();
|
||||||
|
context.reset();
|
||||||
|
} // @autoreleasepool
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -87,6 +87,16 @@ endif()
|
|||||||
#
|
#
|
||||||
|
|
||||||
if(OS_MACOSX)
|
if(OS_MACOSX)
|
||||||
|
option(OPTION_USE_ARC "Build with ARC (automatic Reference Counting) on macOS." ON)
|
||||||
|
if(OPTION_USE_ARC)
|
||||||
|
list(APPEND CEF_COMPILER_FLAGS
|
||||||
|
-fobjc-arc
|
||||||
|
)
|
||||||
|
set_target_properties(${target} PROPERTIES
|
||||||
|
CLANG_ENABLE_OBJC_ARC "YES"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Output paths for the app bundles.
|
# Output paths for the app bundles.
|
||||||
set(CEF_APP "${CEF_TARGET_OUT_DIR}/${CEF_TARGET}.app")
|
set(CEF_APP "${CEF_TARGET_OUT_DIR}/${CEF_TARGET}.app")
|
||||||
set(CEF_HELPER_APP "${CEF_TARGET_OUT_DIR}/${CEF_HELPER_OUTPUT_NAME}.app")
|
set(CEF_HELPER_APP "${CEF_TARGET_OUT_DIR}/${CEF_HELPER_OUTPUT_NAME}.app")
|
||||||
|
@ -12,13 +12,13 @@
|
|||||||
#include "tests/cefsimple/simple_handler.h"
|
#include "tests/cefsimple/simple_handler.h"
|
||||||
|
|
||||||
// Receives notifications from the application.
|
// Receives notifications from the application.
|
||||||
@interface SimpleAppDelegate : NSObject<NSApplicationDelegate>
|
@interface SimpleAppDelegate : NSObject <NSApplicationDelegate>
|
||||||
- (void)createApplication:(id)object;
|
- (void)createApplication:(id)object;
|
||||||
- (void)tryToTerminateApplication:(NSApplication*)app;
|
- (void)tryToTerminateApplication:(NSApplication*)app;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
// Provide the CefAppProtocol implementation required by CEF.
|
// Provide the CefAppProtocol implementation required by CEF.
|
||||||
@interface SimpleApplication : NSApplication<CefAppProtocol> {
|
@interface SimpleApplication : NSApplication <CefAppProtocol> {
|
||||||
@private
|
@private
|
||||||
BOOL handlingSendEvent_;
|
BOOL handlingSendEvent_;
|
||||||
}
|
}
|
||||||
@ -119,48 +119,47 @@ int main(int argc, char* argv[]) {
|
|||||||
// Provide CEF with command-line arguments.
|
// Provide CEF with command-line arguments.
|
||||||
CefMainArgs main_args(argc, argv);
|
CefMainArgs main_args(argc, argv);
|
||||||
|
|
||||||
// Initialize the AutoRelease pool.
|
@autoreleasepool {
|
||||||
NSAutoreleasePool* autopool = [[NSAutoreleasePool alloc] init];
|
// Initialize the SimpleApplication instance.
|
||||||
|
[SimpleApplication sharedApplication];
|
||||||
|
|
||||||
// Initialize the SimpleApplication instance.
|
// Specify CEF global settings here.
|
||||||
[SimpleApplication sharedApplication];
|
CefSettings settings;
|
||||||
|
|
||||||
// Specify CEF global settings here.
|
// When generating projects with CMake the CEF_USE_SANDBOX value will be
|
||||||
CefSettings settings;
|
// defined automatically. Pass -DUSE_SANDBOX=OFF to the CMake command-line
|
||||||
|
// to disable use of the sandbox.
|
||||||
// When generating projects with CMake the CEF_USE_SANDBOX value will be defined
|
|
||||||
// automatically. Pass -DUSE_SANDBOX=OFF to the CMake command-line to disable
|
|
||||||
// use of the sandbox.
|
|
||||||
#if !defined(CEF_USE_SANDBOX)
|
#if !defined(CEF_USE_SANDBOX)
|
||||||
settings.no_sandbox = true;
|
settings.no_sandbox = true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// SimpleApp implements application-level callbacks for the browser process.
|
// SimpleApp implements application-level callbacks for the browser process.
|
||||||
// It will create the first browser instance in OnContextInitialized() after
|
// It will create the first browser instance in OnContextInitialized() after
|
||||||
// CEF has initialized.
|
// CEF has initialized.
|
||||||
CefRefPtr<SimpleApp> app(new SimpleApp);
|
CefRefPtr<SimpleApp> app(new SimpleApp);
|
||||||
|
|
||||||
// Initialize CEF for the browser process.
|
// Initialize CEF for the browser process.
|
||||||
CefInitialize(main_args, settings, app.get(), NULL);
|
CefInitialize(main_args, settings, app.get(), NULL);
|
||||||
|
|
||||||
// Create the application delegate.
|
// Create the application delegate.
|
||||||
NSObject* delegate = [[SimpleAppDelegate alloc] init];
|
NSObject* delegate = [[SimpleAppDelegate alloc] init];
|
||||||
[delegate performSelectorOnMainThread:@selector(createApplication:)
|
[delegate performSelectorOnMainThread:@selector(createApplication:)
|
||||||
withObject:nil
|
withObject:nil
|
||||||
waitUntilDone:NO];
|
waitUntilDone:NO];
|
||||||
|
|
||||||
// Run the CEF message loop. This will block until CefQuitMessageLoop() is
|
// Run the CEF message loop. This will block until CefQuitMessageLoop() is
|
||||||
// called.
|
// called.
|
||||||
CefRunMessageLoop();
|
CefRunMessageLoop();
|
||||||
|
|
||||||
// Shut down CEF.
|
// Shut down CEF.
|
||||||
CefShutdown();
|
CefShutdown();
|
||||||
|
|
||||||
// Release the delegate.
|
// Release the delegate.
|
||||||
[delegate release];
|
#if !__has_feature(objc_arc)
|
||||||
|
[delegate release];
|
||||||
// Release the AutoRelease pool.
|
#endif // !__has_feature(objc_arc)
|
||||||
[autopool release];
|
delegate = nil;
|
||||||
|
} // @autoreleasepool
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,8 @@
|
|||||||
|
|
||||||
void SimpleHandler::PlatformTitleChange(CefRefPtr<CefBrowser> browser,
|
void SimpleHandler::PlatformTitleChange(CefRefPtr<CefBrowser> browser,
|
||||||
const CefString& title) {
|
const CefString& title) {
|
||||||
NSView* view = (NSView*)browser->GetHost()->GetWindowHandle();
|
NSView* view =
|
||||||
|
CAST_CEF_WINDOW_HANDLE_TO_NSVIEW(browser->GetHost()->GetWindowHandle());
|
||||||
NSWindow* window = [view window];
|
NSWindow* window = [view window];
|
||||||
std::string titleStr(title);
|
std::string titleStr(title);
|
||||||
NSString* str = [NSString stringWithUTF8String:titleStr.c_str()];
|
NSString* str = [NSString stringWithUTF8String:titleStr.c_str()];
|
||||||
|
@ -12,7 +12,7 @@ CefWindowHandle GetFakeView() {
|
|||||||
NSScreen* mainScreen = [NSScreen mainScreen];
|
NSScreen* mainScreen = [NSScreen mainScreen];
|
||||||
NSRect screenRect = [mainScreen visibleFrame];
|
NSRect screenRect = [mainScreen visibleFrame];
|
||||||
NSView* fakeView = [[NSView alloc] initWithFrame:screenRect];
|
NSView* fakeView = [[NSView alloc] initWithFrame:screenRect];
|
||||||
return fakeView;
|
return CAST_NSVIEW_TO_CEF_WINDOW_HANDLE(fakeView);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace osr_unittests
|
} // namespace osr_unittests
|
||||||
|
@ -82,14 +82,21 @@ class MainMessageLoopExternalPumpMac : public MainMessageLoopExternalPump {
|
|||||||
namespace client {
|
namespace client {
|
||||||
|
|
||||||
MainMessageLoopExternalPumpMac::MainMessageLoopExternalPumpMac()
|
MainMessageLoopExternalPumpMac::MainMessageLoopExternalPumpMac()
|
||||||
: owner_thread_([[NSThread currentThread] retain]), timer_(nil) {
|
: owner_thread_([NSThread currentThread]), timer_(nil) {
|
||||||
event_handler_ = [[[EventHandler alloc] initWithPump:this] retain];
|
#if !__has_feature(objc_arc)
|
||||||
|
[owner_thread_ retain];
|
||||||
|
#endif // !__has_feature(objc_arc)
|
||||||
|
event_handler_ = [[EventHandler alloc] initWithPump:this];
|
||||||
}
|
}
|
||||||
|
|
||||||
MainMessageLoopExternalPumpMac::~MainMessageLoopExternalPumpMac() {
|
MainMessageLoopExternalPumpMac::~MainMessageLoopExternalPumpMac() {
|
||||||
KillTimer();
|
KillTimer();
|
||||||
|
#if !__has_feature(objc_arc)
|
||||||
[owner_thread_ release];
|
[owner_thread_ release];
|
||||||
[event_handler_ release];
|
[event_handler_ release];
|
||||||
|
#endif // !__has_feature(objc_arc)
|
||||||
|
owner_thread_ = nil;
|
||||||
|
event_handler_ = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainMessageLoopExternalPumpMac::Quit() {
|
void MainMessageLoopExternalPumpMac::Quit() {
|
||||||
@ -140,11 +147,14 @@ void MainMessageLoopExternalPumpMac::SetTimer(int64 delay_ms) {
|
|||||||
DCHECK(!timer_);
|
DCHECK(!timer_);
|
||||||
|
|
||||||
const double delay_s = static_cast<double>(delay_ms) / 1000.0;
|
const double delay_s = static_cast<double>(delay_ms) / 1000.0;
|
||||||
timer_ = [[NSTimer timerWithTimeInterval:delay_s
|
timer_ = [NSTimer timerWithTimeInterval:delay_s
|
||||||
target:event_handler_
|
target:event_handler_
|
||||||
selector:@selector(timerTimeout:)
|
selector:@selector(timerTimeout:)
|
||||||
userInfo:nil
|
userInfo:nil
|
||||||
repeats:NO] retain];
|
repeats:NO];
|
||||||
|
#if !__has_feature(objc_arc)
|
||||||
|
[timer_ retain];
|
||||||
|
#endif // !__has_feature(objc_arc)
|
||||||
|
|
||||||
// Add the timer to default and tracking runloop modes.
|
// Add the timer to default and tracking runloop modes.
|
||||||
NSRunLoop* owner_runloop = [NSRunLoop currentRunLoop];
|
NSRunLoop* owner_runloop = [NSRunLoop currentRunLoop];
|
||||||
@ -155,7 +165,9 @@ void MainMessageLoopExternalPumpMac::SetTimer(int64 delay_ms) {
|
|||||||
void MainMessageLoopExternalPumpMac::KillTimer() {
|
void MainMessageLoopExternalPumpMac::KillTimer() {
|
||||||
if (timer_ != nil) {
|
if (timer_ != nil) {
|
||||||
[timer_ invalidate];
|
[timer_ invalidate];
|
||||||
|
#if !__has_feature(objc_arc)
|
||||||
[timer_ release];
|
[timer_ release];
|
||||||
|
#endif // !__has_feature(objc_arc)
|
||||||
timer_ = nil;
|
timer_ = nil;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user