[poincare] Make HorizontalLayoutNode::positionOfChild faster and lighter

This commit is contained in:
Léa Saviot
2018-09-20 16:00:23 +02:00
parent 6b95ea42c7
commit 986c04dfd5

View File

@@ -213,9 +213,12 @@ KDPoint HorizontalLayoutNode::positionOfChild(LayoutNode * l) {
KDCoordinate x = 0;
int index = indexOfChild(l);
assert(index > -1);
if (index > 0) {
LayoutNode * previousChild = childAtIndex(index-1);
x = previousChild->origin().x() + previousChild->layoutSize().width();
for (LayoutNode * c : children()) {
if (c == l) {
break;
}
KDSize childSize = c->layoutSize();
x += childSize.width();
}
KDCoordinate y = baseline() - l->baseline();
return KDPoint(x, y);