Skip to content
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

Merged

Conversation

knopp
Copy link
Member

@knopp knopp commented Nov 3, 2020

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.

  • I read the contributor guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the C++, Objective-C, Java style guides for the engine.
  • I read the tree hygiene wiki page, which explains my responsibilities.
  • I updated/added relevant documentation.
  • All existing and new tests are passing.
  • I am willing to follow-up on review comments in a timely manner.

Reviewer Checklist

Breaking Change

Did any tests fail when you ran them? Please read handling breaking changes.

@knopp knopp requested a review from stuartmorgan November 3, 2020 17:27
@flutter-dashboard
Copy link

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.

@google-cla google-cla bot added the cla: yes label Nov 3, 2020
@knopp knopp mentioned this pull request Nov 3, 2020
12 tasks
]

sources += _flutter_framework_headers

deps = [
"//flutter/flow:flow",
"//flutter/fml:fml",
Copy link
Contributor

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

Right. Removed.

Copy link
Contributor

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.

Copy link
Member Author

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.

@knopp knopp force-pushed the macos_embedder_code_style_fixes branch from 47972cc to 1b6ca20 Compare November 3, 2020 19:34
Copy link
Contributor

@stuartmorgan stuartmorgan left a 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;
Copy link
Contributor

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
Copy link
Contributor

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;
Copy link
Contributor

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"
Copy link
Contributor

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,
Copy link
Contributor

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}

Copy link
Member Author

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.

Copy link
Contributor

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.

Copy link
Member Author

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.
Copy link
Contributor

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_;
Copy link
Contributor

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.

@knopp
Copy link
Member Author

knopp commented Nov 3, 2020

@stuartmorgan, these should be fixed now.

@stuartmorgan stuartmorgan added the waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land. label Nov 4, 2020
@stuartmorgan
Copy link
Contributor

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants