"var element = document.createElement('div');"
"element.appendChild(range.cloneContents());"
"return element.innerHTML;");
- id result = [[m_webView windowScriptObject]
- evaluateWebScript:wxNSStringWithWxString(script)];
- return wxStringWithNSString([result stringValue]);
+ NSString *result = [m_webView stringByEvaluatingJavaScriptFromString:
+ wxNSStringWithWxString(script)];
+ return wxStringWithNSString(result);
}
wxString wxWebViewWebKit::GetPageText() const
{
- id result = [[m_webView windowScriptObject]
- evaluateWebScript:@"document.body.textContent"];
- return wxStringWithNSString([result stringValue]);
+ NSString *result = [m_webView stringByEvaluatingJavaScriptFromString:
+ @"document.body.textContent"];
+ return wxStringWithNSString(result);
}
void wxWebViewWebKit::EnableHistory(bool enable)
if (webKitWindow && frame == [sender mainFrame]){
NSString *url = [[[[frame dataSource] request] URL] absoluteString];
wxString target = wxStringWithNSString([frame name]);
- wxWebViewEvent event(wxEVT_COMMAND_WEBVIEW_NAVIGATED,
+ wxWebViewEvent event(wxEVT_WEBVIEW_NAVIGATED,
webKitWindow->GetId(),
wxStringWithNSString( url ),
target);
NSString *url = [[[[frame dataSource] request] URL] absoluteString];
wxString target = wxStringWithNSString([frame name]);
- wxWebViewEvent event(wxEVT_COMMAND_WEBVIEW_LOADED,
+ wxWebViewEvent event(wxEVT_WEBVIEW_LOADED,
webKitWindow->GetId(),
wxStringWithNSString( url ),
target);
wxWebViewNavigationError type;
wxString description = nsErrorToWxHtmlError(error, &type);
- wxWebViewEvent event(wxEVT_COMMAND_WEBVIEW_ERROR,
+ wxWebViewEvent event(wxEVT_WEBVIEW_ERROR,
webKitWindow->GetId(),
wxStringWithNSString( url ),
wxEmptyString);
wxWebViewNavigationError type;
wxString description = nsErrorToWxHtmlError(error, &type);
- wxWebViewEvent event(wxEVT_COMMAND_WEBVIEW_ERROR,
+ wxWebViewEvent event(wxEVT_WEBVIEW_ERROR,
webKitWindow->GetId(),
wxStringWithNSString( url ),
wxEmptyString);
forFrame:(WebFrame *)frame
{
wxString target = wxStringWithNSString([frame name]);
- wxWebViewEvent event(wxEVT_COMMAND_WEBVIEW_TITLE_CHANGED,
+ wxWebViewEvent event(wxEVT_WEBVIEW_TITLE_CHANGED,
webKitWindow->GetId(),
webKitWindow->GetCurrentURL(),
target);
webKitWindow->m_busy = true;
NSString *url = [[request URL] absoluteString];
wxString target = wxStringWithNSString([frame name]);
- wxWebViewEvent event(wxEVT_COMMAND_WEBVIEW_NAVIGATING,
+ wxWebViewEvent event(wxEVT_WEBVIEW_NAVIGATING,
webKitWindow->GetId(),
wxStringWithNSString( url ), target);
wxUnusedVar(actionInformation);
NSString *url = [[request URL] absoluteString];
- wxWebViewEvent event(wxEVT_COMMAND_WEBVIEW_NEWWINDOW,
+ wxWebViewEvent event(wxEVT_WEBVIEW_NEWWINDOW,
webKitWindow->GetId(),
wxStringWithNSString( url ), "");
NSURLRequest *request = [self request];
NSString* path = [[request URL] absoluteString];
+ id<NSURLProtocolClient> client = [self client];
+
wxString wxpath = wxStringWithNSString(path);
wxString scheme = wxStringWithNSString([[request URL] scheme]);
wxFSFile* file = g_stringHandlerMap[scheme]->GetFile(wxpath);
+
+ if (!file)
+ {
+ NSError *error = [[NSError alloc] initWithDomain:NSURLErrorDomain
+ code:NSURLErrorFileDoesNotExist
+ userInfo:nil];
+
+ [client URLProtocol:self didFailWithError:error];
+
+ return;
+ }
+
size_t length = file->GetStream()->GetLength();
file->GetStream()->Read(buffer, length);
NSData *data = [[NSData alloc] initWithBytesNoCopy:buffer length:length];
- id<NSURLProtocolClient> client = [self client];
-
//We do not support caching anything yet
[client URLProtocol:self didReceiveResponse:response
cacheStoragePolicy:NSURLCacheStorageNotAllowed];