Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
cd6279c1
Unverified
Commit
cd6279c1
authored
Sep 29, 2020
by
LongCatIsLooong
Committed by
GitHub
Sep 29, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix _getPixelPerfectCursorOffset logic when infinite (#66845)
parent
9efdcf61
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
10 deletions
+17
-10
editable.dart
packages/flutter/lib/src/rendering/editable.dart
+4
-2
editable_text_test.dart
packages/flutter/test/widgets/editable_text_test.dart
+13
-8
No files found.
packages/flutter/lib/src/rendering/editable.dart
View file @
cd6279c1
...
...
@@ -1999,15 +1999,17 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
offset
.
applyContentDimensions
(
0.0
,
_maxScrollExtent
);
}
/// Computes the offset to apply to the given [caretRect] so it perfectly
/// snaps to physical pixels.
Offset
_getPixelPerfectCursorOffset
(
Rect
caretRect
)
{
final
Offset
caretPosition
=
localToGlobal
(
caretRect
.
topLeft
);
final
double
pixelMultiple
=
1.0
/
_devicePixelRatio
;
final
double
pixelPerfectOffsetX
=
caretPosition
.
dx
.
isFinite
?
(
caretPosition
.
dx
/
pixelMultiple
).
round
()
*
pixelMultiple
-
caretPosition
.
dx
:
caretPosition
.
dx
;
:
0
;
final
double
pixelPerfectOffsetY
=
caretPosition
.
dy
.
isFinite
?
(
caretPosition
.
dy
/
pixelMultiple
).
round
()
*
pixelMultiple
-
caretPosition
.
dy
:
caretPosition
.
dy
;
:
0
;
return
Offset
(
pixelPerfectOffsetX
,
pixelPerfectOffsetY
);
}
...
...
packages/flutter/test/widgets/editable_text_test.dart
View file @
cd6279c1
...
...
@@ -3427,17 +3427,22 @@ void main() {
});
testWidgets
(
'
does not throw when sending infinite Rect
'
,
'
zero matrix paint transform
'
,
(
WidgetTester
tester
)
async
{
controller
.
value
=
TextEditingValue
(
text:
'a'
*
100
,
composing:
const
TextRange
(
start:
0
,
end:
10
));
// Use a FittedBox with an zero-sized child to set the paint transform
// to the zero matrix.
await
tester
.
pumpWidget
(
FittedBox
(
child:
SizedBox
.
fromSize
(
size:
Size
.
zero
,
child:
builder
())));
await
tester
.
showKeyboard
(
find
.
byType
(
EditableText
));
expect
(
tester
.
testTextInput
.
log
,
contains
(
matchesMethodCall
(
'TextInput.setMarkedTextRect'
,
args:
<
String
,
dynamic
>
{
'width'
:
-
1
,
'height'
:
-
1
,
'x'
:
0
,
'y'
:
0
,
})));
expect
(
tester
.
testTextInput
.
log
,
contains
(
matchesMethodCall
(
'TextInput.setMarkedTextRect'
,
args:
allOf
(
containsPair
(
'width'
,
isNotNaN
),
containsPair
(
'height'
,
isNotNaN
),
containsPair
(
'x'
,
isNotNaN
),
containsPair
(
'y'
,
isNotNaN
),
),
)));
});
});
...
...
@@ -4695,7 +4700,7 @@ void main() {
final
EditableTextState
state
=
tester
.
state
<
EditableTextState
>(
find
.
byType
(
EditableText
));
final
Rect
rect
=
state
.
renderEditable
.
getLocalRectForCaret
(
const
TextPosition
(
offset:
0
));
expect
(
rect
.
isFinite
,
fals
e
);
expect
(
rect
.
isFinite
,
tru
e
);
expect
(
tester
.
takeException
(),
isNull
);
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment