Skip to content

Conversation

@Hixie
Copy link
Contributor

@Hixie Hixie commented Jan 6, 2017

This implements a new RenderViewport2 class to replace the existing
RenderViewport class.

@Hixie
Copy link
Contributor Author

Hixie commented Jan 6, 2017

(Travis failure is dependency on #7367)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2017

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ha! No! I'm ahead of you on this one. I wrote the code and published it on github in 2016! :-P

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assert that args aren't null.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file should probably be sliver.dart to parallel box.dart

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is operator== allowed to throw exceptions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently not. I'll remove this assert.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a const constructor to make this into a const?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've removed the assert from the constructor and made the main constructor const.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would "consumedExtent" be a more accurate name? Presumably the sliver doesn't actually need to be opaque in this region.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It actually needs to be opaque, but I've updated the docs to be clearer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also changed the default to 0.0. In practice this is ignored for most slivers anyway, added mention of that to the docs too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never mind. I'm removing opaqueExtent entirely. Careful examination revealed the embarrassing truth that it was never actually used.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd make these separate asserts so that its easier to see which one failed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's checking that they're not both true simultaneously.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, yeah.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed for some mixin thing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed. I had copied in the interface and just forgot to remove the ones I didn't want to reimplement yet.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

final, final

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this assert move to the base class?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The base class has a default implementation which makes sense for most kinds of RenderObject.
For RenderSliver, there's no reasonable default paint transform.
What I'd really like to do is "re-abstract" the method, but Dart doesn't support that yet (see dart-lang/sdk#28250 for a suggested @mustOverride which we could use though).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_debugDrawArrow

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

final

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

final, final

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd grab the canvas into a final local

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ChangeNotifiers can't be const.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to do any sort of debug-time validation of the center sliver?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's validated in performLayout. I don't want to validate it here because that would prevent you from setting the center pointer before adding the child, which, in addition to being annoying in general, would be particularly annoying for us at the Widgets layer IIRC.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is kind of ugly, but I understand why you did it this way.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. I could also pass a struct around and have it be filled in then pull the values at the end and put them into the fields, but it seemed unnecessary since it's all private anyway. Happy to change it if you prefer it that way though.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd skip this variable and just declare it on line 1437

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd just return this directly instead of capturing it into a local.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we paint the children after the center backwards?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So that appbars end up on top.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't you, just as easily, want an app-bar like effect at the bottom of the screen? It just seems like an odd sop to headers over footers given that we paint almost everything else in child-order.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even for a bottom effect, you'd still want the app bar to paint after the things after it in the list, otherwise it couldn't overlap them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But maybe I'm misunderstanding what effect you're looking for?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's talk it over with a whiteboard on monday. In any case, don't feel blocked about landing this patch.

@abarth
Copy link
Contributor

abarth commented Jan 6, 2017

LGTM

@abarth
Copy link
Contributor

abarth commented Jan 6, 2017

Something, something code-to-test ratio.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: happenining

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

@Hixie
Copy link
Contributor Author

Hixie commented Jan 7, 2017

The code is tested more by the stuff I have coming at the widgets layer, but yes, it's undertested for sure.

Are there any specific things you'd like to see tested before I land it?

I listed some things that do need testing sooner rather than later at the end of the included test file.

@Hixie
Copy link
Contributor Author

Hixie commented Jan 7, 2017

Updated.

@abarth
Copy link
Contributor

abarth commented Jan 7, 2017

Are there any specific things you'd like to see tested before I land it?

Doesn't need to block landing, but we should probably test that scrolling a viewport doesn't trigger extraneous layout (e.g., of box children or of siblings of the viewport).

I think the way you have things setup, if you have a shrinkwrapping viewport, scrolling will invalidate layout for the viewport's container. That's probably necessary but unfortunate.

@Hixie
Copy link
Contributor Author

Hixie commented Jan 7, 2017

test that scrolling a viewport doesn't trigger extraneous layout (e.g., of box children or of siblings of the viewport)

Will do.

I think the way you have things setup, if you have a shrinkwrapping viewport, scrolling will invalidate layout for the viewport's container. That's probably necessary but unfortunate.

Yeah, shrink-wrapping the viewport is all kinds of expensive. Arguably it's a bad feature to even support in the first place. I mostly just have it because otherwise if you put a viewport in an unbounded area, you'd assert, and we've had bad experience with that kind of thing.

This implements a new RenderViewport2 class to replace the existing
RenderViewport class.
@Hixie
Copy link
Contributor Author

Hixie commented Jan 9, 2017

Added test that we don't relayout the parent when changing a non-shrink-wrapping viewport: https://github.com/Hixie/flutter/blob/f0bbe7783371a4b648226744dfc7a4b1847dde08/packages/flutter/test/rendering/slivers_layout_test.dart

Will land when it goes green.

@Hixie Hixie merged commit e82b18d into flutter:master Jan 9, 2017
@Hixie Hixie deleted the core-slivers branch January 9, 2017 22:49
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants