Engine architecture

Sciter engine is written in bare-bone C++ with the use of some C++11 features.

Internally it contains the following modules:

Modules that Sciter is made of

Modules that Sciter is made of

  • CSS – CSS parser and collection of parsed CSS rules, etc.
  • HTML DOM – HTML parser and DOM tree implementation.
  • layout managers – collection of various layout managers – text layout, default block layout, flex layouts. Support of positioned floating elements is also here. This module does layout calculations heavy lifting. This module is also responsible for rendering of layouts.
  • input behaviors – collection of built-in behaviors – code behind “active” DOM elements: <input>, <select>, <textarea>, etc.
  • script module – source-to-bytecode compiler and virtual machine (VM) with compacting garbage collector (GC). This module also contains runtime implementation of standard classes and objects: Array, Object, Function and others.
  • script DOM – runtime classes that expose DOM and DOM view (a.k.a. window) to the script.
  • graphics abstraction layer – abstract graphics implementation that isolates modules above from particular platform details
    • Direct2D/DirectWrite graphics backend implementation (Windows);
    • GDI+ graphics backend implementation (Windows);
    • CoreGraphics backend implementation (Mac OS X);
    • Cairo backend implementation (GTK on all platforms including Linuxes);
  • core primitives – set of common primitives: string, arrays, hash maps and so on.

The engine is packaged into a dynamic link library module (.dll, .dylib or .so). Static engine linkage is also supported ( engine is compiled into host executable binary ).

The whole API is exposed to the host application by single public function SciterAPI that returns large structure listing all API functions.

Engine-to-application callbacks and notifications handling

window related callbacks

Host application receives window related callbacks and notifications by registering its SciterHostCallback compatible function by calling

SciterSetCallback(hSciterWindow, SciterHostCallback, cbParam)

with its address.

DOM events/callbacks

To receive DOM originated events like button clicks, edit inputs chages and many others the host application calls

SciterWindowAttachEventHandler( hSciterWindow, eventHandlingProc, tag, events );

API function supplying address of its event handling function. That procedure will receive all DOM events as before they will be handled by the DOM or as after they were processed by the DOM.

Native function callbacks

Application can define and register native functions to be called from script. Native functions can be associated as with particular DOM elements as with the view/window so to be globally accessible from any script loaded into the view. This functionality is a part of DOM callbacks handlers. See {sdk}/demos/usciter/ project for the demo of such functions.

Further reading: Introduction for native GUI programmers.