Roll engine; pass semantics child orders (#16970)

* pass semantics children in traversal and hit test orders

* explain why we are inverting _children

* Roll engine
This commit is contained in:
Yegor 2018-05-21 20:55:28 -07:00 committed by GitHub
parent 7471ff8c89
commit 4beb57c324
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 8 deletions

View file

@ -1 +1 @@
d2448888a11ab958beece5ef6df99c8d069d09db
f876bd57106b527cf6ddc8c9a97d0beb4190f868

View file

@ -1346,15 +1346,23 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin {
void _addToUpdate(ui.SemanticsUpdateBuilder builder) {
assert(_dirty);
final SemanticsData data = getSemanticsData();
Int32List children;
Int32List childrenInTraversalOrder;
Int32List childrenInHitTestOrder;
if (!hasChildren || mergeAllDescendantsIntoThisNode) {
children = _kEmptyChildList;
childrenInTraversalOrder = _kEmptyChildList;
childrenInHitTestOrder = _kEmptyChildList;
} else {
final int childCount = _children.length;
final List<SemanticsNode> sortedChildren = _childrenInTraversalOrder();
final int childCount = sortedChildren.length;
children = new Int32List(childCount);
for (int i = 0; i < childCount; ++i) {
children[i] = sortedChildren[i].id;
childrenInTraversalOrder = new Int32List(childCount);
for (int i = 0; i < childCount; i += 1) {
childrenInTraversalOrder[i] = sortedChildren[i].id;
}
// _children is sorted in paint order, so we invert it to get the hit test
// order.
childrenInHitTestOrder = new Int32List(childCount);
for (int i = childCount - 1; i >= 0; i -= 1) {
childrenInHitTestOrder[i] = _children[i].id;
}
}
builder.updateNode(
@ -1374,7 +1382,8 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin {
scrollExtentMax: data.scrollExtentMax != null ? data.scrollExtentMax : double.nan,
scrollExtentMin: data.scrollExtentMin != null ? data.scrollExtentMin : double.nan,
transform: data.transform?.storage ?? _kIdentityTransform,
children: children,
childrenInTraversalOrder: childrenInTraversalOrder,
childrenInHitTestOrder: childrenInHitTestOrder,
);
_dirty = false;
}