Change CLK prefix on static functions to CSS.
Summary: Talked with emilsjolander offline, and we want to keep the prefixes standardized in this lib. Changing CLK prefixes to CSS. Reviewed By: emilsjolander Differential Revision: D4175634 fbshipit-source-id: 7152268b9312df3fdb8eaee7ce3f6baabc5de937
This commit is contained in:
committed by
Facebook Github Bot
parent
204aba80b9
commit
129437f49e
@@ -162,7 +162,7 @@
|
|||||||
NSAssert([NSThread isMainThread], @"CSS Layout calculation must be done on main.");
|
NSAssert([NSThread isMainThread], @"CSS Layout calculation must be done on main.");
|
||||||
NSAssert([self css_usesFlexbox], @"CSS Layout is not enabled for this view.");
|
NSAssert([self css_usesFlexbox], @"CSS Layout is not enabled for this view.");
|
||||||
|
|
||||||
CLKAttachNodesFromViewHierachy(self);
|
CSSAttachNodesFromViewHierachy(self);
|
||||||
|
|
||||||
const CSSNodeRef node = [self cssNode];
|
const CSSNodeRef node = [self cssNode];
|
||||||
CSSNodeCalculateLayout(
|
CSSNodeCalculateLayout(
|
||||||
@@ -180,7 +180,7 @@
|
|||||||
- (void)css_applyLayout
|
- (void)css_applyLayout
|
||||||
{
|
{
|
||||||
[self css_sizeThatFits:self.bounds.size];
|
[self css_sizeThatFits:self.bounds.size];
|
||||||
CLKApplyLayoutToViewHierarchy(self);
|
CSSApplyLayoutToViewHierarchy(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - Private
|
#pragma mark - Private
|
||||||
@@ -197,7 +197,7 @@
|
|||||||
return node.cnode;
|
return node.cnode;
|
||||||
}
|
}
|
||||||
|
|
||||||
static CSSSize CLKMeasureView(
|
static CSSSize CSSMeasureView(
|
||||||
CSSNodeRef node,
|
CSSNodeRef node,
|
||||||
float width,
|
float width,
|
||||||
CSSMeasureMode widthMode,
|
CSSMeasureMode widthMode,
|
||||||
@@ -214,12 +214,12 @@ static CSSSize CLKMeasureView(
|
|||||||
}];
|
}];
|
||||||
|
|
||||||
return (CSSSize) {
|
return (CSSSize) {
|
||||||
.width = CLKSanitizeMeasurement(constrainedWidth, sizeThatFits.width, widthMode),
|
.width = CSSSanitizeMeasurement(constrainedWidth, sizeThatFits.width, widthMode),
|
||||||
.height = CLKSanitizeMeasurement(constrainedHeight, sizeThatFits.height, heightMode),
|
.height = CSSSanitizeMeasurement(constrainedHeight, sizeThatFits.height, heightMode),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
static CGFloat CLKSanitizeMeasurement(
|
static CGFloat CSSSanitizeMeasurement(
|
||||||
CGFloat constrainedSize,
|
CGFloat constrainedSize,
|
||||||
CGFloat measuredSize,
|
CGFloat measuredSize,
|
||||||
CSSMeasureMode measureMode)
|
CSSMeasureMode measureMode)
|
||||||
@@ -236,14 +236,14 @@ static CGFloat CLKSanitizeMeasurement(
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CLKAttachNodesFromViewHierachy(UIView *view) {
|
static void CSSAttachNodesFromViewHierachy(UIView *view) {
|
||||||
CSSNodeRef node = [view cssNode];
|
CSSNodeRef node = [view cssNode];
|
||||||
const BOOL usesFlexbox = [view css_usesFlexbox];
|
const BOOL usesFlexbox = [view css_usesFlexbox];
|
||||||
const BOOL isLeaf = !usesFlexbox || view.subviews.count == 0;
|
const BOOL isLeaf = !usesFlexbox || view.subviews.count == 0;
|
||||||
|
|
||||||
// Only leaf nodes should have a measure function
|
// Only leaf nodes should have a measure function
|
||||||
if (isLeaf) {
|
if (isLeaf) {
|
||||||
CSSNodeSetMeasureFunc(node, CLKMeasureView);
|
CSSNodeSetMeasureFunc(node, CSSMeasureView);
|
||||||
|
|
||||||
// Clear any children
|
// Clear any children
|
||||||
while (CSSNodeChildCount(node) > 0) {
|
while (CSSNodeChildCount(node) > 0) {
|
||||||
@@ -258,7 +258,7 @@ static void CLKAttachNodesFromViewHierachy(UIView *view) {
|
|||||||
if (CSSNodeChildCount(node) < i + 1 || CSSNodeGetChild(node, i) != childNode) {
|
if (CSSNodeChildCount(node) < i + 1 || CSSNodeGetChild(node, i) != childNode) {
|
||||||
CSSNodeInsertChild(node, childNode, i);
|
CSSNodeInsertChild(node, childNode, i);
|
||||||
}
|
}
|
||||||
CLKAttachNodesFromViewHierachy(view.subviews[i]);
|
CSSAttachNodesFromViewHierachy(view.subviews[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove any children which were removed since the last call to css_applyLayout
|
// Remove any children which were removed since the last call to css_applyLayout
|
||||||
@@ -268,7 +268,7 @@ static void CLKAttachNodesFromViewHierachy(UIView *view) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static CGFloat CLKRoundPixelValue(CGFloat value)
|
static CGFloat CSSRoundPixelValue(CGFloat value)
|
||||||
{
|
{
|
||||||
static CGFloat scale;
|
static CGFloat scale;
|
||||||
static dispatch_once_t onceToken;
|
static dispatch_once_t onceToken;
|
||||||
@@ -279,7 +279,7 @@ static CGFloat CLKRoundPixelValue(CGFloat value)
|
|||||||
return round(value * scale) / scale;
|
return round(value * scale) / scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CLKApplyLayoutToViewHierarchy(UIView *view) {
|
static void CSSApplyLayoutToViewHierarchy(UIView *view) {
|
||||||
NSCAssert([NSThread isMainThread], @"Framesetting should only be done on the main thread.");
|
NSCAssert([NSThread isMainThread], @"Framesetting should only be done on the main thread.");
|
||||||
CSSNodeRef node = [view cssNode];
|
CSSNodeRef node = [view cssNode];
|
||||||
|
|
||||||
@@ -295,19 +295,19 @@ static void CLKApplyLayoutToViewHierarchy(UIView *view) {
|
|||||||
|
|
||||||
view.frame = (CGRect) {
|
view.frame = (CGRect) {
|
||||||
.origin = {
|
.origin = {
|
||||||
.x = CLKRoundPixelValue(topLeft.x),
|
.x = CSSRoundPixelValue(topLeft.x),
|
||||||
.y = CLKRoundPixelValue(topLeft.y),
|
.y = CSSRoundPixelValue(topLeft.y),
|
||||||
},
|
},
|
||||||
.size = {
|
.size = {
|
||||||
.width = CLKRoundPixelValue(bottomRight.x) - CLKRoundPixelValue(topLeft.x),
|
.width = CSSRoundPixelValue(bottomRight.x) - CSSRoundPixelValue(topLeft.x),
|
||||||
.height = CLKRoundPixelValue(bottomRight.y) - CLKRoundPixelValue(topLeft.y),
|
.height = CSSRoundPixelValue(bottomRight.y) - CSSRoundPixelValue(topLeft.y),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const BOOL isLeaf = ![view css_usesFlexbox] || view.subviews.count == 0;
|
const BOOL isLeaf = ![view css_usesFlexbox] || view.subviews.count == 0;
|
||||||
if (!isLeaf) {
|
if (!isLeaf) {
|
||||||
for (NSUInteger i = 0; i < view.subviews.count; i++) {
|
for (NSUInteger i = 0; i < view.subviews.count; i++) {
|
||||||
CLKApplyLayoutToViewHierarchy(view.subviews[i]);
|
CSSApplyLayoutToViewHierarchy(view.subviews[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user