XenevaOS
Loading...
Searching...
No Matches
bytecode.h
Go to the documentation of this file.
1/*
2 * This file is part of LibCSS.
3 * Licensed under the MIT License,
4 * http://www.opensource.org/licenses/mit-license.php
5 * Copyright 2008 John-Mark Bell <jmb@netsurf-browser.org>
6 */
7
8#ifndef css_bytecode_bytecode_h_
9#define css_bytecode_bytecode_h_
10
11#include <inttypes.h>
12#include <stdio.h>
13
14#include <libcss/types.h>
15#include <libcss/properties.h>
16
18
20
28
36
37
38typedef enum unit {
39 UNIT_LENGTH = (1u << 8),
40 UNIT_PX = (1u << 8) + 0,
41 UNIT_EX = (1u << 8) + 1,
42 UNIT_EM = (1u << 8) + 2,
43 UNIT_IN = (1u << 8) + 3,
44 UNIT_CM = (1u << 8) + 4,
45 UNIT_MM = (1u << 8) + 5,
46 UNIT_PT = (1u << 8) + 6,
47 UNIT_PC = (1u << 8) + 7,
48 UNIT_CH = (1u << 8) + 8,
49 UNIT_REM = (1u << 8) + 9,
50 UNIT_LH = (1u << 8) + 10,
51 UNIT_VH = (1u << 8) + 11,
52 UNIT_VW = (1u << 8) + 12,
53 UNIT_VI = (1u << 8) + 13,
54 UNIT_VB = (1u << 8) + 14,
55 UNIT_VMIN = (1u << 8) + 15,
56 UNIT_VMAX = (1u << 8) + 16,
57 UNIT_Q = (1u << 8) + 17,
58
59 UNIT_PCT = (1 << 9),
60
61 UNIT_ANGLE = (1 << 10),
62 UNIT_DEG = (1 << 10) + 0,
63 UNIT_GRAD = (1 << 10) + 1,
64 UNIT_RAD = (1 << 10) + 2,
65 UNIT_TURN = (1 << 10) + 3,
66
67 UNIT_TIME = (1 << 11),
68 UNIT_MS = (1 << 11) + 0,
69 UNIT_S = (1 << 11) + 1,
70
71 UNIT_FREQ = (1 << 12),
72 UNIT_HZ = (1 << 12) + 0,
73 UNIT_KHZ = (1 << 12) + 1,
74
75 UNIT_RESOLUTION = (1 << 13),
76 UNIT_DPI = (1 << 13) + 0,
77 UNIT_DPCM = (1 << 13) + 1,
78 UNIT_DPPX = (1 << 13) + 2,
80
82
83typedef enum shape {
84 SHAPE_RECT = 0
86
87static inline css_code_t buildOPV(opcode_t opcode, uint8_t flags, uint16_t value)
88{
89 return (opcode & 0x3ff) | (flags << 10) | ((value & 0x3fff) << 18);
90}
91
92static inline opcode_t getOpcode(css_code_t OPV)
93{
94 return (OPV & 0x3ff);
95}
96
97static inline uint8_t getFlags(css_code_t OPV)
98{
99 return ((OPV >> 10) & 0xff);
100}
101
102static inline uint16_t getValue(css_code_t OPV)
103{
104 return (OPV >> 18);
105}
106
107static inline bool isImportant(css_code_t OPV)
108{
109 return getFlags(OPV) & FLAG_IMPORTANT;
110}
111
112static inline enum flag_value getFlagValue(css_code_t OPV)
113{
114 return (getFlags(OPV) >> 1) & 0x7;
115}
116
117static inline bool hasFlagValue(css_code_t OPV)
118{
119 return getFlagValue(OPV) != FLAG_VALUE__NONE;
120}
121
122static inline bool isInherit(css_code_t OPV)
123{
124 return getFlagValue(OPV) == FLAG_VALUE_INHERIT;
125}
126
127#endif
128
129
130
uint8_t flags
Definition virtio.h:0
unsigned int uint32_t
Definition acefiex.h:163
unsigned char uint8_t
Definition acefiex.h:161
unsigned short int uint16_t
Definition acefiex.h:162
uint32_t colour
Definition bytecode.h:81
unit
Definition bytecode.h:38
@ UNIT_VW
Definition bytecode.h:52
@ UNIT_DPPX
Definition bytecode.h:78
@ UNIT_CH
Definition bytecode.h:48
@ UNIT_GRAD
Definition bytecode.h:63
@ UNIT_PCT
Definition bytecode.h:59
@ UNIT_PT
Definition bytecode.h:46
@ UNIT_Q
Definition bytecode.h:57
@ UNIT_VB
Definition bytecode.h:54
@ UNIT_KHZ
Definition bytecode.h:73
@ UNIT_VMIN
Definition bytecode.h:55
@ UNIT_DPCM
Definition bytecode.h:77
@ UNIT_LENGTH
Definition bytecode.h:39
@ UNIT_S
Definition bytecode.h:69
@ UNIT_CM
Definition bytecode.h:44
@ UNIT_REM
Definition bytecode.h:49
@ UNIT_TURN
Definition bytecode.h:65
@ UNIT_ANGLE
Definition bytecode.h:61
@ UNIT_IN
Definition bytecode.h:43
@ UNIT_RESOLUTION
Definition bytecode.h:75
@ UNIT_EX
Definition bytecode.h:41
@ UNIT_MM
Definition bytecode.h:45
@ UNIT_HZ
Definition bytecode.h:72
@ UNIT_VMAX
Definition bytecode.h:56
@ UNIT_DEG
Definition bytecode.h:62
@ UNIT_PC
Definition bytecode.h:47
@ UNIT_EM
Definition bytecode.h:42
@ UNIT_TIME
Definition bytecode.h:67
@ UNIT_PX
Definition bytecode.h:40
@ UNIT_VI
Definition bytecode.h:53
@ UNIT_RAD
Definition bytecode.h:64
@ UNIT_FREQ
Definition bytecode.h:71
@ UNIT_DPI
Definition bytecode.h:76
@ UNIT_LH
Definition bytecode.h:50
@ UNIT_VH
Definition bytecode.h:51
@ UNIT_MS
Definition bytecode.h:68
shape
Definition bytecode.h:83
@ SHAPE_RECT
Definition bytecode.h:84
flag_value
Definition bytecode.h:21
@ FLAG_VALUE_INHERIT
Definition bytecode.h:23
@ FLAG_VALUE_REVERT
Definition bytecode.h:25
@ FLAG_VALUE_INITIAL
Definition bytecode.h:24
@ FLAG_VALUE_UNSET
Definition bytecode.h:26
@ FLAG_VALUE__NONE
Definition bytecode.h:22
uint32_t css_code_t
Definition bytecode.h:17
flag
Definition bytecode.h:29
@ FLAG_UNSET
Definition bytecode.h:34
@ FLAG_IMPORTANT
Definition bytecode.h:30
@ FLAG_REVERT
Definition bytecode.h:33
@ FLAG_INITIAL
Definition bytecode.h:32
@ FLAG_INHERIT
Definition bytecode.h:31
enum css_properties_e opcode_t
Definition bytecode.h:19
css_properties_e
Definition properties.h:16