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
@ -148,10 +148,10 @@ class RenderEditableLine extends RenderBox {
|
||||
List<TextSelectionPoint> getEndpointsForSelection(TextSelection selection) {
|
||||
// TODO(mpcomplete): We should be more disciplined about when we dirty the
|
||||
// layout state of the text painter so that we can know that the layout is
|
||||
// clean at this point.
|
||||
// clean at this point.
|
||||
_textPainter.layout();
|
||||
|
||||
Offset offset = _paintOffset + new Offset(0.0, -_kCaretHeightOffset);
|
||||
Offset offset = _paintOffset;
|
||||
|
||||
if (selection.isCollapsed) {
|
||||
// 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) {
|
||||
assert(_selectionRects != null);
|
||||
Paint paint = new Paint()..color = _selectionColor;
|
||||
for (ui.TextBox box in _selectionRects) {
|
||||
Rect selectionRect = new Rect.fromLTWH(
|
||||
effectiveOffset.dx + box.left,
|
||||
effectiveOffset.dy + _kCaretHeightOffset,
|
||||
box.right - box.left,
|
||||
size.height - 2.0 * _kCaretHeightOffset
|
||||
);
|
||||
canvas.drawRect(selectionRect, paint);
|
||||
}
|
||||
for (ui.TextBox box in _selectionRects)
|
||||
canvas.drawRect(box.toRect().shift(effectiveOffset), paint);
|
||||
}
|
||||
|
||||
void _paintContents(PaintingContext context, Offset offset) {
|
||||
|
@ -192,7 +192,7 @@ void main() {
|
||||
List<TextSelectionPoint> endpoints = renderLine.getEndpointsForSelection(
|
||||
new TextSelection.collapsed(offset: offset));
|
||||
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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user