Skip to content

Commit

Permalink
various accessing of private members switched to use objective-c publ…
Browse files Browse the repository at this point in the history
…ic accessors in UIViewController.mm
  • Loading branch information
ehren committed Apr 28, 2016
1 parent 8b10200 commit 4b2c9f9
Showing 1 changed file with 24 additions and 23 deletions.
47 changes: 24 additions & 23 deletions Frameworks/UIKit/UIViewController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ - (CGRect)_orientationRect:(UIInterfaceOrientation)orientation {

appFrame = [[UIScreen mainScreen] applicationFrame];

if (priv->_presentationStyle == UIModalPresentationFormSheet) {
if ([self modalPresentationStyle] == UIModalPresentationFormSheet) {
appFrame = [self _modalPresentationFormSheetFrame];
}

Expand Down Expand Up @@ -386,8 +386,8 @@ - (CGRect)_modalPresentationFormSheetFrame {
}

CGRect frame;
if (!CGSizeEqualToSize(priv->_preferredContentSize, CGSizeZero)) {
frame.size = priv->_preferredContentSize;
if (!CGSizeEqualToSize([self preferredContentSize], CGSizeZero)) {
frame.size = [self preferredContentSize];
} else {
frame.size.width = 540;
frame.size.height = 620;
Expand All @@ -401,7 +401,7 @@ - (CGRect)_modalPresentationFormSheetFrame {
}

- (BOOL)_hidesParent {
if (priv->_presentationStyle == UIModalPresentationFormSheet && GetCACompositor()->isTablet()) {
if ([self modalPresentationStyle] == UIModalPresentationFormSheet && GetCACompositor()->isTablet()) {
return NO;
}

Expand All @@ -424,12 +424,12 @@ - (void)setOrientationInternal:(UIInterfaceOrientation)orientation animated:(BOO

[[UIApplication sharedApplication] setStatusBarOrientation:orientation animated:FALSE];

if (priv->_wantsFullScreenLayout) {
if ([self wantsFullScreenLayout]) {
appFrame = [[UIScreen mainScreen] bounds];
} else {
appFrame = [[UIScreen mainScreen] applicationFrame];
}
if (priv->_presentationStyle == UIModalPresentationFormSheet) {
if ([self modalPresentationStyle] == UIModalPresentationFormSheet) {
appFrame = [self _modalPresentationFormSheetFrame];
}

Expand Down Expand Up @@ -801,7 +801,7 @@ - (void)loadView {
CGRect frame = { 0.0f, 0.0f, GetCACompositor()->screenWidth(), GetCACompositor()->screenHeight() };

frame = [[UIScreen mainScreen] applicationFrame]; /** This is correct **/
if (priv->_presentationStyle == UIModalPresentationFormSheet) {
if ([self modalPresentationStyle] == UIModalPresentationFormSheet) {
frame = [self _modalPresentationFormSheetFrame];
}

Expand All @@ -815,16 +815,16 @@ - (void)loadView {
}

- (void)_doResizeToScreen {
if ((priv->_resizeToScreen && priv->view && priv->_autoresize) || priv->_wantsFullScreenLayout) {
if ((priv->_resizeToScreen && priv->view && priv->_autoresize) || [self wantsFullScreenLayout]) {
CGRect frame = { 0.0f, 0.0f, GetCACompositor()->screenHeight(), GetCACompositor()->screenWidth() };

if (priv->_wantsFullScreenLayout) {
if ([self wantsFullScreenLayout]) {
frame = [[UIScreen mainScreen] bounds];
} else {
frame = [[UIScreen mainScreen] applicationFrame];
}

if (priv->_presentationStyle == UIModalPresentationFormSheet) {
if ([self modalPresentationStyle] == UIModalPresentationFormSheet) {
frame = [self _modalPresentationFormSheetFrame];
}
UIInterfaceOrientation curOrientation = (UIInterfaceOrientation)[[UIApplication sharedApplication] statusBarOrientation];
Expand Down Expand Up @@ -858,7 +858,7 @@ - (UIView*)view {
CGRect frame = { 0.0f, 0.0f, GetCACompositor()->screenHeight(), GetCACompositor()->screenWidth() };

frame = [[UIScreen mainScreen] applicationFrame];
if (priv->_presentationStyle == UIModalPresentationFormSheet) {
if ([self modalPresentationStyle] == UIModalPresentationFormSheet) {
frame = [self _modalPresentationFormSheetFrame];
}

Expand Down Expand Up @@ -1040,7 +1040,7 @@ - (void)presentViewController:(UIViewController*)controller animated:(BOOL)anima
if (curController->priv->_visibility != controllerNotVisible) {
shouldShow = true;
}
curController = curController->priv->_parentViewController;
curController = [curController parentViewController];
}
if (!shouldShow) {
TraceWarning(TAG, L"Controller is not visible!");
Expand Down Expand Up @@ -1125,8 +1125,8 @@ - (void)_dismissTransitionStopped:(id)anim finished:(BOOL)finished {
*/
- (void)dismissViewControllerAnimated:(BOOL)animated completion:(void (^)(void))completion {
if (priv->_modalViewController == nil) {
if (priv->_parentViewController) {
[priv->_parentViewController dismissViewControllerAnimated:animated completion:completion];
if ([self parentViewController] != nil) {
[[self parentViewController] dismissViewControllerAnimated:animated completion:completion];
return;
}
TraceWarning(TAG, L"dismissModalViewController invalid!");
Expand Down Expand Up @@ -1222,7 +1222,7 @@ - (void)_transitionStopped:(id)context {
UIView* view = [self view];

if ([self _hidesParent]) {
[[priv->_parentViewController view] setHidden:TRUE];
[[[self parentViewController] view] setHidden:TRUE];
}
[self _notifyDidAppearAnimated:view];
[[UIApplication sharedApplication] endIgnoringInteractionEvents];
Expand All @@ -1233,18 +1233,18 @@ - (void)_addToTop:(NSNumber*)animatedValue {

priv->_isRootView = true;

if (priv->_parentViewController != nil) {
if ([self parentViewController] != nil) {
// TODO: This implementation satisfies the contract that the popoverPresentationController is not nil when presenting a
// UIViewController with modalPresentationType equal to UIModalPresentationPopover.
// The full implementation will need to utilize the UIPresentationController for UIViewController presentations
if (priv->_presentationStyle == UIModalPresentationPopover) {
if ([self modalPresentationStyle] == UIModalPresentationPopover) {
if (priv->_popoverPresentationController != nil) {
[priv->_popoverPresentationController release];
}

priv->_popoverPresentationController =
[[UIPopoverPresentationController alloc] initWithPresentedViewController:self
presentingViewController:priv->_parentViewController];
presentingViewController:[self parentViewController]];

if (priv->_presentationController != nil) {
[priv->_presentationController release];
Expand All @@ -1256,14 +1256,14 @@ - (void)_addToTop:(NSNumber*)animatedValue {
float endY = 0;

UIView* view = [self view];
UIWindow* parentWindow = [[priv->_parentViewController view] window];
UIWindow* parentWindow = [[[self parentViewController] view] window];

if (animated) {
g_presentingAnimated = TRUE;
[[UIApplication sharedApplication] beginIgnoringInteractionEvents];
[self _notifyViewWillAppear:TRUE];
} else if ([self _hidesParent]) {
[[priv->_parentViewController view] setHidden:TRUE];
[[[self parentViewController] view] setHidden:TRUE];
}

if (parentWindow != nil) {
Expand Down Expand Up @@ -1330,7 +1330,7 @@ - (void)_addToTop:(NSNumber*)animatedValue {
}

if ([self _hidesParent]) {
[priv->_parentViewController _notifyViewDidDisappear:animated];
[[self parentViewController] _notifyViewDidDisappear:animated];
}
} else {
TraceVerbose(TAG, L"Modal controller doesn't have a parent!");
Expand Down Expand Up @@ -1371,8 +1371,9 @@ - (BOOL)isModalInPopover {

static UIInterfaceOrientation findOrientation(UIViewController* self) {
UIInterfaceOrientation orientation = (UIInterfaceOrientation)[[UIDevice currentDevice] orientation];
if (self->priv->_parentViewController != nil && [self->priv->_parentViewController _rotationLocked:orientation]) {
UIInterfaceOrientation parentOrientation = (UIInterfaceOrientation)[self->priv->_parentViewController interfaceOrientation];
UIViewController* parent = [self parentViewController];
if (parent != nil && [parent _rotationLocked:orientation]) {
UIInterfaceOrientation parentOrientation = (UIInterfaceOrientation)[parent interfaceOrientation];
if (parentOrientation != 0) {
orientation = parentOrientation;
}
Expand Down

0 comments on commit 4b2c9f9

Please sign in to comment.