-
Notifications
You must be signed in to change notification settings - Fork 29.7k
BoxDecoration should clip its backgroundImage if shape is BoxShape.circle #7292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| List<Invocation> commands = canvas.invocations.where((Invocation invocation) { | ||
| return invocation.memberName == #clipPath || invocation.memberName == #drawImageRect; | ||
| }).toList(); | ||
| expect(commands.length, equals(2)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fwiw, you don't need to say equals(2), you can just say 2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point; done
| /// * If [backgroundImage] is null, this decoration does not paint a background image. | ||
| /// * If [border] is null, this decoration does not paint a border. | ||
| /// * If [borderRadius] is null, this decoration use more efficient background | ||
| /// * If [borderRadius] is null, this decoration uses more efficient background |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to just be a bald-faced lie. We totally ignore the border radius when drawing the background image, as far as I can tell.
Maybe that's another bug? We don't clip the background image to the border radius?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
LGTM. Please file a bug about the border radius not clipping the background image. |
| new BoxDecoration( | ||
| borderRadius: new BorderRadius.all(const Radius.circular(16.0)), | ||
| backgroundImage: backgroundImage, | ||
| ), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i guess we should have a control test too that verifies there's no clip if it's not one of these...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, good catch. I've added one.
|
That's awesome. LGTM! :-) |
| if (clipPath != null) { | ||
| canvas.save(); | ||
| canvas.clipPath(clipPath); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did we already hit test correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The BoxDecoration hitTest() method appears to DTRT for the BoxShape.circle and borderRadius!=null scenarios. I don't think there's a hitTest test though.

Fixes #7289
Fixes #5306