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
70973e02
Unverified
Commit
70973e02
authored
Oct 02, 2020
by
Jason Simmons
Committed by
GitHub
Oct 02, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle empty selection box lists in RenderParagraph.assembleSemanticsNode (#67017)
parent
9e715205
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
1 deletion
+40
-1
paragraph.dart
packages/flutter/lib/src/rendering/paragraph.dart
+1
-1
paragraph_test.dart
packages/flutter/test/rendering/paragraph_test.dart
+39
-0
No files found.
packages/flutter/lib/src/rendering/paragraph.dart
View file @
70973e02
...
...
@@ -891,6 +891,7 @@ class RenderParagraph extends RenderBox
extentOffset:
start
+
info
.
text
.
length
,
);
final
List
<
ui
.
TextBox
>
rects
=
getBoxesForSelection
(
selection
);
start
+=
info
.
text
.
length
;
if
(
rects
.
isEmpty
)
{
continue
;
}
...
...
@@ -958,7 +959,6 @@ class RenderParagraph extends RenderBox
newChildCache
.
addLast
(
newChild
);
newChildren
.
add
(
newChild
);
}
start
+=
info
.
text
.
length
;
}
_cachedChildNodes
=
newChildCache
;
node
.
updateWith
(
config:
config
,
childrenInInversePaintOrder:
newChildren
);
...
...
packages/flutter/test/rendering/paragraph_test.dart
View file @
70973e02
...
...
@@ -16,6 +16,28 @@ import 'rendering_tester.dart';
const
String
_kText
=
"I polished up that handle so carefullee
\n
That now I am the Ruler of the Queen's Navee!"
;
// A subclass of RenderParagraph that returns an empty list in getBoxesForSelection
// for a given TextSelection.
// This is intended to simulate SkParagraph's implementation of Paragraph.getBoxesForRange,
// which may return an empty list in some situations where Libtxt would return a list
// containing an empty box.
class
RenderParagraphWithEmptySelectionBoxList
extends
RenderParagraph
{
RenderParagraphWithEmptySelectionBoxList
(
InlineSpan
text
,
{
TextDirection
textDirection
,
this
.
emptyListSelection
,
})
:
super
(
text
,
textDirection:
textDirection
);
TextSelection
emptyListSelection
;
@override
List
<
ui
.
TextBox
>
getBoxesForSelection
(
TextSelection
selection
)
{
if
(
selection
==
emptyListSelection
)
{
return
<
ui
.
TextBox
>[];
}
return
super
.
getBoxesForSelection
(
selection
);
}
}
void
main
(
)
{
test
(
'getOffsetForCaret control test'
,
()
{
final
RenderParagraph
paragraph
=
RenderParagraph
(
...
...
@@ -546,4 +568,21 @@ void main() {
}
expect
(
failed
,
true
);
},
skip:
isBrowser
);
// https://github.com/flutter/flutter/issues/61020
test
(
'assembleSemanticsNode handles text spans that do not yield selection boxes'
,
()
{
final
RenderParagraph
paragraph
=
RenderParagraphWithEmptySelectionBoxList
(
TextSpan
(
text:
''
,
children:
<
InlineSpan
>[
TextSpan
(
text:
'A'
,
recognizer:
TapGestureRecognizer
()..
onTap
=
()
{}),
TextSpan
(
text:
'B'
,
recognizer:
TapGestureRecognizer
()..
onTap
=
()
{}),
TextSpan
(
text:
'C'
,
recognizer:
TapGestureRecognizer
()..
onTap
=
()
{}),
]),
textDirection:
TextDirection
.
rtl
,
emptyListSelection:
const
TextSelection
(
baseOffset:
0
,
extentOffset:
1
),
);
layout
(
paragraph
);
final
SemanticsNode
node
=
SemanticsNode
();
paragraph
.
assembleSemanticsNode
(
node
,
SemanticsConfiguration
(),
<
SemanticsNode
>[]);
expect
(
node
.
childrenCount
,
2
);
},
skip:
isBrowser
);
// https://github.com/flutter/flutter/issues/61020
}
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