xbintsc 0.6.9 → 0.6.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/cli/help.d.ts +1 -1
- package/dist/src/cli/main.js +1 -0
- package/dist/src/cli/main.js.map +1 -1
- package/dist/src/driver/config.js +1 -0
- package/dist/src/driver/config.js.map +1 -1
- package/dist/src/driver/version.d.ts +1 -1
- package/dist/src/driver/version.js +1 -1
- package/dist/src/driver/version.js.map +1 -1
- package/dist/tests/driver/config.test.js +15 -2
- package/dist/tests/driver/config.test.js.map +1 -1
- package/dist/tests/e2e/gui-helpers.d.ts +2 -0
- package/dist/tests/e2e/gui-helpers.js +1 -0
- package/dist/tests/e2e/gui-helpers.js.map +1 -1
- package/dist/tests/e2e/gui-layout.test.js +47 -0
- package/dist/tests/e2e/gui-layout.test.js.map +1 -1
- package/dist/tests/e2e/gui-paint.test.js +108 -0
- package/dist/tests/e2e/gui-paint.test.js.map +1 -1
- package/dist/tests/e2e/gui-unsupported.test.d.ts +6 -0
- package/dist/tests/e2e/gui-unsupported.test.js +123 -0
- package/dist/tests/e2e/gui-unsupported.test.js.map +1 -0
- package/doc/ai/extensions.md +7 -4
- package/doc/ai/zh-CN/extensions.md +6 -3
- package/doc/gui/dom.md +69 -1
- package/doc/gui/known-issues.md +12 -5
- package/doc/gui/layout.md +19 -6
- package/doc/gui/rendering.md +16 -9
- package/doc/zh-CN/gui/dom.md +61 -1
- package/doc/zh-CN/gui/known-issues.md +11 -4
- package/doc/zh-CN/gui/layout.md +14 -4
- package/doc/zh-CN/gui/rendering.md +13 -10
- package/package.json +7 -7
- package/runtime/ext_gui/clip_values.cpp +11 -0
- package/runtime/ext_gui/css.cpp +27 -2
- package/runtime/ext_gui/css_selector.cpp +23 -0
- package/runtime/ext_gui/css_sheet.cpp +7 -0
- package/runtime/ext_gui/document.cpp +3 -0
- package/runtime/ext_gui/document_animation.cpp +4 -1
- package/runtime/ext_gui/dom_api.cpp +3 -0
- package/runtime/ext_gui/dom_parse.cpp +4 -0
- package/runtime/ext_gui/effect_values.cpp +28 -7
- package/runtime/ext_gui/gradient_values.cpp +25 -5
- package/runtime/ext_gui/inline_svg.cpp +3 -0
- package/runtime/ext_gui/layout_flow.cpp +12 -2
- package/runtime/ext_gui/layout_inline.cpp +80 -7
- package/runtime/ext_gui/media_query.cpp +7 -1
- package/runtime/ext_gui/paint.cpp +58 -23
- package/runtime/ext_gui/paint.h +7 -4
- package/runtime/ext_gui/paint_clip.cpp +74 -19
- package/runtime/ext_gui/paint_internal.h +7 -1
- package/runtime/ext_gui/renderer_clip.cpp +19 -17
- package/runtime/ext_gui/style.cpp +5 -1
- package/runtime/ext_gui/style.h +5 -0
- package/runtime/ext_gui/style_cascade.cpp +2 -0
- package/runtime/ext_gui/style_internal.h +7 -2
- package/runtime/ext_gui/style_print.cpp +3 -0
- package/runtime/ext_gui/style_text.cpp +11 -0
- package/runtime/ext_gui/style_values.cpp +89 -90
- package/runtime/ext_gui/transform.cpp +2 -0
- package/runtime/ext_gui/warnings.cpp +300 -0
- package/runtime/ext_gui/warnings.h +59 -0
- package/src/cli/main.ts +1 -0
- package/src/driver/config.ts +1 -0
- package/src/driver/version.ts +1 -1
|
@@ -65,15 +65,22 @@ void paintBoxInner(const LayoutBox *box, DisplayList &out, const PaintClip &clip
|
|
|
65
65
|
|
|
66
66
|
/** The clip a box imposes on its content: its padding box, intersected with the
|
|
67
67
|
* clip already in effect. Only `overflow: hidden/scroll/auto` clips. A
|
|
68
|
-
*
|
|
69
|
-
|
|
68
|
+
* `border-radius` makes that clip a rounded rectangle, exactly as a browser
|
|
69
|
+
* rounds `overflow` (the GPU scissor stays the bounding box; the rounded shape
|
|
70
|
+
* joins the `clip-path` polygons the renderer intersects). A transformed box
|
|
71
|
+
* clips to the bounding box of its transformed padding box. */
|
|
72
|
+
PaintClip clipForChildren(const LayoutBox *box, const PaintClip &parent, DisplayList &out) {
|
|
70
73
|
if (box->style == nullptr || box->style->overflow == Overflow::Visible) return parent;
|
|
71
|
-
float
|
|
72
|
-
float
|
|
73
|
-
float
|
|
74
|
-
float
|
|
75
|
-
if (
|
|
76
|
-
if (
|
|
74
|
+
float padding_x = box->x + box->border_left;
|
|
75
|
+
float padding_y = box->y + box->border_top;
|
|
76
|
+
float padding_width = box->width - box->border_left - box->border_right;
|
|
77
|
+
float padding_height = box->height - box->border_top - box->border_bottom;
|
|
78
|
+
if (padding_width < 0) padding_width = 0;
|
|
79
|
+
if (padding_height < 0) padding_height = 0;
|
|
80
|
+
float x = padding_x;
|
|
81
|
+
float y = padding_y;
|
|
82
|
+
float width = padding_width;
|
|
83
|
+
float height = padding_height;
|
|
77
84
|
if (box->has_transform) {
|
|
78
85
|
LayoutRect bounds = xt_layout_transform_rect(box->world, x, y, width, height);
|
|
79
86
|
x = bounds.x;
|
|
@@ -88,16 +95,28 @@ PaintClip clipForChildren(const LayoutBox *box, const PaintClip &parent) {
|
|
|
88
95
|
result.y = y;
|
|
89
96
|
result.width = width;
|
|
90
97
|
result.height = height;
|
|
91
|
-
|
|
98
|
+
} else {
|
|
99
|
+
float x0 = std::max(x, parent.x);
|
|
100
|
+
float y0 = std::max(y, parent.y);
|
|
101
|
+
float x1 = std::min(x + width, parent.x + parent.width);
|
|
102
|
+
float y1 = std::min(y + height, parent.y + parent.height);
|
|
103
|
+
result.x = x0;
|
|
104
|
+
result.y = y0;
|
|
105
|
+
result.width = std::max(0.0f, x1 - x0);
|
|
106
|
+
result.height = std::max(0.0f, y1 - y0);
|
|
107
|
+
}
|
|
108
|
+
/* The radius belongs to the border box, so the padding box's inner radius is
|
|
109
|
+
* reduced by the widest border (CSS 8.1). The polygon is built from the
|
|
110
|
+
* *untransformed* padding box and mapped point by point, so a rotated box
|
|
111
|
+
* keeps a round circle instead of a rounded AABB. */
|
|
112
|
+
if (box->border_radius > 0.0f && padding_width > 0.0f && padding_height > 0.0f) {
|
|
113
|
+
float inset = std::max(std::max(box->border_left, box->border_right),
|
|
114
|
+
std::max(box->border_top, box->border_bottom));
|
|
115
|
+
float radius = box->border_radius - inset;
|
|
116
|
+
int index = paint_detail::addRoundedClipPath(out, box->world, padding_x, padding_y,
|
|
117
|
+
padding_width, padding_height, radius);
|
|
118
|
+
result = paint_detail::addClipPath(result, index);
|
|
92
119
|
}
|
|
93
|
-
float x0 = std::max(x, parent.x);
|
|
94
|
-
float y0 = std::max(y, parent.y);
|
|
95
|
-
float x1 = std::min(x + width, parent.x + parent.width);
|
|
96
|
-
float y1 = std::min(y + height, parent.y + parent.height);
|
|
97
|
-
result.x = x0;
|
|
98
|
-
result.y = y0;
|
|
99
|
-
result.width = std::max(0.0f, x1 - x0);
|
|
100
|
-
result.height = std::max(0.0f, y1 - y0);
|
|
101
120
|
return result;
|
|
102
121
|
}
|
|
103
122
|
|
|
@@ -209,6 +228,21 @@ void paintBoxInner(const LayoutBox *box, DisplayList &out, const PaintClip &clip
|
|
|
209
228
|
}
|
|
210
229
|
}
|
|
211
230
|
|
|
231
|
+
/* `border-radius` also clips the box's own background images/gradients and
|
|
232
|
+
* replaced content; a solid background is already painted as a rounded
|
|
233
|
+
* rectangle and needs no polygon. An `<img>`/`<svg>` with only a radius
|
|
234
|
+
* (no `overflow: hidden`) gets its corners clipped this way too. */
|
|
235
|
+
PaintClip contentClip = own;
|
|
236
|
+
if (style != nullptr && !box->is_text && box->border_radius > 0.0f && box->width > 0.0f &&
|
|
237
|
+
box->height > 0.0f) {
|
|
238
|
+
bool replaces = box->is_image || box->is_canvas || box->is_media || box->is_inline_svg;
|
|
239
|
+
if (!style->background_layers.empty() || replaces) {
|
|
240
|
+
int index = paint_detail::addRoundedClipPath(out, box->world, box->x, box->y, box->width,
|
|
241
|
+
box->height, box->border_radius);
|
|
242
|
+
contentClip = paint_detail::addClipPath(contentClip, index);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
212
246
|
if (style != nullptr && box->display != Display::None) {
|
|
213
247
|
if (box->is_text) {
|
|
214
248
|
addTextRuns(box, *style, out, own, chain, viewportWidth, viewportHeight);
|
|
@@ -223,7 +257,7 @@ void paintBoxInner(const LayoutBox *box, DisplayList &out, const PaintClip &clip
|
|
|
223
257
|
* paint above it. */
|
|
224
258
|
paint_detail::addBoxShadows(out, *box, *style, chain, own, false, viewportWidth,
|
|
225
259
|
viewportHeight);
|
|
226
|
-
paint_detail::paintBackgrounds(out, *box, *style, chain,
|
|
260
|
+
paint_detail::paintBackgrounds(out, *box, *style, chain, contentClip, viewportWidth,
|
|
227
261
|
viewportHeight);
|
|
228
262
|
const Matrix2D &matrix = box->world;
|
|
229
263
|
if (style->border_style != BorderStyle::None && style->has_border_color) {
|
|
@@ -254,7 +288,7 @@ void paintBoxInner(const LayoutBox *box, DisplayList &out, const PaintClip &clip
|
|
|
254
288
|
image.height = box->content_height;
|
|
255
289
|
image.canvas_id = box->canvas_id;
|
|
256
290
|
image.transform = matrix;
|
|
257
|
-
paint_detail::addImage(out, image,
|
|
291
|
+
paint_detail::addImage(out, image, contentClip, chain);
|
|
258
292
|
} else if (box->is_media && box->media_id != 0 && box->content_width > 0.0f &&
|
|
259
293
|
box->content_height > 0.0f) {
|
|
260
294
|
PaintImage image;
|
|
@@ -264,7 +298,7 @@ void paintBoxInner(const LayoutBox *box, DisplayList &out, const PaintClip &clip
|
|
|
264
298
|
image.height = box->content_height;
|
|
265
299
|
image.media_id = box->media_id;
|
|
266
300
|
image.transform = matrix;
|
|
267
|
-
paint_detail::addImage(out, image,
|
|
301
|
+
paint_detail::addImage(out, image, contentClip, chain);
|
|
268
302
|
} else if (box->is_inline_svg && !box->svg_markup.empty() && box->content_width > 0.0f &&
|
|
269
303
|
box->content_height > 0.0f) {
|
|
270
304
|
PaintImage image;
|
|
@@ -274,7 +308,7 @@ void paintBoxInner(const LayoutBox *box, DisplayList &out, const PaintClip &clip
|
|
|
274
308
|
image.height = box->content_height;
|
|
275
309
|
image.svg = box->svg_markup;
|
|
276
310
|
image.transform = matrix;
|
|
277
|
-
paint_detail::addImage(out, image,
|
|
311
|
+
paint_detail::addImage(out, image, contentClip, chain);
|
|
278
312
|
} else if (box->is_image && !box->image_src.empty() && box->content_width > 0.0f &&
|
|
279
313
|
box->content_height > 0.0f) {
|
|
280
314
|
PaintImage image;
|
|
@@ -284,7 +318,7 @@ void paintBoxInner(const LayoutBox *box, DisplayList &out, const PaintClip &clip
|
|
|
284
318
|
image.height = box->content_height;
|
|
285
319
|
image.src = box->image_src;
|
|
286
320
|
image.transform = matrix;
|
|
287
|
-
paint_detail::addImage(out, image,
|
|
321
|
+
paint_detail::addImage(out, image, contentClip, chain);
|
|
288
322
|
}
|
|
289
323
|
}
|
|
290
324
|
}
|
|
@@ -293,7 +327,8 @@ void paintBoxInner(const LayoutBox *box, DisplayList &out, const PaintClip &clip
|
|
|
293
327
|
* already been emitted, so descendants must not repeat it. */
|
|
294
328
|
paint_detail::FilterChain childChain = chain;
|
|
295
329
|
childChain.shadows.clear();
|
|
296
|
-
paintChildren(box, out, clipForChildren(box, own), childChain, viewportWidth,
|
|
330
|
+
paintChildren(box, out, clipForChildren(box, own, out), childChain, viewportWidth,
|
|
331
|
+
viewportHeight);
|
|
297
332
|
}
|
|
298
333
|
|
|
299
334
|
/** Paint one box, wrapping it in a `mix-blend-mode` group when it declares one.
|
package/runtime/ext_gui/paint.h
CHANGED
|
@@ -156,17 +156,20 @@ struct ClipPathGeometry {
|
|
|
156
156
|
|
|
157
157
|
/** The clip rectangle in effect for a painted shape (device-space logical
|
|
158
158
|
* pixels — a transformed subtree contributes the bounding box of its clip).
|
|
159
|
-
* `width <= 0` means "no clip". `paths` index `DisplayList::clip_paths
|
|
160
|
-
*
|
|
161
|
-
*
|
|
159
|
+
* `width <= 0` means "no clip". `paths` index `DisplayList::clip_paths`: the
|
|
160
|
+
* `clip-path` shapes and the rounded padding boxes of `overflow` ancestors
|
|
161
|
+
* intersected down the tree. Four nested shapes are kept (CSS would intersect
|
|
162
|
+
* every ancestor; deeper nesting is rare and the outermost four are the ones a
|
|
163
|
+
* shape has to satisfy). */
|
|
162
164
|
struct PaintClip {
|
|
165
|
+
static constexpr int kMaxPaths = 4;
|
|
163
166
|
bool active = false;
|
|
164
167
|
float x = 0;
|
|
165
168
|
float y = 0;
|
|
166
169
|
float width = 0;
|
|
167
170
|
float height = 0;
|
|
168
171
|
int path_count = 0;
|
|
169
|
-
int paths[
|
|
172
|
+
int paths[kMaxPaths] = {-1, -1, -1, -1};
|
|
170
173
|
};
|
|
171
174
|
|
|
172
175
|
enum class PaintKind { Rect, Text, Image, LayerBegin, LayerEnd, Backdrop };
|
|
@@ -215,6 +215,49 @@ void triangulate(std::vector<Point> points, std::vector<ClipTriangle> *triangles
|
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
217
|
|
|
218
|
+
/** Transform a box-local polygon into device space, triangulate it and store it
|
|
219
|
+
* on the display list. A polygon with fewer than three points is kept as an
|
|
220
|
+
* empty clip: a valid `clip-path` that hides everything must not degrade into
|
|
221
|
+
* "no clip". `convex` lets a caller that knows the shape (a rounded rectangle)
|
|
222
|
+
* skip ear clipping and emit a fan. */
|
|
223
|
+
int storeClipPolygon(DisplayList &out, const std::vector<Point> &points, const Matrix2D &world,
|
|
224
|
+
bool convex) {
|
|
225
|
+
ClipPathGeometry geometry;
|
|
226
|
+
geometry.points.reserve(points.size() * 2);
|
|
227
|
+
for (const Point &point : points) {
|
|
228
|
+
float x = point.x;
|
|
229
|
+
float y = point.y;
|
|
230
|
+
world.apply(point.x, point.y, &x, &y);
|
|
231
|
+
geometry.points.push_back(x);
|
|
232
|
+
geometry.points.push_back(y);
|
|
233
|
+
}
|
|
234
|
+
if (points.size() >= 3) {
|
|
235
|
+
if (convex) {
|
|
236
|
+
/* A convex outline is triangulated by a fan from its first vertex; the
|
|
237
|
+
* rounded-overflow shape (the common case) has ~68 points and this keeps
|
|
238
|
+
* its cost linear. */
|
|
239
|
+
for (size_t i = 1; i + 1 < points.size(); i++) {
|
|
240
|
+
ClipTriangle triangle;
|
|
241
|
+
triangle.x[0] = geometry.points[0];
|
|
242
|
+
triangle.y[0] = geometry.points[1];
|
|
243
|
+
triangle.x[1] = geometry.points[i * 2];
|
|
244
|
+
triangle.y[1] = geometry.points[i * 2 + 1];
|
|
245
|
+
triangle.x[2] = geometry.points[(i + 1) * 2];
|
|
246
|
+
triangle.y[2] = geometry.points[(i + 1) * 2 + 1];
|
|
247
|
+
geometry.triangles.push_back(triangle);
|
|
248
|
+
}
|
|
249
|
+
} else {
|
|
250
|
+
std::vector<Point> device;
|
|
251
|
+
device.reserve(points.size());
|
|
252
|
+
for (size_t i = 0; i + 1 < geometry.points.size(); i += 2)
|
|
253
|
+
device.push_back({geometry.points[i], geometry.points[i + 1]});
|
|
254
|
+
triangulate(device, &geometry.triangles);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
out.clip_paths.push_back(std::move(geometry));
|
|
258
|
+
return (int)(out.clip_paths.size() - 1);
|
|
259
|
+
}
|
|
260
|
+
|
|
218
261
|
} // namespace
|
|
219
262
|
|
|
220
263
|
int addClipPathForBox(DisplayList &out, const LayoutBox &box, const XtStyle &style,
|
|
@@ -238,29 +281,41 @@ int addClipPathForBox(DisplayList &out, const LayoutBox &box, const XtStyle &sty
|
|
|
238
281
|
/* An empty but valid shape (`inset(50%)`, `circle(0)`) clips everything away;
|
|
239
282
|
* it must not fall back to "no clip". The paint walk keeps the empty geometry
|
|
240
283
|
* and the renderer emits no geometry for ops that reference it. */
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
if (
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
284
|
+
return storeClipPolygon(out, points, box.world, false);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
int addRoundedClipPath(DisplayList &out, const Matrix2D &world, float x, float y, float width,
|
|
288
|
+
float height, float radius) {
|
|
289
|
+
if (width <= 0.0f || height <= 0.0f || radius <= 0.0f) return -1;
|
|
290
|
+
/* CSS never lets a corner arc exceed half of the shorter side. */
|
|
291
|
+
float limit = std::min(width, height) * 0.5f;
|
|
292
|
+
if (radius > limit) radius = limit;
|
|
293
|
+
if (radius <= 0.0f) return -1;
|
|
294
|
+
/* Sixteen chords per quarter circle keep a large (176px) preview avatar
|
|
295
|
+
* visually round — the chord error at that radius is under half a pixel —
|
|
296
|
+
* and stay cheap to clip quads against. The `inset(... round ...)` outline
|
|
297
|
+
* keeps its coarser six-segment construction. */
|
|
298
|
+
constexpr int kSegments = 16;
|
|
299
|
+
std::vector<Point> points;
|
|
300
|
+
points.reserve((size_t)(kSegments + 1) * 4);
|
|
301
|
+
auto arc = [&](float centerX, float centerY, float start) {
|
|
302
|
+
for (int i = 0; i <= kSegments; i++) {
|
|
303
|
+
float angle = start + (float)i / (float)kSegments * (kPi * 0.5f);
|
|
304
|
+
appendPoint(&points,
|
|
305
|
+
{centerX + std::cos(angle) * radius, centerY + std::sin(angle) * radius});
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
/* Clockwise from the top-left corner, matching `insetOutline`. */
|
|
309
|
+
arc(x + radius, y + radius, kPi);
|
|
310
|
+
arc(x + width - radius, y + radius, kPi * 1.5f);
|
|
311
|
+
arc(x + width - radius, y + height - radius, 0.0f);
|
|
312
|
+
arc(x + radius, y + height - radius, kPi * 0.5f);
|
|
313
|
+
return storeClipPolygon(out, points, world, true);
|
|
259
314
|
}
|
|
260
315
|
|
|
261
316
|
PaintClip addClipPath(PaintClip clip, int index) {
|
|
262
317
|
if (index < 0) return clip;
|
|
263
|
-
if (clip.path_count <
|
|
318
|
+
if (clip.path_count < PaintClip::kMaxPaths) clip.paths[clip.path_count++] = index;
|
|
264
319
|
return clip;
|
|
265
320
|
}
|
|
266
321
|
|
|
@@ -107,7 +107,13 @@ bool addBackdropFilter(DisplayList &out, const LayoutBox &box, const XtStyle &st
|
|
|
107
107
|
int addClipPathForBox(DisplayList &out, const LayoutBox &box, const XtStyle &style,
|
|
108
108
|
float viewportWidth, float viewportHeight);
|
|
109
109
|
|
|
110
|
-
/**
|
|
110
|
+
/** Resolve the rounded padding box an `overflow` clip uses into a device-space
|
|
111
|
+
* triangulated polygon, approximating each corner with short chords. The
|
|
112
|
+
* corners stay round after a transform because every point is mapped. */
|
|
113
|
+
int addRoundedClipPath(DisplayList &out, const Matrix2D &world, float x, float y, float width,
|
|
114
|
+
float height, float radius);
|
|
115
|
+
|
|
116
|
+
/** Push `index` onto a clip chain (at most `PaintClip::kMaxPaths` survive). */
|
|
111
117
|
PaintClip addClipPath(PaintClip clip, int index);
|
|
112
118
|
|
|
113
119
|
} // namespace paint_detail
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
#include "renderer_internal.h"
|
|
11
11
|
|
|
12
12
|
#include <algorithm>
|
|
13
|
+
#include <utility>
|
|
13
14
|
#include <vector>
|
|
14
15
|
|
|
15
16
|
namespace xtgui {
|
|
@@ -86,26 +87,27 @@ uint32_t appendClipped(std::vector<V> &out, const std::vector<V> &quad, const Pa
|
|
|
86
87
|
appendFan(quad, &out);
|
|
87
88
|
return 6;
|
|
88
89
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
for (const ClipTriangle &inner : second->triangles) {
|
|
104
|
-
std::vector<V> secondClip = clipToTriangle(firstClip, inner, mix);
|
|
105
|
-
if (secondClip.size() >= 3) appendFan(secondClip, &out);
|
|
90
|
+
/* Start with the convex quad and clip it by every path in turn. Each path is
|
|
91
|
+
* a triangulated (possibly concave) polygon, so intersecting a convex piece
|
|
92
|
+
* with its triangles partitions it correctly; the result may be several
|
|
93
|
+
* convex pieces, which the next path clips independently. */
|
|
94
|
+
std::vector<std::vector<V>> pieces;
|
|
95
|
+
pieces.push_back(quad);
|
|
96
|
+
for (int p = 0; p < clip.path_count; p++) {
|
|
97
|
+
const ClipPathGeometry *path = pathAt(list, clip.paths[p]);
|
|
98
|
+
if (path == nullptr || path->triangles.empty()) return 0;
|
|
99
|
+
std::vector<std::vector<V>> next;
|
|
100
|
+
for (const std::vector<V> &piece : pieces) {
|
|
101
|
+
for (const ClipTriangle &triangle : path->triangles) {
|
|
102
|
+
std::vector<V> clipped = clipToTriangle(piece, triangle, mix);
|
|
103
|
+
if (clipped.size() >= 3) next.push_back(std::move(clipped));
|
|
106
104
|
}
|
|
107
105
|
}
|
|
106
|
+
pieces = std::move(next);
|
|
107
|
+
if (pieces.empty()) return 0;
|
|
108
108
|
}
|
|
109
|
+
uint32_t before = (uint32_t)out.size();
|
|
110
|
+
for (const std::vector<V> &piece : pieces) appendFan(piece, &out);
|
|
109
111
|
return (uint32_t)out.size() - before;
|
|
110
112
|
}
|
|
111
113
|
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
#include "css_internal.h"
|
|
12
12
|
#include "perf.h"
|
|
13
|
+
#include "warnings.h"
|
|
13
14
|
|
|
14
15
|
#include <algorithm>
|
|
15
16
|
#include <cctype>
|
|
@@ -241,7 +242,9 @@ void applyCandidates(XtStyle *style, std::vector<Candidate> *candidates,
|
|
|
241
242
|
if (xt_css_lower(value).find("current") != std::string::npos) {
|
|
242
243
|
value = xt_style_replace_current_color(value, style->color);
|
|
243
244
|
}
|
|
244
|
-
xt_style_apply_declaration(style, property, value, nodeContext)
|
|
245
|
+
if (!xt_style_apply_declaration(style, property, value, nodeContext)) {
|
|
246
|
+
xt_warn_unsupported_property(property);
|
|
247
|
+
}
|
|
245
248
|
}
|
|
246
249
|
}
|
|
247
250
|
|
|
@@ -359,6 +362,7 @@ std::string resolveContent(const Node *origin, const std::string &raw, bool *gen
|
|
|
359
362
|
}
|
|
360
363
|
if (i < value.size() && value[i] == '(') {
|
|
361
364
|
/* Unsupported function (`counter`, `counters`, `url`, …): skip it. */
|
|
365
|
+
xt_warn_unsupported_function("content", token);
|
|
362
366
|
int depth = 0;
|
|
363
367
|
for (; i < value.size(); i++) {
|
|
364
368
|
if (value[i] == '(') depth++;
|
package/runtime/ext_gui/style.h
CHANGED
|
@@ -33,6 +33,8 @@ enum class AlignContent { Stretch, FlexStart, FlexEnd, Center, SpaceBetween, Spa
|
|
|
33
33
|
enum class FloatSide { None, Left, Right };
|
|
34
34
|
enum class Clear { None, Left, Right, Both };
|
|
35
35
|
enum class TextAlign { Start, Center, End, Justify };
|
|
36
|
+
/** `text-overflow` on an overflowing line; the engine signals it with U+2026. */
|
|
37
|
+
enum class TextOverflow { Clip, Ellipsis };
|
|
36
38
|
enum class WhiteSpace { Normal, NoWrap, Pre, PreWrap, PreLine };
|
|
37
39
|
enum class Overflow { Visible, Hidden, Scroll, Auto };
|
|
38
40
|
enum class BorderStyle { None, Solid, Dashed, Dotted };
|
|
@@ -304,6 +306,9 @@ struct XtStyle {
|
|
|
304
306
|
Length line_height; // Auto = normal; Number = multiplier
|
|
305
307
|
|
|
306
308
|
TextAlign text_align = TextAlign::Start; // inherited
|
|
309
|
+
/** `text-overflow`; not inherited. Only meaningful when the box clips
|
|
310
|
+
* (`overflow` other than `visible`). */
|
|
311
|
+
TextOverflow text_overflow = TextOverflow::Clip;
|
|
307
312
|
WhiteSpace white_space = WhiteSpace::Normal; // inherited
|
|
308
313
|
TextTransform text_transform = TextTransform::None; // inherited
|
|
309
314
|
/** Resolved to pixels in the cascade (em is the element's own font size). */
|
|
@@ -18,6 +18,8 @@ void xt_style_apply_inherit(XtStyle *style, const XtStyle *parent, const std::st
|
|
|
18
18
|
if (parent == nullptr) return;
|
|
19
19
|
if (property == "color") {
|
|
20
20
|
style->color = parent->color;
|
|
21
|
+
} else if (property == "text-overflow") {
|
|
22
|
+
style->text_overflow = parent->text_overflow;
|
|
21
23
|
} else if (property == "clip-path") {
|
|
22
24
|
style->clip_path = parent->clip_path;
|
|
23
25
|
} else if (property == "font") {
|
|
@@ -36,8 +36,13 @@ void xt_style_apply_user_agent(const Node *node, XtStyle *style);
|
|
|
36
36
|
float xt_style_border_radius_px(const Length &radius, float width, float height, float em,
|
|
37
37
|
float root, float vw, float vh);
|
|
38
38
|
|
|
39
|
-
/** Apply a parsed declaration to a computed style.
|
|
40
|
-
|
|
39
|
+
/** Apply a parsed declaration to a computed style.
|
|
40
|
+
*
|
|
41
|
+
* Returns false only when the *property name* is not part of the engine's
|
|
42
|
+
* subset; a recognised property with an unparsable value returns true (the
|
|
43
|
+
* declaration is simply a no-op), so callers can warn about unknown properties
|
|
44
|
+
* without mistaking bad values for unsupported ones. */
|
|
45
|
+
bool xt_style_apply_declaration(XtStyle *style, const std::string &property,
|
|
41
46
|
const std::string &rawValue, const ApplyContext &context);
|
|
42
47
|
|
|
43
48
|
} // namespace xtgui
|
|
@@ -274,6 +274,9 @@ std::string xt_style_property_to_string(const XtStyle &style, const std::string
|
|
|
274
274
|
}
|
|
275
275
|
if (property == "text-align") return alignTextNames[(int)style.text_align];
|
|
276
276
|
if (property == "text-transform") return textTransformNames[(int)style.text_transform];
|
|
277
|
+
if (property == "text-overflow") {
|
|
278
|
+
return style.text_overflow == TextOverflow::Ellipsis ? "ellipsis" : "clip";
|
|
279
|
+
}
|
|
277
280
|
if (property == "letter-spacing") return formatLength(style.letter_spacing);
|
|
278
281
|
if (property == "writing-mode") return writingModeNames[(int)style.writing_mode];
|
|
279
282
|
if (property == "vertical-align") return formatLength(style.vertical_align);
|
|
@@ -167,6 +167,17 @@ bool xt_style_apply_text_property(XtStyle *style, const std::string &property,
|
|
|
167
167
|
parseTextTransform(value, &style->text_transform);
|
|
168
168
|
return true;
|
|
169
169
|
}
|
|
170
|
+
if (property == "text-overflow") {
|
|
171
|
+
/* `clip | ellipsis` (the two-value `start end` form collapses to one
|
|
172
|
+
* behaviour here). A custom string is accepted as `clip`, which is still
|
|
173
|
+
* closer than dropping the declaration. */
|
|
174
|
+
bool ellipsis = false;
|
|
175
|
+
for (const std::string &token : splitTokens(lowerTrim(value))) {
|
|
176
|
+
if (token == "ellipsis") ellipsis = true;
|
|
177
|
+
}
|
|
178
|
+
style->text_overflow = ellipsis ? TextOverflow::Ellipsis : TextOverflow::Clip;
|
|
179
|
+
return true;
|
|
180
|
+
}
|
|
170
181
|
if (property == "writing-mode") {
|
|
171
182
|
parseWritingMode(value, &style->writing_mode);
|
|
172
183
|
return true;
|