Skip to content

Viewport2 should clip visual overflow - #7641

Merged
abarth merged 1 commit into
flutter:masterfrom
abarth:viewport_clip
Jan 25, 2017
Merged

abarth merged 1 commit into
flutter:masterfrom
abarth:viewport_clip

Conversation

@abarth

@abarth abarth commented Jan 25, 2017

Copy link
Copy Markdown
Contributor

When you put a box in a Viewport2, it might paint outside its allocated bounds.
This patch teaches Viewport2 to clip when that happens.

@abarth

abarth commented Jan 25, 2017

Copy link
Copy Markdown
Contributor Author

@Hixie

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should be tested in debugAssertIsValid and printed in toString

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

you can remove this todo now :-)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

it also overflows if scrollOffset > 0.0

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

these should each have a comment saying that we're being extra-conservative here to trade the cost of calculating whether we have overflow for the cost of always doing clipping.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't understand the second term of this or.
Surely we have overflow any time constraints.scrollOffset is greater than 0.0? (Unless we happen to be really lucky and be exactly on a child boundary at our leading edge, but it seems like turning clipping on and off if we happen to hit that boundary is going to be pointless if not extra expensive.)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

actual [Canvas.clipRect] call's argument, singular

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we should document somewhere (in this file's docs) that we're implying a save/restore pair when you call pushClipRect.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The real PaintingContext does this too.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

i don't understand how this passes today

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oh never mind, this is for SliverBlock. I thought it was testing SliverToBoxAdapter.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

add a test identical to this one but with height < 600 and i think it'll fail.

@Hixie

Hixie commented Jan 25, 2017

Copy link
Copy Markdown
Contributor

I'm worried that this bit is just as complicated to get right as the other dimensions in SliverGeometry, but we can give it a try.

LGTM.

When you put a box in a Viewport2, it might paint outside its allocated bounds.
This patch teaches Viewport2 to clip when that happens.
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.

3 participants