-
Notifications
You must be signed in to change notification settings - Fork 6k
[web] Fix shadows for arbitrary paths on PhysicalShape #23830
Conversation
| /// contents against same path for shadow to work since box-shadow doesn't | ||
| /// take clip-path into account. | ||
| /// | ||
| /// Webkit has a bug when applying clip-path on an element that has |
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.
Is there a link to the WebKit bug?
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.
added link.
| /// we size the inner container to cover full pathBounds instead of sizing | ||
| /// to clipping rect bounds (which is the case for elevation == 0.0 where | ||
| /// we shift outer/inner clip area instead to position clip-path). | ||
| final String svgClipPath = elevation == 0.0 ? |
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.
nit: the ? should go on the next line
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.
done.
| offsetY: 0.0, | ||
| scaleX: 1.0 / pathBounds.right, | ||
| scaleY: 1.0 / pathBounds.bottom); | ||
| /// If apply is called multiple times (without update) , remove prior |
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.
nit: remove space before the comma
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.
done.
| DomRenderer.setElementStyle( | ||
| rootElement!, 'clip-path', 'url(#svgClip$_clipIdCounter)'); | ||
| DomRenderer.setElementStyle( | ||
| rootElement!, '-webkit-clip-path', 'url(#svgClip$_clipIdCounter)'); |
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.
Setting style properties has been showing up in our profiles. Can we set either clip-path or -webkit-clip-path depending on the browserEngine, but not both?
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.
done. Moved clip-path code into DomRenderer
|
|
||
| final ui.Rect pathBounds2 = path.getBounds(); | ||
| _svgElement = _pathToSvgElement( | ||
| path, SurfacePaintData()..color = color, '${pathBounds2.right}', '${pathBounds2.bottom}'); |
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.
Does _applyColor need to be revised now that this function also uses the color field?
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.
done.
| _applyColor(); | ||
| } | ||
| if (oldSurface.elevation != elevation || | ||
| if (oldSurface.path != path || oldSurface.elevation != elevation || |
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.
Do we have a test that covers the update codepath? We frequently get bugs that only manifest when the DOM nodes are updated from a previous state.
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.
Done.
yjbanov
left a comment
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.
* 004d8ad Roll Skia from cc6961b9ac5e to 6a272434c2b2 (3 revisions) (flutter/engine#23864) * 7c2da3b reland of flutter/engine#23634 (flutter/engine#23865) * a4f02b7 Share Android surface GrDirectContext (flutter/engine#23798) * 31ef1dd Roll Skia from 6a272434c2b2 to bfc9be0f773f (2 revisions) (flutter/engine#23867) * 6dec57f Remove workarounds now that type promotion accounts for local boolean variables. (flutter/engine#23862) * a787229 Roll Skia from bfc9be0f773f to 3193ff271628 (5 revisions) (flutter/engine#23872) * a242dd8 [web] Fix shadows for arbitrary paths on PhysicalShape (flutter/engine#23830) * 05b4bec Started using Dart_CreateInGroup when using spawn on a release build (flutter/engine#23782)

PhysicalShape shadows failed for non rect/oval shapes since the physical shape adds an svg clip path to render background. This PR adds an SVG asset behind inner clip area to render shadow of physical shape separately.
Related issues:
flutter/flutter#65498
flutter/flutter#66334
flutter/flutter#57527
Tests updated in golden_compositing_test.dart
Pre-launch Checklist
writing and running engine tests.
///).If you need help, consider asking for advice on the #hackers-new channel on [Discord].