-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Fix code style issues in MacOS embedder #22270
Fix code style issues in MacOS embedder #22270
Conversation
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat. Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
shell/platform/darwin/macos/BUILD.gn
Outdated
] | ||
|
||
sources += _flutter_framework_headers | ||
|
||
deps = [ | ||
"//flutter/flow:flow", | ||
"//flutter/fml:fml", |
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 think we don't want to depend on fml
as well.
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.
Right. Removed.
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.
FML is actually okay; we're going to need it for a11y support, so I've looked into it already, and it's generally very base-level, with minimal dependencies.
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.
In this instance it was only used for single FML_DCHECK call, which I've replaced with NSAssert. I can put it back if FML_DCHECK is better.
47972cc
to
1b6ca20
Compare
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.
Some small nits, but overall this looks great. Thanks so much for the quick follow up!
* Returns whether the view should ensure surfaces with given size; | ||
* This will be false during resizing for any size other than size specified | ||
* during beginResize. | ||
*/ | ||
- (bool)shouldEnsureSurfaceForSize:(CGSize)size; |
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.
BOOL
|
||
@interface FlutterResizeSynchronizer () { | ||
uint32_t cookie; // counter to detect stale callbacks | ||
// counter to detect stale callbacks |
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.
Please use sentence style for all of these comments (capital letter to start, . at end)
#import <Cocoa/Cocoa.h> | ||
|
||
// Manages the IOSurfaces for FlutterView | ||
@interface FlutterSurfaceManager : NSObject | ||
|
||
- (instancetype)initWithLayer:(CALayer*)layer openGLContext:(NSOpenGLContext*)opengLContext; | ||
- (instancetype)initWithLayer:(CALayer*)containingLayer | ||
openGLContext:(NSOpenGLContext*)opengLContext; |
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.
These need nullability annotations.
|
||
#include <OpenGL/gl.h> | ||
#import "flutter/shell/platform/darwin/macos/framework/Source/MacOSGLContextSwitch.h" |
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.
Blank line above this. I'm surprised clang-format isn't fixing this up.
kFront = 0, | ||
kBack = 1, | ||
kFrontBuffer = 0, | ||
kBackBuffer = 1, | ||
kBufferCount, |
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.
How about kFlutterSurfaceManager{FrontBuffer,BackBuffer,BufferCount}
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.
Sure. I looked at the constants elsewhere (i.e. FlutterTextInputPlugin) which don't seem to be prefixed, but I don't really mind.
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.
Well, the style guide doesn't require prefixing for non-public constants. But my concern here is that it's much more likely that someone would accidentally not prefix a public constant (as happened with some very unfortunately generic constants in embedder.h, for instance) called kBufferCount
than, say kClearClientMethod
.
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.
No argument here really, fixed in cfbe14bc6.
@@ -20,7 +20,16 @@ | |||
*/ | |||
@interface FlutterView : NSView | |||
|
|||
/** | |||
* Returns the OpenGL context of backing surface. |
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.
s/Returns the/The/; properties are generally documented as nouns rather than actions.
MacOSGLContextSwitch(MacOSGLContextSwitch&&) = delete; | ||
|
||
private: | ||
NSOpenGLContext* prev_; |
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.
previous_
. They style guide very strongly discourages variable name abbreviations.
@stuartmorgan, these should be fixed now. |
Thanks! |
Description
PR to fix code style issues introduced in #21525.
Related Issues
flutter/flutter#44136
Tests
I added the following tests:
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]
). This will ensure a smooth and quick review process.Reviewer Checklist
Breaking Change
Did any tests fail when you ran them? Please read handling breaking changes.