A lightweight web engine and its browser
Soie is an HTML and CSS rendering engine written in C99 for old and small machines, from i486 to x86_64. It has no toolkit and no JavaScript in its core. It parses HTML as the WHATWG specification says and supports the CSS cascade, flexbox, grid, tables, SVG and web fonts. Extensions add cookies, content blocking, WebP images, JavaScript (QuickJS) and audio and video (FFmpeg and ALSA).
xsoie is the reference browser built on the engine. It
is a plain Xlib program. Its address bar and its other bars are
small HTML pages that Soie draws itself. It supports HTTPS, forms,
history, cookies, scripts and video. This manual is mostly about
xsoie. It also covers the other programs of the suite and has a
short section for people who embed the engine. This manual
describes Soie 0.1.11.
- Install
- The programs
- xsoie: start it
- The window
- The address bar
- Keyboard and mouse
- Text, fields and lists
- Find in the page
- about:settings
- Downloads
- HTTP logins
- Cookies, blocking and privacy
- Audio and video
- Files and environment
- wsoie (Wayland)
- gsoie (GTK)
- soie-render
- Bug reports and debugging
- Embedding the engine
- Known limits
- About
Install
On SliTaz the engine and its tools come in the soie
package. The X11 browser is in xsoie, and it is the
browser of the xsoie flavor. The GTK widget, gsoie
and the translations are in soie-gtk.
# spk-add xsoie
The extensions are modules (.so files) installed in
/usr/lib/soie/ext:
| Module | Brings |
|---|---|
| cookies.so | The cookie jar. |
| block.so | Content blocking by host name. |
| webp.so | WebP images. |
| script.so | JavaScript (QuickJS). |
| media.so | Audio and video (FFmpeg, ALSA). It is loaded only when a page first asks for audio or video. |
The browser works without any extension: it then has no cookies,
no scripts and no video. Fonts are found by scanning
/usr/share/fonts, /usr/local/share/fonts,
~/.fonts and ~/.local/share/fonts.
Fontconfig is not used.
The programs
| Program | What it is |
|---|---|
| xsoie | The browser on X11, with no toolkit. Menu entry: "Soie". |
| wsoie | The same browser on Wayland, when it was built. Menu entry: "Soie (Wayland)". |
| gsoie | A small tabbed GTK 3 browser on SoieView, the Soie widget that Toile also uses. |
| soie-render | A command-line renderer: it shows the DOM, computed styles, the box tree, or writes a PNG image. |
xsoie: start it
$ xsoie [-s] [-w WIDTH] [-H HEIGHT] [-o out.png] [URL]
| URL | The page to open. Without it, xsoie opens the
start page of about:settings, or
about:soie when none is set. |
| -s | Scripts off for this window. |
| -w WIDTH, -H HEIGHT | The window size (default 1024x768). |
| -o out.png | No window: load the page, wait for its resources and scripts, and write a PNG of the page area (the height less the 34 px toolbar). This mode uses the default settings, not yours. |
Any other option prints the usage and exits with status 2. Examples:
$ xsoie https://www.slitaz.org/ $ xsoie -s /home/tux/notes.html $ xsoie -w 1280 -H 800 -o slitaz.png https://www.slitaz.org/
Ctrl+N opens another window. Each window is a separate xsoie process, so a crash closes only one window. xsoie has no tabs.
The window
- Toolbar: Back (◀), Forward (▶),
Reload (↻), the address field, and the ⚙ button,
which opens
about:settings. - Scroll bar: a thin bar on the right when the page is taller than the window. Drag its thumb, or click the track to scroll one page up or down.
- Status line: at the bottom left. It shows the link under the pointer, the loading count ("Loading (N)..."), script alerts and download messages.
- Find bar: also at the bottom left, opened with Ctrl+F.
The page and the bars follow the desktop's dark or light theme
(see Files and environment), unless the
settings choose the colours. xsoie checks the theme again each
time the window gets the focus. It uses MIT-SHM shared memory
when the X server runs on the same machine. It works on 32, 24,
16 and 15-bit displays and on 8-bit colormaps. Its window class
is xsoie, Xsoie. The xsoie interface is
in English only.
Built-in pages: about:soie (home),
about:settings, about:auth (logins) and
about:blank.
The address bar
Ctrl+L, F6 or a click puts the focus in the address bar. The address is then selected, and the first key you type replaces it. Enter loads what you typed. Escape puts the current address back. The text you type is read this way:
with ://, or starting with
about: | Loaded as it is. |
starting with / | A local file. Its
#, ? and % are part of
the file name. |
one word with a dot or a colon, or
localhost | Opened over
https://. |
| anything else | A search. Soie uses the search URL
of the settings, else $SOIE_SEARCH (a URL where
%s stands for the words), else DuckDuckGo
Lite. |
/usr/share/doc/index.html -> file:///usr/share/doc/index.html hg.slitaz.org -> https://hg.slitaz.org localhost:631 -> https://localhost:631 slitaz iso -> a search
Keyboard and mouse
| Key | Action |
|---|---|
| Ctrl+L, F6 | Address bar |
| Ctrl+N | New window on about:soie |
| Ctrl+Q, Ctrl+W | Close the window |
| F5, Ctrl+R | Reload |
| Alt+Left, Alt+Right | Back, forward |
| Backspace | Back, when no field has the focus |
| Ctrl+F | Find bar |
| F3, Shift+F3 | Next, previous match |
| Ctrl+plus (or =), Ctrl+minus | Zoom in, out (10% a step) |
| Ctrl+0 | Zoom back to the settings' zoom |
| Ctrl+C | Copy the focused address, the selection in a field, or the selected page text |
| Ctrl+X | Cut the selection of the focused page field |
| Ctrl+V | Paste the clipboard |
| Shift+Insert | Paste the primary selection |
| Ctrl+A | Select all the page text (in a field: all of the field) |
| Arrows Up and Down | Scroll by 40 px |
| Page Up, Page Down, Space | Scroll by a page |
| Home, End | Top, bottom of the page |
| F12 | Save the page for a bug report (see Debugging) |
| Ctrl+Shift+J | Run the script file named by
$SOIE_DEBUG_JS in the page |
A page whose scripts take a key gets it first. With Ctrl, Alt or Meta, a key the page does not take goes to the browser shortcuts.
| Mouse | Action |
|---|---|
| Left click | Follow a link, press a button, focus a field. A click on a video plays or pauses it. |
| Drag, double click, triple click | Select text, a word, a block. Shift+click extends the selection. The selection becomes the primary selection. |
| Middle click | On a link: open it in a new window. In a text field or the address bar: paste the primary selection. |
| Wheel | Scroll 60 px a notch. The wheel scrolls the scrolling box under the pointer first (a frame, an element with overflow auto or scroll), then the page. |
| Buttons 8 and 9 | Back, forward |
Links with target="_blank", and window.open()
called after a click or a key, open a new window. Pop-ups that
scripts open by themselves (from a timer, for example) are
dropped.
Text, fields and lists
Text fields work as in other browsers. A click places the caret. Shift with the arrows, Home or End selects text. Ctrl with the arrows moves by words, and Ctrl+Backspace or Ctrl+Delete deletes a word. Typed or pasted text replaces the selection. In a textarea, Enter makes a new line and Up and Down move between the lines shown. In a one-line field, Enter sends the form. Escape takes the focus away from the field. Ctrl+C and Ctrl+X never copy a password.
A drop-down <select> opens a list of its options
when you click it. Arrows, Home, End, Page Up and Page Down move
in the list. Enter, Space, Tab, F4 or a click picks an option.
Escape, or a click outside the list, closes it. Typed letters jump
to the option that starts with them. When a select has the focus
and its list is closed, the arrows and letters change its value
at once, and Space, Enter, F4 or Alt+Down open the list.
Forms are sent as GET or POST (urlencoded). File upload is not supported.
Find in the page
Ctrl+F opens the find bar. The page is searched as you type, and the bar shows "n of m" or "not found". The current match is highlighted in orange and scrolled into view. Enter goes to the next match, Shift+Enter to the previous one, and Escape closes the bar. Case is ignored for ASCII letters. A match never spans two elements or two lines.
about:settings
The ⚙ button opens the settings page. You can also type
about:settings in the address bar. Web pages can
never open or post to this page. Save writes the settings to
~/.config/soie/settings
($XDG_CONFIG_HOME/soie/settings when that variable
is set).
| Setting | Key and values |
|---|---|
| Start page | home= a URL in http://,
https://, file:/// or about:. Empty means about:soie. |
| Search with | search= an http(s) URL
with exactly one %s. Empty means
$SOIE_SEARCH or DuckDuckGo Lite. |
| JavaScript | scripts= 1 (default) or
0 |
| Colours | colors= system (default),
light or dark |
| Zoom | zoom= 30 to 300, in percent
(default 100) |
| Cookies | cookies= all,
no-third-party (default) or none |
| Block the hosts of my list | block= 1
(default) or 0 |
| Save files in | downloads= an absolute
folder. Empty means $XDG_DOWNLOAD_DIR or
~/Downloads. |
The file holds one key=value per line, and
# starts a comment. You may edit it by hand. Bad
values are left out and the defaults stay in place.
# Soie's settings, written by about:settings home=https://www.slitaz.org/ search=https://lite.duckduckgo.com/lite/?q=%s scripts=1 cookies=no-third-party colors=system zoom=100 block=1 downloads=
The "Clear the cookies and logins" button forgets all cookies and HTTP logins. Scripts and cookie settings apply to the next pages loaded. Other windows read the settings when they open.
Downloads
Some files are not shown as pages: archives, ISO images, anything
sent with Content-Disposition: attachment, and any
type other than text, images, HTML, XML, JSON or JavaScript. These
files are downloaded, and the page on screen stays where it is.
The file goes to the settings' folder, else
$XDG_DOWNLOAD_DIR, else ~/Downloads,
which is created when needed. The file name comes from the server,
else from the URL. A name already taken gets a number, for example
file-1.iso. The body is written to a temporary file in
~/.cache/soie as it arrives, so a large ISO does not
fill the RAM. The status line says "Downloading to ...", then
"Saved to ..." or "Download failed: ...".
HTTP logins
When a page asks for an HTTP Basic login (the CUPS pages on
localhost:631, a router), Soie shows
about:auth with a user name and password form. On
plain http to another machine, the page warns that the password
travels unencrypted. A login is kept in memory until the browser
closes and is sent to that server only. If the server refuses it,
the form comes back. Cancel shows the server's own 401 page. Only
Basic is supported: Digest and Kerberos are not.
Cookies, blocking and privacy
- Cookies: persistent cookies are kept in
~/.local/share/soie/cookies.txt(Netscape format, mode 0600). Session cookies stay in memory. By default, third-party cookies are refused in both directions. - Content blocking: block.so reads
~/.config/soie/block.txt, or the file named by$SOIE_BLOCK. It is a hosts-style list, one host per line, and the usual0.0.0.0 hostlists work as they are. A listed host also blocks its subdomains. Only the resources of a page are blocked, never the page you ask for. Without a list, nothing is blocked. - localStorage: kept in
~/.local/share/soie/storage/, one file per site.$SOIE_STORAGEmoves it elsewhere; set it empty to keep localStorage in memory only. - HTTP cache: in memory only, never on disk. It is partitioned by the site you visit.
- Private network guard: a public web page cannot reach your local network or this machine (router, printer, local servers). A page from the local network cannot reach this machine. Addresses you type and links you follow are not limited.
- Local files: a web page can never open a
file://URL. Only you and local pages can.
Requests send an Accept-Language header taken from
your locale (LC_ALL, LC_MESSAGES,
LANG).
Audio and video
Audio and video need media.so. A video starts only when you click
it: autoplay is ignored, so a page full of videos
stays light. Plain files (mp4, webm, ogg, mp3, wav, flac...) play
directly. Streaming sites such as YouTube play through Media
Source Extensions. Supported codecs are H.264, VP8, AAC, Opus,
Vorbis, FLAC, MP3 and AC-3. VP9, AV1 and HEVC are refused, so sites
fall back to H.264. Sound goes straight to ALSA, without
PulseAudio. On a slow machine, video keeps time by dropping
frames.
| SOIE_AUDIO=none | Play without sound. |
| SOIE_AUDIO=hw:0 | Use this ALSA device. |
Iframes show their pages, but without scripts. An iframe is loaded only when it is scrolled into view.
Files and environment
| File | Use |
|---|---|
| ~/.config/soie/settings | Settings (about:settings) |
| ~/.config/soie/block.txt | Block list |
| ~/.local/share/soie/cookies.txt | Cookies |
| ~/.local/share/soie/storage/ | localStorage |
| ~/.cache/soie/ | Crash reports, busy.log, pages saved with F12, downloads in progress |
| ~/Downloads | Downloaded files (default) |
| /usr/lib/soie/ext/ | Extensions |
| Variable | Effect |
|---|---|
| SOIE_SEARCH | Search URL with %s, used
when the settings set none. |
| SOIE_EXT_DIR | Load extensions from this folder.
Without it, Soie uses the source tree's ext/
when run from the tree, else the installed ones. |
| SOIE_BLOCK | Block list file. |
| SOIE_STORAGE | localStorage folder; empty: memory only. |
| SOIE_COOKIES | Set empty to keep cookies in memory only. |
| SOIE_AUDIO | none, or an ALSA
device. |
| XDG_DOWNLOAD_DIR | Downloads folder. |
| XDG_CONFIG_HOME, XDG_CACHE_HOME | Base folders for the settings and the cache. |
| GTK_THEME | A name containing "dark" makes pages
dark. Without it, xsoie reads gtk-theme-name and
gtk-application-prefer-dark-theme in the
gtk-3.0 and gtk-4.0 settings.ini files: yours
first, then the system's (/etc/xdg). |
| SOIE_DEBUG, SOIE_DEBUG_JS, ... | See Debugging. |
wsoie (Wayland)
$ wsoie [-s] [-w WIDTH] [-H HEIGHT] [-o out.png] [URL]
wsoie is the same browser on a Wayland compositor. It has the same bars, keys, settings and files as xsoie. The compositor draws the title bar. Keys use the compositor's keymap through xkbcommon, with dead keys and compose. The differences from xsoie: the clipboard works (Ctrl+C, Ctrl+V), but there is no primary selection, so a selection is not copied by itself and the middle button does not paste; and the window has no icon. Its menu entry is "Soie (Wayland)". It is hidden in LXDE and Openbox sessions, where xsoie is the one to use.
gsoie (GTK)
$ gsoie [URL...]
gsoie is a small GTK 3 browser with tabs, built on SoieView, the
widget that Toile uses. Each URL on the command line opens a tab;
without one it opens about:soie. The window has
Back, Forward and Reload buttons, an address entry (URL, path or
words to search for) and a status line. The status line shows the
link under the pointer and the progress of downloads, which go to
$XDG_DOWNLOAD_DIR or ~/Downloads. Script
alerts open a dialog. gsoie has no about:settings.
| Ctrl+T | New tab |
| Ctrl+W | Close the tab (the window, on the last one) |
| Ctrl+Q | Quit |
| Ctrl+L | Address entry |
| Ctrl+R, F5 | Reload |
| Alt+Left, Alt+Right | Back, forward |
| Ctrl+plus, Ctrl+minus, Ctrl+0 | Zoom in, out, 100% |
| Middle click, Ctrl+click on a link | Open it in a new tab |
| Right click | Menu: Open Link in New Tab, Back, Forward, Reload, Copy, Copy Link Address, Copy Image Address, Paste |
The context menu and the built-in pages (errors, login, downloads) follow your locale; French is the first translation. Pages follow the GTK theme, also when you switch it while gsoie runs. A tab behind another slows its scripts down to save CPU.
soie-render
$ soie-render [options] FILE|-
soie-render renders a local page (or standard input) without a
window, for tests, scripts and screenshots. It reads only
file:// resources; it never uses the network.
| -d | Dump the DOM tree (default). |
| -c CHARSET | Charset from the transport; skips charset detection. |
| -f CONTEXT | Parse as a fragment inside element CONTEXT. |
| -s | Scripting flag on (<noscript>
as raw text). |
| -p PROPS | Dump these computed properties, comma separated. |
| -l | Dump the box tree with its geometry. |
| -o FILE.png | Render the viewport to a PNG. With -a, render the whole page (65536 rows at most). |
| -w WIDTH, -H HEIGHT | Viewport size (1024x768). |
| -D | prefers-color-scheme: dark. |
| -S | Stub font (every character 0.5em wide), as the tests use. |
| -b URL | Base URL (default: the file's file:// URL). |
| -r DIR | Document root: file:///P reads
DIR/P. |
| -j | Run the page's scripts (and their timers, 2 s at most). Needs script.so. |
| -T MS | Time given to the scripts, in milliseconds. |
| -x MODULE | Load an extension module; may be repeated. |
| -X | Load the installed extensions. |
| -V | Print the library version. |
$ soie-render page.html # the DOM $ soie-render -p display,color,margin-top page.html $ soie-render -l -w 800 page.html # boxes $ soie-render -o page.png -a page.html # the whole page $ soie-render -X -j page.html # with its scripts
Bug reports and debugging
- Crash: a crash writes
~/.cache/soie/crash-PID.txtwith the page, the last events and the backtrace. When/usr/bin/gdbis there, the report also has the backtrace of every thread (SOIE_NO_GDB=1skips that). Attach this file to your report. - Freezes: each task that blocks the window
for a second or more adds a line to
~/.cache/soie/busy.log. The log is kept even without debugging and holds the address without its query. Past 64 KB the old log becomesbusy.log.old. - F12: saves the page as it is after its
scripts ran, as
page-TIME.htmland a.txtbeside it in~/.cache/soie. The .txt holds the address, the last events, the DOM with computed styles, the boxes and a soie-render command line that replays it. The status line shows the path.
| SOIE_DEBUG=1 | On stderr: loads, HTTP status, failed resources, timings, script errors. |
| SOIE_DEBUG=2 | Also input, console.log, scripts' requests and the cache. |
| SOIE_DEBUG=3 | Also scrolling and painting. |
| SOIE_DEBUG_JS=file.js | Script run in the page with Ctrl+Shift+J. The file is read again each time. |
| SOIE_DEBUG_JS_START=file.js | Script run before the page's own scripts. |
| SOIE_DEBUG_PAINT=1 | Checks each partial redraw against a full one and reports differences. |
$ SOIE_DEBUG=1 xsoie https://example.org/ 2>soie.log
Bugs and ideas: maille.slitaz.org/tags/soie.
Embedding the engine
The engine is libsoie (libsoie.so.0 and
libsoie.a). Include <soie/soie.h>
and build with pkg-config:
$ cc app.c $(pkg-config --cflags --libs soie)
The engine never opens a socket: the host gives it bytes through a
fetch callback (soie_fetch_fn), which may answer
SOIE_FETCH_LATER while the bytes are on their way. A
typical program calls these functions:
soie_html_parse(),soie_html_parse_fragment()soie_style_document()withsoie_style_optionssoie_layout_document(),soie_layout_height()soie_paint(),soie_paint_bgra(),soie_layout_damage(),soie_layout_scroll()soie_hit_test(),soie_element_rect(),soie_find(),soie_select()soie_document_update()after changes,soie_node_free()at the end- Extensions:
soie_ext_load_dir(),soie_ext_register(); scripts:soie_script_start(); DOM access through thesoie_node_*andsoie_element_*functions
For GTK 3, soie-gtk (libsoie-gtk.so.0,
header soie-view.h) provides SoieView, a scrollable
web view widget with an API modeled on WebKitWebView:
soie_view_new(), soie_view_load_uri(),
soie_view_go(), soie_view_register_uri_scheme(),
the properties uri, title,
loading and zoom-level, and the signals
create, context-menu and
download-started. Toile and gsoie are built on it.
The ABI is not stable before 1.0 (extension ABI 0.3).
Known limits
- Google search and YouTube may stop answering after a while: their bot checks do not trust Soie's JavaScript engine.
- No JavaScript in iframes.
- No HSTS, and an https page may be redirected to http.
- HTTP logins are Basic only.
- No
:hover,:focusor other user states in style sheets. - No tabs in xsoie and wsoie: use windows (Ctrl+N), or gsoie and Toile for tabs.
- No file upload in forms, no undo (Ctrl+Z) in text fields.
About
Soie is free software under the BSD licence (2 clauses). Sources: hg.slitaz.org/soie, with a read-only git mirror at github.com/pankso/soie.