Fix text selection painting to draw what the engine tells us. (#4397)
BUG=https://github.com/flutter/flutter/issues/4321 BUG=https://github.com/flutter/flutter/issues/4349
This commit is contained in:
parent
48ed80b3be
commit
5de581c6c8
@ -151,7 +151,7 @@ class RenderEditableLine extends RenderBox {
|
|||||||
// clean at this point.
|
// clean at this point.
|
||||||
_textPainter.layout();
|
_textPainter.layout();
|
||||||
|
|
||||||
Offset offset = _paintOffset + new Offset(0.0, -_kCaretHeightOffset);
|
Offset offset = _paintOffset;
|
||||||
|
|
||||||
if (selection.isCollapsed) {
|
if (selection.isCollapsed) {
|
||||||
// TODO(mpcomplete): This doesn't work well at an RTL/LTR boundary.
|
// TODO(mpcomplete): This doesn't work well at an RTL/LTR boundary.
|
||||||
@ -278,15 +278,8 @@ class RenderEditableLine extends RenderBox {
|
|||||||
void _paintSelection(Canvas canvas, Offset effectiveOffset) {
|
void _paintSelection(Canvas canvas, Offset effectiveOffset) {
|
||||||
assert(_selectionRects != null);
|
assert(_selectionRects != null);
|
||||||
Paint paint = new Paint()..color = _selectionColor;
|
Paint paint = new Paint()..color = _selectionColor;
|
||||||
for (ui.TextBox box in _selectionRects) {
|
for (ui.TextBox box in _selectionRects)
|
||||||
Rect selectionRect = new Rect.fromLTWH(
|
canvas.drawRect(box.toRect().shift(effectiveOffset), paint);
|
||||||
effectiveOffset.dx + box.left,
|
|
||||||
effectiveOffset.dy + _kCaretHeightOffset,
|
|
||||||
box.right - box.left,
|
|
||||||
size.height - 2.0 * _kCaretHeightOffset
|
|
||||||
);
|
|
||||||
canvas.drawRect(selectionRect, paint);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _paintContents(PaintingContext context, Offset offset) {
|
void _paintContents(PaintingContext context, Offset offset) {
|
||||||
|
@ -192,7 +192,7 @@ void main() {
|
|||||||
List<TextSelectionPoint> endpoints = renderLine.getEndpointsForSelection(
|
List<TextSelectionPoint> endpoints = renderLine.getEndpointsForSelection(
|
||||||
new TextSelection.collapsed(offset: offset));
|
new TextSelection.collapsed(offset: offset));
|
||||||
expect(endpoints.length, 1);
|
expect(endpoints.length, 1);
|
||||||
return endpoints[0].point;
|
return endpoints[0].point + new Offset(0.0, -2.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
testWidgets('Can long press to select', (WidgetTester tester) async {
|
testWidgets('Can long press to select', (WidgetTester tester) async {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user