[dart:ui] Add view ID to PointerData.toString (flutter/engine#51352)

The `view_id` is useful information as the pointer's `x` and `y` coordinates are relative to the view's origin.

Part of https://github.com/flutter/flutter/issues/112205
Part of https://github.com/flutter/flutter/issues/142845

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
This commit is contained in:
Loïc Sharma
2024-03-12 14:53:41 -07:00
committed by GitHub
parent 242e59c98f
commit b2f119de6b
4 changed files with 9 additions and 8 deletions

View File

@@ -381,7 +381,7 @@ class PointerData {
final double rotation;
@override
String toString() => 'PointerData(x: $physicalX, y: $physicalY)';
String toString() => 'PointerData(viewId: $viewId, x: $physicalX, y: $physicalY)';
/// Returns a complete textual description of the information in this object.
String toStringFull() {

View File

@@ -481,13 +481,13 @@ class PlatformConfiguration final {
void ReportTimings(std::vector<int64_t> timings);
//----------------------------------------------------------------------------
/// @brief Retrieves the Window with the given ID managed by the
/// `PlatformConfiguration`.
/// @brief Retrieves the viewport metrics with the given ID managed by
/// the `PlatformConfiguration`.
///
/// @param[in] window_id The id of the window to find and return.
/// @param[in] view_id The id of the view's viewport metrics to return.
///
/// @return a pointer to the Window. Returns nullptr if the ID is not
/// found.
/// @return a pointer to the ViewportMetrics. Returns nullptr if the ID is
/// not found.
///
const ViewportMetrics* GetMetrics(int view_id);

View File

@@ -111,7 +111,7 @@ class PointerData {
final double rotation;
@override
String toString() => 'PointerData(x: $physicalX, y: $physicalY)';
String toString() => 'PointerData(viewId: $viewId, x: $physicalX, y: $physicalY)';
String toStringFull() {
return '$runtimeType('
'embedderId: $embedderId, '

View File

@@ -2700,7 +2700,7 @@ TEST_F(EmbedderTest, CanSendPointer) {
CREATE_NATIVE_ENTRY([&message_latch](Dart_NativeArguments args) {
auto message = tonic::DartConverter<std::string>::FromDart(
Dart_GetNativeArgument(args, 0));
ASSERT_EQ("PointerData(x: 123.0, y: 456.0)", message);
ASSERT_EQ("PointerData(viewId: 0, x: 123.0, y: 456.0)", message);
message_latch.Signal();
}));
@@ -2715,6 +2715,7 @@ TEST_F(EmbedderTest, CanSendPointer) {
pointer_event.x = 123;
pointer_event.y = 456;
pointer_event.timestamp = static_cast<size_t>(1234567890);
pointer_event.view_id = 0;
FlutterEngineResult result =
FlutterEngineSendPointerEvent(engine.get(), &pointer_event, 1);