From 63f417463899a3d822d25c6943af71a0f0440f61 Mon Sep 17 00:00:00 2001 From: hangyu Date: Fri, 9 Jun 2023 10:00:14 -0700 Subject: [PATCH] Paint SelectableFragments before text (#128375) fixes: #104703 --- packages/flutter/lib/src/rendering/paragraph.dart | 12 +++++++----- .../flutter/test/rendering/paragraph_test.dart | 15 ++++++++++++++- .../flutter/test/widgets/default_colors_test.dart | 12 ++++++------ 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/packages/flutter/lib/src/rendering/paragraph.dart b/packages/flutter/lib/src/rendering/paragraph.dart index b125836b63f672..e9b0402e3b4e85 100644 --- a/packages/flutter/lib/src/rendering/paragraph.dart +++ b/packages/flutter/lib/src/rendering/paragraph.dart @@ -865,6 +865,13 @@ class RenderParagraph extends RenderBox with ContainerRenderObjectMixin[Rect, ui.Paragraph]); selectionParagraph(paragraph, const TextPosition(offset: 2), const TextPosition(offset: 4)); paragraph.paint(paintingContext, Offset.zero); @@ -1293,15 +1297,24 @@ void main() { class MockCanvas extends Fake implements Canvas { Rect? drawnRect; Paint? drawnRectPaint; + List drawnItemTypes=[]; @override void drawRect(Rect rect, Paint paint) { drawnRect = rect; drawnRectPaint = paint; + drawnItemTypes.add(Rect); } @override - void drawParagraph(ui.Paragraph paragraph, Offset offset) { } + void drawParagraph(ui.Paragraph paragraph, Offset offset) { + drawnItemTypes.add(ui.Paragraph); + } + void clear() { + drawnRect = null; + drawnRectPaint = null; + drawnItemTypes.clear(); + } } class MockPaintingContext extends Fake implements PaintingContext { diff --git a/packages/flutter/test/widgets/default_colors_test.dart b/packages/flutter/test/widgets/default_colors_test.dart index c3f3eaf204db8e..af9fa9dca52f06 100644 --- a/packages/flutter/test/widgets/default_colors_test.dart +++ b/packages/flutter/test/widgets/default_colors_test.dart @@ -83,7 +83,7 @@ void main() { child: Align( key: key, alignment: Alignment.topLeft, - child: const Text('Éxp', textDirection: TextDirection.ltr, style: TextStyle(fontSize: _crispText)), + child: const Text('Éxp', textDirection: TextDirection.ltr, style: TextStyle(fontSize: _crispText, color: Color(0xFF000000))), ), ), ), @@ -97,7 +97,7 @@ void main() { await _expectColors( tester, find.byType(Align), - { const Color(0xFFFFFFFF) }, + { const Color(0xFFFFFFFF), const Color(0xFF000000) }, ); // fake a "select all" event to select the text Actions.invoke(key.currentContext!, const SelectAllTextIntent(SelectionChangedCause.keyboard)); @@ -105,13 +105,13 @@ void main() { await _expectColors( tester, find.byType(Align), - { const Color(0xFFFFFFFF), const Color(0xFFBFBFBF) }, // 0x80808080 blended with 0xFFFFFFFF + { const Color(0xFFFFFFFF), const Color(0xFF000000), const Color(0xFFBFBFBF) }, // 0x80808080 blended with 0xFFFFFFFF { - Offset.zero: const Color(0xFFBFBFBF), // the selected text - const Offset(10, 10): const Color(0xFFBFBFBF), // the selected text + Offset.zero: const Color(0xFF000000), // the selected text + const Offset(10, 10): const Color(0xFF000000), // the selected text const Offset(50, 95): const Color(0xFFBFBFBF), // the selected background (under the É) const Offset(250, 50): const Color(0xFFBFBFBF), // the selected background (above the p) - const Offset(250, 95): const Color(0xFFBFBFBF), // the selected text (the p) + const Offset(250, 95): const Color(0xFF000000), // the selected text (the p) const Offset(400, 400): const Color(0xFFFFFFFF), // the background const Offset(799, 599): const Color(0xFFFFFFFF), // the background },