| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 import 'dart:math' as math; | 5 import 'dart:math' as math; |
| 6 import 'dart:sky' as sky; | 6 import 'dart:sky' as sky; |
| 7 | 7 |
| 8 import 'package:vector_math/vector_math.dart'; | 8 import 'package:vector_math/vector_math.dart'; |
| 9 | 9 |
| 10 import '../base/debug.dart'; | 10 import '../base/debug.dart'; |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 } | 299 } |
| 300 // getDistanceToBaseline() returns the distance from the | 300 // getDistanceToBaseline() returns the distance from the |
| 301 // y-coordinate of the position of the box to the y-coordinate of | 301 // y-coordinate of the position of the box to the y-coordinate of |
| 302 // the first given baseline in the box's contents. This is used by | 302 // the first given baseline in the box's contents. This is used by |
| 303 // certain layout models to align adjacent boxes on a common | 303 // certain layout models to align adjacent boxes on a common |
| 304 // baseline, regardless of padding, font size differences, etc. If | 304 // baseline, regardless of padding, font size differences, etc. If |
| 305 // there is no baseline, then it returns the distance from the | 305 // there is no baseline, then it returns the distance from the |
| 306 // y-coordinate of the position of the box to the y-coordinate of | 306 // y-coordinate of the position of the box to the y-coordinate of |
| 307 // the bottom of the box, i.e., the height of the box. Only call | 307 // the bottom of the box, i.e., the height of the box. Only call |
| 308 // this after layout has been performed. You are only allowed to | 308 // this after layout has been performed. You are only allowed to |
| 309 // call this from the parent of this node, and only during | 309 // call this from the parent of this node during that parent's |
| 310 // that parent's performLayout(). | 310 // performLayout() or paint(). |
| 311 double getDistanceToBaseline(TextBaseline baseline) { | 311 double getDistanceToBaseline(TextBaseline baseline) { |
| 312 assert(!needsLayout); | 312 assert(!needsLayout); |
| 313 assert(!_debugDoingBaseline); | 313 assert(!_debugDoingBaseline); |
| 314 final parent = this.parent; // TODO(ianh): Remove this once the analyzer is
cleverer | 314 final parent = this.parent; // TODO(ianh): Remove this once the analyzer is
cleverer |
| 315 assert(parent is RenderObject); | 315 assert(parent is RenderObject); |
| 316 assert(parent == RenderObject.debugActiveLayout); | 316 assert(() { |
| 317 assert(parent.debugDoingThisLayout); | 317 if (RenderObject.debugDoingLayout) |
| 318 return (parent == RenderObject.debugActiveLayout) && parent.debugDoingTh
isLayout; |
| 319 if (RenderObject.debugDoingPaint) |
| 320 return (parent == RenderObject.debugActivePaint) && parent.debugDoingThi
sPaint; |
| 321 return false; |
| 322 }); |
| 318 assert(_debugSetDoingBaseline(true)); | 323 assert(_debugSetDoingBaseline(true)); |
| 319 double result = getDistanceToActualBaseline(baseline); | 324 double result = getDistanceToActualBaseline(baseline); |
| 320 assert(_debugSetDoingBaseline(false)); | 325 assert(_debugSetDoingBaseline(false)); |
| 321 assert(parent == this.parent); // TODO(ianh): Remove this once the analyzer
is cleverer | 326 assert(parent == this.parent); // TODO(ianh): Remove this once the analyzer
is cleverer |
| 322 if (result == null) | 327 if (result == null) |
| 323 return size.height; | 328 return size.height; |
| 324 return result; | 329 return result; |
| 325 } | 330 } |
| 326 // getDistanceToActualBaseline() must only be called from | 331 // getDistanceToActualBaseline() must only be called from |
| 327 // getDistanceToBaseline() and computeDistanceToActualBaseline(). Do | 332 // getDistanceToBaseline() and computeDistanceToActualBaseline(). Do |
| (...skipping 1110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1438 | 1443 |
| 1439 void defaultPaint(PaintingCanvas canvas, Offset offset) { | 1444 void defaultPaint(PaintingCanvas canvas, Offset offset) { |
| 1440 RenderBox child = firstChild; | 1445 RenderBox child = firstChild; |
| 1441 while (child != null) { | 1446 while (child != null) { |
| 1442 assert(child.parentData is ParentDataType); | 1447 assert(child.parentData is ParentDataType); |
| 1443 canvas.paintChild(child, child.parentData.position + offset); | 1448 canvas.paintChild(child, child.parentData.position + offset); |
| 1444 child = child.parentData.nextSibling; | 1449 child = child.parentData.nextSibling; |
| 1445 } | 1450 } |
| 1446 } | 1451 } |
| 1447 } | 1452 } |
| OLD | NEW |