WebKit (the precursor of Blink) was designed to be platform-independent, and was successfully ported to many platforms, such as Mac OS and iOS (using Cocoa), Windows, Linux (using GTK), and Android. Chromium was also designed to be ported to multiple platforms, and adds another platform-independent layer on top of the Blink rendering engine, called the content module. So, from the WebKit code perspective, Blink sits on top of a single platform, called “chromium”.
public/contains the header files makeing up the API between Blink and Chromium’s content layer.
Sourcecontains the actual Blink source code.
LayoutTestshas automated tests for the engine’s features.
Toolscontains scripts for building and running the code.
Tools/Scriptsis heavily referenced in WebKit’s old
At the time of this writing,
WebKit’s source tree has the same
top-level structure. Comparing the
Source/ directories shows the top-level
differences between Blink and WebKit.
The Public API
The headers in
are relatively well-commented, so they make a great starting point for
understanding a part of Chromium.
The public APIs fall into two big categories.
public/webcontains the API implemented by Blink and called by Chromium’s content layer
public/platformhas the lower-level API used by Blink and implemented by the content layer
The classes in the public APIs usually have easy-to-guess corresponding classes
in the implementation. For example, the
WebView abstract class, defined in
has one concrete implementation,
WebViewImpl, which is defined in
contains both the
WebViewImpl implementation, as well as the definitions for
WebView’s static members.
The Source Code
Blink’s implementation is split into the following top-level directories.
Source/webhas the implementations of the public APIs in
Source/corehas the WebCore implementation, and is the meat of the project
Source/wtfdefines primitive types that abstract over differences in the C++ compilers and standard libraries that Blink supports; wtf stands for Web Template Framework
Source/platformcontains some lower-level code used by WebCore
Source/moduleshas implementations for some W3C specifications; for example, the Geolocation API Spefication is implemented in
Source/inspectorcontains the specification of the Chrome remote debugging protocol, and the source code for the Chrome DevTools, which are implemented as a Web application that uses the remote debugging protocol
Source/buildhas an assortment of scripts used by the build process
The Layout Tests
Blink’s regression tests are Web pages that are loaded in a content layer that is hacked to output textual representations of the pages. This is really convenient, because a Web application developer can contribute a failing test for a bug or feature without having to learn C++ or Blink’s inner workings.
Building and Testing
all_webkit target contains the Blink-related deliverables.
Blink cannot run on its own, due to its dependency on Chromium’s content layer. The Content Shell offers a rudimentary UI on top of the content layer, and is a low-overhead way of getting Blink up and running.