XenevaOS
Loading...
Searching...
No Matches
Classes | Macros | Typedefs | Functions
js.c File Reference
#include "js.h"
#include "css.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <quickjs.h>
#include <https.h>
#include <_xeneva.h>
#include <sys/_ketime.h>
Include dependency graph for js.c:

Classes

struct  NsJsConsoleEntry
 
struct  NsJsTimer
 
struct  JsEl
 

Macros

#define NS_JS_TIMER_MAX   16
 
#define NS_JS_TIMER_MIN_MS   10
 
#define NS_JS_RAF_MS   16
 
#define NS_JS_CONSOLE_MAX   24
 
#define NS_JS_CONSOLE_LINE   512
 
#define NS_JS_TITLE_MAX   128
 

Typedefs

typedef struct JsEl JsEl
 

Functions

const char * NsJsVersion (void)
 
void NsJsFlushConsole (void)
 
int NsJsTimerCount (void)
 
bool NsJsTick (void)
 
int NsJsConsumeNav (char *out, size_t outsz)
 
void NsJsSetSink (NsJsSinkFn *fn)
 
void NsJsSetDocument (NsCssNode *root)
 
int NsJsConsumeDirty (void)
 
int NsJsActive (void)
 
void NsJsBegin (const char *url)
 
void NsJsEnd (void)
 
void NsJsScanTitle (const char *src, size_t len)
 
void NsJsScriptSrcAttr (const char *attr)
 
void NsJsScriptType (const char *type)
 
void NsJsScriptChunk (char c)
 
int NsJsDefined (const char *name)
 
void NsJsRunPending (void)
 

Macro Definition Documentation

◆ NS_JS_CONSOLE_LINE

#define NS_JS_CONSOLE_LINE   512

◆ NS_JS_CONSOLE_MAX

#define NS_JS_CONSOLE_MAX   24

◆ NS_JS_RAF_MS

#define NS_JS_RAF_MS   16

◆ NS_JS_TIMER_MAX

#define NS_JS_TIMER_MAX   16

NetSurf QuickJS host implementation. See js.h.

One QuickJS runtime/context per page. Inline <script> bodies are fed to NsJsScriptChunk by the HTML pass and evaled at </script>, so document order and JS-side text injection line up with the rendered page. The context outlives the parse so setTimeout/setInterval callbacks keep firing from the GUI loop until the next page replaces it.

Host shell. getElementById returns a live node once NsJsSetDocument is called; setAttribute("style") updates that node's inline sheet. Lookups before the DOM exists, and every other DOM call, stay soft: console.log/info/warn/error/debug -> styled lines through the sink document.write/writeln -> inline text through the sink document.title -> get/set (title scan preloaded) location.href/replace/assign -> queued navigation (fetched by the caller) document.cookie -> the shared HTTP cookie jar navigator.userAgent -> same Chrome string the fetch sends alert(...) -> warning line setTimeout/setInterval/clear* -> timer slots driven by NsJsTick; callbacks may be functions or source strings requestAnimationFrame -> setTimeout(16ms) compat shim window -> alias of globalThis

◆ NS_JS_TIMER_MIN_MS

#define NS_JS_TIMER_MIN_MS   10

◆ NS_JS_TITLE_MAX

#define NS_JS_TITLE_MAX   128

Typedef Documentation

◆ JsEl

typedef struct JsEl JsEl

Function Documentation

◆ NsJsActive()

int NsJsActive ( void  )

◆ NsJsBegin()

void NsJsBegin ( const char *  url)

◆ NsJsConsumeDirty()

int NsJsConsumeDirty ( void  )

◆ NsJsConsumeNav()

int NsJsConsumeNav ( char *  out,
size_t  outsz 
)

◆ NsJsDefined()

int NsJsDefined ( const char *  name)

◆ NsJsEnd()

void NsJsEnd ( void  )

◆ NsJsFlushConsole()

void NsJsFlushConsole ( void  )

◆ NsJsRunPending()

void NsJsRunPending ( void  )

◆ NsJsScanTitle()

void NsJsScanTitle ( const char *  src,
size_t  len 
)

◆ NsJsScriptChunk()

void NsJsScriptChunk ( char  c)

◆ NsJsScriptSrcAttr()

void NsJsScriptSrcAttr ( const char *  attr)

◆ NsJsScriptType()

void NsJsScriptType ( const char *  type)

◆ NsJsSetDocument()

void NsJsSetDocument ( NsCssNode *  root)

◆ NsJsSetSink()

void NsJsSetSink ( NsJsSinkFn *  fn)

◆ NsJsTick()

bool NsJsTick ( void  )

◆ NsJsTimerCount()

int NsJsTimerCount ( void  )

◆ NsJsVersion()

const char * NsJsVersion ( void  )