[ASEnvironmentTraitCollection] default user interface idiom to UIUserInterfaceIdiomUnspecified (#1998)

* [ASEnvironmentTraitCollection] default user interface idiom to ASEnvironmentTraitCollection

UIUserInterfaceIdiomUnspecified is -1 so we were actually defaulting our trait collection to UIUserInterfaceIdiomPhone (which is 0).

* Fix a few places where we weren’t using the default method to create the base traits
This commit is contained in:
ricky 2016-07-28 10:03:32 -07:00 committed by Adlai Holler
parent 95bf8bbe1f
commit f0b1f12160
4 changed files with 16 additions and 10 deletions

View File

@ -1848,8 +1848,10 @@ static NSInteger incrementIfFound(NSInteger i) {
} }
// now that we have a supernode, propagate its traits to self. // now that we have a supernode, propagate its traits to self.
if (newSupernode != nil) {
ASEnvironmentStatePropagateDown(self, [newSupernode environmentTraitCollection]); ASEnvironmentStatePropagateDown(self, [newSupernode environmentTraitCollection]);
} }
}
} }
// Track that a node will be displayed as part of the current node hierarchy. // Track that a node will be displayed as part of the current node hierarchy.

View File

@ -50,6 +50,7 @@ typedef struct ASEnvironmentLayoutOptionsState {
struct ASEnvironmentStateExtensions _extensions; struct ASEnvironmentStateExtensions _extensions;
} ASEnvironmentLayoutOptionsState; } ASEnvironmentLayoutOptionsState;
extern ASEnvironmentLayoutOptionsState ASEnvironmentLayoutOptionsStateMakeDefault();
#pragma mark - ASEnvironmentHierarchyState #pragma mark - ASEnvironmentHierarchyState
@ -60,6 +61,7 @@ typedef struct ASEnvironmentHierarchyState {
unsigned transitioningSupernodes:1; // = NO unsigned transitioningSupernodes:1; // = NO
unsigned layoutPending:1; // = NO unsigned layoutPending:1; // = NO
} ASEnvironmentHierarchyState; } ASEnvironmentHierarchyState;
extern ASEnvironmentHierarchyState ASEnvironmentHierarchyStateMakeDefault();
#pragma mark - ASEnvironmentDisplayTraits #pragma mark - ASEnvironmentDisplayTraits
@ -72,6 +74,7 @@ typedef struct ASEnvironmentTraitCollection {
CGSize containerSize; CGSize containerSize;
} ASEnvironmentTraitCollection; } ASEnvironmentTraitCollection;
extern ASEnvironmentTraitCollection ASEnvironmentTraitCollectionMakeDefault();
extern ASEnvironmentTraitCollection ASEnvironmentTraitCollectionFromUITraitCollection(UITraitCollection *traitCollection); extern ASEnvironmentTraitCollection ASEnvironmentTraitCollectionFromUITraitCollection(UITraitCollection *traitCollection);
extern BOOL ASEnvironmentTraitCollectionIsEqualToASEnvironmentTraitCollection(ASEnvironmentTraitCollection lhs, ASEnvironmentTraitCollection rhs); extern BOOL ASEnvironmentTraitCollectionIsEqualToASEnvironmentTraitCollection(ASEnvironmentTraitCollection lhs, ASEnvironmentTraitCollection rhs);

View File

@ -11,24 +11,25 @@
#import "ASEnvironmentInternal.h" #import "ASEnvironmentInternal.h"
#import "ASAvailability.h" #import "ASAvailability.h"
ASEnvironmentLayoutOptionsState _ASEnvironmentLayoutOptionsStateMakeDefault() ASEnvironmentLayoutOptionsState ASEnvironmentLayoutOptionsStateMakeDefault()
{ {
return (ASEnvironmentLayoutOptionsState) { return (ASEnvironmentLayoutOptionsState) {
// Default values can be defined in here // Default values can be defined in here
}; };
} }
ASEnvironmentHierarchyState _ASEnvironmentHierarchyStateMakeDefault() ASEnvironmentHierarchyState ASEnvironmentHierarchyStateMakeDefault()
{ {
return (ASEnvironmentHierarchyState) { return (ASEnvironmentHierarchyState) {
// Default values can be defined in here // Default values can be defined in here
}; };
} }
ASEnvironmentTraitCollection _ASEnvironmentTraitCollectionMakeDefault() ASEnvironmentTraitCollection ASEnvironmentTraitCollectionMakeDefault()
{ {
return (ASEnvironmentTraitCollection) { return (ASEnvironmentTraitCollection) {
// Default values can be defined in here // Default values can be defined in here
.userInterfaceIdiom = UIUserInterfaceIdiomUnspecified,
.containerSize = CGSizeZero, .containerSize = CGSizeZero,
}; };
} }
@ -62,9 +63,9 @@ BOOL ASEnvironmentTraitCollectionIsEqualToASEnvironmentTraitCollection(ASEnviron
ASEnvironmentState ASEnvironmentStateMakeDefault() ASEnvironmentState ASEnvironmentStateMakeDefault()
{ {
return (ASEnvironmentState) { return (ASEnvironmentState) {
.layoutOptionsState = _ASEnvironmentLayoutOptionsStateMakeDefault(), .layoutOptionsState = ASEnvironmentLayoutOptionsStateMakeDefault(),
.hierarchyState = _ASEnvironmentHierarchyStateMakeDefault(), .hierarchyState = ASEnvironmentHierarchyStateMakeDefault(),
.environmentTraitCollection = _ASEnvironmentTraitCollectionMakeDefault() .environmentTraitCollection = ASEnvironmentTraitCollectionMakeDefault()
}; };
} }

View File

@ -43,13 +43,13 @@ enum class ASEnvironmentStatePropagation { DOWN, UP };
static const struct ASEnvironmentStateExtensions ASEnvironmentDefaultStateExtensions = {}; static const struct ASEnvironmentStateExtensions ASEnvironmentDefaultStateExtensions = {};
static const struct ASEnvironmentLayoutOptionsState ASEnvironmentDefaultLayoutOptionsState = {}; static const struct ASEnvironmentLayoutOptionsState ASEnvironmentDefaultLayoutOptionsState = ASEnvironmentLayoutOptionsStateMakeDefault();
ASEnvironmentState ASEnvironmentMergeObjectAndState(ASEnvironmentState environmentState, ASEnvironmentLayoutOptionsState state, ASEnvironmentStatePropagation propagation); ASEnvironmentState ASEnvironmentMergeObjectAndState(ASEnvironmentState environmentState, ASEnvironmentLayoutOptionsState state, ASEnvironmentStatePropagation propagation);
static const struct ASEnvironmentHierarchyState ASEnvironmentDefaultHierarchyState = {}; static const struct ASEnvironmentHierarchyState ASEnvironmentDefaultHierarchyState = ASEnvironmentHierarchyStateMakeDefault();
ASEnvironmentState ASEnvironmentMergeObjectAndState(ASEnvironmentState environmentState, ASEnvironmentHierarchyState state, ASEnvironmentStatePropagation propagation); ASEnvironmentState ASEnvironmentMergeObjectAndState(ASEnvironmentState environmentState, ASEnvironmentHierarchyState state, ASEnvironmentStatePropagation propagation);
static const struct ASEnvironmentTraitCollection ASEnvironmentDefaultTraitCollection = {}; static const struct ASEnvironmentTraitCollection ASEnvironmentDefaultTraitCollection = ASEnvironmentTraitCollectionMakeDefault();
ASEnvironmentState ASEnvironmentMergeObjectAndState(ASEnvironmentState environmentState, ASEnvironmentTraitCollection state, ASEnvironmentStatePropagation propagation); ASEnvironmentState ASEnvironmentMergeObjectAndState(ASEnvironmentState environmentState, ASEnvironmentTraitCollection state, ASEnvironmentStatePropagation propagation);