basalt-win32 0.0.0-stage → 0.2.0

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.
Files changed (90) hide show
  1. package/LICENSE +21 -0
  2. package/cli/runWindows.js +35 -0
  3. package/cli/shared.js +75 -0
  4. package/native/CMakeLists.txt +429 -0
  5. package/native/tests/test_win32_accessibility.cpp +585 -0
  6. package/native/tests/test_win32_animated_image.cpp +351 -0
  7. package/native/tests/test_win32_clipboard.cpp +121 -0
  8. package/native/tests/test_win32_focus.cpp +195 -0
  9. package/native/tests/test_win32_hittest.cpp +750 -0
  10. package/native/tests/test_win32_image.cpp +370 -0
  11. package/native/tests/test_win32_imageloader.cpp +208 -0
  12. package/native/tests/test_win32_input.cpp +511 -0
  13. package/native/tests/test_win32_key_events.cpp +84 -0
  14. package/native/tests/test_win32_mounting.cpp +757 -0
  15. package/native/tests/test_win32_paint.cpp +1799 -0
  16. package/native/tests/test_win32_scrollview.cpp +647 -0
  17. package/native/tests/test_win32_selection.cpp +215 -0
  18. package/native/tests/test_win32_text.cpp +1456 -0
  19. package/native/tests/test_win32_textinput.cpp +1594 -0
  20. package/native/tests/test_win32_titlebar.cpp +111 -0
  21. package/native/tests/test_win32_titlebar_actions.cpp +62 -0
  22. package/native/tests/test_win32_view.cpp +222 -0
  23. package/native/win32/ColorSchemeWin32.cpp +56 -0
  24. package/native/win32/ComponentRegistryWin32.cpp +156 -0
  25. package/native/win32/DirectWriteLayout.cpp +485 -0
  26. package/native/win32/DirectWriteLayout.h +77 -0
  27. package/native/win32/DirectWriteLayoutManager.cpp +154 -0
  28. package/native/win32/FontRegistryDirectWrite.cpp +117 -0
  29. package/native/win32/PlatformServicesWin32.cpp +744 -0
  30. package/native/win32/RnWin32Accessible.cpp +343 -0
  31. package/native/win32/RnWin32Accessible.h +130 -0
  32. package/native/win32/RnWin32Image.cpp +588 -0
  33. package/native/win32/RnWin32Image.h +139 -0
  34. package/native/win32/RnWin32TextLayout.cpp +1379 -0
  35. package/native/win32/RnWin32TextLayout.h +390 -0
  36. package/native/win32/RnWin32View.cpp +2956 -0
  37. package/native/win32/RnWin32View.h +926 -0
  38. package/native/win32/Win32AnimationChoreographer.cpp +76 -0
  39. package/native/win32/Win32AnimationChoreographer.h +61 -0
  40. package/native/win32/Win32Clip.h +209 -0
  41. package/native/win32/Win32Cursors.cpp +309 -0
  42. package/native/win32/Win32Cursors.h +121 -0
  43. package/native/win32/Win32DropTarget.cpp +567 -0
  44. package/native/win32/Win32DropTarget.h +42 -0
  45. package/native/win32/Win32Focus.cpp +262 -0
  46. package/native/win32/Win32Focus.h +109 -0
  47. package/native/win32/Win32ImageLoader.cpp +199 -0
  48. package/native/win32/Win32ImageLoader.h +133 -0
  49. package/native/win32/Win32InputScopes.h +92 -0
  50. package/native/win32/Win32KeyEvents.cpp +126 -0
  51. package/native/win32/Win32KeyEvents.h +20 -0
  52. package/native/win32/Win32MenuBar.cpp +382 -0
  53. package/native/win32/Win32MenuBar.h +16 -0
  54. package/native/win32/Win32MountingManager.cpp +1282 -0
  55. package/native/win32/Win32MountingManager.h +243 -0
  56. package/native/win32/Win32Offscreen.h +53 -0
  57. package/native/win32/Win32Packaging.cpp +161 -0
  58. package/native/win32/Win32Packaging.h +56 -0
  59. package/native/win32/Win32RunLoopObserver.cpp +48 -0
  60. package/native/win32/Win32RunLoopObserver.h +42 -0
  61. package/native/win32/Win32ScrollView.cpp +718 -0
  62. package/native/win32/Win32ScrollView.h +256 -0
  63. package/native/win32/Win32SkiaContext.cpp +221 -0
  64. package/native/win32/Win32SkiaContext.h +53 -0
  65. package/native/win32/Win32SkiaModule.cpp +80 -0
  66. package/native/win32/Win32SkiaModule.h +50 -0
  67. package/native/win32/Win32SkiaPeer.cpp +358 -0
  68. package/native/win32/Win32SkiaPeer.h +66 -0
  69. package/native/win32/Win32SkiaUnicode.cpp +42 -0
  70. package/native/win32/Win32Snapshot.cpp +201 -0
  71. package/native/win32/Win32Snapshot.h +66 -0
  72. package/native/win32/Win32Strings.h +54 -0
  73. package/native/win32/Win32TextInput.cpp +1296 -0
  74. package/native/win32/Win32TextInput.h +341 -0
  75. package/native/win32/Win32TitleBar.cpp +562 -0
  76. package/native/win32/Win32TitleBar.h +146 -0
  77. package/native/win32/Win32TitleBarLayout.cpp +46 -0
  78. package/native/win32/Win32TitleBarLayout.h +58 -0
  79. package/native/win32/Win32TouchDispatcher.cpp +577 -0
  80. package/native/win32/Win32TouchDispatcher.h +201 -0
  81. package/native/win32/Win32UiThread.h +27 -0
  82. package/native/win32/Win32WindowControl.cpp +329 -0
  83. package/native/win32/Win32WindowModule.cpp +209 -0
  84. package/native/win32/Win32WindowModule.h +72 -0
  85. package/native/win32/demo_layout_win32.cpp +232 -0
  86. package/native/win32/main_win32.cpp +2722 -0
  87. package/native/win32/mount_harness_win32.cpp +316 -0
  88. package/package.json +25 -4
  89. package/react-native.config.js +22 -0
  90. package/README.md +0 -3
@@ -0,0 +1,926 @@
1
+ // The Windows view layer: a view Fabric's mounting can drive.
2
+ //
3
+ // Deliberately the same shape as `gtk/RnView.h` and `appkit/RnAppKitView.h` --
4
+ // a view owns a tag and an absolute frame, does no layout of its own, and
5
+ // places each child at the rect the shadow tree already resolved. Yoga has done
6
+ // the layout by the time a mutation arrives, and a second layout system
7
+ // underneath it is the thing to avoid, not to add.
8
+ //
9
+ // Three decisions carry the weight here, and the first is the one that makes
10
+ // this platform different from the other two.
11
+ //
12
+ // **A view is not a window.** On GTK a view is a GtkWidget and on macOS an
13
+ // NSView; the obvious Windows translation is a child HWND per view, and it is
14
+ // wrong. An HWND is a kernel object with a message queue association, USER32
15
+ // caps a process at ten thousand of them by default, and a list of a few
16
+ // hundred rows would spend the budget. Worse, none of what the analogy promises
17
+ // arrives: an HWND clips rectangularly and cannot be rotated, so `transform`
18
+ // and rounded `overflow: hidden` would both have to be reimplemented anyway.
19
+ // So the host owns one HWND for the surface, and a view is a plain C++ object
20
+ // painted by the recursive walk in `paint`. That is closer to GTK's snapshot
21
+ // than to AppKit's layer tree, and it means this file owes the platform
22
+ // nothing but Direct2D. The one place a real window is still the right answer
23
+ // is `<TextInput>`, where an EDIT peer brings input methods and every Windows
24
+ // key binding with it -- the same bargain GTK's GtkText and AppKit's
25
+ // NSTextField make.
26
+ //
27
+ // **No flip.** Win32 and Direct2D both put the origin at the top left, which is
28
+ // where React Native puts it. The AppKit side needs `isFlipped` and a test that
29
+ // states the coordinate in numbers; here the coordinate systems already agree,
30
+ // and the only reason to mention it is that a reader coming from that file will
31
+ // go looking for the flip.
32
+ //
33
+ // **Painting is immediate, not retained.** DirectComposition would give a
34
+ // visual per view, which is the closer analogue of CALayer, and it would put
35
+ // transform and opacity in the compositor. It would also make the offscreen
36
+ // snapshot -- the thing that proves this layer paints correctly at all -- a
37
+ // second, separate path. One Direct2D walk renders identically to a window and
38
+ // to a WIC bitmap, so the picture the tests compare is made by the same code
39
+ // that draws the app.
40
+
41
+ #pragma once
42
+
43
+ #include <windows.h>
44
+
45
+ #include <cstdint>
46
+ #include <memory>
47
+ #include <string>
48
+ #include <vector>
49
+
50
+ // For RnImageFit and RnAccessibleInfo, both of which a view stores by value.
51
+ // Nothing heavy: each forward-declares its own Windows types.
52
+ #include "RnWin32Accessible.h"
53
+ #include "RnWin32Image.h"
54
+ // For the thumb's default colour, which core decides so the three hosts cannot
55
+ // drift. Header-only, which is the constraint this library is under: it links
56
+ // no core.
57
+ #include "ScrollIndicator.h"
58
+
59
+ // Direct2D's interfaces are structs, so the paint entry point can be declared
60
+ // without dragging <d2d1.h> -- and windows.h behind it -- into every
61
+ // translation unit that only wants to build a tree. The tests do exactly that.
62
+ struct ID2D1RenderTarget;
63
+ struct ID2D1BitmapRenderTarget;
64
+
65
+ namespace basalt::win32 {
66
+
67
+ class RnWin32TextLayout;
68
+
69
+ struct RnRect {
70
+ float x = 0.0f;
71
+ float y = 0.0f;
72
+ float width = 0.0f;
73
+ float height = 0.0f;
74
+ };
75
+
76
+ // Content this view layer cannot draw itself, drawn by whoever can.
77
+ //
78
+ // One implementor today: the Skia surface behind a `<Canvas>`. It exists
79
+ // because of the split this directory is built around -- `basalt_win32_view`
80
+ // knows Direct2D and nothing else, and Skia lives a layer up in
81
+ // `basalt_win32_mounting`, which is the target that may or may not have been
82
+ // built with it. A `sk_sp<SkSurface>` member here would drag Skia's headers
83
+ // into the demo, the layout tool and every test that builds a view tree, and
84
+ // would make a host without Skia fail to compile rather than fail to draw.
85
+ //
86
+ // So the view holds an interface and calls it in the paint walk, at the point
87
+ // where it would draw an image. What that buys beyond the include: a canvas is
88
+ // clipped, transformed, faded and scrolled by exactly the code that does those
89
+ // things to everything else, and it appears in the offscreen snapshot the
90
+ // tests compare, because the snapshot is the same walk.
91
+ class RnWin32Painter {
92
+ public:
93
+ virtual ~RnWin32Painter() = default;
94
+
95
+ // Draw into a box `boxWidth` by `boxHeight` at the target's current origin
96
+ // -- the same contract as RnWin32Image::draw, and the same units, which are
97
+ // the view's own points.
98
+ virtual void draw(ID2D1RenderTarget *target, float boxWidth, float boxHeight) = 0;
99
+ };
100
+
101
+ class RnWin32View {
102
+ public:
103
+ explicit RnWin32View(int32_t tag);
104
+ ~RnWin32View();
105
+
106
+ RnWin32View(const RnWin32View &) = delete;
107
+ RnWin32View &operator=(const RnWin32View &) = delete;
108
+
109
+ // Fabric's tag for this view. Set once, at creation.
110
+ int32_t tag() const { return tag_; }
111
+
112
+ // --- Geometry ------------------------------------------------------------
113
+
114
+ // The frame the shadow tree resolved, in the parent's coordinates, top-left
115
+ // origin. Applied directly: nothing here recomputes it.
116
+ void setFrame(float x, float y, float width, float height);
117
+ const RnRect &frame() const { return frame_; }
118
+
119
+ // Shifts this view's children by (-x, -y), which is how a ScrollView scrolls.
120
+ //
121
+ // An offset applied while painting rather than by moving every child: the
122
+ // frames the mounting manager wrote stay exactly the ones Yoga produced, and
123
+ // hit testing subtracts the same offset, so the two cannot disagree. Both
124
+ // other platforms arrive at the same arrangement by their own route.
125
+ void setScrollOffset(float x, float y);
126
+
127
+ // What this scroll view's snapping is set to, as core/ScrollSnap.h formats
128
+ // it: a fragment the tree dump prints verbatim, or empty for a view that does
129
+ // not snap. Pushed in by the scroll manager, which is where the props are
130
+ // read.
131
+ void setScrollSnap(std::string description);
132
+ float scrollX() const { return scrollX_; }
133
+ float scrollY() const { return scrollY_; }
134
+
135
+ // The overlay scrollbars, as core/ScrollIndicator.h decides them: an offset
136
+ // along the track and a length, per axis, with a length of zero meaning "do
137
+ // not draw one". Painted above the children and below everything that is not
138
+ // the app's own -- see `paintScrollIndicators`.
139
+ void setScrollIndicators(float verticalOffset,
140
+ float verticalLength,
141
+ float horizontalOffset,
142
+ float horizontalLength);
143
+
144
+ // `indicatorStyle`, arriving as the colour `core/ScrollIndicator.h` resolved
145
+ // it to rather than as the enum: the mapping is the same on all three
146
+ // desktops and belongs in one place, and this layer knows nothing about React
147
+ // Native's vocabulary.
148
+ void setScrollIndicatorColour(float red, float green, float blue, float alpha);
149
+
150
+ // The hairline around the thumb, which `indicatorStyle: 'default'` has and
151
+ // the other two do not: iOS's default is black with a white border, and that
152
+ // border is the whole difference between `default` and `black`. A
153
+ // transparent colour means none, which is what the other two resolve to.
154
+ void setScrollIndicatorBorderColour(float red, float green, float blue, float alpha);
155
+
156
+ // --- Appearance ----------------------------------------------------------
157
+
158
+ // Components are premultiplied-free 0..1, as React Native's colour components
159
+ // arrive. Passing hasColor=false means "no background", which is not the same
160
+ // as transparent black: a view with no background does not paint at all.
161
+ void setBackgroundColor(float red, float green, float blue, float alpha, bool hasColor);
162
+ bool hasBackgroundColor() const { return hasBackgroundColor_; }
163
+
164
+ void setOpacity(float opacity);
165
+ float opacity() const { return opacity_; }
166
+
167
+ // React Native's transform, as sixteen floats in CSS `matrix3d` order. Null
168
+ // clears it.
169
+ //
170
+ // Only the 2D affine part is drawn -- Direct2D has no perspective and neither
171
+ // does the GTK side today -- and the anchor is the view's centre, which is
172
+ // what React Native means by an untouched `transformOrigin`.
173
+ void setTransform(const float *matrix16);
174
+ bool hasTransform() const { return hasTransform_; }
175
+
176
+ // `overflow: hidden`. The background is clipped to the corner radius whether
177
+ // or not this is set; this is only about the children.
178
+ void setClipsChildren(bool clips);
179
+ bool clipsChildren() const { return clipsChildren_; }
180
+
181
+ // One circular radius on all four corners: what `borderRadius` alone asks
182
+ // for, and what the paint tests use.
183
+ void setCornerRadius(float radius);
184
+ // Per corner, each with its own horizontal and vertical radius -- what React
185
+ // Native resolves every radius prop to -- in the order describeTree prints
186
+ // them: top-left, top-right, bottom-right, bottom-left, horizontal then
187
+ // vertical. This host drew one circular radius until it took eight.
188
+ void setCornerRadii(const float radii[8]);
189
+ const float *cornerRadii() const { return cornerRadii_; }
190
+
191
+ // Per edge, in CSS's order -- top, right, bottom, left -- with `colours` as
192
+ // four RGBA quads in the same order. Drawn inside the view's rounded box and
193
+ // over its content, as GTK and AppKit draw them. An edge with no width or no
194
+ // alpha draws nothing, and a view with no such edge has no border at all:
195
+ // which is also exactly when describeTree prints `borderw=` and `borderc=`,
196
+ // decided the way GTK decides it.
197
+ void setBorders(const float widths[4], const float colours[16]);
198
+
199
+ // One `dropShadow()` out of a `filter` list: a shadow of this subtree's
200
+ // *alpha* rather than of its box, which is the whole difference from
201
+ // `boxShadow`. The standard deviation React Native parsed, which is also what
202
+ // `CLSID_D2D1Shadow` takes, so nothing converts.
203
+ struct FilterShadow {
204
+ float dx = 0.0f;
205
+ float dy = 0.0f;
206
+ float standardDeviation = 0.0f;
207
+ float colour[4] = {0.0f, 0.0f, 0.0f, 0.0f};
208
+ };
209
+
210
+ // `filter`, resolved by `core/Filters.h` into one colour matrix, one blur, one
211
+ // opacity and the drop shadows in the order they were written. The matrix is
212
+ // row by row with `out = matrix * in + offset`, which is core's shape; this
213
+ // host transposes it for Direct2D, whose matrix multiplies the other way
214
+ // round.
215
+ struct Filters {
216
+ bool hasMatrix = false;
217
+ float matrix[16] = {1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1};
218
+ float offset[4] = {0, 0, 0, 0};
219
+ float blurRadius = 0.0f;
220
+ float opacity = 1.0f;
221
+ std::vector<FilterShadow> shadows;
222
+
223
+ bool empty() const {
224
+ return !hasMatrix && blurRadius <= 0.0f && opacity >= 1.0f && shadows.empty();
225
+ }
226
+ // Everything but the opacity, which is folded into the view's own rather
227
+ // than being an effect of its own.
228
+ bool needsEffects() const {
229
+ return hasMatrix || blurRadius > 0.0f || !shadows.empty();
230
+ }
231
+ };
232
+
233
+ void setFilters(const Filters &filters);
234
+ const Filters &filters() const { return filters_; }
235
+
236
+ // One stop of a `backgroundImage` gradient: an offset along the gradient's
237
+ // line or radius, and a straight sRGB colour. Both resolved by
238
+ // `core/Gradients.h`, which does CSS's colour-stop fixup.
239
+ struct GradientStop {
240
+ float offset = 0.0f;
241
+ float colour[4] = {0.0f, 0.0f, 0.0f, 0.0f};
242
+ };
243
+
244
+ // One `backgroundImage` gradient, resolved into what a brush takes.
245
+ //
246
+ // Every number is in this view's own coordinates and already offset to where
247
+ // the image goes, which is what `core/BackgroundLayers.h` works out from
248
+ // `backgroundSize`, `backgroundPosition` and `backgroundRepeat`. So this
249
+ // layer draws a gradient and does no CSS.
250
+ struct Gradient {
251
+ enum class Kind { Linear, Radial };
252
+ Kind kind = Kind::Linear;
253
+ // Linear: the ends of the gradient line. Radial: the centre and the radii.
254
+ float startX = 0.0f;
255
+ float startY = 0.0f;
256
+ float endX = 0.0f;
257
+ float endY = 0.0f;
258
+ float centreX = 0.0f;
259
+ float centreY = 0.0f;
260
+ float radiusX = 0.0f;
261
+ float radiusY = 0.0f;
262
+ // Where the image goes, and the tile it repeats in. `x, y, width, height`.
263
+ float area[4] = {0.0f, 0.0f, 0.0f, 0.0f};
264
+ float tile[4] = {0.0f, 0.0f, 0.0f, 0.0f};
265
+ bool repeats = false;
266
+ std::vector<GradientStop> stops;
267
+ };
268
+
269
+ // The whole list, in CSS's order: the first is the one on top. Painted above
270
+ // the background colour and below the content, which is where CSS puts a
271
+ // background image.
272
+ void setGradients(std::vector<Gradient> gradients);
273
+ const std::vector<Gradient> &gradients() const { return gradients_; }
274
+
275
+ // One `boxShadow`, as React Native's six fields. The list crosses the seam as
276
+ // the app wrote it, and `core/LegacyShadow.h` puts the older iOS shadow props
277
+ // in the same list, so one mechanism draws both.
278
+ //
279
+ // `blur` is CSS's radius, which is twice the gaussian's standard deviation --
280
+ // the conversion happens where the effect is made, as it does for a text
281
+ // shadow and an image blur. `spread` grows the box, and may be negative.
282
+ struct BoxShadow {
283
+ float dx = 0.0f;
284
+ float dy = 0.0f;
285
+ float blur = 0.0f;
286
+ float spread = 0.0f;
287
+ float colour[4] = {0.0f, 0.0f, 0.0f, 0.0f};
288
+ bool inset = false;
289
+ };
290
+
291
+ // The whole list, in CSS's order: the first is the one on top. Outset shadows
292
+ // are drawn behind this view's background and inset ones over it, which is
293
+ // where CSS puts them.
294
+ void setBoxShadows(std::vector<BoxShadow> shadows);
295
+ const std::vector<BoxShadow> &boxShadows() const { return boxShadows_; }
296
+
297
+ // The `cursor` style property, as CSS's keyword.
298
+ //
299
+ // The keyword crosses the seam for the reason `core/CursorNames.h` gives:
300
+ // React Native's list is CSS's and so is GDK's, and each view layer answers
301
+ // for its own platform. Empty is `auto`, which means "whatever the view
302
+ // around this one says", so it is an absence rather than an arrow.
303
+ //
304
+ // Nothing in this layer loads a cursor. Win32 has no per-view cursor at all:
305
+ // the window answers `WM_SETCURSOR` with whatever is under the pointer, which
306
+ // is what `cursorNameAt` below is for.
307
+ void setCursor(const char *name);
308
+ const std::string &cursor() const { return cursor_; }
309
+
310
+ // `mixBlendMode`, as CSS's keyword rather than as a Direct2D enum.
311
+ //
312
+ // The keyword is what crosses the seam on all three hosts, for the reason
313
+ // `core/BlendModes.h` gives: React Native's list is CSS's and so is every
314
+ // compositor's, so one place says what a value is called and each view layer
315
+ // answers for its own. Empty, or `normal`, is no blending.
316
+ //
317
+ // A keyword this host cannot blend is still stored and still reported --
318
+ // `describeTree` says what the app asked for -- and the view paints
319
+ // unblended, which is the rule GTK follows for `plus-lighter`. Direct2D has
320
+ // all seventeen, so nothing takes that path today; it is still the behaviour
321
+ // rather than a crash if a future keyword arrives.
322
+ void setBlendMode(const char *name);
323
+ const std::string &blendMode() const { return blendMode_; }
324
+ // Whether this view blends, which is a question its *parent* asks: a blend
325
+ // needs the backdrop, and only the parent can see what is beneath a child.
326
+ bool blends() const { return blends_; }
327
+
328
+ // How a border or an outline is drawn: filled, or stroked with a dash
329
+ // pattern. One enum for both because it is one concept and the three values
330
+ // are React Native's own for each of them.
331
+ enum class LineStyle { Solid, Dotted, Dashed };
332
+
333
+ // `borderStyle`, which is a property of the whole border rather than of a
334
+ // side: a dashed border is one stroked path around the rounded box, and a
335
+ // stroked path carries one dash pattern. React Native has a slot per side and
336
+ // the first that asks for something other than solid decides the border,
337
+ // which is what both other hosts do.
338
+ void setBorderStyle(LineStyle style);
339
+ LineStyle borderStyle() const { return borderStyle_; }
340
+
341
+ // CSS's `outline`: one ring outside the box, one width, one colour, one
342
+ // offset and one style for the whole thing, where a border has four of each.
343
+ // It takes no layout space, so nothing about it touches the frame, and
344
+ // nothing clips it -- see paintOutline.
345
+ void setOutline(float width, float offset, const float colour[4], LineStyle style);
346
+ bool hasBorders() const { return hasBorders_; }
347
+
348
+ // zIndex reorders painting and never the child list: Fabric's Insert and
349
+ // Remove carry an index into that list, so it has to stay in mutation order.
350
+ void setZIndex(int zIndex);
351
+ int zIndex() const { return zIndex_; }
352
+
353
+ // `pointerEvents`, which decides what a press can land on rather than what is
354
+ // drawn. CSS's four values, and React Native's. Read by `hitTest` and by
355
+ // nothing else.
356
+ //
357
+ // On the view rather than in the mounting manager because hit testing is a
358
+ // pure function of the view tree -- `hitTest` takes no React Native types and
359
+ // has nowhere to look a prop up. The AppKit host arranges it the same way.
360
+ enum class PointerEvents { Auto, None, BoxNone, BoxOnly };
361
+ void setPointerEvents(PointerEvents mode) { pointerEvents_ = mode; }
362
+ PointerEvents pointerEvents() const { return pointerEvents_; }
363
+
364
+ // `hitSlop`, which grows the box a press can land on without moving a pixel:
365
+ // a 24pt target can answer for 56pt, which is how a small control is made
366
+ // reachable. Top, right, bottom, left, the order CSS names them and the one
367
+ // the other two hosts store.
368
+ //
369
+ // Read by `hitTest` and by nothing else, and on the view for the reason
370
+ // `pointerEvents` is: hit testing is a pure function of the view tree and has
371
+ // nowhere to look a prop up.
372
+ void setHitSlop(const float insets[4]);
373
+ bool hasHitSlop() const { return hasHitSlop_; }
374
+ const float *hitSlop() const { return hitSlop_; }
375
+
376
+ // Whether this view takes keyboard focus, and therefore whether Tab stops on
377
+ // it.
378
+ //
379
+ // React Native has a `focusable` prop and it does not reach this platform:
380
+ // ReactCommon parses it only into Android's and tvOS's HostPlatformViewProps,
381
+ // and the C++ host's is a bare alias of BaseViewProps. What does reach here
382
+ // is `accessible`, which is what <Pressable> sets on everything it renders.
383
+ // See Win32Focus.h.
384
+ void setFocusable(bool focusable) { focusable_ = focusable; }
385
+ bool focusable() const { return focusable_; }
386
+
387
+ // Whether to paint a focus ring. A view is not its own window here, so there
388
+ // is no Win32 focus to ask about -- Win32FocusManager owns the answer and
389
+ // sets it, exactly as it owns the Tab order.
390
+ void setShowsFocusRing(bool shows) { showsFocusRing_ = shows; }
391
+ bool showsFocusRing() const { return showsFocusRing_; }
392
+
393
+ // `display: none`. A hidden view is neither painted nor hit, and neither are
394
+ // its children. Distinct from `opacity: 0`, which paints nothing and is still
395
+ // there to be pressed.
396
+ void setHidden(bool hidden);
397
+ bool hidden() const { return hidden_; }
398
+
399
+ // `backfaceVisibility: 'hidden'`. A view whose transform has turned it away
400
+ // from the viewer is not painted, and nor are its children -- which is what
401
+ // a card's back should do, and what takes it out of hit testing too, since
402
+ // `hitTest` skips a hidden view.
403
+ //
404
+ // Whether it has turned away is `basalt::facesAway`; see core/Backface.h for
405
+ // why the rule is shared rather than left to each toolkit.
406
+ void setHidesBackFace(bool hides);
407
+
408
+ // The EDIT control a <TextInput> mounted behind this view, or null.
409
+ //
410
+ // The view neither owns it nor draws it -- `Win32TextInputManager` does both
411
+ // -- and the only thing it is for is `describeTree`: a text field's content
412
+ // lives in its peer rather than in a layout, so without this it would be
413
+ // invisible to every test that reads the tree, and the Windows dump would
414
+ // differ from the other two hosts' for a field that was working perfectly.
415
+ // GTK keeps the same back pointer to its GtkText for the same reason.
416
+ void setEditablePeer(HWND control) { editablePeer_ = control; }
417
+ HWND editablePeer() const { return editablePeer_; }
418
+
419
+ // The view's `nativeID`. Kept for the one thing on this platform that reads
420
+ // it: a hidden title bar asks which views are drag regions, and
421
+ // <TitleBar.DragRegion> says so through this prop because it is the one a
422
+ // plain View already carries all the way to the host. See
423
+ // Win32TitleBarLayout.h.
424
+ void setNativeId(std::string nativeId) { nativeId_ = std::move(nativeId); }
425
+ const std::string &nativeId() const { return nativeId_; }
426
+
427
+ // --- Content ---------------------------------------------------------------
428
+
429
+ // The paragraph this view draws, or null for a view that draws none.
430
+ //
431
+ // Text sits above the background and below any children, which is the order
432
+ // `<Text>` with nested views expects and the order the GTK snapshot uses.
433
+ // Held as a shared_ptr because a paragraph is expensive to build and a
434
+ // mutation that changed only layout must not rebuild one -- the mounting
435
+ // manager will hand the same object back.
436
+ void setTextLayout(std::shared_ptr<RnWin32TextLayout> layout);
437
+ const std::shared_ptr<RnWin32TextLayout> &textLayout() const { return textLayout_; }
438
+
439
+ // Where the paragraph's box ends and its text begins: padding and border,
440
+ // which Fabric adds up into `layoutMetrics.contentInsets`.
441
+ //
442
+ // A <Text> may carry padding of its own, and React Native's own LogBox does:
443
+ // its message is a `<Text style={{paddingHorizontal: 12}}>` while the heading
444
+ // above it is a padded <View> around one, so the two lined up on a phone and
445
+ // did not here. Yoga lays the box out with the padding either way; what was
446
+ // missing is that the paragraph was drawn at the box's corner rather than at
447
+ // the content's, and wrapped to the box's width rather than the content's.
448
+ //
449
+ // Everything that reads a point against the text uses it: the draw, the
450
+ // selection highlight drawn with it, the vertical alignment, and
451
+ // `textIndexAtPoint`. React Native offsets an inline view's frame by the same
452
+ // insets in `ParagraphShadowNode::layout`, so a paragraph drawn at the corner
453
+ // also disagreed with the views inside it.
454
+ void setTextInset(float left, float top, float right, float bottom);
455
+
456
+ // How far down its box this view's paragraph is drawn, which is zero for every
457
+ // view that draws no text and for every paragraph that says nothing about
458
+ // `textAlignVertical`.
459
+ //
460
+ // The views inline in a paragraph are moved by it, the way a ScrollView's
461
+ // offset moves its children: React Native measures an attachment against the
462
+ // content box and places it from the top -- `ParagraphShadowNode::layout`
463
+ // adds the content insets and nothing else -- so it knows nothing about a box
464
+ // taller than its text. Without this a marker inside a bottom-aligned
465
+ // sentence stayed at the top while the words went to the bottom.
466
+ float textVerticalOffset() const;
467
+
468
+ // --- Selecting that text ----------------------------------------------------
469
+ //
470
+ // `<Text selectable>`, which `userSelect` also arrives in. The same four
471
+ // questions the other two hosts answer, in the same order and in DirectWrite's
472
+ // unit -- UTF-16 code units, which is also AppKit's. The state machine above
473
+ // them is core/TextSelection.h, shared by all three.
474
+ void setTextSelectable(bool selectable);
475
+ bool textSelectable() const { return textSelectable_; }
476
+
477
+ // -1 when this view draws no paragraph. The point is in the view's own
478
+ // coordinates.
479
+ int textIndexAtPoint(float x, float y) const;
480
+
481
+ void setTextSelection(int start, int length);
482
+ int textSelectionStart() const;
483
+ int textSelectionLength() const;
484
+
485
+ // The selected text, or empty when nothing is selected.
486
+ std::string selectedText() const;
487
+
488
+ // What the paragraph's dump lines say, which neither the box nor the string
489
+ // can show: the direction the app asked for -- "ltr", "rtl", "natural" or
490
+ // null -- and the edge its text ended up against, resolved. Both are literals
491
+ // from core, so the three hosts print the same words; see
492
+ // core/TextAlignments.h and core/WritingDirections.h.
493
+ void setParagraphNames(const char *writingDirection,
494
+ const char *textAlign,
495
+ const char *textVerticalAlign);
496
+
497
+ // The decoded pixels of an <Image>, and how they fill this view's frame. Pass
498
+ // null to clear.
499
+ //
500
+ // Shared rather than owned for the same reason as the paragraph: a mutation
501
+ // that changed only layout must not restart a load, or an <Image> flickers
502
+ // whenever its parent resizes.
503
+ void setImage(std::shared_ptr<RnWin32Image> image, RnImageFit fit);
504
+
505
+ // `tintColor`: recolours the image keeping its alpha. Separate from the image
506
+ // because the tint arrives from the props and the image from a loader, and
507
+ // either can land first.
508
+ void setImageTint(bool hasTint, const float components[4]);
509
+
510
+ // `blurRadius`: blurs the image and not the view, which is what the prop
511
+ // means. Separate from the image for the reason the tint is, and in the
512
+ // view's coordinates rather than the image's pixels, which is the rule the
513
+ // other two hosts measured. Zero or less is no blur.
514
+ void setImageBlur(float radius);
515
+ float imageBlur() const { return imageBlur_; }
516
+
517
+ // The frames of an animated image, their delays as the file carried them,
518
+ // and how many times round. Fewer than two frames clears any animation.
519
+ //
520
+ // The view shows frame zero and advances no further by itself: the host's
521
+ // timer calls `advanceImageAnimations` on the tree, which is what keeps a
522
+ // test about frames deterministic. Both other hosts are split the same way.
523
+ //
524
+ // Passing the same frames again is a no-op, so the re-apply on every
525
+ // mutation does not restart the animation; the loader keeps one vector per
526
+ // URI for exactly that.
527
+ void setImageFrames(std::vector<std::shared_ptr<RnWin32Image>> frames,
528
+ std::vector<unsigned> delaysMs,
529
+ unsigned loopCount);
530
+ // Moves this view's animation on and shows the frame that lands on,
531
+ // answering with how long until the next one, or zero when nothing more is
532
+ // due.
533
+ double advanceImageAnimation(double milliseconds);
534
+ // The same for this view and everything inside it, which is what the host
535
+ // calls. Answers true while anything is still animating.
536
+ bool advanceImageAnimations(double milliseconds);
537
+ bool hasAnimatedImage() const;
538
+ const std::shared_ptr<RnWin32Image> &image() const { return image_; }
539
+ RnImageFit imageFit() const { return imageFit_; }
540
+
541
+ // The painter for this view, or null. Drawn just above where an image would
542
+ // be: a `<Canvas>` carries neither an image nor a paragraph, so the two
543
+ // never meet and the order is a decision rather than a conflict.
544
+ //
545
+ // Shared rather than owned because the thing on the other end outlives a
546
+ // single mutation -- it holds the surface the last frame was rendered into,
547
+ // and rebuilding it per transaction would throw that frame away.
548
+ void setPainter(std::shared_ptr<RnWin32Painter> painter);
549
+ const std::shared_ptr<RnWin32Painter> &painter() const { return painter_; }
550
+
551
+ // --- Controls ----------------------------------------------------------------
552
+ //
553
+ // <ActivityIndicator>, <RefreshControl> and <Switch>, which the other two
554
+ // hosts mount a real toolkit widget for and this one draws.
555
+ //
556
+ // Not an oversight and not laziness: Windows has no spinner control at all
557
+ // (the closest is a marquee progress bar, which is a moving stripe), and no
558
+ // switch either -- the Win32 approximation is a checkbox, and WinUI's toggle
559
+ // is not reachable from a plain HWND app. Both would also be child windows,
560
+ // which is the one thing this view layer is built to avoid; see the note at
561
+ // the top about USER32's handle budget. So they are painted, in the same
562
+ // Direct2D walk as everything else, which is also what makes them appear in
563
+ // the offscreen snapshot the tests compare.
564
+ enum class Control { None, Spinner, Switch };
565
+
566
+ // Everything the drawing needs, which is core/DesktopControls.h's
567
+ // ControlState with the parts that are not pixels left out. A plain struct
568
+ // rather than that type because this target does not link React Native --
569
+ // the demo and half the tests build a view tree with no Fabric anywhere.
570
+ struct ControlStyle {
571
+ bool on = false;
572
+ bool disabled = false;
573
+ bool large = false;
574
+ bool hidesWhenStopped = true;
575
+ bool hasThumb = false;
576
+ float thumb[4] = {0.0f, 0.0f, 0.0f, 0.0f};
577
+ bool hasTrackOn = false;
578
+ float trackOn[4] = {0.0f, 0.0f, 0.0f, 0.0f};
579
+ bool hasTrackOff = false;
580
+ float trackOff[4] = {0.0f, 0.0f, 0.0f, 0.0f};
581
+ };
582
+
583
+ // `description` is what describeTree prints, written by
584
+ // core/DesktopControls.h so that three hosts cannot describe the same switch
585
+ // differently.
586
+ void setControl(Control kind, const ControlStyle &style, std::string description);
587
+ Control control() const { return control_; }
588
+ const ControlStyle &controlStyle() const { return controlStyle_; }
589
+
590
+ // Whether anything in this subtree is a spinner that is turning, and so
591
+ // whether the window has to keep repainting. The host asks the surface root
592
+ // once a frame; see main_win32.cpp.
593
+ bool hasAnimatingSpinner() const;
594
+
595
+ // --- React DevTools' overlay -------------------------------------------------
596
+ //
597
+ // The rectangles a `DebuggingOverlay` draws: an inspected element's blue box,
598
+ // or an outline around everything that just re-rendered. Set from
599
+ // Win32MountingManager, which parses them; see core/DebuggingOverlay.h.
600
+ struct Highlight {
601
+ float x = 0.0f;
602
+ float y = 0.0f;
603
+ float width = 0.0f;
604
+ float height = 0.0f;
605
+ float color[4] = {0.0f, 0.0f, 0.0f, 0.0f};
606
+ bool filled = false;
607
+ };
608
+
609
+ void setHighlights(std::vector<Highlight> highlights);
610
+ const std::vector<Highlight> &highlights() const { return highlights_; }
611
+
612
+ // --- Accessibility ---------------------------------------------------------
613
+
614
+ // What a screen reader is told. Unlike GTK, where the role is a
615
+ // construct-only property and so cannot change after mount, every field here
616
+ // is free to change at any time -- UI Automation pulls rather than being
617
+ // pushed to, so the provider simply reads the current value. See
618
+ // RnWin32Accessible.h.
619
+ void setAccessibleInfo(const RnAccessibleInfo &info);
620
+ const RnAccessibleInfo &accessibleInfo() const { return accessible_; }
621
+
622
+ // What a `<TextInput>` asked for about spelling and about the kind of text it
623
+ // holds, as React Native's own words.
624
+ //
625
+ // Reported rather than acted on, and that is the point: a classic `EDIT` has
626
+ // no spell checker and no autocorrection at all, so the dump is where an app
627
+ // can see that the prop arrived and the support page is where it says what
628
+ // this platform did with it. The two other hosts report the same four words
629
+ // for the same reason -- each honours a different subset. `nullptr` for
630
+ // spelling means the app said nothing, which is a third state rather than
631
+ // off; the other two are plain enums with React Native's own defaults.
632
+ void setTextChecking(const char *spellCheck, const char *autoCorrect);
633
+ void setInputKinds(const char *autoCapitalize, const char *keyboardType);
634
+
635
+ // `caretHidden` and `contextMenuHidden`, for the tree dump. What this host
636
+ // *does* with them is a caret bitmap of zeroes and a swallowed
637
+ // WM_CONTEXTMENU; see Win32TextInput.cpp. Printed because neither is
638
+ // otherwise visible to anything: a hidden caret is the absence of a blink and
639
+ // a suppressed menu the absence of a menu.
640
+ void setInputHiding(bool caretHidden, bool contextMenuHidden);
641
+
642
+ // `accessibilityLabelledBy`, resolved to views by `core/LabelRegistry.h`:
643
+ // other views whose text names this one.
644
+ //
645
+ // Held as pointers because the relation is between views and the tree outlives
646
+ // any one transaction; the *provider* takes a snapshot, which is where the
647
+ // thread-safety rule at the top of RnWin32Accessible.h is answered.
648
+ void setLabelledBy(std::vector<RnWin32View *> labels);
649
+ const std::vector<RnWin32View *> &labelledBy() const { return labelledBy_; }
650
+
651
+ // Every bit of text in this subtree, in paint order, joined with spaces.
652
+ //
653
+ // What a live region says: `accessibilityLiveRegion` reads a status message
654
+ // out when it changes, and the message is whatever the region contains. Both
655
+ // other hosts collect it the same way and for the same reason -- a status line
656
+ // is a <View> with a <Text> inside it, and the view itself carries no string.
657
+ std::string collectText() const;
658
+
659
+ // Reads `text` out through UI Automation, assertively or politely.
660
+ //
661
+ // `UiaRaiseNotificationEvent` is the call that speaks a string: UIA otherwise
662
+ // has no "say this" at all, only properties a client may notice changing.
663
+ // Recorded as well as raised, because nothing in an automated run has a
664
+ // screen reader attached -- the same arrangement GTK uses, where the text is
665
+ // kept even on versions with no `gtk_accessible_announce`.
666
+ void announce(const std::string &text, bool assertive);
667
+ const std::string &lastAnnouncement() const { return lastAnnouncement_; }
668
+
669
+ // A UIA provider over this view, or null when the view is not an
670
+ // accessibility element. The caller owns a reference and must Release it.
671
+ IRawElementProviderSimple *createAccessibleProvider() const;
672
+
673
+ // --- Tree ----------------------------------------------------------------
674
+ //
675
+ // A view does not own its children. The mounting registry owns every view,
676
+ // which is what makes Fabric's "a Remove detaches but must not destroy" rule
677
+ // structural here rather than a reference count that has to be got right: a
678
+ // detached view is simply a view with no parent, still in the registry, ready
679
+ // for the Insert that reparents it. Callers with no registry -- the demo, the
680
+ // tests -- hold their views in a vector of unique_ptr.
681
+
682
+ void insertChild(RnWin32View *child, int index);
683
+ void removeChild(RnWin32View *child);
684
+ const std::vector<RnWin32View *> &children() const { return children_; }
685
+ RnWin32View *parent() const { return parent_; }
686
+
687
+ // The children in the order they are painted: mutation order, restacked by
688
+ // zIndex where any child has one. Painting walks this forwards and hit
689
+ // testing walks it backwards, and they call the same function so that the
690
+ // view a click lands on is always the view drawn on top.
691
+ //
692
+ // Returns a copy. Painting used to avoid it in the common case; one
693
+ // definition of paint order is worth more than the allocation.
694
+ std::vector<RnWin32View *> childrenInPaintOrder() const;
695
+
696
+ // --- Geometry, resolved ----------------------------------------------------
697
+
698
+ // This view's local-to-parent transform, as the six numbers of a 2D affine
699
+ // matrix in Direct2D's Matrix3x2F order: the frame's translation, with any
700
+ // `transform` composed in about the view's centre.
701
+ //
702
+ // Public, and the only place that composition is written. `paint` builds its
703
+ // Direct2D matrix from these and `hitTest` inverts them, so the two cannot
704
+ // disagree about where a view is -- which would show up as a rotated button
705
+ // that is clickable where it used to be, and is exactly the bug
706
+ // `docs/DECISIONS.md` records GTK hitting.
707
+ void localToParent(float out[6]) const;
708
+
709
+ // A point in `root`'s coordinates, expressed in this view's own.
710
+ //
711
+ // Walks up composing `localToParent` and inverts the chain, which is the
712
+ // same matrix `hitTest` inverts one level at a time on the way down -- so a
713
+ // press and the coordinates it reports cannot disagree about where a view
714
+ // is. Answers false when the chain has no inverse, which `scale: 0` produces
715
+ // and which has no sensible point in it.
716
+ bool pageToLocal(const RnWin32View *root, float pageX, float pageY,
717
+ float &outX, float &outY) const;
718
+
719
+ // --- Painting ------------------------------------------------------------
720
+
721
+ // Paints this view and its subtree into `target`, which must be between
722
+ // BeginDraw and EndDraw. The target's transform on entry is the one this
723
+ // view's frame is relative to, and it is restored before returning.
724
+ void paint(ID2D1RenderTarget *target) const;
725
+
726
+ // --- Reporting -----------------------------------------------------------
727
+
728
+ // One line per view, two spaces of indent per level.
729
+ //
730
+ // The format is a cross-platform contract, not a debug convenience:
731
+ // `scripts/compare_hosts.sh` diffs two hosts' dumps line by line, so the
732
+ // fields and their order match `rn_view_describe_into` in gtk/RnView.cpp and
733
+ // `describeInto:depth:` in appkit/RnAppKitView.mm exactly. A field added in
734
+ // the wrong place makes every line differ.
735
+ std::string describeTree() const;
736
+
737
+ private:
738
+ // Paints the children into whatever space the target's transform is already
739
+ // in, which is this view's own. Separate from `paint` so the clip and the
740
+ // scroll offset have an obvious scope, and so no Direct2D type appears above.
741
+ void paintChildren(ID2D1RenderTarget *target,
742
+ ID2D1BitmapRenderTarget *blendLayer = nullptr) const;
743
+ // The spinner and the switch, drawn into this view's own coordinates.
744
+ void paintControl(ID2D1RenderTarget *target) const;
745
+ // React DevTools' overlay, over everything including the children.
746
+ void paintHighlights(ID2D1RenderTarget *target) const;
747
+ // The overlay scrollbars, in this view's own coordinates.
748
+ void paintScrollIndicators(ID2D1RenderTarget *target) const;
749
+ // Recomputes whether the back face is showing, and hides or shows the view.
750
+ void updateBackFace();
751
+ void applyVisibility();
752
+ void collectTextInto(std::string &out) const;
753
+ void paintBorders(ID2D1RenderTarget *target) const;
754
+ void paintStrokedBorder(ID2D1RenderTarget *target) const;
755
+ void paintOutline(ID2D1RenderTarget *target) const;
756
+ // This view and everything inside it, with the target's transform already
757
+ // placing its origin at zero. Split out of `paint` so that a filtered view
758
+ // can draw the same thing into an offscreen bitmap and run an effect graph
759
+ // over it.
760
+ //
761
+ // `blendLayer` is the offscreen `target` draws into when this view's whole
762
+ // subtree goes through one, and null when it draws straight onto the window.
763
+ // Only a blended child needs it: `mixBlendMode` has to read what is beneath
764
+ // it, and what is beneath it is that bitmap.
765
+ void paintContents(ID2D1RenderTarget *target,
766
+ ID2D1BitmapRenderTarget *blendLayer = nullptr) const;
767
+ void paintFiltered(ID2D1RenderTarget *target) const;
768
+ // This view's subtree through an offscreen, so that a blended child has a
769
+ // backdrop to read. The view's opacity is applied to that bitmap rather than
770
+ // inside it, which is both cheaper than a layer and necessary: a pushed layer
771
+ // holds what is drawn in an intermediate surface the backdrop cannot see.
772
+ void paintBlendLayer(ID2D1RenderTarget *target) const;
773
+ // Blends one child into the layer, in place of painting it onto the target.
774
+ void blendChildIntoLayer(ID2D1BitmapRenderTarget *layer, const RnWin32View *child) const;
775
+ bool hasBlendedChild() const;
776
+ // The shadows of one kind, back to front. Called twice by `paintContents`:
777
+ // the outset ones before the background and the inset ones after it.
778
+ // The `backgroundImage` gradients, over the background colour.
779
+ void paintGradients(ID2D1RenderTarget *target) const;
780
+ void paintBoxShadows(ID2D1RenderTarget *target, bool inset) const;
781
+ void paintBoxShadow(ID2D1RenderTarget *target, const BoxShadow &shadow) const;
782
+ void describeInto(std::string &out, int depth) const;
783
+
784
+ int32_t tag_;
785
+ RnRect frame_;
786
+ RnWin32View *parent_ = nullptr;
787
+ std::vector<RnWin32View *> children_;
788
+
789
+ bool hasBackgroundColor_ = false;
790
+ float backgroundColor_[4] = {0.0f, 0.0f, 0.0f, 0.0f};
791
+ float opacity_ = 1.0f;
792
+ bool clipsChildren_ = false;
793
+ // See setCornerRadii and setBorders for the orders these are kept in.
794
+ float cornerRadii_[8] = {};
795
+ bool hasCornerRadii_ = false;
796
+ float borderWidths_[4] = {};
797
+ float borderColours_[16] = {};
798
+ bool hasBorders_ = false;
799
+ HWND editablePeer_ = nullptr;
800
+ std::string nativeId_;
801
+ int zIndex_ = 0;
802
+ PointerEvents pointerEvents_ = PointerEvents::Auto;
803
+ float hitSlop_[4] = {0.0f, 0.0f, 0.0f, 0.0f};
804
+ bool hasHitSlop_ = false;
805
+ float outlineWidth_ = 0.0f;
806
+ float outlineOffset_ = 0.0f;
807
+ float outlineColour_[4] = {0.0f, 0.0f, 0.0f, 0.0f};
808
+ LineStyle outlineStyle_ = LineStyle::Solid;
809
+ LineStyle borderStyle_ = LineStyle::Solid;
810
+ bool focusable_ = false;
811
+ bool showsFocusRing_ = false;
812
+ float scrollX_ = 0.0f;
813
+ float scrollY_ = 0.0f;
814
+ // `caretHidden` and `contextMenuHidden`, for the dump. What the peer does
815
+ // about them is in Win32TextInput.cpp.
816
+ bool caretHidden_ = false;
817
+ bool contextMenuHidden_ = false;
818
+
819
+ float indicatorVerticalOffset_ = 0.0f;
820
+ float indicatorVerticalLength_ = 0.0f;
821
+ float indicatorHorizontalOffset_ = 0.0f;
822
+ float indicatorHorizontalLength_ = 0.0f;
823
+ // The thumb's colour. Core's default rather than a spelled one, so the three
824
+ // hosts cannot drift: black and translucent.
825
+ float indicatorColour_[4] = {0.0f,
826
+ 0.0f,
827
+ 0.0f,
828
+ basalt::kScrollIndicatorAlpha};
829
+ // And the hairline around it, which only `default` has. Core's answer for
830
+ // that style, for the same reason: white, and rather more opaque than the
831
+ // fill so that it separates the thumb from what is behind it.
832
+ float indicatorBorderColour_[4] = {1.0f,
833
+ 1.0f,
834
+ 1.0f,
835
+ basalt::kScrollIndicatorBorderAlpha};
836
+
837
+ bool hidden_ = false;
838
+ bool hidesBackFace_ = false;
839
+ // Set by the back-face rule rather than by the app, so that clearing the
840
+ // rule does not un-hide a view the app itself hid.
841
+ bool hiddenByBackFace_ = false;
842
+ bool hiddenByApp_ = false;
843
+ std::vector<Highlight> highlights_;
844
+ Control control_ = Control::None;
845
+ ControlStyle controlStyle_;
846
+ std::string controlDescription_;
847
+ std::shared_ptr<RnWin32TextLayout> textLayout_;
848
+ const char *writingDirectionName_ = nullptr;
849
+ const char *textAlignName_ = nullptr;
850
+ const char *textVerticalAlignName_ = nullptr;
851
+ // This scroll view's snapping, as core formats it for the dump; see
852
+ // setScrollSnap.
853
+ std::string scrollSnap_;
854
+ // The paragraph's padding and border; see setTextInset.
855
+ float textInsetLeft_ = 0.0f;
856
+ float textInsetTop_ = 0.0f;
857
+ float textInsetRight_ = 0.0f;
858
+ float textInsetBottom_ = 0.0f;
859
+ // `<Text selectable>`; the range itself lives on the layout, which draws it.
860
+ bool textSelectable_ = false;
861
+ std::shared_ptr<RnWin32Image> image_;
862
+ std::shared_ptr<RnWin32Painter> painter_;
863
+ RnImageFit imageFit_ = RnImageFit::Cover;
864
+ bool hasImageTint_ = false;
865
+ float imageTint_[4] = {0.0f, 0.0f, 0.0f, 0.0f};
866
+ float imageBlur_ = 0.0f;
867
+ // An animated image. `image_` is whichever frame is showing, so everything
868
+ // that draws an image stays unchanged.
869
+ std::vector<std::shared_ptr<RnWin32Image>> imageFrames_;
870
+ std::vector<unsigned> imageDelays_;
871
+ unsigned imageLoopCount_ = 0;
872
+ size_t imageFrame_ = 0;
873
+ double imageElapsedMs_ = 0.0;
874
+ Filters filters_;
875
+ std::string spellCheck_;
876
+ std::string autoCorrect_;
877
+ std::string autoCapitalize_;
878
+ std::string keyboardType_;
879
+ std::string cursor_;
880
+ std::vector<Gradient> gradients_;
881
+ std::vector<BoxShadow> boxShadows_;
882
+ // `mixBlendMode`: the keyword the app asked for, and whether this host can
883
+ // blend it. Both, because the dump reports the first and the paint path asks
884
+ // the second.
885
+ std::string blendMode_;
886
+ bool blends_ = false;
887
+ RnAccessibleInfo accessible_;
888
+ std::vector<RnWin32View *> labelledBy_;
889
+ std::string lastAnnouncement_;
890
+ bool hasTransform_ = false;
891
+ // The 2D affine part, in the order Direct2D's Matrix3x2F stores it:
892
+ // _11, _12, _21, _22, _31, _32 -- which is also the order CSS writes a
893
+ // matrix() and the six numbers describeTree prints.
894
+ float transform_[6] = {1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f};
895
+ };
896
+
897
+ // The deepest view at a point, in `root`'s own coordinates, or null for a miss.
898
+ //
899
+ // A free function because it is a pure function of the view tree and nothing
900
+ // else, which is also what makes it testable: hit testing is the part of input
901
+ // most likely to be quietly wrong, and it needs no mouse to exercise. It lives
902
+ // here rather than with a touch dispatcher so that testing it needs no React
903
+ // Native, which is the arrangement the AppKit side settled on too.
904
+ //
905
+ // Windows differs from both other platforms in having to do this at all. GTK
906
+ // gets picking from `gtk_widget_pick` and macOS from AppKit's own hit testing,
907
+ // so on those two the transform has to be pushed *into* the toolkit's geometry
908
+ // or clicks land in the wrong place. Here there is no toolkit geometry to push
909
+ // it into, so this inverts each view's matrix on the way down -- which means a
910
+ // rotated view is clickable where it is drawn, and it is `localToParent` that
911
+ // guarantees "where it is drawn" means the same thing to both.
912
+ RnWin32View *hitTest(RnWin32View *root, float x, float y);
913
+
914
+ // The `cursor` keyword that applies at a point, or an empty string for none.
915
+ //
916
+ // Hit tests and then walks up: CSS's cursor inherits, so a <Text> inside a
917
+ // `cursor: 'pointer'` button shows the hand even though the text itself asked
918
+ // for nothing. Both other hosts get that from their toolkit -- a GTK widget
919
+ // with no cursor of its own inherits its parent's, and an AppKit view installs
920
+ // no cursor rect -- so this is the one place in this project that spells it out.
921
+ //
922
+ // Here rather than in the host because it is the view tree's question, and
923
+ // because this way it has a test that needs no window.
924
+ std::string cursorNameAt(RnWin32View *root, float x, float y);
925
+
926
+ } // namespace basalt::win32