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
a5658485
Unverified
Commit
a5658485
authored
Nov 16, 2020
by
Jason Simmons
Committed by
GitHub
Nov 16, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ignore text selection boxes when assembling semantics for placeholder runs (#70487)
parent
5f56db0a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
27 deletions
+68
-27
paragraph.dart
packages/flutter/lib/src/rendering/paragraph.dart
+27
-27
paragraph_test.dart
packages/flutter/test/rendering/paragraph_test.dart
+41
-0
No files found.
packages/flutter/lib/src/rendering/paragraph.dart
View file @
a5658485
...
@@ -902,13 +902,33 @@ class RenderParagraph extends RenderBox
...
@@ -902,13 +902,33 @@ class RenderParagraph extends RenderBox
RenderBox
?
child
=
firstChild
;
RenderBox
?
child
=
firstChild
;
final
Queue
<
SemanticsNode
>
newChildCache
=
Queue
<
SemanticsNode
>();
final
Queue
<
SemanticsNode
>
newChildCache
=
Queue
<
SemanticsNode
>();
for
(
final
InlineSpanSemanticsInformation
info
in
_combineSemanticsInfo
())
{
for
(
final
InlineSpanSemanticsInformation
info
in
_combineSemanticsInfo
())
{
final
TextDirection
initialDirection
=
currentDirection
;
final
TextSelection
selection
=
TextSelection
(
final
TextSelection
selection
=
TextSelection
(
baseOffset:
start
,
baseOffset:
start
,
extentOffset:
start
+
info
.
text
.
length
,
extentOffset:
start
+
info
.
text
.
length
,
);
);
final
List
<
ui
.
TextBox
>
rects
=
getBoxesForSelection
(
selection
);
start
+=
info
.
text
.
length
;
start
+=
info
.
text
.
length
;
if
(
info
.
isPlaceholder
)
{
// A placeholder span may have 0 to multple semantics nodes, we need
// to annotate all of the semantics nodes belong to this span.
while
(
children
.
length
>
childIndex
&&
children
.
elementAt
(
childIndex
).
isTagged
(
PlaceholderSpanIndexSemanticsTag
(
placeholderIndex
)))
{
final
SemanticsNode
childNode
=
children
.
elementAt
(
childIndex
);
final
TextParentData
parentData
=
child
!.
parentData
!
as
TextParentData
;
childNode
.
rect
=
Rect
.
fromLTWH
(
childNode
.
rect
.
left
,
childNode
.
rect
.
top
,
childNode
.
rect
.
width
*
parentData
.
scale
!,
childNode
.
rect
.
height
*
parentData
.
scale
!,
);
newChildren
.
add
(
childNode
);
childIndex
+=
1
;
}
child
=
childAfter
(
child
!);
placeholderIndex
+=
1
;
}
else
{
final
TextDirection
initialDirection
=
currentDirection
;
final
List
<
ui
.
TextBox
>
rects
=
getBoxesForSelection
(
selection
);
if
(
rects
.
isEmpty
)
{
if
(
rects
.
isEmpty
)
{
continue
;
continue
;
}
}
...
@@ -934,26 +954,6 @@ class RenderParagraph extends RenderBox
...
@@ -934,26 +954,6 @@ class RenderParagraph extends RenderBox
rect
.
right
.
ceilToDouble
()
+
4.0
,
rect
.
right
.
ceilToDouble
()
+
4.0
,
rect
.
bottom
.
ceilToDouble
()
+
4.0
,
rect
.
bottom
.
ceilToDouble
()
+
4.0
,
);
);
if
(
info
.
isPlaceholder
)
{
// A placeholder span may have 0 to multple semantics nodes, we need
// to annotate all of the semantics nodes belong to this span.
while
(
children
.
length
>
childIndex
&&
children
.
elementAt
(
childIndex
).
isTagged
(
PlaceholderSpanIndexSemanticsTag
(
placeholderIndex
)))
{
final
SemanticsNode
childNode
=
children
.
elementAt
(
childIndex
);
final
TextParentData
parentData
=
child
!.
parentData
!
as
TextParentData
;
childNode
.
rect
=
Rect
.
fromLTWH
(
childNode
.
rect
.
left
,
childNode
.
rect
.
top
,
childNode
.
rect
.
width
*
parentData
.
scale
!,
childNode
.
rect
.
height
*
parentData
.
scale
!,
);
newChildren
.
add
(
childNode
);
childIndex
+=
1
;
}
child
=
childAfter
(
child
!);
placeholderIndex
+=
1
;
}
else
{
final
SemanticsConfiguration
configuration
=
SemanticsConfiguration
()
final
SemanticsConfiguration
configuration
=
SemanticsConfiguration
()
..
sortKey
=
OrdinalSortKey
(
ordinal
++)
..
sortKey
=
OrdinalSortKey
(
ordinal
++)
..
textDirection
=
initialDirection
..
textDirection
=
initialDirection
...
...
packages/flutter/test/rendering/paragraph_test.dart
View file @
a5658485
...
@@ -37,6 +37,26 @@ class RenderParagraphWithEmptySelectionBoxList extends RenderParagraph {
...
@@ -37,6 +37,26 @@ class RenderParagraphWithEmptySelectionBoxList extends RenderParagraph {
}
}
}
}
// A subclass of RenderParagraph that returns an empty list in getBoxesForSelection
// for a selection representing a WidgetSpan.
// This is intended to simulate how SkParagraph's implementation of Paragraph.getBoxesForRange
// can return an empty list for a WidgetSpan with empty dimensions.
class
RenderParagraphWithEmptyBoxListForWidgetSpan
extends
RenderParagraph
{
RenderParagraphWithEmptyBoxListForWidgetSpan
(
InlineSpan
text
,
{
required
List
<
RenderBox
>
children
,
required
TextDirection
textDirection
,
})
:
super
(
text
,
children:
children
,
textDirection:
textDirection
);
@override
List
<
ui
.
TextBox
>
getBoxesForSelection
(
TextSelection
selection
)
{
if
(
text
.
getSpanForPosition
(
selection
.
base
)
is
WidgetSpan
)
{
return
<
ui
.
TextBox
>[];
}
return
super
.
getBoxesForSelection
(
selection
);
}
}
void
main
(
)
{
void
main
(
)
{
test
(
'getOffsetForCaret control test'
,
()
{
test
(
'getOffsetForCaret control test'
,
()
{
final
RenderParagraph
paragraph
=
RenderParagraph
(
final
RenderParagraph
paragraph
=
RenderParagraph
(
...
@@ -588,4 +608,25 @@ void main() {
...
@@ -588,4 +608,25 @@ void main() {
paragraph
.
assembleSemanticsNode
(
node
,
SemanticsConfiguration
(),
<
SemanticsNode
>[]);
paragraph
.
assembleSemanticsNode
(
node
,
SemanticsConfiguration
(),
<
SemanticsNode
>[]);
expect
(
node
.
childrenCount
,
2
);
expect
(
node
.
childrenCount
,
2
);
},
skip:
isBrowser
);
// https://github.com/flutter/flutter/issues/61020
},
skip:
isBrowser
);
// https://github.com/flutter/flutter/issues/61020
test
(
'assembleSemanticsNode handles empty WidgetSpans that do not yield selection boxes'
,
()
{
final
TextSpan
text
=
TextSpan
(
text:
''
,
children:
<
InlineSpan
>[
TextSpan
(
text:
'A'
,
recognizer:
TapGestureRecognizer
()..
onTap
=
()
{}),
const
WidgetSpan
(
child:
SizedBox
(
width:
0
,
height:
0
)),
TextSpan
(
text:
'C'
,
recognizer:
TapGestureRecognizer
()..
onTap
=
()
{}),
]);
final
List
<
RenderBox
>
renderBoxes
=
<
RenderBox
>[
RenderParagraph
(
const
TextSpan
(
text:
'b'
),
textDirection:
TextDirection
.
ltr
),
];
final
RenderParagraph
paragraph
=
RenderParagraphWithEmptyBoxListForWidgetSpan
(
text
,
children:
renderBoxes
,
textDirection:
TextDirection
.
ltr
,
);
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