From c03cbceb42aab052ca61dc2d7b4d334d08e1935b Mon Sep 17 00:00:00 2001 From: rh389 Date: Wed, 24 Aug 2016 10:40:32 -0700 Subject: [PATCH] Use quote style for local includes Summary: This PR changes `#include ` to `#include "*.h"` within the `CSSLayout` directory. Rationale: Quote includes are preferred for user (aka local/project) includes, whereas angle includes are preferred for standard libraries and external frameworks. In particular, XCode 7.1+ will not search user paths (even the current directory) when angle brackets are used unless "Always search user paths" is enabled - it is off by default and [Apple recommend](https://developer.apple.com/library/mac/documentation/DeveloperTools/Reference/XcodeBuildSettingRef/1-Build_Setting_Reference/build_setting_ref.html#//apple_ref/doc/uid/TP40003931-CH3-SW110) that it is only enabled for backwards compatibility. I think this is the best fix for https://github.com/facebook/react-native/issues/9014, and seems like good practice in any case. Closes https://github.com/facebook/css-layout/pull/217 Reviewed By: majak Differential Revision: D3764132 Pulled By: emilsjolander fbshipit-source-id: c8a6e8d19db71455922e3ba8f6c72bd66018fa84 --- React/CSSLayout/CSSLayout-internal.h | 93 ++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 React/CSSLayout/CSSLayout-internal.h diff --git a/React/CSSLayout/CSSLayout-internal.h b/React/CSSLayout/CSSLayout-internal.h new file mode 100644 index 00000000000000..da417da357bae8 --- /dev/null +++ b/React/CSSLayout/CSSLayout-internal.h @@ -0,0 +1,93 @@ +/** + * Copyright (c) 2014-present, Facebook, Inc. + * All rights reserved. + * + * 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 + * of patent rights can be found in the PATENTS file in the same directory. + */ + +#pragma once + +#include "CSSLayout.h" +#include "CSSNodeList.h" + +CSS_EXTERN_C_BEGIN + +typedef struct CSSCachedMeasurement { + float availableWidth; + float availableHeight; + CSSMeasureMode widthMeasureMode; + CSSMeasureMode heightMeasureMode; + + float computedWidth; + float computedHeight; +} CSSCachedMeasurement; + +// This value was chosen based on empiracle data. Even the most complicated +// layouts should not require more than 16 entries to fit within the cache. +enum { CSS_MAX_CACHED_RESULT_COUNT = 16 }; + +typedef struct CSSLayout { + float position[4]; + float dimensions[2]; + CSSDirection direction; + + float computedFlexBasis; + + // Instead of recomputing the entire layout every single time, we + // cache some information to break early when nothing changed + uint32_t generationCount; + CSSDirection lastParentDirection; + + uint32_t nextCachedMeasurementsIndex; + CSSCachedMeasurement cachedMeasurements[CSS_MAX_CACHED_RESULT_COUNT]; + float measuredDimensions[2]; + + CSSCachedMeasurement cached_layout; +} CSSLayout; + +typedef struct CSSStyle { + CSSDirection direction; + CSSFlexDirection flexDirection; + CSSJustify justifyContent; + CSSAlign alignContent; + CSSAlign alignItems; + CSSAlign alignSelf; + CSSPositionType positionType; + CSSWrapType flexWrap; + CSSOverflow overflow; + float flexGrow; + float flexShrink; + float flexBasis; + float margin[CSSEdgeCount]; + float position[CSSEdgeCount]; + float padding[CSSEdgeCount]; + float border[CSSEdgeCount]; + float dimensions[2]; + float minDimensions[2]; + float maxDimensions[2]; +} CSSStyle; + +typedef struct CSSNode { + CSSStyle style; + CSSLayout layout; + uint32_t lineIndex; + bool hasNewLayout; + bool isTextNode; + CSSNodeRef parent; + CSSNodeListRef children; + bool isDirty; + + struct CSSNode *nextChild; + + CSSSize (*measure)(void *context, + float width, + CSSMeasureMode widthMode, + float height, + CSSMeasureMode heightMode); + void (*print)(void *context); + void *context; +} CSSNode; + +CSS_EXTERN_C_END