-
Notifications
You must be signed in to change notification settings - Fork 6k
Update formatting in web_ui scene bulder to match flutter style. #14539
Conversation
|
The change LGTM. The new code does read nicer. Did you just add trailing commas and run |
Thoughts on the 2 different ways to format pushShaderMask()? Actually, I just took the suggestion from @Hixie in this PR. If I run dartfmt on the new version of the files, though, it wants to move the fixed arguments into separate lines as well. If the web team is in the habit of running dartfmt on the dart source files then perhaps I should take its suggestion. I'm attaching diffs suggested by dartfmt. |
|
To be clear, this is what the Dart plugin in Android Studio wants to do with pushOffsetLayer if I try to move the fixed arguments to their own lines as dartfmt suggests: I can reduce the indentation to 2 spaces by changing the continuation indent, but then continuations are wrong. I don't see any way to get it to not do an extra indent on the named parameters, though. |
I'd like to abstain :)
Yes, let's apply |
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.
LGTM for the lib/web_ui parts
liyuqian
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.
LGTM
|
It seems that the analyzer likes things like: but dartfmt decides it should be a single line, as in: which the analyzer then complains about because it always wants conditional bodies on separate lines. Rather than making it even more verbose by adding {} braces, I decided to use ?: to initialize the hints in a single line. Thoughts @liyuqian? |
| bool isComplexHint = false, | ||
| bool willChangeHint = false, | ||
| }) { | ||
| final int hints = (isComplexHint ? 1 : 0) | (willChangeHint ? 2 : 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.
@liyuqian this was, debatably, the best compromise I could find to make both dartfmt and the analyzer happy without expanding this code section even more with {} braces and such. Details in the PR comments.
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
I like your new approach. In general, feel free to not strictly follow |
|
I believe over in the flutter/flutter side we're recommending to always use |
There's a similar debate in C++ code too. I believe many prefer over just But some prefer |
|
I like the use of I decided to go with a style that was compatible with dartfmt in case, as @yjbanov said earlier, someone later decides to reformat the file. I only like |
* bb118c6 Roll src/third_party/dart 8d11c1dce64a..642f8d052fd7 (1 commits) (flutter/engine#14574) * 09c434d Use ELF for Dart AOT snapshots on Fuchsia. (flutter/engine#13896) * e1e7851 Roll fuchsia/sdk/core/linux-amd64 from VdBKA... to uFFWW... (flutter/engine#14575) * f317f8f Roll src/third_party/skia c76ac8e325c7..77742c350371 (1 commits) (flutter/engine#14576) * 2ba5633 instructions for running firefox/safari tests (flutter/engine#14562) * 9cf1e46 Roll src/third_party/dart 642f8d052fd7..7113fc79a83c (3 commits) (flutter/engine#14578) * f5b877a [web] Run engine tests on Safari locally by launching safari installed on MacOS (flutter/engine#14555) * 68d9196 Fix DOM-based ParagraphRuler.hitTest() (flutter/engine#14504) * bb65df8 Roll src/third_party/skia 77742c350371..a8352ccaae37 (8 commits) (flutter/engine#14579) * ad1ab56 Roll src/third_party/dart 7113fc79a83c..e50d98cd5651 (8 commits) (flutter/engine#14580) * 22413ef Update formatting in web_ui scene bulder to match flutter style and dartfmt. (flutter/engine#14539) * 6e825e7 Roll fuchsia/sdk/core/mac-amd64 from Ykb4b... to f51Q_... (flutter/engine#14584) * 1d3bb8c Fix message_loop_fuchsia and thus enable fml_tests and flow_tests for Fuchsia (flutter/engine#14583) * 1f7bb9d Wire up OpacityLayer to Scenic (flutter/engine#14577) * 11db035 Roll src/third_party/skia a8352ccaae37..87e9ddb675b6 (11 commits) (flutter/engine#14585) * bd58af7 Roll src/third_party/dart e50d98cd5651..141fcfa61092 (3 commits) (flutter/engine#14586) * 929b1ed Engine support for ImageFiltered widget (flutter/engine#14491) * 40b84fc Fix lint warnings across web_ui, add missing browserEngine case in text field. (flutter/engine#14535) * ea1d330 Roll fuchsia/sdk/core/linux-amd64 from uFFWW... to 25LzW... (flutter/engine#14587) * 854d5f8 Roll src/third_party/skia 87e9ddb675b6..7e2dea568299 (1 commits) (flutter/engine#14589)
In a recent PR to add a new pushFooLayer() API to the SceneBuilder class in engine, the code format of the pushLayer methods was pointed out as not quite matching the flutter framework style. This PR is looking to find a suitable code style for these methods to embrace moving forward.
Most of the methods were formatted in this initial push to adopt the style suggested in the pushImageFilter PR, but it wasn't clear how to adapt the pushShaderMask() method to comply and I tried 2 variants here in the 2 different files for comparison and feedback.
dartfmt suggests that the fixed parameters be moved to separate lines as well, similar to pushPhysicalShape(). Note that the "one line per argument" style is not really embraced in the engine repo right now, so I hesitated on taking that suggestion to diverge even further.
The formatter built in to Android Studio with the Dart plugin also fights this style somewhat. If all of the arguments are moved to separate lines it insists on 4-space indentation which doesn't match the flutter style, but if only the named parameters (inside {}) are on their own lines then it seems perfectly happy with 2-space indentation.
Also, currently the main (non-web) SceneBuilder push...Layer() method code style seems to be universally "everything on one line regardless of how long the line is", which doesn't look very maintainable so that file should probably be consolidated with whatever format is deemed appropriate here for the web versions of that class.