react-native-windows 0.81.20 → 0.81.21
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/Folly/TEMP_UntilFollyUpdate/hash/SpookyHashV2.h +334 -0
- package/Microsoft.ReactNative/Fabric/Composition/TooltipService.cpp +80 -0
- package/Microsoft.ReactNative/Fabric/Composition/TooltipService.h +17 -0
- package/PropertySheets/Generated/PackageVersion.g.props +3 -3
- package/package.json +1 -1
|
@@ -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
|
|
@@ -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.
|
|
13
|
+
<ReactNativeWindowsVersion>0.81.21</ReactNativeWindowsVersion>
|
|
14
14
|
<ReactNativeWindowsMajor>0</ReactNativeWindowsMajor>
|
|
15
15
|
<ReactNativeWindowsMinor>81</ReactNativeWindowsMinor>
|
|
16
|
-
<ReactNativeWindowsPatch>
|
|
16
|
+
<ReactNativeWindowsPatch>21</ReactNativeWindowsPatch>
|
|
17
17
|
<ReactNativeWindowsCanary>false</ReactNativeWindowsCanary>
|
|
18
|
-
<ReactNativeWindowsCommitId>
|
|
18
|
+
<ReactNativeWindowsCommitId>8620c45845172a7428e8d0e27037515b6382e5dd</ReactNativeWindowsCommitId>
|
|
19
19
|
</PropertyGroup>
|
|
20
20
|
</Project>
|