XenevaOS
Loading...
Searching...
No Matches
helpers.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 2009 John-Mark Bell <jmb@netsurf-browser.org>
6 */
7
8#ifndef css_select_properties_helpers_h_
9#define css_select_properties_helpers_h_
10
11#include "select/helpers.h"
12
17
24 lwc_string *));
31 css_unit));
35 css_unit));
39 css_unit));
43 css_unit));
47 css_unit));
61
63static inline css_error css__copy_lwc_string_array(
64 bool ref,
65 lwc_string *const*orig,
66 lwc_string ***copy_out)
67{
68 size_t count = 0;
69 lwc_string **copy = NULL;
70
71 if (orig != NULL) {
72 for (lwc_string *const*i = orig; (*i) != NULL; i++) {
73 count++;
74 }
75
76 copy = malloc((count + 1) * sizeof(*copy));
77 if (copy == NULL) {
78 return CSS_NOMEM;
79 }
80
81 if (ref) {
82 for (size_t i = 0; i < count; i++) {
83 copy[i] = lwc_string_ref(orig[i]);
84 }
85 copy[count] = NULL;
86 } else {
87 memcpy(copy, orig, (count + 1) * sizeof(*copy));
88 }
89 }
90
91 *copy_out = copy;
92 return CSS_OK;
93}
94
96static inline css_error css__copy_computed_counter_array(
97 bool ref,
98 const css_computed_counter *orig,
99 css_computed_counter **copy_out)
100{
101 size_t count = 0;
103
104 if (orig != NULL) {
105 for (const css_computed_counter *i = orig;
106 i->name != NULL; i++) {
107 count++;
108 }
109
110 copy = malloc((count + 1) * sizeof(*copy));
111 if (copy == NULL) {
112 return CSS_NOMEM;
113 }
114
115 if (ref) {
116 for (size_t i = 0; i < count; i++) {
117 copy[i].name = lwc_string_ref(orig[i].name);
118 copy[i].value = orig[i].value;
119 }
120 copy[count].name = NULL;
121 copy[count].value = 0;
122 } else {
123 memcpy(copy, orig, (count + 1) * sizeof(*copy));
124 }
125 }
126
127 *copy_out = copy;
128 return CSS_OK;
129}
130
132static inline css_error css__copy_computed_content_item_array(
133 bool ref,
134 const css_computed_content_item *orig,
135 css_computed_content_item **copy_out)
136{
137 size_t count = 0;
139
140 if (orig != NULL) {
141 for (const css_computed_content_item *i = orig;
142 i->type != CSS_COMPUTED_CONTENT_NONE; i++) {
143 count++;
144 }
145
146 copy = malloc((count + 1) * sizeof(*copy));
147 if (copy == NULL) {
148 return CSS_NOMEM;
149 }
150
151 if (ref) {
152 for (size_t i = 0; i < count; i++) {
153 switch (orig[i].type) {
155 copy[i].data.string = lwc_string_ref(
156 orig[i].data.string);
157 break;
159 copy[i].data.uri = lwc_string_ref(
160 orig[i].data.uri);
161 break;
163 copy[i].data.attr = lwc_string_ref(
164 orig[i].data.attr);
165 break;
167 copy[i].data.counter.name = lwc_string_ref(
168 orig[i].data.counter.name);
169 copy[i].data.counter.style =
170 orig[i].data.counter.style;
171 break;
173 copy[i].data.counters.name = lwc_string_ref(
174 orig[i].data.counters.name);
175 copy[i].data.counters.sep = lwc_string_ref(
176 orig[i].data.counters.sep);
177 copy[i].data.counters.style =
178 orig[i].data.counters.style;
179 break;
180 default:
181 break;
182 }
183 copy[i].type = orig[i].type;
184 }
185 copy[count].type = CSS_COMPUTED_CONTENT_NONE;
186 } else {
187 memcpy(copy, orig, (count + 1) * sizeof(*copy));
188 }
189 }
190
191 *copy_out = copy;
192 return CSS_OK;
193}
194
195#endif
css_unit
Definition types.h:82
uint32_t css_color
Definition types.h:79
unsigned int uint32_t
Definition acefiex.h:163
unsigned char uint8_t
Definition acefiex.h:161
#define NULL
Definition actypes.h:561
struct drm_crtc struct drm_plane struct drm_plane const struct drm_crtc_funcs const char * name
Definition drm_crtc.h:1242
int32_t css_fixed
Definition fpmath.h:23
@ CSS_COMPUTED_CONTENT_NONE
Definition computed.h:50
@ CSS_COMPUTED_CONTENT_STRING
Definition computed.h:51
@ CSS_COMPUTED_CONTENT_COUNTERS
Definition computed.h:54
@ CSS_COMPUTED_CONTENT_COUNTER
Definition computed.h:53
@ CSS_COMPUTED_CONTENT_URI
Definition computed.h:52
@ CSS_COMPUTED_CONTENT_ATTR
Definition computed.h:55
void memcpy(void)
void * data
Definition kthread.h:30
css_error
Definition errors.h:18
@ CSS_NOMEM
Definition errors.h:21
@ CSS_OK
Definition errors.h:19
css_error css__cascade_number(uint32_t opv, css_style *style, css_select_state *state, css_error(*fun)(css_computed_style *, uint8_t, css_fixed))
Definition helpers.c:311
css_error css__cascade_length(uint32_t opv, css_style *style, css_select_state *state, css_error(*fun)(css_computed_style *, uint8_t, css_fixed, css_unit))
Definition helpers.c:283
css_error css__cascade_length_normal(uint32_t opv, css_style *style, css_select_state *state, css_error(*fun)(css_computed_style *, uint8_t, css_fixed, css_unit))
Definition helpers.c:215
css_error css__cascade_border_width(uint32_t opv, css_style *style, css_select_state *state, css_error(*fun)(css_computed_style *, uint8_t, css_fixed, css_unit))
Definition helpers.c:141
css_error css__cascade_break_after_before_inside(uint32_t opv, css_style *style, css_select_state *state, css_error(*fun)(css_computed_style *, uint8_t))
Definition helpers.c:372
uint32_t generic_destroy_uri(void *bytecode)
css_error css__cascade_length_auto(uint32_t opv, css_style *style, css_select_state *state, css_error(*fun)(css_computed_style *, uint8_t, css_fixed, css_unit))
Definition helpers.c:181
uint32_t generic_destroy_color(void *bytecode)
css_error css__cascade_bg_border_color(uint32_t opv, css_style *style, css_select_state *state, css_error(*fun)(css_computed_style *, uint8_t, css_color))
Definition helpers.c:22
css_error css__cascade_uri_none(uint32_t opv, css_style *style, css_select_state *state, css_error(*fun)(css_computed_style *, uint8_t, lwc_string *))
Definition helpers.c:60
uint32_t generic_destroy_length(void *bytecode)
css_error css__cascade_counter_increment_reset(uint32_t opv, css_style *style, css_select_state *state, css_error(*fun)(css_computed_style *, uint8_t, css_computed_counter *))
Definition helpers.c:421
css_error css__cascade_length_none(uint32_t opv, css_style *style, css_select_state *state, css_error(*fun)(css_computed_style *, uint8_t, css_fixed, css_unit))
Definition helpers.c:249
css_error css__cascade_page_break_after_before_inside(uint32_t opv, css_style *style, css_select_state *state, css_error(*fun)(css_computed_style *, uint8_t))
Definition helpers.c:335
css_error css__cascade_border_style(uint32_t opv, css_style *style, css_select_state *state, css_error(*fun)(css_computed_style *, uint8_t))
Definition helpers.c:90
uint32_t generic_destroy_number(void *bytecode)
#define malloc(s)
Definition quickjs.c:2290
Definition computed.h:62
union css_computed_content_item::@832 data
lwc_string * sep
Definition computed.h:74
lwc_string * string
Definition computed.h:65
uint8_t type
Definition computed.h:63
lwc_string * attr
Definition computed.h:67
lwc_string * uri
Definition computed.h:66
lwc_string * name
Definition computed.h:69
struct css_computed_content_item::@832::@834 counters
struct css_computed_content_item::@832::@833 counter
uint8_t style
Definition computed.h:70
Definition computed.h:27
lwc_string * name
Definition computed.h:28
css_fixed value
Definition computed.h:29
Definition autogenerated_computed.h:272
Definition select.h:69
Definition stylesheet.h:29
Definition libwapcaplet.h:41
#define state(x)