]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/webview_webkit.mm
Add wxTimer::StartOnce().
[wxWidgets.git] / src / osx / webview_webkit.mm
index 018dacf3f59592ef9d12e8376bffa9d983c6c3f3..1609dfd59a388f83fd47f00e2939adb153256882 100644 (file)
@@ -909,16 +909,16 @@ wxString wxWebViewWebKit::GetSelectedSource() const
                        "var element = document.createElement('div');"
                        "element.appendChild(range.cloneContents());"
                        "return element.innerHTML;");
                        "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
 {
 }
 
 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)
 }
 
 void wxWebViewWebKit::EnableHistory(bool enable)
@@ -1291,9 +1291,23 @@ wxString nsErrorToWxHtmlError(NSError* error, wxWebViewNavigationError* out)
     NSURLRequest *request = [self request];
        NSString* path = [[request URL] absoluteString];
 
     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);
     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();
 
 
     size_t length = file->GetStream()->GetLength();
 
 
@@ -1307,8 +1321,6 @@ wxString nsErrorToWxHtmlError(NSError* error, wxWebViewNavigationError* out)
     file->GetStream()->Read(buffer, length);
     NSData *data = [[NSData alloc] initWithBytesNoCopy:buffer length:length];
 
     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];
     //We do not support caching anything yet
        [client URLProtocol:self didReceiveResponse:response
             cacheStoragePolicy:NSURLCacheStorageNotAllowed];