CHORE - Remove Trailing Spaces
Summary:Remove Trailing Spaces. Why: Sometimes there are conflicts with trailing spaces Saves space Those whose tools automatically delete them will have their pr watered down with trailing space removal Closes https://github.com/facebook/react-native/pull/6787 Differential Revision: D3144704 fb-gh-sync-id: d8a62f115a3f8a8a49d5b07f56c540a02af38cf8 fbshipit-source-id: d8a62f115a3f8a8a49d5b07f56c540a02af38cf8
This commit is contained in:
parent
37caef246d
commit
2a03182b1c
|
@ -46,7 +46,7 @@ var DatePickerAndroidExample = React.createClass({
|
||||||
async showPicker(stateKey, options) {
|
async showPicker(stateKey, options) {
|
||||||
try {
|
try {
|
||||||
var newState = {};
|
var newState = {};
|
||||||
const {action, year, month, day} = await DatePickerAndroid.open(options);
|
const {action, year, month, day} = await DatePickerAndroid.open(options);
|
||||||
if (action === DatePickerAndroid.dismissedAction) {
|
if (action === DatePickerAndroid.dismissedAction) {
|
||||||
newState[stateKey + 'Text'] = 'dismissed';
|
newState[stateKey + 'Text'] = 'dismissed';
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -230,7 +230,7 @@ class ImageCropper extends React.Component {
|
||||||
);
|
);
|
||||||
this._minimumZoomScale = Math.max(
|
this._minimumZoomScale = Math.max(
|
||||||
this.props.size.width / this._scaledImageSize.width,
|
this.props.size.width / this._scaledImageSize.width,
|
||||||
this.props.size.height / this._scaledImageSize.height
|
this.props.size.height / this._scaledImageSize.height
|
||||||
);
|
);
|
||||||
this._updateTransformData(
|
this._updateTransformData(
|
||||||
this._contentOffset,
|
this._contentOffset,
|
||||||
|
|
|
@ -416,7 +416,7 @@ exports.examples = [
|
||||||
secureTextEntry={true}
|
secureTextEntry={true}
|
||||||
style={styles.singleLine}
|
style={styles.singleLine}
|
||||||
/>
|
/>
|
||||||
<TextInput
|
<TextInput
|
||||||
secureTextEntry={true}
|
secureTextEntry={true}
|
||||||
style={[styles.singleLine, {color: 'red'}]}
|
style={[styles.singleLine, {color: 'red'}]}
|
||||||
placeholder="color is supported too"
|
placeholder="color is supported too"
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
@interface OCMArg : NSObject
|
@interface OCMArg : NSObject
|
||||||
|
|
||||||
// constraining arguments
|
// constraining arguments
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
|
||||||
@interface OCMConstraint : NSObject
|
@interface OCMConstraint : NSObject
|
||||||
|
|
||||||
+ (instancetype)constraint;
|
+ (instancetype)constraint;
|
||||||
- (BOOL)evaluate:(id)value;
|
- (BOOL)evaluate:(id)value;
|
||||||
|
|
|
@ -241,10 +241,10 @@ RCT_EXPORT_MODULE(TestModule)
|
||||||
NSString *injectedStuff;
|
NSString *injectedStuff;
|
||||||
RUN_RUNLOOP_WHILE(!(injectedStuff = _jsExecutor.injectedStuff[@"__fbBatchedBridgeConfig"]));
|
RUN_RUNLOOP_WHILE(!(injectedStuff = _jsExecutor.injectedStuff[@"__fbBatchedBridgeConfig"]));
|
||||||
XCTAssertNotNil(injectedStuff);
|
XCTAssertNotNil(injectedStuff);
|
||||||
|
|
||||||
__block NSNumber *testModuleID = nil;
|
__block NSNumber *testModuleID = nil;
|
||||||
__block NSNumber *testMethodID = nil;
|
__block NSNumber *testMethodID = nil;
|
||||||
|
|
||||||
NSArray *remoteModuleConfig = RCTJSONParse(injectedStuff, NULL)[@"remoteModuleConfig"];
|
NSArray *remoteModuleConfig = RCTJSONParse(injectedStuff, NULL)[@"remoteModuleConfig"];
|
||||||
[remoteModuleConfig enumerateObjectsUsingBlock:^(id moduleConfig, NSUInteger i, __unused BOOL *stop) {
|
[remoteModuleConfig enumerateObjectsUsingBlock:^(id moduleConfig, NSUInteger i, __unused BOOL *stop) {
|
||||||
if ([moduleConfig isKindOfClass:[NSArray class]] && [moduleConfig[0] isEqualToString:@"UnregisteredTestModule"]) {
|
if ([moduleConfig isKindOfClass:[NSArray class]] && [moduleConfig[0] isEqualToString:@"UnregisteredTestModule"]) {
|
||||||
|
@ -253,15 +253,15 @@ RCT_EXPORT_MODULE(TestModule)
|
||||||
*stop = YES;
|
*stop = YES;
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
|
|
||||||
XCTAssertNotNil(testModuleID);
|
XCTAssertNotNil(testModuleID);
|
||||||
XCTAssertNotNil(testMethodID);
|
XCTAssertNotNil(testMethodID);
|
||||||
|
|
||||||
NSArray *args = @[];
|
NSArray *args = @[];
|
||||||
NSArray *buffer = @[@[testModuleID], @[testMethodID], @[args]];
|
NSArray *buffer = @[@[testModuleID], @[testMethodID], @[args]];
|
||||||
|
|
||||||
[_bridge.batchedBridge handleBuffer:buffer];
|
[_bridge.batchedBridge handleBuffer:buffer];
|
||||||
|
|
||||||
dispatch_sync(_unregisteredTestModule.methodQueue, ^{
|
dispatch_sync(_unregisteredTestModule.methodQueue, ^{
|
||||||
XCTAssertTrue(_unregisteredTestModule.testMethodCalled);
|
XCTAssertTrue(_unregisteredTestModule.testMethodCalled);
|
||||||
});
|
});
|
||||||
|
|
|
@ -41,11 +41,11 @@ var ActionSheetIOS = {
|
||||||
callback
|
callback
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display the iOS share sheet. The `options` object should contain
|
* Display the iOS share sheet. The `options` object should contain
|
||||||
* one or both of:
|
* one or both of:
|
||||||
*
|
*
|
||||||
* - `message` (string) - a message to share
|
* - `message` (string) - a message to share
|
||||||
* - `url` (string) - a URL to share
|
* - `url` (string) - a URL to share
|
||||||
*
|
*
|
||||||
|
|
|
@ -70,7 +70,7 @@ RCT_EXPORT_METHOD(showActionSheetWithOptions:(NSDictionary *)options
|
||||||
while (controller.presentedViewController) {
|
while (controller.presentedViewController) {
|
||||||
controller = controller.presentedViewController;
|
controller = controller.presentedViewController;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (controller == nil) {
|
if (controller == nil) {
|
||||||
RCTLogError(@"Tried to display action sheet but there is no application window. options: %@", options);
|
RCTLogError(@"Tried to display action sheet but there is no application window. options: %@", options);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -60,7 +60,7 @@ var SegmentedControlIOS = React.createClass({
|
||||||
values: PropTypes.arrayOf(PropTypes.string),
|
values: PropTypes.arrayOf(PropTypes.string),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The index in `props.values` of the segment to be (pre)selected.
|
* The index in `props.values` of the segment to be (pre)selected.
|
||||||
*/
|
*/
|
||||||
selectedIndex: PropTypes.number,
|
selectedIndex: PropTypes.number,
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ type ImageCropData = {
|
||||||
*/
|
*/
|
||||||
size: {
|
size: {
|
||||||
width: number;
|
width: number;
|
||||||
height: number;
|
height: number;
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* (Optional) size to scale the cropped image to.
|
* (Optional) size to scale the cropped image to.
|
||||||
|
@ -52,7 +52,7 @@ class ImageEditor {
|
||||||
/**
|
/**
|
||||||
* Crop the image specified by the URI param. If URI points to a remote
|
* Crop the image specified by the URI param. If URI points to a remote
|
||||||
* image, it will be downloaded automatically. If the image cannot be
|
* image, it will be downloaded automatically. If the image cannot be
|
||||||
* loaded/downloaded, the failure callback will be called.
|
* loaded/downloaded, the failure callback will be called.
|
||||||
*
|
*
|
||||||
* If the cropping process is successful, the resultant cropped image
|
* If the cropping process is successful, the resultant cropped image
|
||||||
* will be stored in the ImageStore, and the URI returned in the success
|
* will be stored in the ImageStore, and the URI returned in the success
|
||||||
|
|
|
@ -30,7 +30,7 @@ var ImageStylePropTypes = {
|
||||||
borderRadius: ReactPropTypes.number,
|
borderRadius: ReactPropTypes.number,
|
||||||
overflow: ReactPropTypes.oneOf(['visible', 'hidden']),
|
overflow: ReactPropTypes.oneOf(['visible', 'hidden']),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* iOS-Specific style to "tint" an image.
|
* iOS-Specific style to "tint" an image.
|
||||||
* Changes the color of all the non-transparent pixels to the tintColor.
|
* Changes the color of all the non-transparent pixels to the tintColor.
|
||||||
* @platform ios
|
* @platform ios
|
||||||
|
@ -44,7 +44,7 @@ var ImageStylePropTypes = {
|
||||||
* implementation of rounded corners:
|
* implementation of rounded corners:
|
||||||
* - Certain resize modes, such as 'contain'
|
* - Certain resize modes, such as 'contain'
|
||||||
* - Animated GIFs
|
* - Animated GIFs
|
||||||
*
|
*
|
||||||
* A typical way to use this prop is with images displayed on a solid
|
* A typical way to use this prop is with images displayed on a solid
|
||||||
* background and setting the `overlayColor` to the same color
|
* background and setting the `overlayColor` to the same color
|
||||||
* as the background.
|
* as the background.
|
||||||
|
|
|
@ -347,7 +347,7 @@ typedef NS_ENUM(NSUInteger, FBTestSnapshotFileNameType) {
|
||||||
- (UIImage *)_snapshotViewOrLayer:(id)viewOrLayer
|
- (UIImage *)_snapshotViewOrLayer:(id)viewOrLayer
|
||||||
{
|
{
|
||||||
CALayer *layer = nil;
|
CALayer *layer = nil;
|
||||||
|
|
||||||
if ([viewOrLayer isKindOfClass:[UIView class]]) {
|
if ([viewOrLayer isKindOfClass:[UIView class]]) {
|
||||||
return [self _renderView:viewOrLayer];
|
return [self _renderView:viewOrLayer];
|
||||||
} else if ([viewOrLayer isKindOfClass:[CALayer class]]) {
|
} else if ([viewOrLayer isKindOfClass:[CALayer class]]) {
|
||||||
|
@ -370,19 +370,19 @@ typedef NS_ENUM(NSUInteger, FBTestSnapshotFileNameType) {
|
||||||
UIGraphicsBeginImageContextWithOptions(bounds.size, NO, 0);
|
UIGraphicsBeginImageContextWithOptions(bounds.size, NO, 0);
|
||||||
CGContextRef context = UIGraphicsGetCurrentContext();
|
CGContextRef context = UIGraphicsGetCurrentContext();
|
||||||
NSAssert1(context, @"Could not generate context for layer %@", layer);
|
NSAssert1(context, @"Could not generate context for layer %@", layer);
|
||||||
|
|
||||||
CGContextSaveGState(context);
|
CGContextSaveGState(context);
|
||||||
{
|
{
|
||||||
[layer renderInContext:context];
|
[layer renderInContext:context];
|
||||||
}
|
}
|
||||||
CGContextRestoreGState(context);
|
CGContextRestoreGState(context);
|
||||||
|
|
||||||
UIImage *snapshot = UIGraphicsGetImageFromCurrentImageContext();
|
UIImage *snapshot = UIGraphicsGetImageFromCurrentImageContext();
|
||||||
UIGraphicsEndImageContext();
|
UIGraphicsEndImageContext();
|
||||||
|
|
||||||
return snapshot;
|
return snapshot;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (UIImage *)_renderView:(UIView *)view
|
- (UIImage *)_renderView:(UIView *)view
|
||||||
{
|
{
|
||||||
[view layoutIfNeeded];
|
[view layoutIfNeeded];
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
- (BOOL)compareWithImage:(UIImage *)image
|
- (BOOL)compareWithImage:(UIImage *)image
|
||||||
{
|
{
|
||||||
NSAssert(CGSizeEqualToSize(self.size, image.size), @"Images must be same size.");
|
NSAssert(CGSizeEqualToSize(self.size, image.size), @"Images must be same size.");
|
||||||
|
|
||||||
// The images have the equal size, so we could use the smallest amount of bytes because of byte padding
|
// The images have the equal size, so we could use the smallest amount of bytes because of byte padding
|
||||||
size_t minBytesPerRow = MIN(CGImageGetBytesPerRow(self.CGImage), CGImageGetBytesPerRow(image.CGImage));
|
size_t minBytesPerRow = MIN(CGImageGetBytesPerRow(self.CGImage), CGImageGetBytesPerRow(image.CGImage));
|
||||||
size_t referenceImageSizeBytes = CGImageGetHeight(self.CGImage) * minBytesPerRow;
|
size_t referenceImageSizeBytes = CGImageGetHeight(self.CGImage) * minBytesPerRow;
|
||||||
|
@ -47,7 +47,7 @@
|
||||||
free(imagePixels);
|
free(imagePixels);
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
CGContextRef referenceImageContext = CGBitmapContextCreate(referenceImagePixels,
|
CGContextRef referenceImageContext = CGBitmapContextCreate(referenceImagePixels,
|
||||||
CGImageGetWidth(self.CGImage),
|
CGImageGetWidth(self.CGImage),
|
||||||
CGImageGetHeight(self.CGImage),
|
CGImageGetHeight(self.CGImage),
|
||||||
|
@ -64,11 +64,11 @@
|
||||||
CGImageGetColorSpace(image.CGImage),
|
CGImageGetColorSpace(image.CGImage),
|
||||||
(CGBitmapInfo)kCGImageAlphaPremultipliedLast
|
(CGBitmapInfo)kCGImageAlphaPremultipliedLast
|
||||||
);
|
);
|
||||||
|
|
||||||
CGFloat scaleFactor = [UIScreen mainScreen].scale;
|
CGFloat scaleFactor = [UIScreen mainScreen].scale;
|
||||||
CGContextScaleCTM(referenceImageContext, scaleFactor, scaleFactor);
|
CGContextScaleCTM(referenceImageContext, scaleFactor, scaleFactor);
|
||||||
CGContextScaleCTM(imageContext, scaleFactor, scaleFactor);
|
CGContextScaleCTM(imageContext, scaleFactor, scaleFactor);
|
||||||
|
|
||||||
if (!referenceImageContext || !imageContext) {
|
if (!referenceImageContext || !imageContext) {
|
||||||
CGContextRelease(referenceImageContext);
|
CGContextRelease(referenceImageContext);
|
||||||
CGContextRelease(imageContext);
|
CGContextRelease(imageContext);
|
||||||
|
@ -76,12 +76,12 @@
|
||||||
free(imagePixels);
|
free(imagePixels);
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
CGContextDrawImage(referenceImageContext, CGRectMake(0.0f, 0.0f, self.size.width, self.size.height), self.CGImage);
|
CGContextDrawImage(referenceImageContext, CGRectMake(0.0f, 0.0f, self.size.width, self.size.height), self.CGImage);
|
||||||
CGContextDrawImage(imageContext, CGRectMake(0.0f, 0.0f, image.size.width, image.size.height), image.CGImage);
|
CGContextDrawImage(imageContext, CGRectMake(0.0f, 0.0f, image.size.width, image.size.height), image.CGImage);
|
||||||
CGContextRelease(referenceImageContext);
|
CGContextRelease(referenceImageContext);
|
||||||
CGContextRelease(imageContext);
|
CGContextRelease(imageContext);
|
||||||
|
|
||||||
BOOL imageEqual = (memcmp(referenceImagePixels, imagePixels, referenceImageSizeBytes) == 0);
|
BOOL imageEqual = (memcmp(referenceImagePixels, imagePixels, referenceImageSizeBytes) == 0);
|
||||||
free(referenceImagePixels);
|
free(referenceImagePixels);
|
||||||
free(imagePixels);
|
free(imagePixels);
|
||||||
|
|
|
@ -291,7 +291,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder)
|
||||||
if (textView.textWasPasted) {
|
if (textView.textWasPasted) {
|
||||||
textView.textWasPasted = NO;
|
textView.textWasPasted = NO;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
[_eventDispatcher sendTextEventWithType:RCTTextEventTypeKeyPress
|
[_eventDispatcher sendTextEventWithType:RCTTextEventTypeKeyPress
|
||||||
reactTag:self.reactTag
|
reactTag:self.reactTag
|
||||||
text:nil
|
text:nil
|
||||||
|
|
|
@ -49,7 +49,7 @@ const _takeSnapshot = UIManager.takeSnapshot;
|
||||||
* Capture an image of the screen, window or an individual view. The image
|
* Capture an image of the screen, window or an individual view. The image
|
||||||
* will be stored in a temporary file that will only exist for as long as the
|
* will be stored in a temporary file that will only exist for as long as the
|
||||||
* app is running.
|
* app is running.
|
||||||
*
|
*
|
||||||
* The `view` argument can be the literal string `window` if you want to
|
* The `view` argument can be the literal string `window` if you want to
|
||||||
* capture the entire window, or it can be a reference to a specific
|
* capture the entire window, or it can be a reference to a specific
|
||||||
* React Native component.
|
* React Native component.
|
||||||
|
|
|
@ -601,7 +601,7 @@ static void layoutNodeImpl(css_node_t *node, float parentMaxWidth, float parentM
|
||||||
if (isRowUndefined || isColumnUndefined) {
|
if (isRowUndefined || isColumnUndefined) {
|
||||||
css_dim_t measureDim = node->measure(
|
css_dim_t measureDim = node->measure(
|
||||||
node->context,
|
node->context,
|
||||||
|
|
||||||
width,
|
width,
|
||||||
height
|
height
|
||||||
);
|
);
|
||||||
|
|
|
@ -9,7 +9,7 @@ Make sure you have the following installed:
|
||||||
- Android Support Repository 17 (for Android Support Library)
|
- Android Support Repository 17 (for Android Support Library)
|
||||||
|
|
||||||
Follow steps on https://github.com/facebook/react-native/blob/master/react-native-cli/CONTRIBUTING.md, but be sure to bump the version of react-native in package.json to some version > 0.9 (latest published npm version) or set up proxying properly for react-native
|
Follow steps on https://github.com/facebook/react-native/blob/master/react-native-cli/CONTRIBUTING.md, but be sure to bump the version of react-native in package.json to some version > 0.9 (latest published npm version) or set up proxying properly for react-native
|
||||||
|
|
||||||
- From the react-native-android repo:
|
- From the react-native-android repo:
|
||||||
- `./gradlew :ReactAndroid:installArchives`
|
- `./gradlew :ReactAndroid:installArchives`
|
||||||
- *Assuming you already have android-jsc installed to local maven repo, no steps included here*
|
- *Assuming you already have android-jsc installed to local maven repo, no steps included here*
|
||||||
|
|
|
@ -119,7 +119,7 @@ afterEvaluate { project ->
|
||||||
repositories.mavenDeployer {
|
repositories.mavenDeployer {
|
||||||
// Deploy to react-native/android, ready to publish to npm
|
// Deploy to react-native/android, ready to publish to npm
|
||||||
repository url: "file://${projectDir}/../android"
|
repository url: "file://${projectDir}/../android"
|
||||||
|
|
||||||
configureReactNativePom pom
|
configureReactNativePom pom
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -227,19 +227,19 @@ public class LayoutEngine {
|
||||||
float parentMaxHeight,
|
float parentMaxHeight,
|
||||||
CSSDirection parentDirection) {
|
CSSDirection parentDirection) {
|
||||||
/** START_GENERATED **/
|
/** START_GENERATED **/
|
||||||
|
|
||||||
CSSDirection direction = resolveDirection(node, parentDirection);
|
CSSDirection direction = resolveDirection(node, parentDirection);
|
||||||
int mainAxis = resolveAxis(getFlexDirection(node), direction);
|
int mainAxis = resolveAxis(getFlexDirection(node), direction);
|
||||||
int crossAxis = getCrossFlexDirection(mainAxis, direction);
|
int crossAxis = getCrossFlexDirection(mainAxis, direction);
|
||||||
int resolvedRowAxis = resolveAxis(CSS_FLEX_DIRECTION_ROW, direction);
|
int resolvedRowAxis = resolveAxis(CSS_FLEX_DIRECTION_ROW, direction);
|
||||||
|
|
||||||
// Handle width and height style attributes
|
// Handle width and height style attributes
|
||||||
setDimensionFromStyle(node, mainAxis);
|
setDimensionFromStyle(node, mainAxis);
|
||||||
setDimensionFromStyle(node, crossAxis);
|
setDimensionFromStyle(node, crossAxis);
|
||||||
|
|
||||||
// Set the resolved resolution in the node's layout
|
// Set the resolved resolution in the node's layout
|
||||||
node.layout.direction = direction;
|
node.layout.direction = direction;
|
||||||
|
|
||||||
// The position is set by the parent, but we need to complete it with a
|
// The position is set by the parent, but we need to complete it with a
|
||||||
// delta composed of the margin and left/top/right/bottom
|
// delta composed of the margin and left/top/right/bottom
|
||||||
node.layout.position[leading[mainAxis]] += node.style.margin.getWithFallback(leadingSpacing[mainAxis], leading[mainAxis]) +
|
node.layout.position[leading[mainAxis]] += node.style.margin.getWithFallback(leadingSpacing[mainAxis], leading[mainAxis]) +
|
||||||
|
@ -250,16 +250,16 @@ public class LayoutEngine {
|
||||||
getRelativePosition(node, crossAxis);
|
getRelativePosition(node, crossAxis);
|
||||||
node.layout.position[trailing[crossAxis]] += node.style.margin.getWithFallback(trailingSpacing[crossAxis], trailing[crossAxis]) +
|
node.layout.position[trailing[crossAxis]] += node.style.margin.getWithFallback(trailingSpacing[crossAxis], trailing[crossAxis]) +
|
||||||
getRelativePosition(node, crossAxis);
|
getRelativePosition(node, crossAxis);
|
||||||
|
|
||||||
// Inline immutable values from the target node to avoid excessive method
|
// Inline immutable values from the target node to avoid excessive method
|
||||||
// invocations during the layout calculation.
|
// invocations during the layout calculation.
|
||||||
int childCount = node.getChildCount();
|
int childCount = node.getChildCount();
|
||||||
float paddingAndBorderAxisResolvedRow = ((node.style.padding.getWithFallback(leadingSpacing[resolvedRowAxis], leading[resolvedRowAxis]) + node.style.border.getWithFallback(leadingSpacing[resolvedRowAxis], leading[resolvedRowAxis])) + (node.style.padding.getWithFallback(trailingSpacing[resolvedRowAxis], trailing[resolvedRowAxis]) + node.style.border.getWithFallback(trailingSpacing[resolvedRowAxis], trailing[resolvedRowAxis])));
|
float paddingAndBorderAxisResolvedRow = ((node.style.padding.getWithFallback(leadingSpacing[resolvedRowAxis], leading[resolvedRowAxis]) + node.style.border.getWithFallback(leadingSpacing[resolvedRowAxis], leading[resolvedRowAxis])) + (node.style.padding.getWithFallback(trailingSpacing[resolvedRowAxis], trailing[resolvedRowAxis]) + node.style.border.getWithFallback(trailingSpacing[resolvedRowAxis], trailing[resolvedRowAxis])));
|
||||||
float paddingAndBorderAxisColumn = ((node.style.padding.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_COLUMN], leading[CSS_FLEX_DIRECTION_COLUMN]) + node.style.border.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_COLUMN], leading[CSS_FLEX_DIRECTION_COLUMN])) + (node.style.padding.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_COLUMN], trailing[CSS_FLEX_DIRECTION_COLUMN]) + node.style.border.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_COLUMN], trailing[CSS_FLEX_DIRECTION_COLUMN])));
|
float paddingAndBorderAxisColumn = ((node.style.padding.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_COLUMN], leading[CSS_FLEX_DIRECTION_COLUMN]) + node.style.border.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_COLUMN], leading[CSS_FLEX_DIRECTION_COLUMN])) + (node.style.padding.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_COLUMN], trailing[CSS_FLEX_DIRECTION_COLUMN]) + node.style.border.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_COLUMN], trailing[CSS_FLEX_DIRECTION_COLUMN])));
|
||||||
|
|
||||||
if (isMeasureDefined(node)) {
|
if (isMeasureDefined(node)) {
|
||||||
boolean isResolvedRowDimDefined = (!Float.isNaN(node.layout.dimensions[dim[resolvedRowAxis]]) && node.layout.dimensions[dim[resolvedRowAxis]] >= 0.0);
|
boolean isResolvedRowDimDefined = (!Float.isNaN(node.layout.dimensions[dim[resolvedRowAxis]]) && node.layout.dimensions[dim[resolvedRowAxis]] >= 0.0);
|
||||||
|
|
||||||
float width = CSSConstants.UNDEFINED;
|
float width = CSSConstants.UNDEFINED;
|
||||||
if ((!Float.isNaN(node.style.dimensions[dim[resolvedRowAxis]]) && node.style.dimensions[dim[resolvedRowAxis]] >= 0.0)) {
|
if ((!Float.isNaN(node.style.dimensions[dim[resolvedRowAxis]]) && node.style.dimensions[dim[resolvedRowAxis]] >= 0.0)) {
|
||||||
width = node.style.dimensions[DIMENSION_WIDTH];
|
width = node.style.dimensions[DIMENSION_WIDTH];
|
||||||
|
@ -270,7 +270,7 @@ public class LayoutEngine {
|
||||||
(node.style.margin.getWithFallback(leadingSpacing[resolvedRowAxis], leading[resolvedRowAxis]) + node.style.margin.getWithFallback(trailingSpacing[resolvedRowAxis], trailing[resolvedRowAxis]));
|
(node.style.margin.getWithFallback(leadingSpacing[resolvedRowAxis], leading[resolvedRowAxis]) + node.style.margin.getWithFallback(trailingSpacing[resolvedRowAxis], trailing[resolvedRowAxis]));
|
||||||
}
|
}
|
||||||
width -= paddingAndBorderAxisResolvedRow;
|
width -= paddingAndBorderAxisResolvedRow;
|
||||||
|
|
||||||
float height = CSSConstants.UNDEFINED;
|
float height = CSSConstants.UNDEFINED;
|
||||||
if ((!Float.isNaN(node.style.dimensions[dim[CSS_FLEX_DIRECTION_COLUMN]]) && node.style.dimensions[dim[CSS_FLEX_DIRECTION_COLUMN]] >= 0.0)) {
|
if ((!Float.isNaN(node.style.dimensions[dim[CSS_FLEX_DIRECTION_COLUMN]]) && node.style.dimensions[dim[CSS_FLEX_DIRECTION_COLUMN]] >= 0.0)) {
|
||||||
height = node.style.dimensions[DIMENSION_HEIGHT];
|
height = node.style.dimensions[DIMENSION_HEIGHT];
|
||||||
|
@ -281,18 +281,18 @@ public class LayoutEngine {
|
||||||
(node.style.margin.getWithFallback(leadingSpacing[resolvedRowAxis], leading[resolvedRowAxis]) + node.style.margin.getWithFallback(trailingSpacing[resolvedRowAxis], trailing[resolvedRowAxis]));
|
(node.style.margin.getWithFallback(leadingSpacing[resolvedRowAxis], leading[resolvedRowAxis]) + node.style.margin.getWithFallback(trailingSpacing[resolvedRowAxis], trailing[resolvedRowAxis]));
|
||||||
}
|
}
|
||||||
height -= ((node.style.padding.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_COLUMN], leading[CSS_FLEX_DIRECTION_COLUMN]) + node.style.border.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_COLUMN], leading[CSS_FLEX_DIRECTION_COLUMN])) + (node.style.padding.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_COLUMN], trailing[CSS_FLEX_DIRECTION_COLUMN]) + node.style.border.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_COLUMN], trailing[CSS_FLEX_DIRECTION_COLUMN])));
|
height -= ((node.style.padding.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_COLUMN], leading[CSS_FLEX_DIRECTION_COLUMN]) + node.style.border.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_COLUMN], leading[CSS_FLEX_DIRECTION_COLUMN])) + (node.style.padding.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_COLUMN], trailing[CSS_FLEX_DIRECTION_COLUMN]) + node.style.border.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_COLUMN], trailing[CSS_FLEX_DIRECTION_COLUMN])));
|
||||||
|
|
||||||
// We only need to give a dimension for the text if we haven't got any
|
// We only need to give a dimension for the text if we haven't got any
|
||||||
// for it computed yet. It can either be from the style attribute or because
|
// for it computed yet. It can either be from the style attribute or because
|
||||||
// the element is flexible.
|
// the element is flexible.
|
||||||
boolean isRowUndefined = !(!Float.isNaN(node.style.dimensions[dim[resolvedRowAxis]]) && node.style.dimensions[dim[resolvedRowAxis]] >= 0.0) && !isResolvedRowDimDefined;
|
boolean isRowUndefined = !(!Float.isNaN(node.style.dimensions[dim[resolvedRowAxis]]) && node.style.dimensions[dim[resolvedRowAxis]] >= 0.0) && !isResolvedRowDimDefined;
|
||||||
boolean isColumnUndefined = !(!Float.isNaN(node.style.dimensions[dim[CSS_FLEX_DIRECTION_COLUMN]]) && node.style.dimensions[dim[CSS_FLEX_DIRECTION_COLUMN]] >= 0.0) &&
|
boolean isColumnUndefined = !(!Float.isNaN(node.style.dimensions[dim[CSS_FLEX_DIRECTION_COLUMN]]) && node.style.dimensions[dim[CSS_FLEX_DIRECTION_COLUMN]] >= 0.0) &&
|
||||||
Float.isNaN(node.layout.dimensions[dim[CSS_FLEX_DIRECTION_COLUMN]]);
|
Float.isNaN(node.layout.dimensions[dim[CSS_FLEX_DIRECTION_COLUMN]]);
|
||||||
|
|
||||||
// Let's not measure the text if we already know both dimensions
|
// Let's not measure the text if we already know both dimensions
|
||||||
if (isRowUndefined || isColumnUndefined) {
|
if (isRowUndefined || isColumnUndefined) {
|
||||||
MeasureOutput measureDim = node.measure(
|
MeasureOutput measureDim = node.measure(
|
||||||
|
|
||||||
layoutContext.measureOutput,
|
layoutContext.measureOutput,
|
||||||
width,
|
width,
|
||||||
height
|
height
|
||||||
|
@ -310,33 +310,33 @@ public class LayoutEngine {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isNodeFlexWrap = (node.style.flexWrap == CSSWrap.WRAP);
|
boolean isNodeFlexWrap = (node.style.flexWrap == CSSWrap.WRAP);
|
||||||
|
|
||||||
CSSJustify justifyContent = node.style.justifyContent;
|
CSSJustify justifyContent = node.style.justifyContent;
|
||||||
|
|
||||||
float leadingPaddingAndBorderMain = (node.style.padding.getWithFallback(leadingSpacing[mainAxis], leading[mainAxis]) + node.style.border.getWithFallback(leadingSpacing[mainAxis], leading[mainAxis]));
|
float leadingPaddingAndBorderMain = (node.style.padding.getWithFallback(leadingSpacing[mainAxis], leading[mainAxis]) + node.style.border.getWithFallback(leadingSpacing[mainAxis], leading[mainAxis]));
|
||||||
float leadingPaddingAndBorderCross = (node.style.padding.getWithFallback(leadingSpacing[crossAxis], leading[crossAxis]) + node.style.border.getWithFallback(leadingSpacing[crossAxis], leading[crossAxis]));
|
float leadingPaddingAndBorderCross = (node.style.padding.getWithFallback(leadingSpacing[crossAxis], leading[crossAxis]) + node.style.border.getWithFallback(leadingSpacing[crossAxis], leading[crossAxis]));
|
||||||
float paddingAndBorderAxisMain = ((node.style.padding.getWithFallback(leadingSpacing[mainAxis], leading[mainAxis]) + node.style.border.getWithFallback(leadingSpacing[mainAxis], leading[mainAxis])) + (node.style.padding.getWithFallback(trailingSpacing[mainAxis], trailing[mainAxis]) + node.style.border.getWithFallback(trailingSpacing[mainAxis], trailing[mainAxis])));
|
float paddingAndBorderAxisMain = ((node.style.padding.getWithFallback(leadingSpacing[mainAxis], leading[mainAxis]) + node.style.border.getWithFallback(leadingSpacing[mainAxis], leading[mainAxis])) + (node.style.padding.getWithFallback(trailingSpacing[mainAxis], trailing[mainAxis]) + node.style.border.getWithFallback(trailingSpacing[mainAxis], trailing[mainAxis])));
|
||||||
float paddingAndBorderAxisCross = ((node.style.padding.getWithFallback(leadingSpacing[crossAxis], leading[crossAxis]) + node.style.border.getWithFallback(leadingSpacing[crossAxis], leading[crossAxis])) + (node.style.padding.getWithFallback(trailingSpacing[crossAxis], trailing[crossAxis]) + node.style.border.getWithFallback(trailingSpacing[crossAxis], trailing[crossAxis])));
|
float paddingAndBorderAxisCross = ((node.style.padding.getWithFallback(leadingSpacing[crossAxis], leading[crossAxis]) + node.style.border.getWithFallback(leadingSpacing[crossAxis], leading[crossAxis])) + (node.style.padding.getWithFallback(trailingSpacing[crossAxis], trailing[crossAxis]) + node.style.border.getWithFallback(trailingSpacing[crossAxis], trailing[crossAxis])));
|
||||||
|
|
||||||
boolean isMainDimDefined = (!Float.isNaN(node.layout.dimensions[dim[mainAxis]]) && node.layout.dimensions[dim[mainAxis]] >= 0.0);
|
boolean isMainDimDefined = (!Float.isNaN(node.layout.dimensions[dim[mainAxis]]) && node.layout.dimensions[dim[mainAxis]] >= 0.0);
|
||||||
boolean isCrossDimDefined = (!Float.isNaN(node.layout.dimensions[dim[crossAxis]]) && node.layout.dimensions[dim[crossAxis]] >= 0.0);
|
boolean isCrossDimDefined = (!Float.isNaN(node.layout.dimensions[dim[crossAxis]]) && node.layout.dimensions[dim[crossAxis]] >= 0.0);
|
||||||
boolean isMainRowDirection = (mainAxis == CSS_FLEX_DIRECTION_ROW || mainAxis == CSS_FLEX_DIRECTION_ROW_REVERSE);
|
boolean isMainRowDirection = (mainAxis == CSS_FLEX_DIRECTION_ROW || mainAxis == CSS_FLEX_DIRECTION_ROW_REVERSE);
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
int ii;
|
int ii;
|
||||||
CSSNode child;
|
CSSNode child;
|
||||||
int axis;
|
int axis;
|
||||||
|
|
||||||
CSSNode firstAbsoluteChild = null;
|
CSSNode firstAbsoluteChild = null;
|
||||||
CSSNode currentAbsoluteChild = null;
|
CSSNode currentAbsoluteChild = null;
|
||||||
|
|
||||||
float definedMainDim = CSSConstants.UNDEFINED;
|
float definedMainDim = CSSConstants.UNDEFINED;
|
||||||
if (isMainDimDefined) {
|
if (isMainDimDefined) {
|
||||||
definedMainDim = node.layout.dimensions[dim[mainAxis]] - paddingAndBorderAxisMain;
|
definedMainDim = node.layout.dimensions[dim[mainAxis]] - paddingAndBorderAxisMain;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We want to execute the next two loops one per line with flex-wrap
|
// We want to execute the next two loops one per line with flex-wrap
|
||||||
int startLine = 0;
|
int startLine = 0;
|
||||||
int endLine = 0;
|
int endLine = 0;
|
||||||
|
@ -348,19 +348,19 @@ public class LayoutEngine {
|
||||||
int linesCount = 0;
|
int linesCount = 0;
|
||||||
while (endLine < childCount) {
|
while (endLine < childCount) {
|
||||||
// <Loop A> Layout non flexible children and count children by type
|
// <Loop A> Layout non flexible children and count children by type
|
||||||
|
|
||||||
// mainContentDim is accumulation of the dimensions and margin of all the
|
// mainContentDim is accumulation of the dimensions and margin of all the
|
||||||
// non flexible children. This will be used in order to either set the
|
// non flexible children. This will be used in order to either set the
|
||||||
// dimensions of the node if none already exist, or to compute the
|
// dimensions of the node if none already exist, or to compute the
|
||||||
// remaining space left for the flexible children.
|
// remaining space left for the flexible children.
|
||||||
float mainContentDim = 0;
|
float mainContentDim = 0;
|
||||||
|
|
||||||
// There are three kind of children, non flexible, flexible and absolute.
|
// There are three kind of children, non flexible, flexible and absolute.
|
||||||
// We need to know how many there are in order to distribute the space.
|
// We need to know how many there are in order to distribute the space.
|
||||||
int flexibleChildrenCount = 0;
|
int flexibleChildrenCount = 0;
|
||||||
float totalFlexible = 0;
|
float totalFlexible = 0;
|
||||||
int nonFlexibleChildrenCount = 0;
|
int nonFlexibleChildrenCount = 0;
|
||||||
|
|
||||||
// Use the line loop to position children in the main axis for as long
|
// Use the line loop to position children in the main axis for as long
|
||||||
// as they are using a simple stacking behaviour. Children that are
|
// as they are using a simple stacking behaviour. Children that are
|
||||||
// immediately stacked in the initial loop will not be touched again
|
// immediately stacked in the initial loop will not be touched again
|
||||||
|
@ -369,31 +369,31 @@ public class LayoutEngine {
|
||||||
(isMainDimDefined && justifyContent == CSSJustify.FLEX_START) ||
|
(isMainDimDefined && justifyContent == CSSJustify.FLEX_START) ||
|
||||||
(!isMainDimDefined && justifyContent != CSSJustify.CENTER);
|
(!isMainDimDefined && justifyContent != CSSJustify.CENTER);
|
||||||
int firstComplexMain = (isSimpleStackMain ? childCount : startLine);
|
int firstComplexMain = (isSimpleStackMain ? childCount : startLine);
|
||||||
|
|
||||||
// Use the initial line loop to position children in the cross axis for
|
// Use the initial line loop to position children in the cross axis for
|
||||||
// as long as they are relatively positioned with alignment STRETCH or
|
// as long as they are relatively positioned with alignment STRETCH or
|
||||||
// FLEX_START. Children that are immediately stacked in the initial loop
|
// FLEX_START. Children that are immediately stacked in the initial loop
|
||||||
// will not be touched again in <Loop D>.
|
// will not be touched again in <Loop D>.
|
||||||
boolean isSimpleStackCross = true;
|
boolean isSimpleStackCross = true;
|
||||||
int firstComplexCross = childCount;
|
int firstComplexCross = childCount;
|
||||||
|
|
||||||
CSSNode firstFlexChild = null;
|
CSSNode firstFlexChild = null;
|
||||||
CSSNode currentFlexChild = null;
|
CSSNode currentFlexChild = null;
|
||||||
|
|
||||||
float mainDim = leadingPaddingAndBorderMain;
|
float mainDim = leadingPaddingAndBorderMain;
|
||||||
float crossDim = 0;
|
float crossDim = 0;
|
||||||
|
|
||||||
float maxWidth = CSSConstants.UNDEFINED;
|
float maxWidth = CSSConstants.UNDEFINED;
|
||||||
float maxHeight = CSSConstants.UNDEFINED;
|
float maxHeight = CSSConstants.UNDEFINED;
|
||||||
for (i = startLine; i < childCount; ++i) {
|
for (i = startLine; i < childCount; ++i) {
|
||||||
child = node.getChildAt(i);
|
child = node.getChildAt(i);
|
||||||
child.lineIndex = linesCount;
|
child.lineIndex = linesCount;
|
||||||
|
|
||||||
child.nextAbsoluteChild = null;
|
child.nextAbsoluteChild = null;
|
||||||
child.nextFlexChild = null;
|
child.nextFlexChild = null;
|
||||||
|
|
||||||
CSSAlign alignItem = getAlignItem(node, child);
|
CSSAlign alignItem = getAlignItem(node, child);
|
||||||
|
|
||||||
// Pre-fill cross axis dimensions when the child is using stretch before
|
// Pre-fill cross axis dimensions when the child is using stretch before
|
||||||
// we call the recursive layout pass
|
// we call the recursive layout pass
|
||||||
if (alignItem == CSSAlign.STRETCH &&
|
if (alignItem == CSSAlign.STRETCH &&
|
||||||
|
@ -416,7 +416,7 @@ public class LayoutEngine {
|
||||||
currentAbsoluteChild.nextAbsoluteChild = child;
|
currentAbsoluteChild.nextAbsoluteChild = child;
|
||||||
}
|
}
|
||||||
currentAbsoluteChild = child;
|
currentAbsoluteChild = child;
|
||||||
|
|
||||||
// Pre-fill dimensions when using absolute position and both offsets for the axis are defined (either both
|
// Pre-fill dimensions when using absolute position and both offsets for the axis are defined (either both
|
||||||
// left and right or top and bottom).
|
// left and right or top and bottom).
|
||||||
for (ii = 0; ii < 2; ii++) {
|
for (ii = 0; ii < 2; ii++) {
|
||||||
|
@ -437,15 +437,15 @@ public class LayoutEngine {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float nextContentDim = 0;
|
float nextContentDim = 0;
|
||||||
|
|
||||||
// It only makes sense to consider a child flexible if we have a computed
|
// It only makes sense to consider a child flexible if we have a computed
|
||||||
// dimension for the node.
|
// dimension for the node.
|
||||||
if (isMainDimDefined && (child.style.positionType == CSSPositionType.RELATIVE && child.style.flex > 0)) {
|
if (isMainDimDefined && (child.style.positionType == CSSPositionType.RELATIVE && child.style.flex > 0)) {
|
||||||
flexibleChildrenCount++;
|
flexibleChildrenCount++;
|
||||||
totalFlexible += child.style.flex;
|
totalFlexible += child.style.flex;
|
||||||
|
|
||||||
// Store a private linked list of flexible children so that we can
|
// Store a private linked list of flexible children so that we can
|
||||||
// efficiently traverse them later.
|
// efficiently traverse them later.
|
||||||
if (firstFlexChild == null) {
|
if (firstFlexChild == null) {
|
||||||
|
@ -455,18 +455,18 @@ public class LayoutEngine {
|
||||||
currentFlexChild.nextFlexChild = child;
|
currentFlexChild.nextFlexChild = child;
|
||||||
}
|
}
|
||||||
currentFlexChild = child;
|
currentFlexChild = child;
|
||||||
|
|
||||||
// Even if we don't know its exact size yet, we already know the padding,
|
// Even if we don't know its exact size yet, we already know the padding,
|
||||||
// border and margin. We'll use this partial information, which represents
|
// border and margin. We'll use this partial information, which represents
|
||||||
// the smallest possible size for the child, to compute the remaining
|
// the smallest possible size for the child, to compute the remaining
|
||||||
// available space.
|
// available space.
|
||||||
nextContentDim = ((child.style.padding.getWithFallback(leadingSpacing[mainAxis], leading[mainAxis]) + child.style.border.getWithFallback(leadingSpacing[mainAxis], leading[mainAxis])) + (child.style.padding.getWithFallback(trailingSpacing[mainAxis], trailing[mainAxis]) + child.style.border.getWithFallback(trailingSpacing[mainAxis], trailing[mainAxis]))) +
|
nextContentDim = ((child.style.padding.getWithFallback(leadingSpacing[mainAxis], leading[mainAxis]) + child.style.border.getWithFallback(leadingSpacing[mainAxis], leading[mainAxis])) + (child.style.padding.getWithFallback(trailingSpacing[mainAxis], trailing[mainAxis]) + child.style.border.getWithFallback(trailingSpacing[mainAxis], trailing[mainAxis]))) +
|
||||||
(child.style.margin.getWithFallback(leadingSpacing[mainAxis], leading[mainAxis]) + child.style.margin.getWithFallback(trailingSpacing[mainAxis], trailing[mainAxis]));
|
(child.style.margin.getWithFallback(leadingSpacing[mainAxis], leading[mainAxis]) + child.style.margin.getWithFallback(trailingSpacing[mainAxis], trailing[mainAxis]));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
maxWidth = CSSConstants.UNDEFINED;
|
maxWidth = CSSConstants.UNDEFINED;
|
||||||
maxHeight = CSSConstants.UNDEFINED;
|
maxHeight = CSSConstants.UNDEFINED;
|
||||||
|
|
||||||
if (!isMainRowDirection) {
|
if (!isMainRowDirection) {
|
||||||
if ((!Float.isNaN(node.layout.dimensions[dim[resolvedRowAxis]]) && node.layout.dimensions[dim[resolvedRowAxis]] >= 0.0)) {
|
if ((!Float.isNaN(node.layout.dimensions[dim[resolvedRowAxis]]) && node.layout.dimensions[dim[resolvedRowAxis]] >= 0.0)) {
|
||||||
maxWidth = node.layout.dimensions[dim[resolvedRowAxis]] -
|
maxWidth = node.layout.dimensions[dim[resolvedRowAxis]] -
|
||||||
|
@ -486,12 +486,12 @@ public class LayoutEngine {
|
||||||
paddingAndBorderAxisColumn;
|
paddingAndBorderAxisColumn;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is the main recursive call. We layout non flexible children.
|
// This is the main recursive call. We layout non flexible children.
|
||||||
if (alreadyComputedNextLayout == 0) {
|
if (alreadyComputedNextLayout == 0) {
|
||||||
layoutNode(layoutContext, child, maxWidth, maxHeight, direction);
|
layoutNode(layoutContext, child, maxWidth, maxHeight, direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Absolute positioned elements do not take part of the layout, so we
|
// Absolute positioned elements do not take part of the layout, so we
|
||||||
// don't use them to compute mainContentDim
|
// don't use them to compute mainContentDim
|
||||||
if (child.style.positionType == CSSPositionType.RELATIVE) {
|
if (child.style.positionType == CSSPositionType.RELATIVE) {
|
||||||
|
@ -500,7 +500,7 @@ public class LayoutEngine {
|
||||||
nextContentDim = (child.layout.dimensions[dim[mainAxis]] + child.style.margin.getWithFallback(leadingSpacing[mainAxis], leading[mainAxis]) + child.style.margin.getWithFallback(trailingSpacing[mainAxis], trailing[mainAxis]));
|
nextContentDim = (child.layout.dimensions[dim[mainAxis]] + child.style.margin.getWithFallback(leadingSpacing[mainAxis], leading[mainAxis]) + child.style.margin.getWithFallback(trailingSpacing[mainAxis], trailing[mainAxis]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The element we are about to add would make us go to the next line
|
// The element we are about to add would make us go to the next line
|
||||||
if (isNodeFlexWrap &&
|
if (isNodeFlexWrap &&
|
||||||
isMainDimDefined &&
|
isMainDimDefined &&
|
||||||
|
@ -512,7 +512,7 @@ public class LayoutEngine {
|
||||||
alreadyComputedNextLayout = 1;
|
alreadyComputedNextLayout = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disable simple stacking in the main axis for the current line as
|
// Disable simple stacking in the main axis for the current line as
|
||||||
// we found a non-trivial child. The remaining children will be laid out
|
// we found a non-trivial child. The remaining children will be laid out
|
||||||
// in <Loop C>.
|
// in <Loop C>.
|
||||||
|
@ -521,7 +521,7 @@ public class LayoutEngine {
|
||||||
isSimpleStackMain = false;
|
isSimpleStackMain = false;
|
||||||
firstComplexMain = i;
|
firstComplexMain = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disable simple stacking in the cross axis for the current line as
|
// Disable simple stacking in the cross axis for the current line as
|
||||||
// we found a non-trivial child. The remaining children will be laid out
|
// we found a non-trivial child. The remaining children will be laid out
|
||||||
// in <Loop D>.
|
// in <Loop D>.
|
||||||
|
@ -532,37 +532,37 @@ public class LayoutEngine {
|
||||||
isSimpleStackCross = false;
|
isSimpleStackCross = false;
|
||||||
firstComplexCross = i;
|
firstComplexCross = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isSimpleStackMain) {
|
if (isSimpleStackMain) {
|
||||||
child.layout.position[pos[mainAxis]] += mainDim;
|
child.layout.position[pos[mainAxis]] += mainDim;
|
||||||
if (isMainDimDefined) {
|
if (isMainDimDefined) {
|
||||||
child.layout.position[trailing[mainAxis]] = node.layout.dimensions[dim[mainAxis]] - child.layout.dimensions[dim[mainAxis]] - child.layout.position[pos[mainAxis]];
|
child.layout.position[trailing[mainAxis]] = node.layout.dimensions[dim[mainAxis]] - child.layout.dimensions[dim[mainAxis]] - child.layout.position[pos[mainAxis]];
|
||||||
}
|
}
|
||||||
|
|
||||||
mainDim += (child.layout.dimensions[dim[mainAxis]] + child.style.margin.getWithFallback(leadingSpacing[mainAxis], leading[mainAxis]) + child.style.margin.getWithFallback(trailingSpacing[mainAxis], trailing[mainAxis]));
|
mainDim += (child.layout.dimensions[dim[mainAxis]] + child.style.margin.getWithFallback(leadingSpacing[mainAxis], leading[mainAxis]) + child.style.margin.getWithFallback(trailingSpacing[mainAxis], trailing[mainAxis]));
|
||||||
crossDim = Math.max(crossDim, boundAxis(child, crossAxis, (child.layout.dimensions[dim[crossAxis]] + child.style.margin.getWithFallback(leadingSpacing[crossAxis], leading[crossAxis]) + child.style.margin.getWithFallback(trailingSpacing[crossAxis], trailing[crossAxis]))));
|
crossDim = Math.max(crossDim, boundAxis(child, crossAxis, (child.layout.dimensions[dim[crossAxis]] + child.style.margin.getWithFallback(leadingSpacing[crossAxis], leading[crossAxis]) + child.style.margin.getWithFallback(trailingSpacing[crossAxis], trailing[crossAxis]))));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isSimpleStackCross) {
|
if (isSimpleStackCross) {
|
||||||
child.layout.position[pos[crossAxis]] += linesCrossDim + leadingPaddingAndBorderCross;
|
child.layout.position[pos[crossAxis]] += linesCrossDim + leadingPaddingAndBorderCross;
|
||||||
if (isCrossDimDefined) {
|
if (isCrossDimDefined) {
|
||||||
child.layout.position[trailing[crossAxis]] = node.layout.dimensions[dim[crossAxis]] - child.layout.dimensions[dim[crossAxis]] - child.layout.position[pos[crossAxis]];
|
child.layout.position[trailing[crossAxis]] = node.layout.dimensions[dim[crossAxis]] - child.layout.dimensions[dim[crossAxis]] - child.layout.position[pos[crossAxis]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
alreadyComputedNextLayout = 0;
|
alreadyComputedNextLayout = 0;
|
||||||
mainContentDim += nextContentDim;
|
mainContentDim += nextContentDim;
|
||||||
endLine = i + 1;
|
endLine = i + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// <Loop B> Layout flexible children and allocate empty space
|
// <Loop B> Layout flexible children and allocate empty space
|
||||||
|
|
||||||
// In order to position the elements in the main axis, we have two
|
// In order to position the elements in the main axis, we have two
|
||||||
// controls. The space between the beginning and the first element
|
// controls. The space between the beginning and the first element
|
||||||
// and the space between each two elements.
|
// and the space between each two elements.
|
||||||
float leadingMainDim = 0;
|
float leadingMainDim = 0;
|
||||||
float betweenMainDim = 0;
|
float betweenMainDim = 0;
|
||||||
|
|
||||||
// The remaining available space that needs to be allocated
|
// The remaining available space that needs to be allocated
|
||||||
float remainingMainDim = 0;
|
float remainingMainDim = 0;
|
||||||
if (isMainDimDefined) {
|
if (isMainDimDefined) {
|
||||||
|
@ -570,14 +570,14 @@ public class LayoutEngine {
|
||||||
} else {
|
} else {
|
||||||
remainingMainDim = Math.max(mainContentDim, 0) - mainContentDim;
|
remainingMainDim = Math.max(mainContentDim, 0) - mainContentDim;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there are flexible children in the mix, they are going to fill the
|
// If there are flexible children in the mix, they are going to fill the
|
||||||
// remaining space
|
// remaining space
|
||||||
if (flexibleChildrenCount != 0) {
|
if (flexibleChildrenCount != 0) {
|
||||||
float flexibleMainDim = remainingMainDim / totalFlexible;
|
float flexibleMainDim = remainingMainDim / totalFlexible;
|
||||||
float baseMainDim;
|
float baseMainDim;
|
||||||
float boundMainDim;
|
float boundMainDim;
|
||||||
|
|
||||||
// If the flex share of remaining space doesn't meet min/max bounds,
|
// If the flex share of remaining space doesn't meet min/max bounds,
|
||||||
// remove this child from flex calculations.
|
// remove this child from flex calculations.
|
||||||
currentFlexChild = firstFlexChild;
|
currentFlexChild = firstFlexChild;
|
||||||
|
@ -585,22 +585,22 @@ public class LayoutEngine {
|
||||||
baseMainDim = flexibleMainDim * currentFlexChild.style.flex +
|
baseMainDim = flexibleMainDim * currentFlexChild.style.flex +
|
||||||
((currentFlexChild.style.padding.getWithFallback(leadingSpacing[mainAxis], leading[mainAxis]) + currentFlexChild.style.border.getWithFallback(leadingSpacing[mainAxis], leading[mainAxis])) + (currentFlexChild.style.padding.getWithFallback(trailingSpacing[mainAxis], trailing[mainAxis]) + currentFlexChild.style.border.getWithFallback(trailingSpacing[mainAxis], trailing[mainAxis])));
|
((currentFlexChild.style.padding.getWithFallback(leadingSpacing[mainAxis], leading[mainAxis]) + currentFlexChild.style.border.getWithFallback(leadingSpacing[mainAxis], leading[mainAxis])) + (currentFlexChild.style.padding.getWithFallback(trailingSpacing[mainAxis], trailing[mainAxis]) + currentFlexChild.style.border.getWithFallback(trailingSpacing[mainAxis], trailing[mainAxis])));
|
||||||
boundMainDim = boundAxis(currentFlexChild, mainAxis, baseMainDim);
|
boundMainDim = boundAxis(currentFlexChild, mainAxis, baseMainDim);
|
||||||
|
|
||||||
if (baseMainDim != boundMainDim) {
|
if (baseMainDim != boundMainDim) {
|
||||||
remainingMainDim -= boundMainDim;
|
remainingMainDim -= boundMainDim;
|
||||||
totalFlexible -= currentFlexChild.style.flex;
|
totalFlexible -= currentFlexChild.style.flex;
|
||||||
}
|
}
|
||||||
|
|
||||||
currentFlexChild = currentFlexChild.nextFlexChild;
|
currentFlexChild = currentFlexChild.nextFlexChild;
|
||||||
}
|
}
|
||||||
flexibleMainDim = remainingMainDim / totalFlexible;
|
flexibleMainDim = remainingMainDim / totalFlexible;
|
||||||
|
|
||||||
// The non flexible children can overflow the container, in this case
|
// The non flexible children can overflow the container, in this case
|
||||||
// we should just assume that there is no space available.
|
// we should just assume that there is no space available.
|
||||||
if (flexibleMainDim < 0) {
|
if (flexibleMainDim < 0) {
|
||||||
flexibleMainDim = 0;
|
flexibleMainDim = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
currentFlexChild = firstFlexChild;
|
currentFlexChild = firstFlexChild;
|
||||||
while (currentFlexChild != null) {
|
while (currentFlexChild != null) {
|
||||||
// At this point we know the final size of the element in the main
|
// At this point we know the final size of the element in the main
|
||||||
|
@ -609,7 +609,7 @@ public class LayoutEngine {
|
||||||
flexibleMainDim * currentFlexChild.style.flex +
|
flexibleMainDim * currentFlexChild.style.flex +
|
||||||
((currentFlexChild.style.padding.getWithFallback(leadingSpacing[mainAxis], leading[mainAxis]) + currentFlexChild.style.border.getWithFallback(leadingSpacing[mainAxis], leading[mainAxis])) + (currentFlexChild.style.padding.getWithFallback(trailingSpacing[mainAxis], trailing[mainAxis]) + currentFlexChild.style.border.getWithFallback(trailingSpacing[mainAxis], trailing[mainAxis])))
|
((currentFlexChild.style.padding.getWithFallback(leadingSpacing[mainAxis], leading[mainAxis]) + currentFlexChild.style.border.getWithFallback(leadingSpacing[mainAxis], leading[mainAxis])) + (currentFlexChild.style.padding.getWithFallback(trailingSpacing[mainAxis], trailing[mainAxis]) + currentFlexChild.style.border.getWithFallback(trailingSpacing[mainAxis], trailing[mainAxis])))
|
||||||
);
|
);
|
||||||
|
|
||||||
maxWidth = CSSConstants.UNDEFINED;
|
maxWidth = CSSConstants.UNDEFINED;
|
||||||
if ((!Float.isNaN(node.layout.dimensions[dim[resolvedRowAxis]]) && node.layout.dimensions[dim[resolvedRowAxis]] >= 0.0)) {
|
if ((!Float.isNaN(node.layout.dimensions[dim[resolvedRowAxis]]) && node.layout.dimensions[dim[resolvedRowAxis]] >= 0.0)) {
|
||||||
maxWidth = node.layout.dimensions[dim[resolvedRowAxis]] -
|
maxWidth = node.layout.dimensions[dim[resolvedRowAxis]] -
|
||||||
|
@ -628,15 +628,15 @@ public class LayoutEngine {
|
||||||
(node.style.margin.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_COLUMN], leading[CSS_FLEX_DIRECTION_COLUMN]) + node.style.margin.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_COLUMN], trailing[CSS_FLEX_DIRECTION_COLUMN])) -
|
(node.style.margin.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_COLUMN], leading[CSS_FLEX_DIRECTION_COLUMN]) + node.style.margin.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_COLUMN], trailing[CSS_FLEX_DIRECTION_COLUMN])) -
|
||||||
paddingAndBorderAxisColumn;
|
paddingAndBorderAxisColumn;
|
||||||
}
|
}
|
||||||
|
|
||||||
// And we recursively call the layout algorithm for this child
|
// And we recursively call the layout algorithm for this child
|
||||||
layoutNode(layoutContext, currentFlexChild, maxWidth, maxHeight, direction);
|
layoutNode(layoutContext, currentFlexChild, maxWidth, maxHeight, direction);
|
||||||
|
|
||||||
child = currentFlexChild;
|
child = currentFlexChild;
|
||||||
currentFlexChild = currentFlexChild.nextFlexChild;
|
currentFlexChild = currentFlexChild.nextFlexChild;
|
||||||
child.nextFlexChild = null;
|
child.nextFlexChild = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We use justifyContent to figure out how to allocate the remaining
|
// We use justifyContent to figure out how to allocate the remaining
|
||||||
// space available
|
// space available
|
||||||
} else if (justifyContent != CSSJustify.FLEX_START) {
|
} else if (justifyContent != CSSJustify.FLEX_START) {
|
||||||
|
@ -659,18 +659,18 @@ public class LayoutEngine {
|
||||||
leadingMainDim = betweenMainDim / 2;
|
leadingMainDim = betweenMainDim / 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// <Loop C> Position elements in the main axis and compute dimensions
|
// <Loop C> Position elements in the main axis and compute dimensions
|
||||||
|
|
||||||
// At this point, all the children have their dimensions set. We need to
|
// At this point, all the children have their dimensions set. We need to
|
||||||
// find their position. In order to do that, we accumulate data in
|
// find their position. In order to do that, we accumulate data in
|
||||||
// variables that are also useful to compute the total dimensions of the
|
// variables that are also useful to compute the total dimensions of the
|
||||||
// container!
|
// container!
|
||||||
mainDim += leadingMainDim;
|
mainDim += leadingMainDim;
|
||||||
|
|
||||||
for (i = firstComplexMain; i < endLine; ++i) {
|
for (i = firstComplexMain; i < endLine; ++i) {
|
||||||
child = node.getChildAt(i);
|
child = node.getChildAt(i);
|
||||||
|
|
||||||
if (child.style.positionType == CSSPositionType.ABSOLUTE &&
|
if (child.style.positionType == CSSPositionType.ABSOLUTE &&
|
||||||
!Float.isNaN(child.style.position[leading[mainAxis]])) {
|
!Float.isNaN(child.style.position[leading[mainAxis]])) {
|
||||||
// In case the child is position absolute and has left/top being
|
// In case the child is position absolute and has left/top being
|
||||||
|
@ -683,12 +683,12 @@ public class LayoutEngine {
|
||||||
// If the child is position absolute (without top/left) or relative,
|
// If the child is position absolute (without top/left) or relative,
|
||||||
// we put it at the current accumulated offset.
|
// we put it at the current accumulated offset.
|
||||||
child.layout.position[pos[mainAxis]] += mainDim;
|
child.layout.position[pos[mainAxis]] += mainDim;
|
||||||
|
|
||||||
// Define the trailing position accordingly.
|
// Define the trailing position accordingly.
|
||||||
if (isMainDimDefined) {
|
if (isMainDimDefined) {
|
||||||
child.layout.position[trailing[mainAxis]] = node.layout.dimensions[dim[mainAxis]] - child.layout.dimensions[dim[mainAxis]] - child.layout.position[pos[mainAxis]];
|
child.layout.position[trailing[mainAxis]] = node.layout.dimensions[dim[mainAxis]] - child.layout.dimensions[dim[mainAxis]] - child.layout.position[pos[mainAxis]];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now that we placed the element, we need to update the variables
|
// Now that we placed the element, we need to update the variables
|
||||||
// We only need to do that for relative elements. Absolute elements
|
// We only need to do that for relative elements. Absolute elements
|
||||||
// do not take part in that phase.
|
// do not take part in that phase.
|
||||||
|
@ -702,7 +702,7 @@ public class LayoutEngine {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float containerCrossAxis = node.layout.dimensions[dim[crossAxis]];
|
float containerCrossAxis = node.layout.dimensions[dim[crossAxis]];
|
||||||
if (!isCrossDimDefined) {
|
if (!isCrossDimDefined) {
|
||||||
containerCrossAxis = Math.max(
|
containerCrossAxis = Math.max(
|
||||||
|
@ -713,11 +713,11 @@ public class LayoutEngine {
|
||||||
paddingAndBorderAxisCross
|
paddingAndBorderAxisCross
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// <Loop D> Position elements in the cross axis
|
// <Loop D> Position elements in the cross axis
|
||||||
for (i = firstComplexCross; i < endLine; ++i) {
|
for (i = firstComplexCross; i < endLine; ++i) {
|
||||||
child = node.getChildAt(i);
|
child = node.getChildAt(i);
|
||||||
|
|
||||||
if (child.style.positionType == CSSPositionType.ABSOLUTE &&
|
if (child.style.positionType == CSSPositionType.ABSOLUTE &&
|
||||||
!Float.isNaN(child.style.position[leading[crossAxis]])) {
|
!Float.isNaN(child.style.position[leading[crossAxis]])) {
|
||||||
// In case the child is absolutely positionned and has a
|
// In case the child is absolutely positionned and has a
|
||||||
|
@ -726,10 +726,10 @@ public class LayoutEngine {
|
||||||
child.layout.position[pos[crossAxis]] = (Float.isNaN(child.style.position[leading[crossAxis]]) ? 0 : child.style.position[leading[crossAxis]]) +
|
child.layout.position[pos[crossAxis]] = (Float.isNaN(child.style.position[leading[crossAxis]]) ? 0 : child.style.position[leading[crossAxis]]) +
|
||||||
node.style.border.getWithFallback(leadingSpacing[crossAxis], leading[crossAxis]) +
|
node.style.border.getWithFallback(leadingSpacing[crossAxis], leading[crossAxis]) +
|
||||||
child.style.margin.getWithFallback(leadingSpacing[crossAxis], leading[crossAxis]);
|
child.style.margin.getWithFallback(leadingSpacing[crossAxis], leading[crossAxis]);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
float leadingCrossDim = leadingPaddingAndBorderCross;
|
float leadingCrossDim = leadingPaddingAndBorderCross;
|
||||||
|
|
||||||
// For a relative children, we're either using alignItems (parent) or
|
// For a relative children, we're either using alignItems (parent) or
|
||||||
// alignSelf (child) in order to determine the position in the cross axis
|
// alignSelf (child) in order to determine the position in the cross axis
|
||||||
if (child.style.positionType == CSSPositionType.RELATIVE) {
|
if (child.style.positionType == CSSPositionType.RELATIVE) {
|
||||||
|
@ -748,7 +748,7 @@ public class LayoutEngine {
|
||||||
// You never want to go smaller than padding
|
// You never want to go smaller than padding
|
||||||
((child.style.padding.getWithFallback(leadingSpacing[crossAxis], leading[crossAxis]) + child.style.border.getWithFallback(leadingSpacing[crossAxis], leading[crossAxis])) + (child.style.padding.getWithFallback(trailingSpacing[crossAxis], trailing[crossAxis]) + child.style.border.getWithFallback(trailingSpacing[crossAxis], trailing[crossAxis])))
|
((child.style.padding.getWithFallback(leadingSpacing[crossAxis], leading[crossAxis]) + child.style.border.getWithFallback(leadingSpacing[crossAxis], leading[crossAxis])) + (child.style.padding.getWithFallback(trailingSpacing[crossAxis], trailing[crossAxis]) + child.style.border.getWithFallback(trailingSpacing[crossAxis], trailing[crossAxis])))
|
||||||
);
|
);
|
||||||
|
|
||||||
// If the size has changed, and this child has children we need to re-layout this child
|
// If the size has changed, and this child has children we need to re-layout this child
|
||||||
if (dimCrossAxis != child.layout.dimensions[dim[crossAxis]] && child.getChildCount() > 0) {
|
if (dimCrossAxis != child.layout.dimensions[dim[crossAxis]] && child.getChildCount() > 0) {
|
||||||
// Reset child margins before re-layout as they are added back in layoutNode and would be doubled
|
// Reset child margins before re-layout as they are added back in layoutNode and would be doubled
|
||||||
|
@ -760,7 +760,7 @@ public class LayoutEngine {
|
||||||
getRelativePosition(child, crossAxis);
|
getRelativePosition(child, crossAxis);
|
||||||
child.layout.position[trailing[crossAxis]] -= child.style.margin.getWithFallback(trailingSpacing[crossAxis], trailing[crossAxis]) +
|
child.layout.position[trailing[crossAxis]] -= child.style.margin.getWithFallback(trailingSpacing[crossAxis], trailing[crossAxis]) +
|
||||||
getRelativePosition(child, crossAxis);
|
getRelativePosition(child, crossAxis);
|
||||||
|
|
||||||
layoutNode(layoutContext, child, maxWidth, maxHeight, direction);
|
layoutNode(layoutContext, child, maxWidth, maxHeight, direction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -769,7 +769,7 @@ public class LayoutEngine {
|
||||||
// dimensions+margin.
|
// dimensions+margin.
|
||||||
float remainingCrossDim = containerCrossAxis -
|
float remainingCrossDim = containerCrossAxis -
|
||||||
paddingAndBorderAxisCross - (child.layout.dimensions[dim[crossAxis]] + child.style.margin.getWithFallback(leadingSpacing[crossAxis], leading[crossAxis]) + child.style.margin.getWithFallback(trailingSpacing[crossAxis], trailing[crossAxis]));
|
paddingAndBorderAxisCross - (child.layout.dimensions[dim[crossAxis]] + child.style.margin.getWithFallback(leadingSpacing[crossAxis], leading[crossAxis]) + child.style.margin.getWithFallback(trailingSpacing[crossAxis], trailing[crossAxis]));
|
||||||
|
|
||||||
if (alignItem == CSSAlign.CENTER) {
|
if (alignItem == CSSAlign.CENTER) {
|
||||||
leadingCrossDim += remainingCrossDim / 2;
|
leadingCrossDim += remainingCrossDim / 2;
|
||||||
} else { // CSSAlign.FLEX_END
|
} else { // CSSAlign.FLEX_END
|
||||||
|
@ -777,23 +777,23 @@ public class LayoutEngine {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// And we apply the position
|
// And we apply the position
|
||||||
child.layout.position[pos[crossAxis]] += linesCrossDim + leadingCrossDim;
|
child.layout.position[pos[crossAxis]] += linesCrossDim + leadingCrossDim;
|
||||||
|
|
||||||
// Define the trailing position accordingly.
|
// Define the trailing position accordingly.
|
||||||
if (isCrossDimDefined) {
|
if (isCrossDimDefined) {
|
||||||
child.layout.position[trailing[crossAxis]] = node.layout.dimensions[dim[crossAxis]] - child.layout.dimensions[dim[crossAxis]] - child.layout.position[pos[crossAxis]];
|
child.layout.position[trailing[crossAxis]] = node.layout.dimensions[dim[crossAxis]] - child.layout.dimensions[dim[crossAxis]] - child.layout.position[pos[crossAxis]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
linesCrossDim += crossDim;
|
linesCrossDim += crossDim;
|
||||||
linesMainDim = Math.max(linesMainDim, mainDim);
|
linesMainDim = Math.max(linesMainDim, mainDim);
|
||||||
linesCount += 1;
|
linesCount += 1;
|
||||||
startLine = endLine;
|
startLine = endLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
// <Loop E>
|
// <Loop E>
|
||||||
//
|
//
|
||||||
// Note(prenaux): More than one line, we need to layout the crossAxis
|
// Note(prenaux): More than one line, we need to layout the crossAxis
|
||||||
|
@ -811,10 +811,10 @@ public class LayoutEngine {
|
||||||
float nodeCrossAxisInnerSize = node.layout.dimensions[dim[crossAxis]] -
|
float nodeCrossAxisInnerSize = node.layout.dimensions[dim[crossAxis]] -
|
||||||
paddingAndBorderAxisCross;
|
paddingAndBorderAxisCross;
|
||||||
float remainingAlignContentDim = nodeCrossAxisInnerSize - linesCrossDim;
|
float remainingAlignContentDim = nodeCrossAxisInnerSize - linesCrossDim;
|
||||||
|
|
||||||
float crossDimLead = 0;
|
float crossDimLead = 0;
|
||||||
float currentLead = leadingPaddingAndBorderCross;
|
float currentLead = leadingPaddingAndBorderCross;
|
||||||
|
|
||||||
CSSAlign alignContent = node.style.alignContent;
|
CSSAlign alignContent = node.style.alignContent;
|
||||||
if (alignContent == CSSAlign.FLEX_END) {
|
if (alignContent == CSSAlign.FLEX_END) {
|
||||||
currentLead += remainingAlignContentDim;
|
currentLead += remainingAlignContentDim;
|
||||||
|
@ -825,11 +825,11 @@ public class LayoutEngine {
|
||||||
crossDimLead = (remainingAlignContentDim / linesCount);
|
crossDimLead = (remainingAlignContentDim / linesCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int endIndex = 0;
|
int endIndex = 0;
|
||||||
for (i = 0; i < linesCount; ++i) {
|
for (i = 0; i < linesCount; ++i) {
|
||||||
int startIndex = endIndex;
|
int startIndex = endIndex;
|
||||||
|
|
||||||
// compute the line's height and find the endIndex
|
// compute the line's height and find the endIndex
|
||||||
float lineHeight = 0;
|
float lineHeight = 0;
|
||||||
for (ii = startIndex; ii < childCount; ++ii) {
|
for (ii = startIndex; ii < childCount; ++ii) {
|
||||||
|
@ -849,13 +849,13 @@ public class LayoutEngine {
|
||||||
}
|
}
|
||||||
endIndex = ii;
|
endIndex = ii;
|
||||||
lineHeight += crossDimLead;
|
lineHeight += crossDimLead;
|
||||||
|
|
||||||
for (ii = startIndex; ii < endIndex; ++ii) {
|
for (ii = startIndex; ii < endIndex; ++ii) {
|
||||||
child = node.getChildAt(ii);
|
child = node.getChildAt(ii);
|
||||||
if (child.style.positionType != CSSPositionType.RELATIVE) {
|
if (child.style.positionType != CSSPositionType.RELATIVE) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
CSSAlign alignContentAlignItem = getAlignItem(node, child);
|
CSSAlign alignContentAlignItem = getAlignItem(node, child);
|
||||||
if (alignContentAlignItem == CSSAlign.FLEX_START) {
|
if (alignContentAlignItem == CSSAlign.FLEX_START) {
|
||||||
child.layout.position[pos[crossAxis]] = currentLead + child.style.margin.getWithFallback(leadingSpacing[crossAxis], leading[crossAxis]);
|
child.layout.position[pos[crossAxis]] = currentLead + child.style.margin.getWithFallback(leadingSpacing[crossAxis], leading[crossAxis]);
|
||||||
|
@ -870,14 +870,14 @@ public class LayoutEngine {
|
||||||
// (auto) crossAxis dimension.
|
// (auto) crossAxis dimension.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
currentLead += lineHeight;
|
currentLead += lineHeight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean needsMainTrailingPos = false;
|
boolean needsMainTrailingPos = false;
|
||||||
boolean needsCrossTrailingPos = false;
|
boolean needsCrossTrailingPos = false;
|
||||||
|
|
||||||
// If the user didn't specify a width or height, and it has not been set
|
// If the user didn't specify a width or height, and it has not been set
|
||||||
// by the container, then we set it via the children.
|
// by the container, then we set it via the children.
|
||||||
if (!isMainDimDefined) {
|
if (!isMainDimDefined) {
|
||||||
|
@ -888,13 +888,13 @@ public class LayoutEngine {
|
||||||
// We can never assign a width smaller than the padding and borders
|
// We can never assign a width smaller than the padding and borders
|
||||||
paddingAndBorderAxisMain
|
paddingAndBorderAxisMain
|
||||||
);
|
);
|
||||||
|
|
||||||
if (mainAxis == CSS_FLEX_DIRECTION_ROW_REVERSE ||
|
if (mainAxis == CSS_FLEX_DIRECTION_ROW_REVERSE ||
|
||||||
mainAxis == CSS_FLEX_DIRECTION_COLUMN_REVERSE) {
|
mainAxis == CSS_FLEX_DIRECTION_COLUMN_REVERSE) {
|
||||||
needsMainTrailingPos = true;
|
needsMainTrailingPos = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isCrossDimDefined) {
|
if (!isCrossDimDefined) {
|
||||||
node.layout.dimensions[dim[crossAxis]] = Math.max(
|
node.layout.dimensions[dim[crossAxis]] = Math.max(
|
||||||
// For the cross dim, we add both sides at the end because the value
|
// For the cross dim, we add both sides at the end because the value
|
||||||
|
@ -903,28 +903,28 @@ public class LayoutEngine {
|
||||||
boundAxis(node, crossAxis, linesCrossDim + paddingAndBorderAxisCross),
|
boundAxis(node, crossAxis, linesCrossDim + paddingAndBorderAxisCross),
|
||||||
paddingAndBorderAxisCross
|
paddingAndBorderAxisCross
|
||||||
);
|
);
|
||||||
|
|
||||||
if (crossAxis == CSS_FLEX_DIRECTION_ROW_REVERSE ||
|
if (crossAxis == CSS_FLEX_DIRECTION_ROW_REVERSE ||
|
||||||
crossAxis == CSS_FLEX_DIRECTION_COLUMN_REVERSE) {
|
crossAxis == CSS_FLEX_DIRECTION_COLUMN_REVERSE) {
|
||||||
needsCrossTrailingPos = true;
|
needsCrossTrailingPos = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// <Loop F> Set trailing position if necessary
|
// <Loop F> Set trailing position if necessary
|
||||||
if (needsMainTrailingPos || needsCrossTrailingPos) {
|
if (needsMainTrailingPos || needsCrossTrailingPos) {
|
||||||
for (i = 0; i < childCount; ++i) {
|
for (i = 0; i < childCount; ++i) {
|
||||||
child = node.getChildAt(i);
|
child = node.getChildAt(i);
|
||||||
|
|
||||||
if (needsMainTrailingPos) {
|
if (needsMainTrailingPos) {
|
||||||
child.layout.position[trailing[mainAxis]] = node.layout.dimensions[dim[mainAxis]] - child.layout.dimensions[dim[mainAxis]] - child.layout.position[pos[mainAxis]];
|
child.layout.position[trailing[mainAxis]] = node.layout.dimensions[dim[mainAxis]] - child.layout.dimensions[dim[mainAxis]] - child.layout.position[pos[mainAxis]];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (needsCrossTrailingPos) {
|
if (needsCrossTrailingPos) {
|
||||||
child.layout.position[trailing[crossAxis]] = node.layout.dimensions[dim[crossAxis]] - child.layout.dimensions[dim[crossAxis]] - child.layout.position[pos[crossAxis]];
|
child.layout.position[trailing[crossAxis]] = node.layout.dimensions[dim[crossAxis]] - child.layout.dimensions[dim[crossAxis]] - child.layout.position[pos[crossAxis]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// <Loop G> Calculate dimensions for absolutely positioned elements
|
// <Loop G> Calculate dimensions for absolutely positioned elements
|
||||||
currentAbsoluteChild = firstAbsoluteChild;
|
currentAbsoluteChild = firstAbsoluteChild;
|
||||||
while (currentAbsoluteChild != null) {
|
while (currentAbsoluteChild != null) {
|
||||||
|
@ -932,7 +932,7 @@ public class LayoutEngine {
|
||||||
// the axis are defined (either both left and right or top and bottom).
|
// the axis are defined (either both left and right or top and bottom).
|
||||||
for (ii = 0; ii < 2; ii++) {
|
for (ii = 0; ii < 2; ii++) {
|
||||||
axis = (ii != 0) ? CSS_FLEX_DIRECTION_ROW : CSS_FLEX_DIRECTION_COLUMN;
|
axis = (ii != 0) ? CSS_FLEX_DIRECTION_ROW : CSS_FLEX_DIRECTION_COLUMN;
|
||||||
|
|
||||||
if ((!Float.isNaN(node.layout.dimensions[dim[axis]]) && node.layout.dimensions[dim[axis]] >= 0.0) &&
|
if ((!Float.isNaN(node.layout.dimensions[dim[axis]]) && node.layout.dimensions[dim[axis]] >= 0.0) &&
|
||||||
!(!Float.isNaN(currentAbsoluteChild.style.dimensions[dim[axis]]) && currentAbsoluteChild.style.dimensions[dim[axis]] >= 0.0) &&
|
!(!Float.isNaN(currentAbsoluteChild.style.dimensions[dim[axis]]) && currentAbsoluteChild.style.dimensions[dim[axis]] >= 0.0) &&
|
||||||
!Float.isNaN(currentAbsoluteChild.style.position[leading[axis]]) &&
|
!Float.isNaN(currentAbsoluteChild.style.position[leading[axis]]) &&
|
||||||
|
@ -948,7 +948,7 @@ public class LayoutEngine {
|
||||||
((currentAbsoluteChild.style.padding.getWithFallback(leadingSpacing[axis], leading[axis]) + currentAbsoluteChild.style.border.getWithFallback(leadingSpacing[axis], leading[axis])) + (currentAbsoluteChild.style.padding.getWithFallback(trailingSpacing[axis], trailing[axis]) + currentAbsoluteChild.style.border.getWithFallback(trailingSpacing[axis], trailing[axis])))
|
((currentAbsoluteChild.style.padding.getWithFallback(leadingSpacing[axis], leading[axis]) + currentAbsoluteChild.style.border.getWithFallback(leadingSpacing[axis], leading[axis])) + (currentAbsoluteChild.style.padding.getWithFallback(trailingSpacing[axis], trailing[axis]) + currentAbsoluteChild.style.border.getWithFallback(trailingSpacing[axis], trailing[axis])))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Float.isNaN(currentAbsoluteChild.style.position[trailing[axis]]) &&
|
if (!Float.isNaN(currentAbsoluteChild.style.position[trailing[axis]]) &&
|
||||||
!!Float.isNaN(currentAbsoluteChild.style.position[leading[axis]])) {
|
!!Float.isNaN(currentAbsoluteChild.style.position[leading[axis]])) {
|
||||||
currentAbsoluteChild.layout.position[leading[axis]] =
|
currentAbsoluteChild.layout.position[leading[axis]] =
|
||||||
|
@ -957,7 +957,7 @@ public class LayoutEngine {
|
||||||
(Float.isNaN(currentAbsoluteChild.style.position[trailing[axis]]) ? 0 : currentAbsoluteChild.style.position[trailing[axis]]);
|
(Float.isNaN(currentAbsoluteChild.style.position[trailing[axis]]) ? 0 : currentAbsoluteChild.style.position[trailing[axis]]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
child = currentAbsoluteChild;
|
child = currentAbsoluteChild;
|
||||||
currentAbsoluteChild = currentAbsoluteChild.nextAbsoluteChild;
|
currentAbsoluteChild = currentAbsoluteChild.nextAbsoluteChild;
|
||||||
child.nextAbsoluteChild = null;
|
child.nextAbsoluteChild = null;
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class Prerequisites {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Code is simplified version of getDetectedVersion()
|
// Code is simplified version of getDetectedVersion()
|
||||||
// from cts/tests/tests/graphics/src/android/opengl/cts/OpenGlEsVersionTest.java
|
// from cts/tests/tests/graphics/src/android/opengl/cts/OpenGlEsVersionTest.java
|
||||||
static public boolean supportsOpenGL20() {
|
static public boolean supportsOpenGL20() {
|
||||||
EGL10 egl = (EGL10) EGLContext.getEGL();
|
EGL10 egl = (EGL10) EGLContext.getEGL();
|
||||||
EGLDisplay display = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
|
EGLDisplay display = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class ToastModule extends ReactContextBaseJavaModule {
|
||||||
UiThreadUtil.runOnUiThread(new Runnable() {
|
UiThreadUtil.runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run(){
|
public void run(){
|
||||||
Toast.makeText(getReactApplicationContext(), message, duration).show();
|
Toast.makeText(getReactApplicationContext(), message, duration).show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ public abstract class BaseViewManager<T extends View, C extends LayoutShadowNode
|
||||||
public void setOpacity(T view, float opacity) {
|
public void setOpacity(T view, float opacity) {
|
||||||
view.setAlpha(opacity);
|
view.setAlpha(opacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ReactProp(name = PROP_ELEVATION)
|
@ReactProp(name = PROP_ELEVATION)
|
||||||
public void setElevation(T view, float elevation) {
|
public void setElevation(T view, float elevation) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||||
|
|
|
@ -731,7 +731,7 @@ public class UIImplementation {
|
||||||
absoluteY,
|
absoluteY,
|
||||||
mOperationsQueue,
|
mOperationsQueue,
|
||||||
mNativeViewHierarchyOptimizer);
|
mNativeViewHierarchyOptimizer);
|
||||||
|
|
||||||
// notify JS about layout event if requested
|
// notify JS about layout event if requested
|
||||||
if (cssNode.shouldNotifyOnLayout()) {
|
if (cssNode.shouldNotifyOnLayout()) {
|
||||||
eventDispatcher.dispatchEvent(
|
eventDispatcher.dispatchEvent(
|
||||||
|
|
|
@ -267,7 +267,7 @@ public class ReactWebViewManager extends SimpleViewManager<WebView> {
|
||||||
public void setDomStorageEnabled(WebView view, boolean enabled) {
|
public void setDomStorageEnabled(WebView view, boolean enabled) {
|
||||||
view.getSettings().setDomStorageEnabled(enabled);
|
view.getSettings().setDomStorageEnabled(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ReactProp(name = "userAgent")
|
@ReactProp(name = "userAgent")
|
||||||
public void setUserAgent(WebView view, @Nullable String userAgent) {
|
public void setUserAgent(WebView view, @Nullable String userAgent) {
|
||||||
|
|
|
@ -44,13 +44,13 @@
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ANDROID
|
#ifdef ANDROID
|
||||||
#include <android/log.h>
|
#include <android/log.h>
|
||||||
#else
|
#else
|
||||||
// These declarations are needed for our internal use even on non-Android builds.
|
// These declarations are needed for our internal use even on non-Android builds.
|
||||||
// (they are borrowed from <android/log.h>)
|
// (they are borrowed from <android/log.h>)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Android log priority values, in ascending priority order.
|
* Android log priority values, in ascending priority order.
|
||||||
*/
|
*/
|
||||||
|
@ -65,12 +65,12 @@ extern "C" {
|
||||||
ANDROID_LOG_FATAL,
|
ANDROID_LOG_FATAL,
|
||||||
ANDROID_LOG_SILENT, /* only for SetMinPriority(); must be last */
|
ANDROID_LOG_SILENT, /* only for SetMinPriority(); must be last */
|
||||||
} android_LogPriority;
|
} android_LogPriority;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Send a simple string to the log.
|
* Send a simple string to the log.
|
||||||
*/
|
*/
|
||||||
int __android_log_write(int prio, const char *tag, const char *text);
|
int __android_log_write(int prio, const char *tag, const char *text);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Send a formatted string to the log, used like printf(fmt,...)
|
* Send a formatted string to the log, used like printf(fmt,...)
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -103,7 +103,7 @@ static void lastResort(const char* tag, const char* msg, const char* arg = nullp
|
||||||
} else {
|
} else {
|
||||||
__android_log_print(ANDROID_LOG_ERROR, tag, "%s: %s", msg, arg);
|
__android_log_print(ANDROID_LOG_ERROR, tag, "%s: %s", msg, arg);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
std::cerr << msg;
|
std::cerr << msg;
|
||||||
if (arg) {
|
if (arg) {
|
||||||
std::cerr << ": " << arg;
|
std::cerr << ": " << arg;
|
||||||
|
|
|
@ -41,7 +41,7 @@ void setCountableForJava(JNIEnv* env, jobject obj, RefPtr<Countable>&& countable
|
||||||
*
|
*
|
||||||
* This method deletes the corresponding native object on whatever thread the method is called
|
* This method deletes the corresponding native object on whatever thread the method is called
|
||||||
* on. In the common case when this is called by Countable#finalize(), this will be called on the
|
* on. In the common case when this is called by Countable#finalize(), this will be called on the
|
||||||
* system finalizer thread. If you manually call dispose on the Java object, the native object
|
* system finalizer thread. If you manually call dispose on the Java object, the native object
|
||||||
* will be deleted synchronously on that thread.
|
* will be deleted synchronously on that thread.
|
||||||
*/
|
*/
|
||||||
void dispose(JNIEnv* env, jobject obj) {
|
void dispose(JNIEnv* env, jobject obj) {
|
||||||
|
|
|
@ -27,7 +27,7 @@ struct LocalReferenceDeleter {
|
||||||
if (localReference != nullptr) {
|
if (localReference != nullptr) {
|
||||||
Environment::current()->DeleteLocalRef(localReference);
|
Environment::current()->DeleteLocalRef(localReference);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
|
|
|
@ -227,7 +227,7 @@ void JSCExecutor::loadApplicationScript(
|
||||||
#else
|
#else
|
||||||
String jsScript = String::createExpectingAscii(script);
|
String jsScript = String::createExpectingAscii(script);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ReactMarker::logMarker("loadApplicationScript_endStringConvert");
|
ReactMarker::logMarker("loadApplicationScript_endStringConvert");
|
||||||
|
|
||||||
String jsSourceURL(sourceURL.c_str());
|
String jsSourceURL(sourceURL.c_str());
|
||||||
|
|
|
@ -162,13 +162,13 @@ class ReactView: UIView {
|
||||||
|
|
||||||
let rootView: RCTRootView = RCTRootView(bundleURL: NSURL(string: "http://localhost:8081/index.ios.bundle?platform=ios"),
|
let rootView: RCTRootView = RCTRootView(bundleURL: NSURL(string: "http://localhost:8081/index.ios.bundle?platform=ios"),
|
||||||
moduleName: "SimpleApp", initialProperties: nil, launchOptions: nil)
|
moduleName: "SimpleApp", initialProperties: nil, launchOptions: nil)
|
||||||
|
|
||||||
override func layoutSubviews() {
|
override func layoutSubviews() {
|
||||||
super.layoutSubviews()
|
super.layoutSubviews()
|
||||||
|
|
||||||
loadReact()
|
loadReact()
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadReact () {
|
func loadReact () {
|
||||||
addSubview(rootView)
|
addSubview(rootView)
|
||||||
rootView.frame = self.bounds
|
rootView.frame = self.bounds
|
||||||
|
|
|
@ -57,7 +57,7 @@ sudo npm install -g flow-bin
|
||||||
|
|
||||||
## Setting up an Android Device
|
## Setting up an Android Device
|
||||||
|
|
||||||
Let's set up an Android device to run our starter project.
|
Let's set up an Android device to run our starter project.
|
||||||
|
|
||||||
First thing is to plug in your device and check the manufacturer code by using `lsusb`, which should output something like this:
|
First thing is to plug in your device and check the manufacturer code by using `lsusb`, which should output something like this:
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ First thing is to plug in your device and check the manufacturer code by using `
|
||||||
$ lsusb
|
$ lsusb
|
||||||
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
|
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
|
||||||
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
|
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
|
||||||
Bus 001 Device 003: ID 22b8:2e76 Motorola PCS
|
Bus 001 Device 003: ID 22b8:2e76 Motorola PCS
|
||||||
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
|
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
|
||||||
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
|
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
|
||||||
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
|
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
|
||||||
|
@ -90,7 +90,7 @@ You'll see that after removing the phone, the line which has the phone model ("M
|
||||||
|
|
||||||
From the above line, you want to grab the first four digits from the device ID:
|
From the above line, you want to grab the first four digits from the device ID:
|
||||||
|
|
||||||
`22b8:2e76`
|
`22b8:2e76`
|
||||||
|
|
||||||
In this case, it's `22b8`. That's the identifier for Motorola.
|
In this case, it's `22b8`. That's the identifier for Motorola.
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ Examples: [#6378](https://github.com/facebook/react-native/issues/6378), [#6015]
|
||||||
Feel free to also answer some [SO questions](stackoverflow.com/questions/tagged/react-native), you'll get rep :)
|
Feel free to also answer some [SO questions](stackoverflow.com/questions/tagged/react-native), you'll get rep :)
|
||||||
|
|
||||||
### An issue is a question that's been answered
|
### An issue is a question that's been answered
|
||||||
Sometimes and issue has been resolved in the comments.
|
Sometimes and issue has been resolved in the comments.
|
||||||
Comment `@facebook-github-bot answered` to close it.
|
Comment `@facebook-github-bot answered` to close it.
|
||||||
Example: [#6045](https://github.com/facebook/react-native/issues/6045)
|
Example: [#6045](https://github.com/facebook/react-native/issues/6045)
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ Browser
|
||||||
* [XMLHttpRequest, fetch](/react-native/docs/network.html#content)
|
* [XMLHttpRequest, fetch](/react-native/docs/network.html#content)
|
||||||
* [{set, clear}{Timeout, Interval, Immediate}, {request, cancel}AnimationFrame](/react-native/docs/timers.html#content)
|
* [{set, clear}{Timeout, Interval, Immediate}, {request, cancel}AnimationFrame](/react-native/docs/timers.html#content)
|
||||||
* [navigator.geolocation](/react-native/docs/geolocation.html#content)
|
* [navigator.geolocation](/react-native/docs/geolocation.html#content)
|
||||||
|
|
||||||
ES6
|
ES6
|
||||||
|
|
||||||
* [Object.assign](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign)
|
* [Object.assign](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign)
|
||||||
|
|
|
@ -9,7 +9,7 @@ next: tutorial
|
||||||
|
|
||||||
__NOTE: This guide focuses on Android development. You'll need a Mac to build iOS apps.__
|
__NOTE: This guide focuses on Android development. You'll need a Mac to build iOS apps.__
|
||||||
|
|
||||||
As React Native on iOS requires a Mac and most of the engineers at Facebook and contributors use Macs, support for OS X is a top priority. However, we would like to support developers using Linux and Windows too. We believe we'll get the best Linux and Windows support from people using these operating systems on a daily basis.
|
As React Native on iOS requires a Mac and most of the engineers at Facebook and contributors use Macs, support for OS X is a top priority. However, we would like to support developers using Linux and Windows too. We believe we'll get the best Linux and Windows support from people using these operating systems on a daily basis.
|
||||||
|
|
||||||
Therefore, Linux and Windows support for the development environment is an ongoing community responsibility. This can mean filing issues and submitting PRs, and we'll help review and merge them. We are looking forward to your contributions and appreciate your patience.
|
Therefore, Linux and Windows support for the development environment is an ongoing community responsibility. This can mean filing issues and submitting PRs, and we'll help review and merge them. We are looking forward to your contributions and appreciate your patience.
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ As of **version 0.14** Android development with React native is mostly possible
|
||||||
## What's missing on Windows
|
## What's missing on Windows
|
||||||
|
|
||||||
On Windows the packager won't be started automatically when you run `react-native run-android`. You can start it manually using:
|
On Windows the packager won't be started automatically when you run `react-native run-android`. You can start it manually using:
|
||||||
|
|
||||||
cd MyAwesomeApp
|
cd MyAwesomeApp
|
||||||
react-native start
|
react-native start
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ Behind the scenes, this is going to be converted to a flat `NSAttributedString`
|
||||||
|
|
||||||
## Containers
|
## Containers
|
||||||
|
|
||||||
The `<Text>` element is special relative to layout: everything inside is no longer using the flexbox layout but using text layout. This means that elements inside of a `<Text>` are no longer rectangles, but wrap when they see the end of the line.
|
The `<Text>` element is special relative to layout: everything inside is no longer using the flexbox layout but using text layout. This means that elements inside of a `<Text>` are no longer rectangles, but wrap when they see the end of the line.
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
<Text>
|
<Text>
|
||||||
|
|
|
@ -219,7 +219,7 @@ Add some initial state to our application so that we can check `this.state.movie
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
movies: null,
|
movies: null,
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* This source code is licensed under the BSD-style license found in the
|
* This source code is licensed under the BSD-style license found in the
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
* LICENSE file in the root directory of this source tree. An additional grant
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
*
|
*
|
||||||
* @flow
|
* @flow
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -18,13 +18,13 @@ function parseDevicesResult(result: string): Array<string> {
|
||||||
if (!result) {
|
if (!result) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
const devices = [];
|
const devices = [];
|
||||||
const lines = result.trim().split(/\r?\n/);
|
const lines = result.trim().split(/\r?\n/);
|
||||||
|
|
||||||
for (let i=0; i < lines.length; i++) {
|
for (let i=0; i < lines.length; i++) {
|
||||||
let words = lines[i].split(/[ ,\t]+/).filter((w) => w !== '');
|
let words = lines[i].split(/[ ,\t]+/).filter((w) => w !== '');
|
||||||
|
|
||||||
if (words[1] === 'device') {
|
if (words[1] === 'device') {
|
||||||
devices.push(words[0]);
|
devices.push(words[0]);
|
||||||
}
|
}
|
||||||
|
@ -42,8 +42,8 @@ function getDevices(): Array<string> {
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
|
@ -120,7 +120,7 @@ function buildAndRun(args, reject) {
|
||||||
: 'adb';
|
: 'adb';
|
||||||
|
|
||||||
const devices = adb.getDevices();
|
const devices = adb.getDevices();
|
||||||
|
|
||||||
if (devices && devices.length > 0) {
|
if (devices && devices.length > 0) {
|
||||||
devices.forEach((device) => {
|
devices.forEach((device) => {
|
||||||
|
|
||||||
|
@ -130,8 +130,8 @@ function buildAndRun(args, reject) {
|
||||||
`Starting the app on ${device} (${adbPath} ${adbArgs.join(' ')})...`
|
`Starting the app on ${device} (${adbPath} ${adbArgs.join(' ')})...`
|
||||||
));
|
));
|
||||||
|
|
||||||
child_process.spawnSync(adbPath, adbArgs, {stdio: 'inherit'});
|
child_process.spawnSync(adbPath, adbArgs, {stdio: 'inherit'});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// If we cannot execute based on adb devices output, fall back to
|
// If we cannot execute based on adb devices output, fall back to
|
||||||
// shell am start
|
// shell am start
|
||||||
|
|
|
@ -14,11 +14,11 @@ case "$CONFIGURATION" in
|
||||||
Debug)
|
Debug)
|
||||||
# Speed up build times by skipping the creation of the offline package for debug
|
# Speed up build times by skipping the creation of the offline package for debug
|
||||||
# builds on the simulator since the packager is supposed to be running anyways.
|
# builds on the simulator since the packager is supposed to be running anyways.
|
||||||
if [[ "$PLATFORM_NAME" = "iphonesimulator" ]]; then
|
if [[ "$PLATFORM_NAME" = "iphonesimulator" ]]; then
|
||||||
echo "Skipping bundling for Simulator platform"
|
echo "Skipping bundling for Simulator platform"
|
||||||
exit 0;
|
exit 0;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
DEV=true
|
DEV=true
|
||||||
;;
|
;;
|
||||||
"")
|
"")
|
||||||
|
|
|
@ -77,7 +77,7 @@ if (!String.prototype.includes) {
|
||||||
if (typeof start !== 'number') {
|
if (typeof start !== 'number') {
|
||||||
start = 0;
|
start = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (start + search.length > this.length) {
|
if (start + search.length > this.length) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -48,10 +48,10 @@ var index = React.createClass({
|
||||||
<Prism>
|
<Prism>
|
||||||
{`// iOS
|
{`// iOS
|
||||||
|
|
||||||
import React, {
|
import React, {
|
||||||
Component,
|
Component,
|
||||||
TabBarIOS,
|
TabBarIOS,
|
||||||
NavigatorIOS
|
NavigatorIOS
|
||||||
} from 'react-native';
|
} from 'react-native';
|
||||||
|
|
||||||
class App extends Component {
|
class App extends Component {
|
||||||
|
@ -70,11 +70,11 @@ class App extends Component {
|
||||||
<Prism>
|
<Prism>
|
||||||
{`// Android
|
{`// Android
|
||||||
|
|
||||||
import React, {
|
import React, {
|
||||||
Component,
|
Component,
|
||||||
DrawerLayoutAndroid,
|
DrawerLayoutAndroid,
|
||||||
ProgressBarAndroid,
|
ProgressBarAndroid,
|
||||||
Text
|
Text
|
||||||
} from 'react-native';
|
} from 'react-native';
|
||||||
|
|
||||||
class App extends Component {
|
class App extends Component {
|
||||||
|
@ -105,7 +105,7 @@ class App extends Component {
|
||||||
<Prism>
|
<Prism>
|
||||||
{`// iOS & Android
|
{`// iOS & Android
|
||||||
|
|
||||||
import React, {
|
import React, {
|
||||||
Component,
|
Component,
|
||||||
ScrollView,
|
ScrollView,
|
||||||
TouchableHighlight,
|
TouchableHighlight,
|
||||||
|
@ -134,10 +134,10 @@ class TouchDemo extends Component {
|
||||||
|
|
||||||
var React, {
|
var React, {
|
||||||
Component,
|
Component,
|
||||||
Image,
|
Image,
|
||||||
StyleSheet,
|
StyleSheet,
|
||||||
Text,
|
Text,
|
||||||
View
|
View
|
||||||
} from 'react-native';
|
} from 'react-native';
|
||||||
|
|
||||||
class ReactNative extends Component {
|
class ReactNative extends Component {
|
||||||
|
@ -176,9 +176,9 @@ var styles = StyleSheet.create({
|
||||||
<Prism>
|
<Prism>
|
||||||
{`// iOS & Android
|
{`// iOS & Android
|
||||||
|
|
||||||
import React, {
|
import React, {
|
||||||
Component,
|
Component,
|
||||||
Text
|
Text
|
||||||
} from 'react-native';
|
} from 'react-native';
|
||||||
|
|
||||||
class GeoInfo extends Component {
|
class GeoInfo extends Component {
|
||||||
|
@ -283,7 +283,7 @@ RCT_EXPORT_VIEW_PROPERTY(myCustomProperty, NSString);
|
||||||
<Prism>
|
<Prism>
|
||||||
{`// JavaScript
|
{`// JavaScript
|
||||||
|
|
||||||
import React, {
|
import React, {
|
||||||
Component,
|
Component,
|
||||||
requireNativeComponent
|
requireNativeComponent
|
||||||
} from 'react-native';
|
} from 'react-native';
|
||||||
|
@ -379,7 +379,7 @@ public class MyCustomViewManager extends SimpleViewManager<MyCustomView> {
|
||||||
|
|
||||||
import React, {
|
import React, {
|
||||||
Component,
|
Component,
|
||||||
requireNativeComponent
|
requireNativeComponent
|
||||||
} from 'react-native';
|
} from 'react-native';
|
||||||
|
|
||||||
var NativeMyCustomView = requireNativeComponent('MyCustomView', MyCustomView);
|
var NativeMyCustomView = requireNativeComponent('MyCustomView', MyCustomView);
|
||||||
|
|
Loading…
Reference in New Issue