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