Commit 91a783bf authored by Adam Barth's avatar Adam Barth

Rename Widget.root to Widget.renderObject

The name `root` is confusing because this value isn't the root of anything.
It's just the associated `RenderObject` instance.
parent 46fc8e6a
...@@ -24,14 +24,14 @@ class SpriteWidget extends OneChildRenderObjectWrapper { ...@@ -24,14 +24,14 @@ class SpriteWidget extends OneChildRenderObjectWrapper {
/// var mySpriteWidget = new SpriteWidget(mySpriteTree, SpriteBoxTransformMode.fixedHeight); /// var mySpriteWidget = new SpriteWidget(mySpriteTree, SpriteBoxTransformMode.fixedHeight);
SpriteWidget(this.rootNode, [this.transformMode = SpriteBoxTransformMode.letterbox]); SpriteWidget(this.rootNode, [this.transformMode = SpriteBoxTransformMode.letterbox]);
SpriteBox get root => super.root; SpriteBox get renderObject => super.renderObject;
SpriteBox createNode() => new SpriteBox(rootNode, transformMode); SpriteBox createNode() => new SpriteBox(rootNode, transformMode);
void syncRenderObject(SpriteWidget old) { void syncRenderObject(SpriteWidget old) {
super.syncRenderObject(old); super.syncRenderObject(old);
root.rootNode = rootNode; renderObject.rootNode = rootNode;
root.transformMode = transformMode; renderObject.transformMode = transformMode;
} }
} }
...@@ -115,7 +115,7 @@ class OverlayGeometryApp extends App { ...@@ -115,7 +115,7 @@ class OverlayGeometryApp extends App {
setState(() { setState(() {
markers[MarkerType.touch] = new Point(event.x, event.y); markers[MarkerType.touch] = new Point(event.x, event.y);
markers[MarkerType.topLeft] = target.localToGlobal(new Point(0.0, 0.0)); markers[MarkerType.topLeft] = target.localToGlobal(new Point(0.0, 0.0));
Size size = (target.root as RenderBox).size; Size size = (target.renderObject as RenderBox).size;
markers[MarkerType.bottomRight] = target.localToGlobal(new Point(size.width, size.height)); markers[MarkerType.bottomRight] = target.localToGlobal(new Point(size.width, size.height));
Scrollable scrollable = findScrollableAncestor(target: target); Scrollable scrollable = findScrollableAncestor(target: target);
......
This diff is collapsed.
...@@ -88,7 +88,7 @@ class BlockViewport extends RenderObjectWrapper { ...@@ -88,7 +88,7 @@ class BlockViewport extends RenderObjectWrapper {
Object token; Object token;
BlockViewportLayoutState layoutState; BlockViewportLayoutState layoutState;
RenderBlockViewport get root => super.root; RenderBlockViewport get renderObject => super.renderObject;
RenderBlockViewport createNode() => new RenderBlockViewport(); RenderBlockViewport createNode() => new RenderBlockViewport();
void walkChildren(WidgetTreeWalker walker) { void walkChildren(WidgetTreeWalker walker) {
...@@ -101,20 +101,20 @@ class BlockViewport extends RenderObjectWrapper { ...@@ -101,20 +101,20 @@ class BlockViewport extends RenderObjectWrapper {
void insertChildRoot(RenderObjectWrapper child, dynamic slot) { void insertChildRoot(RenderObjectWrapper child, dynamic slot) {
if (slot == _omit) if (slot == _omit)
return; return;
final root = this.root; // TODO(ianh): Remove this once the analyzer is cleverer final renderObject = this.renderObject; // TODO(ianh): Remove this once the analyzer is cleverer
assert(slot == null || slot is RenderObject); assert(slot == null || slot is RenderObject);
assert(root is ContainerRenderObjectMixin); assert(renderObject is ContainerRenderObjectMixin);
root.add(child.root, before: slot); renderObject.add(child.renderObject, before: slot);
assert(root == this.root); // TODO(ianh): Remove this once the analyzer is cleverer assert(renderObject == this.renderObject); // TODO(ianh): Remove this once the analyzer is cleverer
} }
void detachChildRoot(RenderObjectWrapper child) { void detachChildRoot(RenderObjectWrapper child) {
final root = this.root; // TODO(ianh): Remove this once the analyzer is cleverer final renderObject = this.renderObject; // TODO(ianh): Remove this once the analyzer is cleverer
assert(root is ContainerRenderObjectMixin); assert(renderObject is ContainerRenderObjectMixin);
if (child.root.parent != root) if (child.renderObject.parent != renderObject)
return; // probably had slot == _omit when inserted return; // probably had slot == _omit when inserted
root.remove(child.root); renderObject.remove(child.renderObject);
assert(root == this.root); // TODO(ianh): Remove this once the analyzer is cleverer assert(renderObject == this.renderObject); // TODO(ianh): Remove this once the analyzer is cleverer
} }
void remove() { void remove() {
...@@ -126,12 +126,12 @@ class BlockViewport extends RenderObjectWrapper { ...@@ -126,12 +126,12 @@ class BlockViewport extends RenderObjectWrapper {
} }
void didMount() { void didMount() {
root.callback = layout; renderObject.callback = layout;
super.didMount(); super.didMount();
} }
void didUnmount() { void didUnmount() {
root.callback = null; renderObject.callback = null;
super.didUnmount(); super.didUnmount();
} }
...@@ -173,12 +173,12 @@ class BlockViewport extends RenderObjectWrapper { ...@@ -173,12 +173,12 @@ class BlockViewport extends RenderObjectWrapper {
void syncRenderObject(BlockViewport old) { void syncRenderObject(BlockViewport old) {
super.syncRenderObject(old); super.syncRenderObject(old);
if (layoutState._dirty || !layoutState.isValid) { if (layoutState._dirty || !layoutState.isValid) {
root.markNeedsLayout(); renderObject.markNeedsLayout();
} else { } else {
if (layoutState._visibleChildCount > 0) { if (layoutState._visibleChildCount > 0) {
assert(layoutState.firstVisibleChildIndex >= 0); assert(layoutState.firstVisibleChildIndex >= 0);
assert(builder != null); assert(builder != null);
assert(root != null); assert(renderObject != null);
final int startIndex = layoutState._firstVisibleChildIndex; final int startIndex = layoutState._firstVisibleChildIndex;
int lastIndex = startIndex + layoutState._visibleChildCount - 1; int lastIndex = startIndex + layoutState._visibleChildCount - 1;
for (int index = startIndex; index <= lastIndex; index += 1) { for (int index = startIndex; index <= lastIndex; index += 1) {
...@@ -188,8 +188,8 @@ class BlockViewport extends RenderObjectWrapper { ...@@ -188,8 +188,8 @@ class BlockViewport extends RenderObjectWrapper {
_Key key = new _Key.fromWidget(widget); _Key key = new _Key.fromWidget(widget);
Widget oldWidget = layoutState._childrenByKey[key]; Widget oldWidget = layoutState._childrenByKey[key];
assert(oldWidget != null); assert(oldWidget != null);
assert(oldWidget.root.parent == root); assert(oldWidget.renderObject.parent == renderObject);
widget = syncChild(widget, oldWidget, root.childAfter(oldWidget.root)); widget = syncChild(widget, oldWidget, renderObject.childAfter(oldWidget.renderObject));
assert(widget != null); assert(widget != null);
layoutState._childrenByKey[key] = widget; layoutState._childrenByKey[key] = widget;
} }
...@@ -214,7 +214,7 @@ class BlockViewport extends RenderObjectWrapper { ...@@ -214,7 +214,7 @@ class BlockViewport extends RenderObjectWrapper {
newWidget = syncChild(newWidget, oldWidget, _omit); newWidget = syncChild(newWidget, oldWidget, _omit);
assert(newWidget != null); assert(newWidget != null);
// Update the offsets based on the newWidget's height. // Update the offsets based on the newWidget's height.
RenderBox widgetRoot = newWidget.root; RenderBox widgetRoot = newWidget.renderObject;
assert(widgetRoot is RenderBox); assert(widgetRoot is RenderBox);
double newHeight = widgetRoot.getMaxIntrinsicHeight(innerConstraints); double newHeight = widgetRoot.getMaxIntrinsicHeight(innerConstraints);
double oldHeight = offsets[index + 1] - offsets[index]; double oldHeight = offsets[index + 1] - offsets[index];
...@@ -237,7 +237,7 @@ class BlockViewport extends RenderObjectWrapper { ...@@ -237,7 +237,7 @@ class BlockViewport extends RenderObjectWrapper {
if (index >= offsets.length - 1) { if (index >= offsets.length - 1) {
assert(index == offsets.length - 1); assert(index == offsets.length - 1);
final double widgetStartOffset = offsets[index]; final double widgetStartOffset = offsets[index];
RenderBox widgetRoot = widget.root; RenderBox widgetRoot = widget.renderObject;
assert(widgetRoot is RenderBox); assert(widgetRoot is RenderBox);
final double widgetEndOffset = widgetStartOffset + widgetRoot.getMaxIntrinsicHeight(innerConstraints); final double widgetEndOffset = widgetStartOffset + widgetRoot.getMaxIntrinsicHeight(innerConstraints);
offsets.add(widgetEndOffset); offsets.add(widgetEndOffset);
...@@ -266,7 +266,7 @@ class BlockViewport extends RenderObjectWrapper { ...@@ -266,7 +266,7 @@ class BlockViewport extends RenderObjectWrapper {
final List<double> offsets = layoutState._childOffsets; final List<double> offsets = layoutState._childOffsets;
final Map<_Key, Widget> childrenByKey = layoutState._childrenByKey; final Map<_Key, Widget> childrenByKey = layoutState._childrenByKey;
final double height = root.size.height; final double height = renderObject.size.height;
final double endOffset = startOffset + height; final double endOffset = startOffset + height;
BoxConstraints innerConstraints = new BoxConstraints.tightFor(width: constraints.constrainWidth()); BoxConstraints innerConstraints = new BoxConstraints.tightFor(width: constraints.constrainWidth());
...@@ -362,7 +362,7 @@ class BlockViewport extends RenderObjectWrapper { ...@@ -362,7 +362,7 @@ class BlockViewport extends RenderObjectWrapper {
int index = startIndex; int index = startIndex;
if (haveChildren) { if (haveChildren) {
// Build all the widgets we need. // Build all the widgets we need.
root.startOffset = offsets[index] - startOffset; renderObject.startOffset = offsets[index] - startOffset;
while (offsets[index] < endOffset) { while (offsets[index] < endOffset) {
if (!builtChildren.containsKey(index)) { if (!builtChildren.containsKey(index)) {
Widget widget = _getWidget(index, innerConstraints); Widget widget = _getWidget(index, innerConstraints);
...@@ -392,14 +392,14 @@ class BlockViewport extends RenderObjectWrapper { ...@@ -392,14 +392,14 @@ class BlockViewport extends RenderObjectWrapper {
while (index > startIndex) { while (index > startIndex) {
index -= 1; index -= 1;
Widget widget = builtChildren[index]; Widget widget = builtChildren[index];
if (widget.root.parent == root) { if (widget.renderObject.parent == renderObject) {
root.move(widget.root, before: nextSibling); renderObject.move(widget.renderObject, before: nextSibling);
} else { } else {
assert(widget.root.parent == null); assert(widget.renderObject.parent == null);
root.add(widget.root, before: nextSibling); renderObject.add(widget.renderObject, before: nextSibling);
} }
widget.updateSlot(nextSibling); widget.updateSlot(nextSibling);
nextSibling = widget.root; nextSibling = widget.renderObject;
} }
} }
......
...@@ -64,16 +64,16 @@ class _CheckboxWrapper extends LeafRenderObjectWrapper { ...@@ -64,16 +64,16 @@ class _CheckboxWrapper extends LeafRenderObjectWrapper {
final Color uncheckedColor; final Color uncheckedColor;
final Color accentColor; final Color accentColor;
_RenderCheckbox get root => super.root; _RenderCheckbox get renderObject => super.renderObject;
_RenderCheckbox createNode() => new _RenderCheckbox( _RenderCheckbox createNode() => new _RenderCheckbox(
value: value, uncheckedColor: uncheckedColor, onChanged: onChanged); value: value, uncheckedColor: uncheckedColor, onChanged: onChanged);
void syncRenderObject(_CheckboxWrapper old) { void syncRenderObject(_CheckboxWrapper old) {
super.syncRenderObject(old); super.syncRenderObject(old);
root.value = value; renderObject.value = value;
root.onChanged = onChanged; renderObject.onChanged = onChanged;
root.uncheckedColor = uncheckedColor; renderObject.uncheckedColor = uncheckedColor;
root.accentColor = accentColor; renderObject.accentColor = accentColor;
} }
} }
......
This diff is collapsed.
...@@ -131,6 +131,6 @@ class InkWell extends OneChildRenderObjectWrapper { ...@@ -131,6 +131,6 @@ class InkWell extends OneChildRenderObjectWrapper {
InkWell({ Key key, Widget child }) InkWell({ Key key, Widget child })
: super(key: key, child: child); : super(key: key, child: child);
RenderInkWell get root => super.root; RenderInkWell get renderObject => super.renderObject;
RenderInkWell createNode() => new RenderInkWell(); RenderInkWell createNode() => new RenderInkWell();
} }
...@@ -196,7 +196,7 @@ class Scaffold extends RenderObjectWrapper { ...@@ -196,7 +196,7 @@ class Scaffold extends RenderObjectWrapper {
Map<ScaffoldSlots, Widget> _slots = new Map<ScaffoldSlots, Widget>(); Map<ScaffoldSlots, Widget> _slots = new Map<ScaffoldSlots, Widget>();
RenderScaffold get root => super.root; RenderScaffold get renderObject => super.renderObject;
RenderScaffold createNode() => new RenderScaffold(); RenderScaffold createNode() => new RenderScaffold();
void walkChildren(WidgetTreeWalker walker) { void walkChildren(WidgetTreeWalker walker) {
...@@ -208,15 +208,15 @@ class Scaffold extends RenderObjectWrapper { ...@@ -208,15 +208,15 @@ class Scaffold extends RenderObjectWrapper {
} }
void insertChildRoot(RenderObjectWrapper child, ScaffoldSlots slot) { void insertChildRoot(RenderObjectWrapper child, ScaffoldSlots slot) {
root[slot] = child != null ? child.root : null; renderObject[slot] = child != null ? child.renderObject : null;
} }
void detachChildRoot(RenderObjectWrapper child) { void detachChildRoot(RenderObjectWrapper child) {
final root = this.root; // TODO(ianh): Remove this once the analyzer is cleverer final renderObject = this.renderObject; // TODO(ianh): Remove this once the analyzer is cleverer
assert(root is RenderScaffold); assert(renderObject is RenderScaffold);
assert(root == child.root.parent); assert(renderObject == child.renderObject.parent);
root.remove(child.root); renderObject.remove(child.renderObject);
assert(root == this.root); // TODO(ianh): Remove this once the analyzer is cleverer assert(renderObject == this.renderObject); // TODO(ianh): Remove this once the analyzer is cleverer
} }
void remove() { void remove() {
......
...@@ -233,20 +233,20 @@ Scrollable findScrollableAncestor({ Widget target }) { ...@@ -233,20 +233,20 @@ Scrollable findScrollableAncestor({ Widget target }) {
bool ensureWidgetIsVisible(Widget target, { ValueAnimation<double> animation }) { bool ensureWidgetIsVisible(Widget target, { ValueAnimation<double> animation }) {
assert(target.mounted); assert(target.mounted);
assert(target.root is RenderBox); assert(target.renderObject is RenderBox);
Scrollable scrollable = findScrollableAncestor(target: target); Scrollable scrollable = findScrollableAncestor(target: target);
if (scrollable == null) if (scrollable == null)
return false; return false;
Size targetSize = (target.root as RenderBox).size; Size targetSize = (target.renderObject as RenderBox).size;
Point targetCenter = target.localToGlobal( Point targetCenter = target.localToGlobal(
scrollable.scrollDirection == ScrollDirection.vertical scrollable.scrollDirection == ScrollDirection.vertical
? new Point(0.0, targetSize.height / 2.0) ? new Point(0.0, targetSize.height / 2.0)
: new Point(targetSize.width / 2.0, 0.0) : new Point(targetSize.width / 2.0, 0.0)
); );
Size scrollableSize = (scrollable.root as RenderBox).size; Size scrollableSize = (scrollable.renderObject as RenderBox).size;
Point scrollableCenter = scrollable.localToGlobal( Point scrollableCenter = scrollable.localToGlobal(
scrollable.scrollDirection == ScrollDirection.vertical scrollable.scrollDirection == ScrollDirection.vertical
? new Point(0.0, scrollableSize.height / 2.0) ? new Point(0.0, scrollableSize.height / 2.0)
......
...@@ -55,15 +55,15 @@ class _SwitchWrapper extends LeafRenderObjectWrapper { ...@@ -55,15 +55,15 @@ class _SwitchWrapper extends LeafRenderObjectWrapper {
final ValueChanged onChanged; final ValueChanged onChanged;
final Color thumbColor; final Color thumbColor;
_RenderSwitch get root => super.root; _RenderSwitch get renderObject => super.renderObject;
_RenderSwitch createNode() => new _RenderSwitch( _RenderSwitch createNode() => new _RenderSwitch(
value: value, thumbColor: thumbColor, onChanged: onChanged); value: value, thumbColor: thumbColor, onChanged: onChanged);
void syncRenderObject(_SwitchWrapper old) { void syncRenderObject(_SwitchWrapper old) {
super.syncRenderObject(old); super.syncRenderObject(old);
root.value = value; renderObject.value = value;
root.onChanged = onChanged; renderObject.onChanged = onChanged;
root.thumbColor = thumbColor; renderObject.thumbColor = thumbColor;
} }
} }
......
...@@ -287,18 +287,18 @@ class TabBarWrapper extends MultiChildRenderObjectWrapper { ...@@ -287,18 +287,18 @@ class TabBarWrapper extends MultiChildRenderObjectWrapper {
final bool isScrollable; final bool isScrollable;
final LayoutChanged onLayoutChanged; final LayoutChanged onLayoutChanged;
RenderTabBar get root => super.root; RenderTabBar get renderObject => super.renderObject;
RenderTabBar createNode() => new RenderTabBar(onLayoutChanged); RenderTabBar createNode() => new RenderTabBar(onLayoutChanged);
void syncRenderObject(Widget old) { void syncRenderObject(Widget old) {
super.syncRenderObject(old); super.syncRenderObject(old);
root.selectedIndex = selectedIndex; renderObject.selectedIndex = selectedIndex;
root.backgroundColor = backgroundColor; renderObject.backgroundColor = backgroundColor;
root.indicatorColor = indicatorColor; renderObject.indicatorColor = indicatorColor;
root.indicatorRect = indicatorRect; renderObject.indicatorRect = indicatorRect;
root.textAndIcons = textAndIcons; renderObject.textAndIcons = textAndIcons;
root.isScrollable = isScrollable; renderObject.isScrollable = isScrollable;
root.onLayoutChanged = onLayoutChanged; renderObject.onLayoutChanged = onLayoutChanged;
} }
} }
......
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