tags:

views:

154

answers:

1

I have a simple NSView that hosts a WebView.

When I try to make the view layer backed, the WebView stops rendering content - all it renders are the scroll bars.

For simplicity, I added the following code to the applicationDidFinishLaunching method of the app delegate of a brand new xcode project :-

NSView* view = [window contentView];

[view setWantsLayered:YES]; // This is the problematic line!

WebView* webView = [[WebView alloc] initWithFrame:NSMakeRect(0,0,400,400)];
WebFrame* mainFrame = [webView mainFrame];
[view addSubView:webView];
[mainFrame loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.google.com"]]];

If I leave out setWantsLayered the WebKit renders the web page. If I set it, WebKit just renders a white square with scroll bars.

+2  A: 

Layer backed WebView's aren't supported. From the Leopard release notes:

Most of the standard views and controls that AppKit and Mac OS X's other Cocoa frameworks provide are able to function in layer-backed mode in Leopard, with the exception of certain specialized views such as WebKit WebViews and Quartz Composer QCViews, whose use in layer-backed mode is not presently supported.

(http://developer.apple.com/mac/library/releasenotes/cocoa/AppKitOlderNotes.html#Animation - Last paragraph of the "New View Animation Facilities, and Layer-Backed View Drawing" section)

You should file a bug with Apple and reference rdar://5270371 as found in this mailing list post http://lists.apple.com/archives/Webkitsdk-dev/2007/Dec/msg00042.html.

Matt Lilek