<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">From the description, it sounds like you have some native code which needs to be able to modify the DOM and you need events from the DOM to be able to call code from your library. You can do this today without modifying WebKit.</div><div class=""><br class=""></div><div class="">The way for native code to modify the DOM is for the native code to generate a JavaScript string and submit the string to be run inside the JavaScript context of the page. You can do this in WK1 by JSEvaluateScript(), the WebScriptObject, or by stringByEvaluatingJavaScriptFromString. In WebKit2, WKWebView has a method evaluateJavaScript (Or from C you can run WKPageRunJavaScriptInMainFrame, but this isn’t considered API)</div><div class=""><br class=""></div>You can also use Objective-C DOM bindings to manipulate the DOM directly from native code, this approach is discouraged.<div class=""><br class=""><div class="">One way for DOM events to call code from your library is to create a JavaScript object or method which is backed by native code. Then, the JavaScript event handler can call the functions on this object, which causes your native code to run. This can be done with the functions listed inside Source/JavaScriptCore/API/JSObjectRef.h.</div><div class=""><br class=""></div><div class="">In WebKit2, this native-backed-object can still be made, but it must be done inside the Web process (not the UI process), and therefore must be done with the InjectedBundle. Inside the InjectedBundle, you can run native code in the web process, and there are facilities to send messages between the Web process & UI process. You can find out more if you search for “InjectedBundle” inside Source/WebKit2/UIProcess/API. Note, however, that use of the InjectedBundle is not considered API.</div><div class=""><br class=""></div><div class="">We rely on the above mechanisms heavily in our testing infrastructure. Our Tools/DumpRenderTree and Tools/WebKitTestRunner projects use the techniques described above.</div><div class=""><br class=""></div><div class="">The Windows port currently doesn’t support WebKit2, so you’ll have to use the WebKit1 approach on Windows.</div><div class=""><br class=""></div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jun 1, 2016, at 11:49 AM, Andy Somogyi <<a href="mailto:somogyie@umail.iu.edu" class="">somogyie@umail.iu.edu</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Jun 1, 2016, at 1:37 PM, Myles C. Maxfield <<a href="mailto:mmaxfield@apple.com" class="">mmaxfield@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="content-type" content="text/html; charset=utf-8" class=""><div dir="auto" class=""><div class=""></div><div class="">Replies inline.</div></div></div></blockquote><br class=""><blockquote type="cite" class=""><div class=""><div dir="auto" class=""><div class="">Generating a DOM is usually done in JavaScript. I'm curious about the problem you are trying to solve where JavaScript is not sufficient.</div><div class=""><br class=""></div><div class="">Drawing into an existing window is usually done by inserting a WebView into the view </div></div></div></blockquote></div></div></div></blockquote><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><blockquote type="cite" class=""><div class=""><div dir="auto" class=""><div class="">reallyhierarchy of the window. Yet again, I'm interested in why this is not sufficient.</div></div></div></blockquote><div class=""><br class=""></div><div class="">I have the source code of the new language, and a parser/compiler for it written in C++. I’d hate to have to introduce a new set of languages into the mix. </div><div class=""><br class=""></div><div class=""><div class="">The new programming language is designed to be visually edited, hence the need for hit detection. So, a component may be dragged from one region to another. This would trigger an event which would cause one branch of the AST to be pruned, modified and re-attached to another branch. This in turn would trigger a re-gen of the render tree, and eventually a repaint. I've done something very similar in the past where I created a visual computer algebra system. The entire runtime, including AST are written in C++, and it would be nice to connect it to an existing rendering/layout engine, and be able to respond to user events directly in my C++ code. </div><div class=""><br class=""></div><div class="">I see this as a very dynamic application, and all of the internal logic which is a mix of C and JIT compiled code from the new language needs to interact with both the visual representation, and the physics engine (the Lang is designed for real-time physics simulation). Ideally, I'd like to be able to render a visual representation of a language element to an OpenGL texture, and have this exist in the physics engine. </div><div class=""><br class=""></div><div class="">However, being as the DOM is publicly available from WebKit in C++ (I think they’re all exposed publicly as pure virtual interfaces), it would be relatively straightforward for me to to compile the new language to target the C++ v-table ABI. </div></div><div class=""><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div dir="auto" class=""><blockquote type="cite" class=""><div class=""><div class=""><span class="" style="font-family: Menlo-Regular; font-size: 11px;">Do you think this would be possible using WebCore as a library and have these custom render tree / dom tree derived objects live in my own library (this is really, really the way I’d prefer to do things), or do you think it would be better to add these objects directly into the WebCore library. </span><br class="" style="font-family: Menlo-Regular; font-size: 11px;"><br class="" style="font-family: Menlo-Regular; font-size: 11px;"></div></div></blockquote><div class=""><br class=""></div><div class="">Are you planning on committing any changes to trunk?</div><div class=""><br class=""></div><div class="">Of course it is ::possible:: to do something like this - it's all software. Are you asking if it's easy to do it? Or the best way to do it</div></div></div></blockquote><br class=""></div><div class="">On OSX, I don’t think I’ll have to do any changes at all to WebKit. I’ve got proof of concept working where I create a new RenderElement derived object, and give it a new GraphicsContext. </div><div class=""><br class=""></div><div class="">However, on Windows, the classes I use from WebKit in my own code would need to be exported via the WEBCORE_EXPORT macro, this would need to be added to each class definition in WebKit. I suppose what I could do is write a quick script which adds this macro to each class that I use as part of my build process. That way, I would not have to touch the upstream webkit source at all. </div><br class=""></div></div></blockquote></div><br class=""></div></div></body></html>