Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Unified Diff: sky/sdk/lib/rendering/auto_layout.dart

Issue 1230033002: [AutoLayout] Address further concerns raised in https://codereview.chromium.org/1230583003 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/sdk/example/rendering/simple_autolayout.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/sdk/lib/rendering/auto_layout.dart
diff --git a/sky/sdk/lib/rendering/auto_layout.dart b/sky/sdk/lib/rendering/auto_layout.dart
index d5424ba7f4b4451ee1f1695c8d507a64cc2928f0..4f30097605cebff4514e902e39b39f50d3ac6767 100644
--- a/sky/sdk/lib/rendering/auto_layout.dart
+++ b/sky/sdk/lib/rendering/auto_layout.dart
@@ -53,7 +53,15 @@ abstract class _AutoLayoutParamMixin {
solver.suggestValueForVariable(_rightEdge.variable, size.width);
}
+ /// Called when the solver has updated at least one of the layout parameters
+ /// of this object. The object is now responsible for applying this update to
+ /// it other properties (if necessary)
Hixie 2015/07/09 21:52:07 s/it/the/, I assume?
void _applyAutolayoutParameterUpdates();
+
+ /// Returns the set of implicit constraints that need to be applied to all
+ /// instances of this class when they are moved into a render object with an
+ /// active solver. If no implicit constraints needs to be applied, the object
+ /// may return null.
Hixie 2015/07/09 21:52:07 If it's for all instances, why isn't it static?
List<al.Constraint> _constructImplicitConstraints();
void _setupImplicitConstraints(al.Solver solver) {
@@ -79,17 +87,18 @@ abstract class _AutoLayoutParamMixin {
_implicitConstraints = null;
}
+
}
class AutoLayoutParentData extends BoxParentData
with ContainerParentDataMixin<RenderBox>, _AutoLayoutParamMixin {
- final RenderBox _renderBox;
-
AutoLayoutParentData(this._renderBox) {
_setupLayoutParameters(this);
}
+ final RenderBox _renderBox;
+
@override
void _applyAutolayoutParameterUpdates() {
BoxConstraints box = new BoxConstraints.tightFor(
@@ -117,26 +126,23 @@ class RenderAutoLayout extends RenderBox
RenderBoxContainerDefaultsMixin<RenderBox, AutoLayoutParentData>,
_AutoLayoutParamMixin {
- final al.Solver _solver = new al.Solver();
- List<al.Constraint> _explicitConstraints = new List<al.Constraint>();
-
- RenderAutoLayout({List<RenderBox> children}) {
+ RenderAutoLayout({ List<RenderBox> children }) {
_setupLayoutParameters(this);
_setupEditVariablesInSolver(_solver, al.Priority.required - 1);
-
addAll(children);
}
+ final al.Solver _solver = new al.Solver();
+ List<al.Constraint> _explicitConstraints = new List<al.Constraint>();
+
/// Adds all the given constraints to the solver. Either all constraints are
/// added or none
al.Result addConstraints(List<al.Constraint> constraints) {
al.Result result = _solver.addConstraints(constraints);
-
if (result == al.Result.success) {
markNeedsLayout();
_explicitConstraints.addAll(constraints);
}
-
return result;
}
@@ -166,9 +172,8 @@ class RenderAutoLayout extends RenderBox
@override
void setupParentData(RenderObject child) {
- if (child.parentData is! AutoLayoutParentData) {
+ if (child.parentData is! AutoLayoutParentData)
child.parentData = new AutoLayoutParentData(child);
- }
}
@override
@@ -213,13 +218,14 @@ class RenderAutoLayout extends RenderBox
void dropChild(RenderObject child) {
child.parentData._collectImplicitConstraints(_solver);
- // Call super last as this collects parent data
super.dropChild(child);
}
@override
List<al.Constraint> _constructImplicitConstraints() {
- // Only edits are present on layout containers
+ // Only edits variables are present on layout containers. If, in the future,
+ // implicit constraints (for say margins, padding, etc.) need to be added,
+ // they must be returned from here.
return null;
}
}
« no previous file with comments | « sky/sdk/example/rendering/simple_autolayout.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698