mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Make changing your layout manager work.
If your layout manager changes, then you need to setNeedsLayout, otherwise the next frame doesn't even get scheduled. We already correctly handle going from not having layout to having one or vice versa by doing the more drastic reattaching since that requires changing your actual render class. R=eseidel@chromium.org Review URL: https://codereview.chromium.org/1060013005
This commit is contained in:
parent
a1d93b2847
commit
c8d918efa9
@ -971,6 +971,8 @@ void Element::setLayoutManager(PassOwnPtr<LayoutCallback> callback)
|
||||
// those are all tied to changes to the RenderStyle.
|
||||
markAncestorsWithChildNeedsStyleRecalc();
|
||||
detach();
|
||||
} else if (callback.get() != m_layoutManager) {
|
||||
setNeedsLayout();
|
||||
}
|
||||
m_layoutManager = callback;
|
||||
}
|
||||
|
||||
@ -84,30 +84,39 @@ void main() {
|
||||
expect(secondChild.offsetWidth, equals(150));
|
||||
assertNonChangingValues();
|
||||
|
||||
parent.setLayoutManager(null);
|
||||
parent.setLayoutManager(() {
|
||||
parent.width = 250.0;
|
||||
});
|
||||
|
||||
window.requestAnimationFrame((_) {
|
||||
expect(parent.offsetWidth, equals(300));
|
||||
expect(parent.offsetHeight, equals(50));
|
||||
expect(parent.offsetTop, equals(0));
|
||||
expect(parent.offsetLeft, equals(0));
|
||||
expect(parent.offsetWidth, equals(250));
|
||||
assertNonChangingValues();
|
||||
|
||||
expect(firstChild.offsetWidth, equals(300));
|
||||
expect(firstChild.offsetHeight, equals(25));
|
||||
expect(firstChild.offsetTop, equals(0));
|
||||
expect(firstChild.offsetLeft, equals(0));
|
||||
parent.setLayoutManager(null);
|
||||
|
||||
expect(secondChild.offsetWidth, equals(300));
|
||||
expect(secondChild.offsetHeight, equals(25));
|
||||
expect(secondChild.offsetTop, equals(25));
|
||||
expect(secondChild.offsetLeft, equals(0));
|
||||
window.requestAnimationFrame((_) {
|
||||
expect(parent.offsetWidth, equals(300));
|
||||
expect(parent.offsetHeight, equals(50));
|
||||
expect(parent.offsetTop, equals(0));
|
||||
expect(parent.offsetLeft, equals(0));
|
||||
|
||||
expect(grandChild.offsetWidth, equals(25));
|
||||
expect(grandChild.offsetHeight, equals(25));
|
||||
expect(grandChild.offsetTop, equals(0));
|
||||
expect(grandChild.offsetLeft, equals(0));
|
||||
expect(firstChild.offsetWidth, equals(300));
|
||||
expect(firstChild.offsetHeight, equals(25));
|
||||
expect(firstChild.offsetTop, equals(0));
|
||||
expect(firstChild.offsetLeft, equals(0));
|
||||
|
||||
completer.complete();
|
||||
expect(secondChild.offsetWidth, equals(300));
|
||||
expect(secondChild.offsetHeight, equals(25));
|
||||
expect(secondChild.offsetTop, equals(25));
|
||||
expect(secondChild.offsetLeft, equals(0));
|
||||
|
||||
expect(grandChild.offsetWidth, equals(25));
|
||||
expect(grandChild.offsetHeight, equals(25));
|
||||
expect(grandChild.offsetTop, equals(0));
|
||||
expect(grandChild.offsetLeft, equals(0));
|
||||
|
||||
completer.complete();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user