Commit aef18a90 authored by Hixie's avatar Hixie

Add asserts to catch potential misuses of the rendering framework.

New asserts:
- verify that after layout, the size fits the constraints
- verify that after layout, the size isn't infinite
- verify that you don't set the size in performLayout() if you have
  sizedByParent set
- verify that nobody reads your size during layout except you, or your
  parent if they said parentUsesSize:true

Fixes some bugs found by those asserts:
- RenderBlock, RenderStack, and RenderScaffold were not always setting
  parentUsesSize correctly
- RenderScaffold was setting its slot entries to null rather than
  removing them when the slot went away, which led to null derefs in
  certain circumstances

Also, rename a local variable in RenderStack.performLayout() because
it was shadowing a variable on the object itself, which was really
confusing when I first tried to debug this function...

R=abarth@chromium.org

Review URL: https://codereview.chromium.org/1213473003.
parent ab246ebc
...@@ -75,6 +75,17 @@ abstract class RenderSector extends RenderObject { ...@@ -75,6 +75,17 @@ abstract class RenderSector extends RenderObject {
} }
SectorConstraints get constraints => super.constraints; SectorConstraints get constraints => super.constraints;
bool debugDoesMeetConstraints() {
assert(constraints != null);
assert(deltaRadius != null);
assert(deltaRadius < double.INFINITY);
assert(deltaTheta != null);
assert(deltaTheta < double.INFINITY);
return constraints.minDeltaRadius <= deltaRadius &&
deltaRadius <= math.max(constraints.minDeltaRadius, constraints.maxDeltaRadius) &&
constraints.minDeltaTheta <= deltaTheta &&
deltaTheta <= math.max(constraints.minDeltaTheta, constraints.maxDeltaTheta);
}
void performResize() { void performResize() {
// default behaviour for subclasses that have sizedByParent = true // default behaviour for subclasses that have sizedByParent = true
deltaRadius = constraints.constrainDeltaRadius(0.0); deltaRadius = constraints.constrainDeltaRadius(0.0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment