forked from firka/flutter
Take paint offset into account for Editable children (#127843)
This commit is contained in:
@@ -2459,7 +2459,7 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin,
|
||||
}
|
||||
|
||||
_textPainter.paint(context.canvas, effectiveOffset);
|
||||
paintInlineChildren(context, offset);
|
||||
paintInlineChildren(context, effectiveOffset);
|
||||
|
||||
if (foregroundChild != null) {
|
||||
context.paintChild(foregroundChild, offset);
|
||||
|
||||
@@ -1558,6 +1558,45 @@ void main() {
|
||||
expect(composingRect, null);
|
||||
}, skip: isBrowser); // https://github.com/flutter/flutter/issues/61021
|
||||
|
||||
test('WidgetSpan render box is painted at correct offset when scrolled', () async {
|
||||
final TextSelectionDelegate delegate = _FakeEditableTextState()
|
||||
..textEditingValue = const TextEditingValue(
|
||||
text: 'test',
|
||||
selection: TextSelection.collapsed(offset: 3),
|
||||
);
|
||||
final List<RenderBox> renderBoxes = <RenderBox>[
|
||||
RenderParagraph(const TextSpan(text: 'b'), textDirection: TextDirection.ltr),
|
||||
];
|
||||
final ViewportOffset viewportOffset = ViewportOffset.fixed(100.0);
|
||||
final RenderEditable editable = RenderEditable(
|
||||
backgroundCursorColor: Colors.grey,
|
||||
selectionColor: Colors.black,
|
||||
textDirection: TextDirection.ltr,
|
||||
cursorColor: Colors.red,
|
||||
offset: viewportOffset,
|
||||
textSelectionDelegate: delegate,
|
||||
startHandleLayerLink: LayerLink(),
|
||||
endHandleLayerLink: LayerLink(),
|
||||
maxLines: null,
|
||||
text: TextSpan(
|
||||
style: const TextStyle(height: 1.0, fontSize: 10.0),
|
||||
children: <InlineSpan>[
|
||||
const TextSpan(text: 'test'),
|
||||
WidgetSpan(child: Container(width: 10, height: 10, color: Colors.blue)),
|
||||
],
|
||||
),
|
||||
selection: const TextSelection.collapsed(offset: 3),
|
||||
children: renderBoxes,
|
||||
);
|
||||
_applyParentData(renderBoxes, editable.text!);
|
||||
layout(editable);
|
||||
editable.hasFocus = true;
|
||||
pumpFrame();
|
||||
|
||||
final Rect composingRect = editable.getRectForComposingRange(const TextRange(start: 4, end: 5))!;
|
||||
expect(composingRect, const Rect.fromLTRB(40.0, -100.0, 54.0, -86.0));
|
||||
}, skip: isBrowser); // https://github.com/flutter/flutter/issues/61021
|
||||
|
||||
test('can compute IntrinsicWidth for WidgetSpans', () {
|
||||
// Regression test for https://github.com/flutter/flutter/issues/59316
|
||||
const double screenWidth = 1000.0;
|
||||
|
||||
Reference in New Issue
Block a user