| 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 import 'dart:typed_data'; | 7 import 'dart:typed_data'; |
| 8 import 'object.dart'; | 8 import 'object.dart'; |
| 9 import 'package:vector_math/vector_math.dart'; | 9 import 'package:vector_math/vector_math.dart'; |
| 10 import 'package:sky/framework/net/image_cache.dart' as image_cache; | 10 import 'package:sky/framework/net/image_cache.dart' as image_cache; |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 child.layout(constraints.apply(_additionalConstraints)); | 322 child.layout(constraints.apply(_additionalConstraints)); |
| 323 size = child.size; | 323 size = child.size; |
| 324 } else { | 324 } else { |
| 325 performResize(); | 325 performResize(); |
| 326 } | 326 } |
| 327 } | 327 } |
| 328 | 328 |
| 329 String debugDescribeSettings(String prefix) => '${super.debugDescribeSettings(
prefix)}${prefix}additionalConstraints: ${additionalConstraints}\n'; | 329 String debugDescribeSettings(String prefix) => '${super.debugDescribeSettings(
prefix)}${prefix}additionalConstraints: ${additionalConstraints}\n'; |
| 330 } | 330 } |
| 331 | 331 |
| 332 class RenderShrinkWrapWidth extends RenderProxyBox { |
| 333 RenderShrinkWrapWidth({ RenderBox child }) : super(child); |
| 334 |
| 335 BoxConstraints _getInnerConstraints(BoxConstraints constraints) { |
| 336 double width = child.getMaxIntrinsicWidth(constraints); |
| 337 assert(width == constraints.constrainWidth(width)); |
| 338 return new BoxConstraints(minWidth: width, |
| 339 maxWidth: width, |
| 340 minHeight: constraints.minHeight, |
| 341 maxHeight: constraints.maxHeight); |
| 342 } |
| 343 |
| 344 double getMinIntrinsicWidth(BoxConstraints constraints) { |
| 345 return child.getMaxIntrinsicWidth(constraints); |
| 346 } |
| 347 |
| 348 double getMaxIntrinsicWidth(BoxConstraints constraints) { |
| 349 return child.getMaxIntrinsicWidth(constraints); |
| 350 } |
| 351 |
| 352 double getMinIntrinsicHeight(BoxConstraints constraints) { |
| 353 return child.getMinIntrinsicHeight(_getInnerConstraints(constraints)); |
| 354 } |
| 355 |
| 356 double getMaxIntrinsicHeight(BoxConstraints constraints) { |
| 357 return child.getMaxIntrinsicHeight(_getInnerConstraints(constraints)); |
| 358 } |
| 359 |
| 360 void performLayout() { |
| 361 child.layout(_getInnerConstraints(constraints)); |
| 362 size = child.size; |
| 363 } |
| 364 } |
| 365 |
| 332 class RenderClip extends RenderProxyBox { | 366 class RenderClip extends RenderProxyBox { |
| 333 RenderClip({ RenderBox child }) : super(child); | 367 RenderClip({ RenderBox child }) : super(child); |
| 334 | 368 |
| 335 void paint(RenderObjectDisplayList canvas) { | 369 void paint(RenderObjectDisplayList canvas) { |
| 336 if (child != null) { | 370 if (child != null) { |
| 337 canvas.save(); | 371 canvas.save(); |
| 338 canvas.clipRect(new Rect.fromSize(size)); | 372 canvas.clipRect(new Rect.fromSize(size)); |
| 339 child.paint(canvas); | 373 child.paint(canvas); |
| 340 canvas.restore(); | 374 canvas.restore(); |
| 341 } | 375 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 354 EdgeDims get padding => _padding; | 388 EdgeDims get padding => _padding; |
| 355 void set padding (EdgeDims value) { | 389 void set padding (EdgeDims value) { |
| 356 assert(value != null); | 390 assert(value != null); |
| 357 if (_padding == value) | 391 if (_padding == value) |
| 358 return; | 392 return; |
| 359 _padding = value; | 393 _padding = value; |
| 360 markNeedsLayout(); | 394 markNeedsLayout(); |
| 361 } | 395 } |
| 362 | 396 |
| 363 double getMinIntrinsicWidth(BoxConstraints constraints) { | 397 double getMinIntrinsicWidth(BoxConstraints constraints) { |
| 398 double totalPadding = padding.left + padding.right; |
| 364 if (child != null) | 399 if (child != null) |
| 365 return child.getMinIntrinsicWidth(constraints.deflate(padding)); | 400 return child.getMinIntrinsicWidth(constraints.deflate(padding)) + totalPad
ding; |
| 366 return constraints.constrainWidth(padding.left + padding.right); | 401 return constraints.constrainWidth(totalPadding); |
| 367 } | 402 } |
| 368 | 403 |
| 369 double getMaxIntrinsicWidth(BoxConstraints constraints) { | 404 double getMaxIntrinsicWidth(BoxConstraints constraints) { |
| 405 double totalPadding = padding.left + padding.right; |
| 370 if (child != null) | 406 if (child != null) |
| 371 return child.getMaxIntrinsicWidth(constraints.deflate(padding)); | 407 return child.getMaxIntrinsicWidth(constraints.deflate(padding)) + totalPad
ding; |
| 372 return constraints.constrainWidth(padding.left + padding.right); | 408 return constraints.constrainWidth(totalPadding); |
| 373 } | 409 } |
| 374 | 410 |
| 375 double getMinIntrinsicHeight(BoxConstraints constraints) { | 411 double getMinIntrinsicHeight(BoxConstraints constraints) { |
| 412 double totalPadding = padding.top + padding.bottom; |
| 376 if (child != null) | 413 if (child != null) |
| 377 return child.getMinIntrinsicHeight(constraints.deflate(padding)); | 414 return child.getMinIntrinsicHeight(constraints.deflate(padding)) + totalPa
dding; |
| 378 return constraints.constrainHeight(padding.top + padding.bottom); | 415 return constraints.constrainHeight(totalPadding); |
| 379 } | 416 } |
| 380 | 417 |
| 381 double getMaxIntrinsicHeight(BoxConstraints constraints) { | 418 double getMaxIntrinsicHeight(BoxConstraints constraints) { |
| 419 double totalPadding = padding.top + padding.bottom; |
| 382 if (child != null) | 420 if (child != null) |
| 383 return child.getMaxIntrinsicHeight(constraints.deflate(padding)); | 421 return child.getMaxIntrinsicHeight(constraints.deflate(padding)) + totalPa
dding; |
| 384 return constraints.constrainHeight(padding.top + padding.bottom); | 422 return constraints.constrainHeight(totalPadding); |
| 385 } | 423 } |
| 386 | 424 |
| 387 void performLayout() { | 425 void performLayout() { |
| 388 assert(padding != null); | 426 assert(padding != null); |
| 389 BoxConstraints innerConstraints = constraints.deflate(padding); | 427 BoxConstraints innerConstraints = constraints.deflate(padding); |
| 390 if (child == null) { | 428 if (child == null) { |
| 391 size = innerConstraints.constrain( | 429 size = innerConstraints.constrain( |
| 392 new Size(padding.left + padding.right, padding.top + padding.bottom)); | 430 new Size(padding.left + padding.right, padding.top + padding.bottom)); |
| 393 return; | 431 return; |
| 394 } | 432 } |
| (...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 924 | 962 |
| 925 void defaultPaint(RenderObjectDisplayList canvas) { | 963 void defaultPaint(RenderObjectDisplayList canvas) { |
| 926 RenderBox child = firstChild; | 964 RenderBox child = firstChild; |
| 927 while (child != null) { | 965 while (child != null) { |
| 928 assert(child.parentData is ParentDataType); | 966 assert(child.parentData is ParentDataType); |
| 929 canvas.paintChild(child, child.parentData.position); | 967 canvas.paintChild(child, child.parentData.position); |
| 930 child = child.parentData.nextSibling; | 968 child = child.parentData.nextSibling; |
| 931 } | 969 } |
| 932 } | 970 } |
| 933 } | 971 } |
| OLD | NEW |