[[PageOutline]] = Hacker's guide to WebKit/GTK+ = Check out the project web site: [http://webkitgtk.org/] == Code layout == The GTK+ port targets the cross-platform GLib and GTK+ APIs as well as related libraries. This means that it can be built against any of the windowing systems supported by GTK+ and Cairo without modification -- those tested so far are X11 and DirectFB. Windows should work too. Code specific to any one backend should be conditionally compiled only when that windowing system is available. One examples of this kind of feature might be direct X11/Win32 use for plugin support. This can be done at configure time or with a switch passed to the build system, or even just using the definitions provided by the gdk headers. === Main port components === * [http://trac.webkit.org/projects/webkit/browser/trunk/JavaScriptCore/wtf/gobject JavaScriptCore/wtf/gobject]: GObject helpers for WTF * [http://trac.webkit.org/projects/webkit/browser/trunk/JavaScriptCore/wtf/gtk JavaScriptCore/wtf/gtk]: GTK+ helpers for WTF * [http://trac.webkit.org/projects/webkit/browser/trunk/WebCore/platform/gtk WebCore/platform/gtk]: GTK+-specific theme rendering, events, clipboard access, etc * [http://trac.webkit.org/projects/webkit/browser/trunk/WebCore/platform/graphics/gtk WebCore/platform/graphics/gtk] and [http://trac.webkit.org/projects/webkit/browser/trunk/WebCore/platform/graphics/cairo WebCore/platform/graphics/cairo]: Cairo and GTK+-specific graphics context, images, fonts, etc * [http://trac.webkit.org/projects/webkit/browser/trunk/WebCore/page/gtk WebCore/page/gtk]: GTK+-specific code for the "page" subdirectory * [http://trac.webkit.org/projects/webkit/browser/trunk/WebCore/platform/network/soup WebCore/platform/network/soup]: The libsoup networking layer * [http://trac.webkit.org/projects/webkit/browser/trunk/WebKit/gtk WebKit/gtk]: WebKit GTK+ * [http://trac.webkit.org/browser/trunk/WebKit/gtk/webkit webkit] Public API implementation and headers files * [http://trac.webkit.org/projects/webkit/browser/trunk/WebKit/gtk/WebCoreSupport WebCoreSupport]: GTK+-specific glue layer between WebKit and WebCore * [http://trac.webkit.org/projects/webkit/browser/trunk/WebKit/gtk/docs docs]: API documentation * [http://trac.webkit.org/projects/webkit/browser/trunk/WebKit/gtk/tests tests]: API functional and unit tests * [http://trac.webkit.org/projects/webkit/browser/trunk/WebKit/gtk/po po]: String localization * [http://trac.webkit.org/projects/webkit/browser/trunk/Tools/GtkLauncher Tools/GtkLauncher]: Barebones example application === Shared code modules === While the GTK+ port is the primary consumer of these backends, we aim to keep them portable, avoiding even ifdef'd sections specific to the Gtk+ port: * [http://trac.webkit.org/projects/webkit/browser/trunk/JavaScriptCore/wtf/gobject JavaScriptCore/wtf/gobject] * [http://trac.webkit.org/projects/webkit/browser/trunk/WebCore/platform/network/soup WebCore/platform/network/soup] * [http://trac.webkit.org/projects/webkit/browser/trunk/WebCore/platform/graphics/cairo WebCore/platform/graphics/cairo] * [http://trac.webkit.org/projects/webkit/browser/trunk/WebCore/platform/graphics/gtk/MediaPlayerPrivateGStreamer.cpp WebCore/platform/graphics/gtk/MediaPlayerPrivateGStreamer.cpp] (''has small dependencies on GTK+/Cairo that can be easily abstracted if other ports want to share the GStreamer backend'') === Bundled code modules === Bundled code is code checked into WebKit SVN that is developed and maintained primarily in some other source code repository. * Don't change the coding style of bundled code to match the WebKit guidelines * Avoid making needless changes to bundled code * Don't change the copyright headers without permission * Contribute modifications back to the originating project promptly where relevant There isn't much bundled code at the moment, since we now use the Cairo, libpng, libjpeg etc. versions installed on the user's system. These files are bundled from other projects: * RenderThemeGtk backend (from Mozilla) * [http://trac.webkit.org/projects/webkit/browser/trunk/WebCore/platform/gtk/gtk2drawing.c WebCore/platform/gtk/gtk2drawing.c] [http://bonsai.mozilla.org/cvslog.cgi?file=mozilla/widget/src/gtk2/gtk2drawing.c&rev=HEAD remote] * [http://trac.webkit.org/projects/webkit/browser/trunk/WebCore/platform/gtk/gtkdrawing.h WebCore/platform/gtk/gtkdrawing.h] [http://bonsai.mozilla.org/cvslog.cgi?file=mozilla/widget/src/gtk2/gtkdrawing.h&rev=HEAD remote] * Plugin support (from Mozilla) * [http://trac.webkit.org/browser/trunk/WebCore/plugins/gtk WebCore/plugins/gtk]: gtk2xtbin.c, gtk2xtbin.h, xembed.h == Working on WebCore == * The GTK+ elements of WebCore follow the WebKit coding style. * There is no API stability in this layer. If an abstraction does not fit GTK+/Cairo/GStreamer/Libsoup concepts, feel free to seek advice on how to generalise the abstraction layer. This should not be necessary too often though. * Documentation is generally avoided in favour of clear, self-explanatory code and good variable names. == Working on the public API == * Follow the precedent set by the Mac and Win ports. There is [http://developer.apple.com/documentation/Cocoa/Reference/WebKit/ObjC_classic/index.html Mac API documentation] available for reference. * Document new additions with [http://live.gnome.org/DocumentationProject/GtkDoc GtkDoc]. It is OK to base GTK+ API documentation on the Objective-C documentation, but remember that "the receiver" will be "@this" or similar in GTK+ terminology, and a "method" translates to a "function" etc. * If you find mistakes in the Objective-C API documentation, take notes and add them in the comments of your bug report. * Check function parameters with g_return_if_fail() and g_return_val_if_fail() * Don't use the abbreviation "URL" or "url" in any public API headers or documentation. Instead, use "URI" or "uri". This is a strong convention in GLib/GTK+ which deviates from the one used in WebCore and other WebKit ports. * Recommendation: Internally, relevant gchar* variables to be passed to or from the user should also be named "uri" until parsed into a KURL or WebCore data structure, at which point they should be called "url". * Try to implement several functions at the same time to get a better understanding of how they work together and to improve consistency. This is more effective than just implementing functions and signals one by one as needed. * Avoid drawing inspiration from ports other than Mac and Win, since they might have decided to follow their own interpretation. This is like going for the primary sources in a research project. * If a method looks strange or out of place, '''ask questions''' until someone explains why it is the way it is. The Mac port may contain deprecated/bad API that exists only for the sake of compatibility -- we want to learn from those mistakes rather than copying them. * See [wiki:"WebKitGTK/AddingNewWebKit2API" AddingNewWebKit2API] for WebKit2 guidelines == API rationale == The strategy here is to develop a GObject-based interpretation of the Objective-C API combined with experience working with GtkTextView, GtkHtml and gtkmozembed. This allows us to benefit from the maturity of a widely-deployed API, but demands extra caution not to adopt any of the baggage or legacy that might be present for backward compatibility only. The Win port is also a useful resource but is less suitable for direct inspiration since it hasn't been deployed as a stable API yet and has a large API footprint that would be difficult to support in the long term. For more information, check out the [http://webkitgtk.org/reference/webkitgtk/stable/index.html API reference] on the official WebKit GTK+ page. == The build bots == There is a [http://build.webkit.org/ build bot] available for most ports including GTK+. The [http://build.webkit.org/waterfall waterfall view] is particularly useful. This helps keep all the ports buildable. There is also compile output provided which is helpful for understanding the build environments and compiler flags used by other ports and tracking down compiler warnings. == LayoutTests == See [http://trac.webkit.org/wiki/WebKitGtkLayoutTests WebKitGTK+ Layout Tests] == Optimization == See [wiki:"OptimizingGtk" the hacker's guide to optimizing WebKit/GTK+].