react-native-windows 0.81.20 → 0.81.22

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.
@@ -0,0 +1,334 @@
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ // This is version 2 of SpookyHash, incompatible with version 1.
18
+ //
19
+ // SpookyHash: a 128-bit noncryptographic hash function
20
+ // By Bob Jenkins, public domain
21
+ // Oct 31 2010: alpha, framework + SpookyHash::Mix appears right
22
+ // Oct 31 2011: alpha again, Mix only good to 2^^69 but rest appears right
23
+ // Dec 31 2011: beta, improved Mix, tested it for 2-bit deltas
24
+ // Feb 2 2012: production, same bits as beta
25
+ // Feb 5 2012: adjusted definitions of uint* to be more portable
26
+ // Mar 30 2012: 3 bytes/cycle, not 4. Alpha was 4 but wasn't thorough enough.
27
+ // August 5 2012: SpookyV2 (different results)
28
+ //
29
+ // Up to 3 bytes/cycle for long messages. Reasonably fast for short messages.
30
+ // All 1 or 2 bit deltas achieve avalanche within 1% bias per output bit.
31
+ //
32
+ // This was developed for and tested on 64-bit x86-compatible processors.
33
+ // It assumes the processor is little-endian. There is a macro
34
+ // controlling whether unaligned reads are allowed (by default they are).
35
+ // This should be an equally good hash on big-endian machines, but it will
36
+ // compute different results on them than on little-endian machines.
37
+ //
38
+ // Google's CityHash has similar specs to SpookyHash, and CityHash is faster
39
+ // on new Intel boxes. MD4 and MD5 also have similar specs, but they are orders
40
+ // of magnitude slower. CRCs are two or more times slower, but unlike
41
+ // SpookyHash, they have nice math for combining the CRCs of pieces to form
42
+ // the CRCs of wholes. There are also cryptographic hashes, but those are even
43
+ // slower than MD5.
44
+ //
45
+
46
+ #pragma once
47
+
48
+ #include <cassert>
49
+ #include <cstddef>
50
+ #include <cstdint>
51
+
52
+ #include <folly/CPortability.h>
53
+ #include <folly/Portability.h>
54
+ #include <folly/lang/CString.h>
55
+
56
+ namespace folly {
57
+ namespace hash {
58
+
59
+ // clang-format off
60
+
61
+ class SpookyHashV2
62
+ {
63
+ public:
64
+ //
65
+ // SpookyHash: hash a single message in one call, produce 128-bit output
66
+ //
67
+ static void Hash128(
68
+ const void *message, // message to hash
69
+ size_t length, // length of message in bytes
70
+ uint64_t *hash1, // in/out: in seed 1, out hash value 1
71
+ uint64_t *hash2); // in/out: in seed 2, out hash value 2
72
+
73
+ //
74
+ // Hash64: hash a single message in one call, return 64-bit output
75
+ //
76
+ static uint64_t Hash64(
77
+ const void *message, // message to hash
78
+ size_t length, // length of message in bytes
79
+ uint64_t seed) // seed
80
+ {
81
+ uint64_t hash1 = seed;
82
+ Hash128(message, length, &hash1, &seed);
83
+ return hash1;
84
+ }
85
+
86
+ //
87
+ // Hash32: hash a single message in one call, produce 32-bit output
88
+ //
89
+ static uint32_t Hash32(
90
+ const void *message, // message to hash
91
+ size_t length, // length of message in bytes
92
+ uint32_t seed) // seed
93
+ {
94
+ uint64_t hash1 = seed, hash2 = seed;
95
+ Hash128(message, length, &hash1, &hash2);
96
+ return (uint32_t)hash1;
97
+ }
98
+
99
+ //
100
+ // Init: initialize the context of a SpookyHash
101
+ //
102
+ void Init(
103
+ uint64_t seed1, // any 64-bit value will do, including 0
104
+ uint64_t seed2); // different seeds produce independent hashes
105
+
106
+ //
107
+ // Update: add a piece of a message to a SpookyHash state
108
+ //
109
+ void Update(
110
+ const void *message, // message fragment
111
+ size_t length); // length of message fragment in bytes
112
+
113
+
114
+ //
115
+ // Final: compute the hash for the current SpookyHash state
116
+ //
117
+ // This does not modify the state; you can keep updating it afterward
118
+ //
119
+ // The result is the same as if SpookyHash() had been called with
120
+ // all the pieces concatenated into one message.
121
+ //
122
+ void Final(
123
+ uint64_t *hash1, // out only: first 64 bits of hash value.
124
+ uint64_t *hash2) const; // out only: second 64 bits of hash value.
125
+
126
+ //
127
+ // left rotate a 64-bit value by k bytes
128
+ //
129
+ static inline uint64_t Rot64(uint64_t x, int k)
130
+ {
131
+ return (x << k) | (x >> (64 - k));
132
+ }
133
+
134
+ //
135
+ // This is used if the input is 96 bytes long or longer.
136
+ //
137
+ // The internal state is fully overwritten every 96 bytes.
138
+ // Every input bit appears to cause at least 128 bits of entropy
139
+ // before 96 other bytes are combined, when run forward or backward
140
+ // For every input bit,
141
+ // Two inputs differing in just that input bit
142
+ // Where "differ" means xor or subtraction
143
+ // And the base value is random
144
+ // When run forward or backwards one Mix
145
+ // I tried 3 pairs of each; they all differed by at least 212 bits.
146
+ //
147
+ static inline void Mix(
148
+ const uint64_t *data,
149
+ uint64_t &s0, uint64_t &s1, uint64_t &s2, uint64_t &s3,
150
+ uint64_t &s4, uint64_t &s5, uint64_t &s6, uint64_t &s7,
151
+ uint64_t &s8, uint64_t &s9, uint64_t &s10,uint64_t &s11)
152
+ {
153
+ auto read = [&](auto off) { return Read8(data, off); };
154
+ s0 += read(0); s2 ^= s10; s11 ^= s0; s0 = Rot64(s0,11); s11 += s1;
155
+ s1 += read(1); s3 ^= s11; s0 ^= s1; s1 = Rot64(s1,32); s0 += s2;
156
+ s2 += read(2); s4 ^= s0; s1 ^= s2; s2 = Rot64(s2,43); s1 += s3;
157
+ s3 += read(3); s5 ^= s1; s2 ^= s3; s3 = Rot64(s3,31); s2 += s4;
158
+ s4 += read(4); s6 ^= s2; s3 ^= s4; s4 = Rot64(s4,17); s3 += s5;
159
+ s5 += read(5); s7 ^= s3; s4 ^= s5; s5 = Rot64(s5,28); s4 += s6;
160
+ s6 += read(6); s8 ^= s4; s5 ^= s6; s6 = Rot64(s6,39); s5 += s7;
161
+ s7 += read(7); s9 ^= s5; s6 ^= s7; s7 = Rot64(s7,57); s6 += s8;
162
+ s8 += read(8); s10 ^= s6; s7 ^= s8; s8 = Rot64(s8,55); s7 += s9;
163
+ s9 += read(9); s11 ^= s7; s8 ^= s9; s9 = Rot64(s9,54); s8 += s10;
164
+ s10 += read(10); s0 ^= s8; s9 ^= s10; s10 = Rot64(s10,22); s9 += s11;
165
+ s11 += read(11); s1 ^= s9; s10 ^= s11; s11 = Rot64(s11,46); s10 += s0;
166
+ }
167
+
168
+ //
169
+ // Mix all 12 inputs together so that h0, h1 are a hash of them all.
170
+ //
171
+ // For two inputs differing in just the input bits
172
+ // Where "differ" means xor or subtraction
173
+ // And the base value is random, or a counting value starting at that bit
174
+ // The final result will have each bit of h0, h1 flip
175
+ // For every input bit,
176
+ // with probability 50 +- .3%
177
+ // For every pair of input bits,
178
+ // with probability 50 +- 3%
179
+ //
180
+ // This does not rely on the last Mix() call having already mixed some.
181
+ // Two iterations was almost good enough for a 64-bit result, but a
182
+ // 128-bit result is reported, so End() does three iterations.
183
+ //
184
+ static inline void EndPartial(
185
+ uint64_t &h0, uint64_t &h1, uint64_t &h2, uint64_t &h3,
186
+ uint64_t &h4, uint64_t &h5, uint64_t &h6, uint64_t &h7,
187
+ uint64_t &h8, uint64_t &h9, uint64_t &h10,uint64_t &h11)
188
+ {
189
+ h11+= h1; h2 ^= h11; h1 = Rot64(h1,44);
190
+ h0 += h2; h3 ^= h0; h2 = Rot64(h2,15);
191
+ h1 += h3; h4 ^= h1; h3 = Rot64(h3,34);
192
+ h2 += h4; h5 ^= h2; h4 = Rot64(h4,21);
193
+ h3 += h5; h6 ^= h3; h5 = Rot64(h5,38);
194
+ h4 += h6; h7 ^= h4; h6 = Rot64(h6,33);
195
+ h5 += h7; h8 ^= h5; h7 = Rot64(h7,10);
196
+ h6 += h8; h9 ^= h6; h8 = Rot64(h8,13);
197
+ h7 += h9; h10^= h7; h9 = Rot64(h9,38);
198
+ h8 += h10; h11^= h8; h10= Rot64(h10,53);
199
+ h9 += h11; h0 ^= h9; h11= Rot64(h11,42);
200
+ h10+= h0; h1 ^= h10; h0 = Rot64(h0,54);
201
+ }
202
+
203
+ static inline void End(
204
+ const uint64_t *data,
205
+ uint64_t &h0, uint64_t &h1, uint64_t &h2, uint64_t &h3,
206
+ uint64_t &h4, uint64_t &h5, uint64_t &h6, uint64_t &h7,
207
+ uint64_t &h8, uint64_t &h9, uint64_t &h10,uint64_t &h11)
208
+ {
209
+ h0 += data[0]; h1 += data[1]; h2 += data[2]; h3 += data[3];
210
+ h4 += data[4]; h5 += data[5]; h6 += data[6]; h7 += data[7];
211
+ h8 += data[8]; h9 += data[9]; h10 += data[10]; h11 += data[11];
212
+ EndPartial(h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11);
213
+ EndPartial(h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11);
214
+ EndPartial(h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11);
215
+ }
216
+
217
+ //
218
+ // The goal is for each bit of the input to expand into 128 bits of
219
+ // apparent entropy before it is fully overwritten.
220
+ // n trials both set and cleared at least m bits of h0 h1 h2 h3
221
+ // n: 2 m: 29
222
+ // n: 3 m: 46
223
+ // n: 4 m: 57
224
+ // n: 5 m: 107
225
+ // n: 6 m: 146
226
+ // n: 7 m: 152
227
+ // when run forwards or backwards
228
+ // for all 1-bit and 2-bit diffs
229
+ // with diffs defined by either xor or subtraction
230
+ // with a base of all zeros plus a counter, or plus another bit, or random
231
+ //
232
+ static inline void ShortMix(uint64_t &h0, uint64_t &h1,
233
+ uint64_t &h2, uint64_t &h3)
234
+ {
235
+ h2 = Rot64(h2,50); h2 += h3; h0 ^= h2;
236
+ h3 = Rot64(h3,52); h3 += h0; h1 ^= h3;
237
+ h0 = Rot64(h0,30); h0 += h1; h2 ^= h0;
238
+ h1 = Rot64(h1,41); h1 += h2; h3 ^= h1;
239
+ h2 = Rot64(h2,54); h2 += h3; h0 ^= h2;
240
+ h3 = Rot64(h3,48); h3 += h0; h1 ^= h3;
241
+ h0 = Rot64(h0,38); h0 += h1; h2 ^= h0;
242
+ h1 = Rot64(h1,37); h1 += h2; h3 ^= h1;
243
+ h2 = Rot64(h2,62); h2 += h3; h0 ^= h2;
244
+ h3 = Rot64(h3,34); h3 += h0; h1 ^= h3;
245
+ h0 = Rot64(h0,5); h0 += h1; h2 ^= h0;
246
+ h1 = Rot64(h1,36); h1 += h2; h3 ^= h1;
247
+ }
248
+
249
+ //
250
+ // Mix all 4 inputs together so that h0, h1 are a hash of them all.
251
+ //
252
+ // For two inputs differing in just the input bits
253
+ // Where "differ" means xor or subtraction
254
+ // And the base value is random, or a counting value starting at that bit
255
+ // The final result will have each bit of h0, h1 flip
256
+ // For every input bit,
257
+ // with probability 50 +- .3% (it is probably better than that)
258
+ // For every pair of input bits,
259
+ // with probability 50 +- .75% (the worst case is approximately that)
260
+ //
261
+ static inline void ShortEnd(uint64_t &h0, uint64_t &h1,
262
+ uint64_t &h2, uint64_t &h3)
263
+ {
264
+ h3 ^= h2; h2 = Rot64(h2,15); h3 += h2;
265
+ h0 ^= h3; h3 = Rot64(h3,52); h0 += h3;
266
+ h1 ^= h0; h0 = Rot64(h0,26); h1 += h0;
267
+ h2 ^= h1; h1 = Rot64(h1,51); h2 += h1;
268
+ h3 ^= h2; h2 = Rot64(h2,28); h3 += h2;
269
+ h0 ^= h3; h3 = Rot64(h3,9); h0 += h3;
270
+ h1 ^= h0; h0 = Rot64(h0,47); h1 += h0;
271
+ h2 ^= h1; h1 = Rot64(h1,54); h2 += h1;
272
+ h3 ^= h2; h2 = Rot64(h2,32); h3 += h2;
273
+ h0 ^= h3; h3 = Rot64(h3,25); h0 += h3;
274
+ h1 ^= h0; h0 = Rot64(h0,63); h1 += h0;
275
+ }
276
+
277
+ private:
278
+
279
+ //
280
+ // Short is used for messages under 192 bytes in length
281
+ // Short has a low startup cost, the normal mode is good for long
282
+ // keys, the cost crossover is at about 192 bytes. The two modes were
283
+ // held to the same quality bar.
284
+ //
285
+ static void Short(
286
+ const void *message, // message (byte array, not necessarily aligned)
287
+ size_t length, // length of message (in bytes)
288
+ uint64_t *hash1, // in/out: in the seed, out the hash value
289
+ uint64_t *hash2); // in/out: in the seed, out the hash value
290
+
291
+ //
292
+ // Helper to read 8 consecutive bytes from a buffer
293
+ // If the platform has unaligned access, may be called with unaligned buf
294
+ // Otherwise, must be called only with aligned buf
295
+ //
296
+ FOLLY_ALWAYS_INLINE static uint64_t Read8(const uint64_t* buf, size_t off) {
297
+ if constexpr (kHasUnalignedAccess) {
298
+ uint64_t out;
299
+ FOLLY_BUILTIN_MEMCPY(&out, buf + off, sizeof(out));
300
+ return out;
301
+ } else {
302
+ //assert(0 == reinterpret_cast<uintptr_t>(buf) % sizeof(*buf)); // Windows
303
+ return buf[off];
304
+ }
305
+ }
306
+
307
+ // number of uint64_t's in internal state
308
+ static constexpr size_t sc_numVars = 12;
309
+
310
+ // size of the internal state
311
+ static constexpr size_t sc_blockSize = sc_numVars*8;
312
+
313
+ // size of buffer of unhashed data, in bytes
314
+ static constexpr size_t sc_bufSize = 2*sc_blockSize;
315
+
316
+ //
317
+ // sc_const: a constant which:
318
+ // * is not zero
319
+ // * is odd
320
+ // * is a not-very-regular mix of 1's and 0's
321
+ // * does not need any other special mathematical properties
322
+ //
323
+ static constexpr uint64_t sc_const = 0xdeadbeefdeadbeefULL;
324
+
325
+ uint64_t m_data[2*sc_numVars]; // unhashed data, for partial messages
326
+ uint64_t m_state[sc_numVars]; // internal state of the hash
327
+ size_t m_length; // total length of the input so far
328
+ uint8_t m_remainder; // length of unhashed data stashed in m_data
329
+ };
330
+
331
+ // clang-format on
332
+
333
+ } // namespace hash
334
+ } // namespace folly
@@ -227,6 +227,28 @@ void CompositionEventHandler::Initialize() noexcept {
227
227
  }
228
228
  });
229
229
 
230
+ // Issue #16047: when ScrollView calls VisualInteractionSource::TryRedirectForManipulation
231
+ // and the OS hands the pointer over to the InteractionTracker, WinAppSDK
232
+ // does not fire PointerCaptureLost on this source — but it does fire
233
+ // PointerRoutedAway. Treat it the same way as captureloss: cancel any
234
+ // active touch RN is tracking for this pointer so Pressables don't get
235
+ // stuck in their pressed state.
236
+ m_pointerRoutedAwayToken =
237
+ pointerSource.PointerRoutedAway([wkThis = weak_from_this()](
238
+ winrt::Microsoft::UI::Input::InputPointerSource const &,
239
+ winrt::Microsoft::UI::Input::PointerEventArgs const &args) {
240
+ if (auto strongThis = wkThis.lock()) {
241
+ if (auto strongRootView = strongThis->m_wkRootView.get()) {
242
+ if (strongThis->SurfaceId() == -1)
243
+ return;
244
+
245
+ auto pp = winrt::make<winrt::Microsoft::ReactNative::Composition::Input::implementation::PointerPoint>(
246
+ args.CurrentPoint(), strongRootView.ScaleFactor());
247
+ strongThis->onPointerRoutedAway(pp, args.KeyModifiers());
248
+ }
249
+ }
250
+ });
251
+
230
252
  m_pointerWheelChangedToken =
231
253
  pointerSource.PointerWheelChanged([wkThis = weak_from_this()](
232
254
  winrt::Microsoft::UI::Input::InputPointerSource const &,
@@ -374,6 +396,7 @@ CompositionEventHandler::~CompositionEventHandler() {
374
396
  pointerSource.PointerReleased(m_pointerReleasedToken);
375
397
  pointerSource.PointerMoved(m_pointerMovedToken);
376
398
  pointerSource.PointerCaptureLost(m_pointerCaptureLostToken);
399
+ pointerSource.PointerRoutedAway(m_pointerRoutedAwayToken);
377
400
  pointerSource.PointerWheelChanged(m_pointerWheelChangedToken);
378
401
  pointerSource.PointerExited(m_pointerExitedToken);
379
402
  auto keyboardSource = winrt::Microsoft::UI::Input::InputKeyboardSource::GetForIsland(island);
@@ -1123,24 +1146,49 @@ void CompositionEventHandler::onPointerCaptureLost(
1123
1146
  m_pointerCapturingComponentTag = -1;
1124
1147
  }
1125
1148
 
1126
- // Also cancel any active touch for the specific pointer that lost capture, even
1127
- // when no JS-level CapturePointer was ever issued. This handles ScrollView (and
1128
- // any other VisualInteractionSource) calling TryRedirectForManipulation: the OS
1129
- // reassigns the pointer to the InteractionTracker, fires PointerCaptureLost, and
1130
- // then stops delivering PointerMoved/PointerReleased to us. Without this cleanup
1131
- // m_activeTouches keeps a zombie entry whose target is the originally-pressed
1132
- // Pressable, leaving it visually pressed and causing later taps to be attributed
1133
- // to that original target. If the entry was already cleared above (for a JS-level
1134
- // capture) or by onPointerReleased running first, the find() is a no-op.
1135
- PointerId pointerId = pointerPoint.PointerId();
1149
+ // Defense-in-depth cleanup for the specific pointer that lost capture, even
1150
+ // when no JS-level CapturePointer was ever issued. The ScrollView
1151
+ // TryRedirectForManipulation path comes in via PointerRoutedAway, not
1152
+ // PointerCaptureLost (see onPointerRoutedAway and issue #16047), so this
1153
+ // path covers the remaining system-driven losses (focus change, another
1154
+ // window stealing input, system back gesture, etc.).
1155
+ CancelActiveTouchForPointerInternal(pointerPoint.PointerId(), pointerPoint, keyModifiers);
1156
+ }
1157
+
1158
+ void CompositionEventHandler::onPointerRoutedAway(
1159
+ const winrt::Microsoft::ReactNative::Composition::Input::PointerPoint &pointerPoint,
1160
+ winrt::Windows::System::VirtualKeyModifiers keyModifiers) noexcept {
1161
+ if (SurfaceId() == -1)
1162
+ return;
1163
+
1164
+ // Issue #16047: WinAppSDK fires PointerRoutedAway when the OS hands the
1165
+ // pointer to another InputPointerSource — most importantly for us, when
1166
+ // ScrollView calls VisualInteractionSource::TryRedirectForManipulation and
1167
+ // the InteractionTracker takes the gesture for scrolling. We never get
1168
+ // PointerMoved / PointerReleased / PointerCaptureLost for that pointer
1169
+ // afterwards, so without this cleanup m_activeTouches keeps a zombie entry
1170
+ // and the originally-pressed Pressable stays stuck in its pressed state.
1171
+ CancelActiveTouchForPointerInternal(pointerPoint.PointerId(), pointerPoint, keyModifiers);
1172
+ }
1173
+
1174
+ bool CompositionEventHandler::CancelActiveTouchForPointerInternal(
1175
+ PointerId pointerId,
1176
+ const winrt::Microsoft::ReactNative::Composition::Input::PointerPoint &pointerPoint,
1177
+ winrt::Windows::System::VirtualKeyModifiers keyModifiers) noexcept {
1136
1178
  auto activeTouch = m_activeTouches.find(pointerId);
1137
- if (activeTouch != m_activeTouches.end()) {
1138
- ActiveTouch cancelledTouchCopy = std::move(activeTouch->second);
1139
- m_activeTouches.erase(activeTouch);
1140
- if (cancelledTouchCopy.eventEmitter) {
1141
- DispatchSynthesizedTouchCancelForActiveTouch(cancelledTouchCopy, pointerPoint, keyModifiers);
1142
- }
1179
+ if (activeTouch == m_activeTouches.end()) {
1180
+ return false;
1181
+ }
1182
+
1183
+ ActiveTouch cancelledTouchCopy = std::move(activeTouch->second);
1184
+ m_activeTouches.erase(activeTouch);
1185
+
1186
+ if (!cancelledTouchCopy.eventEmitter) {
1187
+ return false;
1143
1188
  }
1189
+
1190
+ DispatchSynthesizedTouchCancelForActiveTouch(cancelledTouchCopy, pointerPoint, keyModifiers);
1191
+ return true;
1144
1192
  }
1145
1193
 
1146
1194
  void CompositionEventHandler::onPointerMoved(
@@ -66,6 +66,9 @@ class CompositionEventHandler : public std::enable_shared_from_this<CompositionE
66
66
  void onPointerCaptureLost(
67
67
  const winrt::Microsoft::ReactNative::Composition::Input::PointerPoint &pointerPoint,
68
68
  winrt::Windows::System::VirtualKeyModifiers keyModifiers) noexcept;
69
+ void onPointerRoutedAway(
70
+ const winrt::Microsoft::ReactNative::Composition::Input::PointerPoint &pointerPoint,
71
+ winrt::Windows::System::VirtualKeyModifiers keyModifiers) noexcept;
69
72
  void onKeyDown(const winrt::Microsoft::ReactNative::Composition::Input::KeyRoutedEventArgs &args) noexcept;
70
73
  void onKeyUp(const winrt::Microsoft::ReactNative::Composition::Input::KeyRoutedEventArgs &args) noexcept;
71
74
  void onCharacterReceived(
@@ -156,6 +159,13 @@ class CompositionEventHandler : public std::enable_shared_from_this<CompositionE
156
159
  const winrt::Microsoft::ReactNative::Composition::Input::PointerPoint &pointerPoint,
157
160
  winrt::Windows::System::VirtualKeyModifiers keyModifiers);
158
161
 
162
+ // Look up the active touch for pointerId, erase it, and dispatch cancel events.
163
+ // Returns true iff a touch was found and cancel events were dispatched.
164
+ bool CancelActiveTouchForPointerInternal(
165
+ PointerId pointerId,
166
+ const winrt::Microsoft::ReactNative::Composition::Input::PointerPoint &pointerPoint,
167
+ winrt::Windows::System::VirtualKeyModifiers keyModifiers) noexcept;
168
+
159
169
  std::vector<winrt::Microsoft::ReactNative::ComponentView> GetTouchableViewsInPathToRoot(
160
170
  const winrt::Microsoft::ReactNative::ComponentView &componentView);
161
171
 
@@ -187,6 +197,7 @@ class CompositionEventHandler : public std::enable_shared_from_this<CompositionE
187
197
  winrt::event_token m_pointerMovedToken;
188
198
  winrt::event_token m_pointerWheelChangedToken;
189
199
  winrt::event_token m_pointerCaptureLostToken;
200
+ winrt::event_token m_pointerRoutedAwayToken;
190
201
  winrt::event_token m_pointerExitedToken;
191
202
  winrt::event_token m_keyDownToken;
192
203
  winrt::event_token m_keyUpToken;
@@ -23,6 +23,7 @@
23
23
  #include <functional>
24
24
  #include "ContentIslandComponentView.h"
25
25
  #include "JSValueReader.h"
26
+ #include "ReactNativeIsland.h"
26
27
  #include "RootComponentView.h"
27
28
 
28
29
  namespace winrt::Microsoft::ReactNative::Composition::implementation {
@@ -849,13 +850,27 @@ void ScrollViewComponentView::updateStateWithContentOffset() noexcept {
849
850
  return;
850
851
  }
851
852
 
852
- auto scrollPosition = m_scrollVisual.ScrollPosition();
853
- m_verticalScrollbarComponent->ContentOffset(scrollPosition);
854
- m_horizontalScrollbarComponent->ContentOffset(scrollPosition);
855
-
856
- m_state->updateState([scrollPosition](const facebook::react::ScrollViewShadowNode::ConcreteState::Data &data) {
853
+ // Issue #16047: m_scrollVisual.ScrollPosition() returns the InteractionTracker
854
+ // position in PHYSICAL pixels (the visual is sized as
855
+ // layoutMetrics.frame.size.* * pointScaleFactor — see updateLayoutMetrics /
856
+ // updateContentVisualSize) but ScrollViewShadowNode state's contentOffset is
857
+ // in DIPs. Without the conversion, JS UIManager.measure() over-subtracts by
858
+ // pointScaleFactor on non-100% display scales, leaving Pressables inside a
859
+ // scrolled ScrollView with stale page-space bounds that don't contain the
860
+ // touch — Pressability fires LEAVE_PRESS_RECT inside pressIn and suppresses
861
+ // press. The JS-event-emitter paths in this file (see lines using
862
+ // args.Position() / pointScaleFactor) already do this division.
863
+ auto rawScrollPosition = m_scrollVisual.ScrollPosition();
864
+ const float pointScaleFactor = m_layoutMetrics.pointScaleFactor > 0.0f ? m_layoutMetrics.pointScaleFactor : 1.0f;
865
+ facebook::react::Point contentOffsetDips{
866
+ rawScrollPosition.x / pointScaleFactor, rawScrollPosition.y / pointScaleFactor};
867
+
868
+ m_verticalScrollbarComponent->ContentOffset(rawScrollPosition);
869
+ m_horizontalScrollbarComponent->ContentOffset(rawScrollPosition);
870
+
871
+ m_state->updateState([contentOffsetDips](const facebook::react::ScrollViewShadowNode::ConcreteState::Data &data) {
857
872
  auto newData = data;
858
- newData.contentOffset = {scrollPosition.x, scrollPosition.y};
873
+ newData.contentOffset = contentOffsetDips;
859
874
  return std::make_shared<facebook::react::ScrollViewShadowNode::ConcreteState::Data const>(newData);
860
875
  });
861
876
  }
@@ -1389,6 +1404,13 @@ winrt::Microsoft::ReactNative::Composition::Experimental::IVisual ScrollViewComp
1389
1404
  [this](
1390
1405
  winrt::IInspectable const & /*sender*/,
1391
1406
  winrt::Microsoft::ReactNative::Composition::Experimental::IScrollPositionChangedArgs const &args) {
1407
+ // Issue #16047: push the FINAL settled scroll position into Fabric's
1408
+ // shadow tree before notifying JS. The per-frame ScrollPositionChanged
1409
+ // updates can drop the last inertia delta, leaving contentOffset stale
1410
+ // and JS UIManager.measure() returning pre-settle-relative bounds.
1411
+ // ScrollEndDrag / ScrollBeginDrag already call this; momentum-end was
1412
+ // the missing completion path.
1413
+ updateStateWithContentOffset();
1392
1414
  auto eventEmitter = GetEventEmitter();
1393
1415
  if (eventEmitter) {
1394
1416
  auto scrollMetrics = getScrollMetrics(eventEmitter, args);
@@ -169,12 +169,22 @@ TooltipTracker::TooltipTracker(
169
169
  view.PointerEntered({this, &TooltipTracker::OnPointerEntered});
170
170
  view.PointerExited({this, &TooltipTracker::OnPointerExited});
171
171
  view.PointerMoved({this, &TooltipTracker::OnPointerMoved});
172
+ view.GotFocus({this, &TooltipTracker::OnGotFocus});
173
+ view.LostFocus({this, &TooltipTracker::OnLostFocus});
172
174
  view.Unmounted({this, &TooltipTracker::OnUnmounted});
173
175
  }
174
176
 
175
177
  TooltipTracker::~TooltipTracker() {
176
178
  DestroyTimer();
177
179
  DestroyTooltip();
180
+ m_outer->NotifyDismiss(this);
181
+ }
182
+
183
+ void TooltipTracker::DismissForExternalRequest() noexcept {
184
+ // Service is already updating its active slot; do not call back into it.
185
+ m_focusTooltip = false;
186
+ DestroyTimer();
187
+ DestroyTooltip();
178
188
  }
179
189
 
180
190
  facebook::react::Tag TooltipTracker::Tag() const noexcept {
@@ -192,6 +202,9 @@ void TooltipTracker::OnPointerEntered(
192
202
  auto pp = args.GetCurrentPoint(-1);
193
203
  m_pos = pp.Position();
194
204
 
205
+ // Claim the single tooltip slot, dismissing any other tracker's pending or visible tooltip.
206
+ m_outer->NotifyShow(this);
207
+
195
208
  m_timer = winrt::Microsoft::ReactNative::Timer::Create(m_properties.Handle());
196
209
  m_timer.Interval(std::chrono::milliseconds(toolTipTimeToShowMs));
197
210
  m_timer.Tick({this, &TooltipTracker::OnTick});
@@ -225,6 +238,56 @@ void TooltipTracker::OnPointerExited(
225
238
  return;
226
239
  DestroyTimer();
227
240
  DestroyTooltip();
241
+ m_outer->NotifyDismiss(this);
242
+ }
243
+
244
+ void TooltipTracker::OnGotFocus(
245
+ const winrt::Windows::Foundation::IInspectable & /*sender*/,
246
+ const winrt::Microsoft::ReactNative::Composition::Input::RoutedEventArgs & /*args*/) noexcept {
247
+ // Skip if a mouse-driven tooltip or its dwell timer is already in flight on this view.
248
+ if (m_hwndTip || m_timer) {
249
+ return;
250
+ }
251
+
252
+ auto view = m_view.view();
253
+ if (!view) {
254
+ return;
255
+ }
256
+
257
+ auto viewCompView = view.try_as<winrt::Microsoft::ReactNative::Composition::ViewComponentView>();
258
+ if (!viewCompView) {
259
+ return;
260
+ }
261
+ auto selfView =
262
+ winrt::get_self<winrt::Microsoft::ReactNative::Composition::implementation::ViewComponentView>(viewCompView);
263
+ RECT rc = selfView->getClientRect();
264
+ auto scaleFactor = view.LayoutMetrics().PointScaleFactor;
265
+ if (scaleFactor <= 0) {
266
+ return;
267
+ }
268
+
269
+ // Anchor in DIPs at the horizontal center of the view's top edge; ShowTooltip re-applies scaleFactor.
270
+ m_pos = {static_cast<float>(rc.left + rc.right) / 2.0f / scaleFactor, static_cast<float>(rc.top) / scaleFactor};
271
+
272
+ m_focusTooltip = true;
273
+ // Claim the single tooltip slot, dismissing any other tracker's pending or visible tooltip.
274
+ m_outer->NotifyShow(this);
275
+ m_timer = winrt::Microsoft::ReactNative::Timer::Create(m_properties.Handle());
276
+ m_timer.Interval(std::chrono::milliseconds(toolTipTimeToShowMs));
277
+ m_timer.Tick({this, &TooltipTracker::OnTick});
278
+ m_timer.Start();
279
+ }
280
+
281
+ void TooltipTracker::OnLostFocus(
282
+ const winrt::Windows::Foundation::IInspectable & /*sender*/,
283
+ const winrt::Microsoft::ReactNative::Composition::Input::RoutedEventArgs & /*args*/) noexcept {
284
+ if (!m_focusTooltip) {
285
+ return;
286
+ }
287
+ m_focusTooltip = false;
288
+ DestroyTimer();
289
+ DestroyTooltip();
290
+ m_outer->NotifyDismiss(this);
228
291
  }
229
292
 
230
293
  void TooltipTracker::OnUnmounted(
@@ -232,6 +295,7 @@ void TooltipTracker::OnUnmounted(
232
295
  const winrt::Microsoft::ReactNative::ComponentView &) noexcept {
233
296
  DestroyTimer();
234
297
  DestroyTooltip();
298
+ m_outer->NotifyDismiss(this);
235
299
  }
236
300
 
237
301
  void TooltipTracker::ShowTooltip(const winrt::Microsoft::ReactNative::ComponentView &view) noexcept {
@@ -326,6 +390,22 @@ void TooltipService::StopTracking(const winrt::Microsoft::ReactNative::Component
326
390
  }
327
391
  }
328
392
 
393
+ void TooltipService::NotifyShow(TooltipTracker *tracker) noexcept {
394
+ if (m_activeTracker == tracker) {
395
+ return;
396
+ }
397
+ if (m_activeTracker) {
398
+ m_activeTracker->DismissForExternalRequest();
399
+ }
400
+ m_activeTracker = tracker;
401
+ }
402
+
403
+ void TooltipService::NotifyDismiss(TooltipTracker *tracker) noexcept {
404
+ if (m_activeTracker == tracker) {
405
+ m_activeTracker = nullptr;
406
+ }
407
+ }
408
+
329
409
  static const ReactPropertyId<winrt::Microsoft::ReactNative::ReactNonAbiValue<std::shared_ptr<TooltipService>>>
330
410
  &TooltipServicePropertyId() noexcept {
331
411
  static const ReactPropertyId<winrt::Microsoft::ReactNative::ReactNonAbiValue<std::shared_ptr<TooltipService>>> prop{
@@ -27,6 +27,12 @@ struct TooltipTracker {
27
27
  void OnPointerExited(
28
28
  const winrt::Windows::Foundation::IInspectable &sender,
29
29
  const winrt::Microsoft::ReactNative::Composition::Input::PointerRoutedEventArgs &args) noexcept;
30
+ void OnGotFocus(
31
+ const winrt::Windows::Foundation::IInspectable &sender,
32
+ const winrt::Microsoft::ReactNative::Composition::Input::RoutedEventArgs &args) noexcept;
33
+ void OnLostFocus(
34
+ const winrt::Windows::Foundation::IInspectable &sender,
35
+ const winrt::Microsoft::ReactNative::Composition::Input::RoutedEventArgs &args) noexcept;
30
36
  void OnTick(
31
37
  const winrt::Windows::Foundation::IInspectable &,
32
38
  const winrt::Windows::Foundation::IInspectable &) noexcept;
@@ -36,6 +42,10 @@ struct TooltipTracker {
36
42
 
37
43
  facebook::react::Tag Tag() const noexcept;
38
44
 
45
+ // Cancel pending dwell timer and close any visible tooltip popup; used by the service when another tracker takes
46
+ // over.
47
+ void DismissForExternalRequest() noexcept;
48
+
39
49
  private:
40
50
  void ShowTooltip(const winrt::Microsoft::ReactNative::ComponentView &view) noexcept;
41
51
  void DestroyTimer() noexcept;
@@ -46,6 +56,7 @@ struct TooltipTracker {
46
56
  ::Microsoft::ReactNative::ReactTaggedView m_view;
47
57
  winrt::Microsoft::ReactNative::ITimer m_timer;
48
58
  HWND m_hwndTip{nullptr};
59
+ bool m_focusTooltip{false};
49
60
  winrt::Microsoft::ReactNative::ReactPropertyBag m_properties;
50
61
  };
51
62
 
@@ -54,12 +65,18 @@ struct TooltipService {
54
65
  void StartTracking(const winrt::Microsoft::ReactNative::ComponentView &view) noexcept;
55
66
  void StopTracking(const winrt::Microsoft::ReactNative::ComponentView &view) noexcept;
56
67
 
68
+ // Enforce "only one tooltip visible at a time": dismisses the previously active tracker, if any.
69
+ void NotifyShow(TooltipTracker *tracker) noexcept;
70
+ // Clears the active-tracker slot if it still points at `tracker`.
71
+ void NotifyDismiss(TooltipTracker *tracker) noexcept;
72
+
57
73
  static std::shared_ptr<TooltipService> GetCurrent(
58
74
  const winrt::Microsoft::ReactNative::ReactPropertyBag &properties) noexcept;
59
75
 
60
76
  private:
61
77
  std::vector<std::shared_ptr<TooltipTracker>> m_enteredTrackers;
62
78
  std::vector<std::shared_ptr<TooltipTracker>> m_trackers;
79
+ TooltipTracker *m_activeTracker{nullptr};
63
80
  winrt::Microsoft::ReactNative::ReactPropertyBag m_properties;
64
81
  };
65
82
 
@@ -10,11 +10,11 @@
10
10
  -->
11
11
  <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
12
12
  <PropertyGroup>
13
- <ReactNativeWindowsVersion>0.81.20</ReactNativeWindowsVersion>
13
+ <ReactNativeWindowsVersion>0.81.22</ReactNativeWindowsVersion>
14
14
  <ReactNativeWindowsMajor>0</ReactNativeWindowsMajor>
15
15
  <ReactNativeWindowsMinor>81</ReactNativeWindowsMinor>
16
- <ReactNativeWindowsPatch>20</ReactNativeWindowsPatch>
16
+ <ReactNativeWindowsPatch>22</ReactNativeWindowsPatch>
17
17
  <ReactNativeWindowsCanary>false</ReactNativeWindowsCanary>
18
- <ReactNativeWindowsCommitId>29ff929a448c74d7ab0362c6ef8bde4313d31b47</ReactNativeWindowsCommitId>
18
+ <ReactNativeWindowsCommitId>aaa05f5c3491ec4f2d62cb630b7ae51cd6a0f750</ReactNativeWindowsCommitId>
19
19
  </PropertyGroup>
20
20
  </Project>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-windows",
3
- "version": "0.81.20",
3
+ "version": "0.81.22",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -15,6 +15,7 @@
15
15
  <ApplicationType>Windows Store</ApplicationType>
16
16
  <ApplicationTypeRevision>10.0</ApplicationTypeRevision>
17
17
  </PropertyGroup>
18
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
18
19
  <PropertyGroup Label="ReactNativeWindowsProps">
19
20
  <ReactNativeWindowsDir Condition="'$(ReactNativeWindowsDir)' == ''">$([MSBuild]::GetDirectoryNameOfFileAbove($(SolutionDir), 'node_modules\react-native-windows\package.json'))\node_modules\react-native-windows\</ReactNativeWindowsDir>
20
21
  </PropertyGroup>
@@ -23,7 +24,6 @@
23
24
  <WindowsTargetPlatformVersion Condition=" '$(WindowsTargetPlatformVersion)' == '' ">10.0.22621.0</WindowsTargetPlatformVersion>
24
25
  <WindowsTargetPlatformMinVersion Condition=" '$(WindowsTargetPlatformMinVersion)' == '' ">10.0.17763.0</WindowsTargetPlatformMinVersion>
25
26
  </PropertyGroup>
26
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
27
27
  <ItemGroup Label="ProjectConfigurations">
28
28
  <ProjectConfiguration Include="Debug|ARM64">
29
29
  <Configuration>Debug</Configuration>
@@ -16,11 +16,11 @@
16
16
  <MinimumVisualStudioVersion>17.0</MinimumVisualStudioVersion>
17
17
  <AppxPackage>false</AppxPackage>
18
18
  </PropertyGroup>
19
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
19
20
  <PropertyGroup Label="ReactNativeWindowsProps">
20
21
  <ReactNativeWindowsDir Condition="'$(ReactNativeWindowsDir)' == ''">$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), 'node_modules\react-native-windows\package.json'))\node_modules\react-native-windows\</ReactNativeWindowsDir>
21
22
  </PropertyGroup>
22
23
  <Import Project="$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.WindowsSdk.Default.props" />
23
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
24
24
  <ItemGroup Label="ProjectConfigurations">
25
25
  <ProjectConfiguration Include="Debug|Win32">
26
26
  <Configuration>Debug</Configuration>
@@ -14,12 +14,12 @@
14
14
  <MinimumVisualStudioVersion>17.0</MinimumVisualStudioVersion>
15
15
  <AppxPackage>false</AppxPackage>
16
16
  </PropertyGroup>
17
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
17
18
  <PropertyGroup Label="ReactNativeWindowsProps">
18
19
  <ReactNativeWindowsDir Condition="'$(ReactNativeWindowsDir)' == ''">$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), 'node_modules\react-native-windows\package.json'))\node_modules\react-native-windows\</ReactNativeWindowsDir>
19
20
  <RunAutolinkCheck>false</RunAutolinkCheck>
20
21
  </PropertyGroup>
21
22
  <Import Project="$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.WindowsSdk.Default.props" />
22
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
23
23
  <ItemGroup Label="ProjectConfigurations">
24
24
  <ProjectConfiguration Include="Debug|Win32">
25
25
  <Configuration>Debug</Configuration>