|
10 | 10 | #include "third_party/skia/include/core/SkSurface.h" |
11 | 11 |
|
12 | 12 | namespace flutter_runner { |
| 13 | +namespace { |
| 14 | + |
| 15 | +// Since the flatland hit-region can be transformed (rotated, scaled or |
| 16 | +// translated), we must ensure that the size of the hit-region will not cause |
| 17 | +// overflows on operations (like FLT_MAX would). |
| 18 | +constexpr float kMaxHitRegionSize = 1'000'000.f; |
| 19 | + |
| 20 | +} // namespace |
13 | 21 |
|
14 | 22 | FlatlandExternalViewEmbedder::FlatlandExternalViewEmbedder( |
15 | 23 | fuchsia::ui::views::ViewCreationToken view_creation_token, |
@@ -312,11 +320,12 @@ void FlatlandExternalViewEmbedder::SubmitFrame( |
312 | 320 | child_transforms_.emplace_back( |
313 | 321 | flatland_layers_[flatland_layer_index].transform_id); |
314 | 322 |
|
315 | | - // Attach full-screen hit testing shield. |
| 323 | + // Attach full-screen hit testing shield. Note that since the hit-region |
| 324 | + // may be transformed (translated, rotated), we do not want to set |
| 325 | + // width/height to FLT_MAX. This will cause a numeric overflow. |
316 | 326 | flatland_->flatland()->SetHitRegions( |
317 | 327 | flatland_layers_[flatland_layer_index].transform_id, |
318 | | - {{{0, 0, std::numeric_limits<float>::max(), |
319 | | - std::numeric_limits<float>::max()}, |
| 328 | + {{{0, 0, kMaxHitRegionSize, kMaxHitRegionSize}, |
320 | 329 | fuchsia::ui::composition::HitTestInteraction:: |
321 | 330 | SEMANTICALLY_INVISIBLE}}); |
322 | 331 | } |
|
0 commit comments