Skip to content

Instantly share code, notes, and snippets.

@alanjrogers
Created April 18, 2012 05:49
Show Gist options
  • Save alanjrogers/2411352 to your computer and use it in GitHub Desktop.
Save alanjrogers/2411352 to your computer and use it in GitHub Desktop.
WebKit crash
// When the dom node is [object HTMLObjectElement]
// element is not a valid object ==> crash
- (void)mouseMoved:(NSEvent *)theEvent {
NSPoint mouseLocation = [self.webView convertPoint:[theEvent locationInWindow] fromView:nil];
mouseLocation.y = [self.webView frame].size.height - mouseLocation.y;
id element2 = [[self.webView windowScriptObject] evaluateWebScript:[NSString stringWithFormat:@"document.elementFromPoint(%f,%f);", mouseLocation.x, mouseLocation.y]];
id element = [[self.webView windowScriptObject] evaluateWebScript:[NSString stringWithFormat:@"\"result: \" + document.elementFromPoint(%f,%f)", mouseLocation.x, mouseLocation.y]];
NSLog(@"element %@, %@", element, element2);
}
@alanjrogers
Copy link
Author

So my theory is that the bridge from JS object to ObjC object is failing for [object HTMLObjectElement]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment