Commit 887e3396 authored by Adam Barth's avatar Adam Barth

Start using protected annotation (#4288)

There are many more places we can use this annotation. This patch starts out
small to test the waters.
parent a0e7cdba
...@@ -7,6 +7,7 @@ import 'dart:ui' as ui show lerpDouble; ...@@ -7,6 +7,7 @@ import 'dart:ui' as ui show lerpDouble;
import 'package:flutter/animation.dart'; import 'package:flutter/animation.dart';
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
import 'package:meta/meta.dart';
import 'package:vector_math/vector_math_64.dart'; import 'package:vector_math/vector_math_64.dart';
import 'debug.dart'; import 'debug.dart';
...@@ -815,6 +816,7 @@ abstract class RenderBox extends RenderObject { ...@@ -815,6 +816,7 @@ abstract class RenderBox extends RenderObject {
/// ///
/// Subclasses should override this function to supply the distances to their /// Subclasses should override this function to supply the distances to their
/// baselines. /// baselines.
@protected
double computeDistanceToActualBaseline(TextBaseline baseline) { double computeDistanceToActualBaseline(TextBaseline baseline) {
assert(_debugDoingBaseline); assert(_debugDoingBaseline);
return null; return null;
...@@ -1035,6 +1037,7 @@ abstract class RenderBox extends RenderObject { ...@@ -1035,6 +1037,7 @@ abstract class RenderBox extends RenderObject {
/// Override this function if this render object can be hit even if its /// Override this function if this render object can be hit even if its
/// children were not hit. /// children were not hit.
@protected
bool hitTestSelf(Point position) => false; bool hitTestSelf(Point position) => false;
/// Override this function to check whether any children are located at the /// Override this function to check whether any children are located at the
...@@ -1043,6 +1046,7 @@ abstract class RenderBox extends RenderObject { ...@@ -1043,6 +1046,7 @@ abstract class RenderBox extends RenderObject {
/// Typically children should be hit tested in reverse paint order so that /// Typically children should be hit tested in reverse paint order so that
/// hit tests at locations where children overlap hit the child that is /// hit tests at locations where children overlap hit the child that is
/// visually "on top" (i.e., paints later). /// visually "on top" (i.e., paints later).
@protected
bool hitTestChildren(HitTestResult result, { Point position }) => false; bool hitTestChildren(HitTestResult result, { Point position }) => false;
/// Multiply the transform from the parent's coordinate system to this box's /// Multiply the transform from the parent's coordinate system to this box's
...@@ -1149,6 +1153,7 @@ abstract class RenderBox extends RenderObject { ...@@ -1149,6 +1153,7 @@ abstract class RenderBox extends RenderObject {
/// In debug mode, paints a border around this render box. /// In debug mode, paints a border around this render box.
/// ///
/// Called for every [RenderBox] when [debugPaintSizeEnabled] is true. /// Called for every [RenderBox] when [debugPaintSizeEnabled] is true.
@protected
void debugPaintSize(PaintingContext context, Offset offset) { void debugPaintSize(PaintingContext context, Offset offset) {
assert(() { assert(() {
Paint paint = new Paint() Paint paint = new Paint()
...@@ -1163,6 +1168,7 @@ abstract class RenderBox extends RenderObject { ...@@ -1163,6 +1168,7 @@ abstract class RenderBox extends RenderObject {
/// In debug mode, paints a line for each baseline. /// In debug mode, paints a line for each baseline.
/// ///
/// Called for every [RenderBox] when [debugPaintBaselinesEnabled] is true. /// Called for every [RenderBox] when [debugPaintBaselinesEnabled] is true.
@protected
void debugPaintBaselines(PaintingContext context, Offset offset) { void debugPaintBaselines(PaintingContext context, Offset offset) {
assert(() { assert(() {
Paint paint = new Paint() Paint paint = new Paint()
...@@ -1194,6 +1200,7 @@ abstract class RenderBox extends RenderObject { ...@@ -1194,6 +1200,7 @@ abstract class RenderBox extends RenderObject {
/// In debug mode, paints a rectangle if this render box has received more pointer downs than pointer up events. /// In debug mode, paints a rectangle if this render box has received more pointer downs than pointer up events.
/// ///
/// Called for every [RenderBox] when [debugPaintPointersEnabled] is true. /// Called for every [RenderBox] when [debugPaintPointersEnabled] is true.
@protected
void debugPaintPointers(PaintingContext context, Offset offset) { void debugPaintPointers(PaintingContext context, Offset offset) {
assert(() { assert(() {
if (_debugActivePointers > 0) { if (_debugActivePointers > 0) {
......
...@@ -9,6 +9,7 @@ import 'package:flutter/foundation.dart'; ...@@ -9,6 +9,7 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
import 'package:flutter/painting.dart'; import 'package:flutter/painting.dart';
import 'package:flutter/scheduler.dart'; import 'package:flutter/scheduler.dart';
import 'package:meta/meta.dart';
import 'package:mojo_services/mojo/gfx/composition/scene_token.mojom.dart' as mojom; import 'package:mojo_services/mojo/gfx/composition/scene_token.mojom.dart' as mojom;
import 'package:vector_math/vector_math_64.dart'; import 'package:vector_math/vector_math_64.dart';
...@@ -29,6 +30,7 @@ export 'package:flutter/foundation.dart' show FlutterError, InformationCollector ...@@ -29,6 +30,7 @@ export 'package:flutter/foundation.dart' show FlutterError, InformationCollector
/// to other children. /// to other children.
class ParentData { class ParentData {
/// Called when the RenderObject is removed from the tree. /// Called when the RenderObject is removed from the tree.
@mustCallSuper
void detach() { } void detach() { }
@override @override
...@@ -1438,6 +1440,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget { ...@@ -1438,6 +1440,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
/// property isn't used when debugCanParentUseSize isn't set, then that /// property isn't used when debugCanParentUseSize isn't set, then that
/// subclass should override debugResetSize() to reapply the current values of /// subclass should override debugResetSize() to reapply the current values of
/// debugCanParentUseSize to that state. /// debugCanParentUseSize to that state.
@protected
void debugResetSize() { } void debugResetSize() { }
/// Whether the constraints are the only input to the sizing algorithm (in /// Whether the constraints are the only input to the sizing algorithm (in
...@@ -1459,6 +1462,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget { ...@@ -1459,6 +1462,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
/// to compute their size. /// to compute their size.
/// ///
/// This function is called only if [sizedByParent] is true. /// This function is called only if [sizedByParent] is true.
@protected
void performResize(); void performResize();
/// Do the work of computing the layout for this render object. /// Do the work of computing the layout for this render object.
...@@ -1480,6 +1484,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget { ...@@ -1480,6 +1484,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
/// parentUsesSize ensures that this render object will undergo layout if the /// parentUsesSize ensures that this render object will undergo layout if the
/// child undergoes layout. Otherwise, the child can changes its layout /// child undergoes layout. Otherwise, the child can changes its layout
/// information without informing this render object. /// information without informing this render object.
@protected
void performLayout(); void performLayout();
// We cache a closure to performLayout so that the callsite is monomorphic. // We cache a closure to performLayout so that the callsite is monomorphic.
...@@ -1489,6 +1494,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget { ...@@ -1489,6 +1494,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
/// Allows this render object to mutate its child list during layout and /// Allows this render object to mutate its child list during layout and
/// calls callback. /// calls callback.
@protected
void invokeLayoutCallback(LayoutCallback callback) { void invokeLayoutCallback(LayoutCallback callback) {
assert(_debugMutationsLocked); assert(_debugMutationsLocked);
assert(_debugDoingThisLayout); assert(_debugDoingThisLayout);
...@@ -1754,6 +1760,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget { ...@@ -1754,6 +1760,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
Rect get paintBounds; Rect get paintBounds;
/// Override this function to paint debugging information. /// Override this function to paint debugging information.
@protected
void debugPaint(PaintingContext context, Offset offset) { } void debugPaint(PaintingContext context, Offset offset) { }
/// Paint this render object into the given context at the given offset. /// Paint this render object into the given context at the given offset.
...@@ -2094,6 +2101,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget { ...@@ -2094,6 +2101,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
/// Returns a list of strings describing the current node's fields, one field /// Returns a list of strings describing the current node's fields, one field
/// per string. Subclasses should override this to have their information /// per string. Subclasses should override this to have their information
/// included in toStringDeep(). /// included in toStringDeep().
@protected
void debugFillDescription(List<String> description) { void debugFillDescription(List<String> description) {
if (debugCreator != null) if (debugCreator != null)
description.add('creator: $debugCreator'); description.add('creator: $debugCreator');
...@@ -2103,6 +2111,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget { ...@@ -2103,6 +2111,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
/// Returns a string describing the current node's descendants. Each line of /// Returns a string describing the current node's descendants. Each line of
/// the subtree in the output should be indented by the prefix argument. /// the subtree in the output should be indented by the prefix argument.
@protected
String debugDescribeChildren(String prefix) => ''; String debugDescribeChildren(String prefix) => '';
} }
......
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