YGStyle
: wrap all fields into accessors
Summary: @public In order to encapsulate property access on `YGStyle`, as a first measure we wrap all fields with accessors. This will e.g. enable dynamic property storage and instrumentation in the future. All accessors have a `const` version that allows direct access via `const&`. For mutation, bit fields are wrapped with a custom reference object. This style allows for the least amount of changes in client code. Property access simply needs appended parens, eg `style.direction` becomes `style.direction`. Reviewed By: shergin Differential Revision: D14999096 fbshipit-source-id: fbf29f7ddab520513d4618f5e70094c4f6330b30
This commit is contained in:
committed by
Facebook Github Bot
parent
e167642672
commit
dee93017f7
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
#pragma once
|
||||
#include <stdio.h>
|
||||
#include "CompactValue.h"
|
||||
#include "YGConfig.h"
|
||||
#include "YGLayout.h"
|
||||
#include "YGStyle.h"
|
||||
@@ -62,6 +63,8 @@ private:
|
||||
// DO NOT CHANGE THE VISIBILITY OF THIS METHOD!
|
||||
YGNode& operator=(YGNode&&) = default;
|
||||
|
||||
using CompactValue = facebook::yoga::detail::CompactValue;
|
||||
|
||||
public:
|
||||
YGNode()
|
||||
: hasNewLayout_{true},
|
||||
@@ -210,14 +213,6 @@ public:
|
||||
|
||||
void setNodeType(YGNodeType nodeType) { nodeType_ = nodeType; }
|
||||
|
||||
void setStyleFlexDirection(YGFlexDirection direction) {
|
||||
style_.flexDirection = direction;
|
||||
}
|
||||
|
||||
void setStyleAlignContent(YGAlign alignContent) {
|
||||
style_.alignContent = alignContent;
|
||||
}
|
||||
|
||||
void setMeasureFunc(YGMeasureFunc measureFunc);
|
||||
void setMeasureFunc(MeasureWithContextFn);
|
||||
void setMeasureFunc(std::nullptr_t) {
|
||||
@@ -296,8 +291,8 @@ public:
|
||||
|
||||
void cloneChildrenIfNeeded(void*);
|
||||
void markDirtyAndPropogate();
|
||||
float resolveFlexGrow();
|
||||
float resolveFlexShrink();
|
||||
float resolveFlexGrow() const;
|
||||
float resolveFlexShrink() const;
|
||||
bool isNodeFlexible();
|
||||
bool didUseLegacyFlag();
|
||||
bool isLayoutTreeEqualToNode(const YGNode& node) const;
|
||||
|
Reference in New Issue
Block a user