XenevaOS
Loading...
Searching...
No Matches
layout.h
Go to the documentation of this file.
1
9#ifndef NS_LAYOUT_H
10#define NS_LAYOUT_H
11
12#include <stdint.h>
13#include <stddef.h>
14#include "css.h"
15#include <chitralekha.h>
16#include <font.h>
17#include <draw.h>
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
23/* Decoded-image lookup. The layout engine gives the callback the raw
24 * src attribute; it should resolve it against the page URL and return
25 * 0xAARRGGBB pixels plus the intrinsic size, or NULL when unavailable. */
26typedef const uint32_t* (*NsImageLookupFn)(const char* src, int* width, int* height,
27 int* intrinsic_width, int* intrinsic_height);
29
30/* Inline <svg> elements have no fetchable src. The host serialises the
31 * subtree and rasterises it through the same SVG decoder used for files. */
32typedef const uint32_t* (*NsInlineSvgLookupFn)(NsCssNode* node, int* width, int* height,
33 int* intrinsic_width, int* intrinsic_height);
35
36/* Build a layout for root. viewport_w/h are the page widget's content
37 * size in pixels. Styles must still be alive (call before NsCssEnd). */
38int NsLayoutBuild(NsCssNode* root, int viewport_w, int viewport_h);
39void NsLayoutDestroy(void);
40
41int NsLayoutActive(void);
42int NsLayoutPageHeight(void);
43int NsLayoutPageWidth(void);
44int NsLayoutContentHeight(void);
45/* Diagnostic counters for --selftest. */
46void NsLayoutStats(int* blocks, int* lines, int* runs, int* links);
48
49/* Paint with the page coordinate origin at (vx,vy) and the given scroll
50 * offset. Everything is clipped to the viewport rectangle. */
51void NsLayoutPaint(ChCanvas* canv, int vx, int vy, int vw, int vh, int scroll_y);
52
53/* Hit-test a link. x/y are page coordinates (caller adds scroll). */
54int NsLayoutHitLink(int x, int y, char* href, size_t hrefsz);
55
56/* Hit-test an interactive form control (input, textarea, button, select).
57 * x/y are page coordinates (caller adds scroll). */
58int NsLayoutHitControl(int x, int y, NsCssNode** node);
59
60/* Live edit value painted over a form control. node == NULL disables the
61 * override. Used while a field has keyboard focus. */
62void NsLayoutSetEdit(NsCssNode* node, const char* text, int cursor, int active);
63
64/* Plain text of the laid-out page, for --selftest and status output. */
65const char* NsLayoutText(void);
66
67/* Diagnostics: dump the first N link rects and their hit-test result. */
68void NsLayoutPrintLinks(int max);
69void NsLayoutDumpBoxes(void);
70/* Paint into an offscreen Chitralekha canvas and count non-background
71 * pixels. Returns the count, or -1/-2 when no graph device is available. */
72int NsLayoutPaintTest(int w, int h, int scroll);
73/* Render to a PPM on the guest filesystem (used by the headless selftest). */
74int NsLayoutDumpPpm(const char* path, int w, int h, int scroll);
75
76#ifdef __cplusplus
77}
78#endif
79
80#endif
unsigned int uint32_t
Definition acefiex.h:163
void * fn
Definition audrv.c:980
struct drm_crtc struct drm_plane struct drm_plane * cursor
Definition drm_crtc.h:1240
void int node
Definition kthread.h:31
int h
Definition layout.c:118
const char * href
Definition layout.c:119
int NsLayoutPaintTest(int w, int h, int scroll)
Definition layout.c:3120
uint32_t NsLayoutPageBg(void)
Definition layout.c:2948
int NsLayoutHitLink(int x, int y, char *href, size_t hrefsz)
Definition layout.c:2977
const uint32_t *(* NsInlineSvgLookupFn)(NsCssNode *node, int *width, int *height, int *intrinsic_width, int *intrinsic_height)
Definition layout.h:32
int NsLayoutActive(void)
Definition layout.c:2921
int NsLayoutPageWidth(void)
Definition layout.c:2929
int NsLayoutHitControl(int x, int y, NsCssNode **node)
Definition layout.c:3006
const char * NsLayoutText(void)
Definition layout.c:3212
void NsLayoutPaint(ChCanvas *canv, int vx, int vy, int vw, int vh, int scroll_y)
Definition layout.c:2952
int NsLayoutDumpPpm(const char *path, int w, int h, int scroll)
Definition layout.c:3167
int NsLayoutPageHeight(void)
Definition layout.c:2925
void NsLayoutSetEdit(NsCssNode *node, const char *text, int cursor, int active)
Definition layout.c:3021
void NsLayoutDumpBoxes(void)
Definition layout.c:3103
const uint32_t *(* NsImageLookupFn)(const char *src, int *width, int *height, int *intrinsic_width, int *intrinsic_height)
Definition layout.h:26
void NsLayoutSetImageLookup(NsImageLookupFn fn)
Definition layout.c:141
void NsLayoutPrintLinks(int max)
Definition layout.c:3107
void NsLayoutSetInlineSvgLookup(NsInlineSvgLookupFn fn)
Definition layout.c:145
void NsLayoutDestroy(void)
Definition layout.c:2894
void NsLayoutStats(int *blocks, int *lines, int *runs, int *links)
Definition layout.c:2937
int NsLayoutContentHeight(void)
Definition layout.c:2933
int NsLayoutBuild(NsCssNode *root, int viewport_w, int viewport_h)
Definition layout.c:2850
#define max(a, b)
Definition minmax.h:28
line_t * lines
Definition p_setup.c:67
Definition css.h:37
Definition chitralekha.h:40
Definition path.h:8
TTY * root
Definition tty.cpp:47