error.dart 1.17 KB
Newer Older
1 2 3 4
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5 6 7
import 'box.dart';
import 'debug.dart';
import 'object.dart';
8 9 10 11

const double _kMaxWidth = 100000.0;
const double _kMaxHeight = 100000.0;

12
/// A render object used as a placeholder when an error occurs
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
class RenderErrorBox extends RenderBox {

  double getMinIntrinsicWidth(BoxConstraints constraints) {
    return constraints.constrainWidth(0.0);
  }

  double getMaxIntrinsicWidth(BoxConstraints constraints) {
    return constraints.constrainWidth(_kMaxWidth);
  }

  double getMinIntrinsicHeight(BoxConstraints constraints) {
    return constraints.constrainHeight(0.0);
  }

  double getMaxIntrinsicHeight(BoxConstraints constraints) {
    return constraints.constrainHeight(_kMaxHeight);
  }

  bool get sizedByParent => true;

Adam Barth's avatar
Adam Barth committed
33 34
  bool hitTestSelf(Point position) => true;

35 36 37 38 39 40 41 42 43
  void performResize() {
    size = constraints.constrain(const Size(_kMaxWidth, _kMaxHeight));
  }

  void paint(PaintingContext context, Offset offset) {
    context.canvas.drawRect(offset & size, new Paint() .. color = debugErrorBoxColor);
  }

}