| 1260 | } |
| 1261 | |
| 1262 | jlong ValdiAndroid::NativeBridge::notifyScroll( // NOLINT |
| 1263 | fbjni::alias_ref<fbjni::JClass> /* clazz */, // NOLINT |
| 1264 | jlong runtimeHandle, |
| 1265 | jlong viewNodeHandle, |
| 1266 | jint eventType, |
| 1267 | jint pixelDirectionDependentContentOffsetX, |
| 1268 | jint pixelDirectionDependentContentOffsetY, |
| 1269 | jint pixelDirectionDependentUnclampedContentOffsetX, |
| 1270 | jint pixelDirectionDependentUnclampedContentOffsetY, |
| 1271 | jfloat pixelDirectionDependentInvertedVelocityX, |
| 1272 | jfloat pixelDirectionDependentInvertedVelocityY) { |
| 1273 | auto* runtimeWrapper = getRuntimeWrapper(runtimeHandle); |
| 1274 | auto viewNode = getViewNode(viewNodeHandle); |
| 1275 | jlong out = std::numeric_limits<jlong>::min(); |
| 1276 | |
| 1277 | if (runtimeWrapper == nullptr || viewNode == nullptr) { |
| 1278 | return out; |
| 1279 | } |
| 1280 | |
| 1281 | auto* viewNodeTree = viewNode->getViewNodeTree(); |
| 1282 | |
| 1283 | if (viewNodeTree == nullptr) { |
| 1284 | // TODO: is this a valid state? |
| 1285 | return 0; |
| 1286 | } |
| 1287 | |
| 1288 | viewNodeTree->withLock([&]() { |
| 1289 | auto pointScale = runtimeWrapper->getPointScale(); |
| 1290 | |
| 1291 | auto pointDirectionDependentContentOffset = |
| 1292 | Valdi::Point::fromPixels(static_cast<int32_t>(pixelDirectionDependentContentOffsetX), |
| 1293 | static_cast<int32_t>(pixelDirectionDependentContentOffsetY), |
| 1294 | pointScale); |
| 1295 | |
| 1296 | auto pointDirectionDependentUnclampedContentOffset = |
| 1297 | Valdi::Point::fromPixels(static_cast<int32_t>(pixelDirectionDependentUnclampedContentOffsetX), |
| 1298 | static_cast<int32_t>(pixelDirectionDependentUnclampedContentOffsetY), |
| 1299 | pointScale); |
| 1300 | |
| 1301 | auto pointDirectionDependentVelocityX = |
| 1302 | -Valdi::pixelsToPoints(static_cast<float>(pixelDirectionDependentInvertedVelocityX), pointScale); |
| 1303 | auto pointDirectionDependentVelocityY = |
| 1304 | -Valdi::pixelsToPoints(static_cast<float>(pixelDirectionDependentInvertedVelocityY), pointScale); |
| 1305 | auto pointDirectionDependentVelocity = |
| 1306 | Valdi::Point(pointDirectionDependentVelocityX, pointDirectionDependentVelocityY); |
| 1307 | |
| 1308 | switch (static_cast<ScrollEventType>(eventType)) { |
| 1309 | case ScrollEventTypeOnScroll: { |
| 1310 | auto adjustedDirectionDependentContentOffset = |
| 1311 | viewNode->onScroll(pointDirectionDependentContentOffset, |
| 1312 | pointDirectionDependentUnclampedContentOffset, |
| 1313 | pointDirectionDependentVelocity); |
| 1314 | |
| 1315 | if (adjustedDirectionDependentContentOffset) { |
| 1316 | out = convertPointToPackedPixels(adjustedDirectionDependentContentOffset.value(), pointScale); |
| 1317 | } |
| 1318 | } break; |
| 1319 |
nothing calls this directly
no test coverage detected