Changes between Version 4 and Version 5 of WebKit/Overview


Ignore:
Timestamp:
Nov 22, 2024, 1:27:14 PM (4 weeks ago)
Author:
Zardshard
Comment:

Rearrange content and fix formatting

Legend:

Unmodified
Added
Removed
Modified
  • WebKit/Overview

    v4 v5  
    1 This page gives an overview of the [WebKit port](https://github.com/haiku/webkit), how it's done, where the useful sources are, etc.
     1This page gives an overview of the [https://github.com/haiku/webkit WebKit port], how it's done, where the useful sources are, etc.
    22
    33There are two "versions" of WebKit called WebKiLegacy and "WebKit" or WebKit2. The former is a single-process architecture, where the whole browser is a single application. The latter is a multi-process system, where the browser is just a shell, and there are WebProcess (html parsing, etc) and NetworkProcess (http requests) programs running in the background to do the actual work, providing some sandboxing. Haiku is currently using the former, work is ongoing (in the webkit2 branch) for moving to WebKit2.
     
    2121- WebKitLegacy is the "legacy" single-process code.
    2222
     23== Implementation-specific code ==
     24
    2325All of these (maybe except JavascriptCore) have some amount of platform-specific code. In WTF, for obvious reasons. In WebCore, for all the HTTP request (soup, curl, haiku, ...), rendering (cairo, freetype, ...), and any other platform specific things at this level. In WebKitLegacy and WebKit, for the APIs exposed to application willing to embed an HTML view or the like.
    2426
    2527So, the main directories for the Haiku-specific sources are: Source/WebCore/platform/graphics/haiku ; Source/WebCore/platform/network/haiku ; Source/WebKitLegacy/haiku . There are a few additional files and in some cases specific code in files shared between platforms.
    2628
    27 = Source Tree =
    28 ---------
     29Some of the other ports can be used for inspiration. The names of the folders relating to other ports are
     30
     31* gtk - https://www.webkitgtk.org/
     32* wpe - https://wpewebkit.org/
     33* playstation
     34* win - Windows
     35* ios
     36* mac
     37
     38Here are some of the other folders containing implementation-specific code. They don't relate directly with any of the ports, but are used in some of them, including ours:
     39
     40* glib - Contains implementations of functions using the [https://docs.gtk.org/glib/index.html GLib] library.
     41* unix - Contains implementations of functions using things available on UNIX.
     42* cocoa - Contains implementations of functions using the [https://en.wikipedia.org/wiki/Cocoa_(API) cocoa] API.
     43* soup - Uses [https://libsoup.org/libsoup-3.0/ libsoup]
     44* curl - Uses curl
     45* skia - Uses [https://skia.org/ skia]
     46* cairo - Uses [https://www.cairographics.org/ cairo]
     47* and several others
     48
     49**See also:**
     50* https://docs.webkit.org/Ports/Introduction.html
     51
     52== Source Tree ==
     53
     54Here's a quick overview of some of the files and directories in WebKit:
    2955
    3056* Tools/
     
    77103    * WebKitLegacy/ - The old API. It runs everything in a single process.
    78104
    79 [What is WebKit?](https://github.com/WebKit/WebKit/blob/main/Introduction.md#what-is-webkit) also has a nice explanation for some of the folders.
    80 
    81 
    82 =Other ports =
    83 
    84 As you browse the directory tree, you'll see several folders over and over again in different directories. These contain technology-specific code. They can contain inspiration for how to implement unimplemented functions on Haiku.
    85 
    86 Some of the folders you'll find repeated across WebKit relate to the ports of WebKit. They are
    87 
    88 * haiku - that's us!
    89 * gtk - https://www.webkitgtk.org/
    90 * wpe - https://wpewebkit.org/
    91 * playstation
    92 * win - Windows
    93 * ios
    94 * mac
    95 
    96 Here are some of the other folders. They don't relate directly with any of the ports, but are used in some of them:
    97 
    98 * glib - Contains implementations of functions using the [GLib](https://docs.gtk.org/glib/index.html) library.
    99 * unix - Contains implementations of functions using things available on UNIX.
    100 * cocoa - Contains implementations of functions using the [cocoa](https://en.wikipedia.org/wiki/Cocoa_\(API\)) API.
    101 * soup - Uses [libsoup](https://libsoup.org/libsoup-3.0/)
    102 * curl - Uses curl
    103 * skia - Uses [skia](https://skia.org/)
    104 * cairo - Uses [cairo](https://www.cairographics.org/)
    105 * and several others
    106 
    107 **See also:**
    108 * https://docs.webkit.org/Ports/Introduction.html
    109 
    110 
    111 = Other Notes=
    112 
    113 PLATFORM vs HAVE vs USE vs OS
    114 -----------------------------
    115 
    116 Quite often in the code, you'll see `#if PLATFORM(HAIKU)` or `#if OS(HAIKU)`. They're all quite similar, but there is a way to use them properly. Source/WTF/wtf/Platform.h's comments explain when to use these quite nicely.
    117 
    118 
    119 
    120 Rendering
    121 ---------
    122 
    123 ### Coordinated graphics
    124 
    125 As far as I've been able to figure out, coordinated graphics refers to WebProcess and UIProcess coordinating graphics with each other. The UI process has to tell the web process about resizing, scrolling, etc. and the web process has to do the actual painting and then tell the UI process to update what has been displayed.
    126 
    127 A nice overview of coordinated graphics (and how rendering is done in general) is given at https://www.chromium.org/developers/design-documents/gpu-accelerated-compositing-in-chrome/. Yes, it's for chromium, but it matches what happens in WebKit *very* closely. Also see https://trac.webkit.org/wiki/CoordinatedGraphicsSystem
     105[https://github.com/WebKit/WebKit/blob/main/Introduction.md#what-is-webkit What is WebKit?] also has a nice explanation for some of the folders.
    128106
    129107= Philosophy of WebKit Porting =
     
    134112= Logging =
    135113
    136 Logs are not printed to the console, but to a special program called DevConsole.
     114Logs are not printed to the console, but to a special program called DevConsole. The [https://github.com/haiku/haikuwebkit/?tab=readme-ov-file#logging README] explains
    137115
    138116> To facilitate debugging with multiple processes, logging is done using the DevConsole tool. This allows clearly tagging each log with the originating process (especially useful for WebKit2 where there are multiple processes).
    139117>
    140118> Logging can be controlled using the WEBKIT_DEBUG environment variable. The default is to have all logs disabled. You can enable everythin by setting the variable to "all", or enable specific debug sources. Most logs require some compile time options as well.
    141 >
    142 > ([source](https://github.com/haiku/haikuwebkit/?tab=readme-ov-file#logging))
    143119
    144120
    145 Further reading
    146 ---------------
    147121
    148 * [Introduction.md in WebKit's source](https://github.com/WebKit/WebKit/blob/main/Introduction.md)
     122= Other Notes =
     123
     124=== PLATFORM vs HAVE vs USE vs OS ===
     125
     126Quite often in the code, you'll see `#if PLATFORM(HAIKU)` or `#if OS(HAIKU)`. They're all quite similar, but there is a way to use them properly. Source/WTF/wtf/Platform.h's comments explain when to use these quite nicely.
     127
     128=== What is coordinated graphics? ===
     129
     130As far as I've been able to figure out, coordinated graphics refers to WebProcess and UIProcess coordinating graphics with each other. The UI process has to tell the web process about resizing, scrolling, etc. and the web process has to do the actual painting and then tell the UI process to update what has been displayed.
     131
     132A nice overview of coordinated graphics (and how rendering is done in general) is given at https://www.chromium.org/developers/design-documents/gpu-accelerated-compositing-in-chrome/. Yes, it's for chromium, but it matches what happens in WebKit *very* closely. Also see https://trac.webkit.org/wiki/CoordinatedGraphicsSystem
     133
     134= Further reading =
     135
     136* [https://github.com/WebKit/WebKit/blob/main/Introduction.md Introduction.md in WebKit's source]
    149137* https://www.haiku-os.org/blog/pulkomandy/2024-02-28_so_you_want_to_help_with_webkit#working-on-webkit2
    150138* https://trac.webkit.org/wiki