Fabric: Making `YogaStylableProps.yogaStyle` protected

Summary: `YogaStylableProps.yogaStyle` is designed to be consumed by Yoga only. Making it `protected` allows us to avoid confusion and misuse of this props.

Reviewed By: JoshuaGross

Differential Revision: D15296474

fbshipit-source-id: cf9e416afee99fb426d72765557b34d303a63dbe
This commit is contained in:
Valentin Shergin 2019-05-10 15:31:00 -07:00 коммит произвёл Facebook Github Bot
Родитель 16499c1086
Коммит 184073813e
6 изменённых файлов: 25 добавлений и 5 удалений

Просмотреть файл

@ -185,8 +185,8 @@ using namespace facebook::react;
}
// `overflow`
if (oldViewProps.yogaStyle.overflow() != newViewProps.yogaStyle.overflow()) {
self.clipsToBounds = newViewProps.yogaStyle.overflow() != YGOverflowVisible;
if (oldViewProps.getClipsContentToBounds() != newViewProps.getClipsContentToBounds()) {
self.clipsToBounds = newViewProps.getClipsContentToBounds();
needsInvalidateLayer = YES;
}

Просмотреть файл

@ -161,7 +161,7 @@ local_ref<JString> getPlatformComponentName(const ShadowView& shadowView) {
std::dynamic_pointer_cast<const ScrollViewProps>(shadowView.props);
if (newViewProps &&
newViewProps->yogaStyle.flexDirection() == YGFlexDirectionRow) {
newViewProps->getProbablyMoreHorizontalThanVertical_DEPRECATED()) {
componentName = make_jstring("AndroidHorizontalScrollView");
} else {
componentName = make_jstring(shadowView.componentName);

Просмотреть файл

@ -146,6 +146,16 @@ BorderMetrics ViewProps::resolveBorderMetrics(
};
}
bool ViewProps::getClipsContentToBounds() const {
return yogaStyle.overflow() != YGOverflowVisible;
}
#ifdef ANDROID
bool ViewProps::getProbablyMoreHorizontalThanVertical_DEPRECATED() const {
return yogaStyle.flexDirection() == YGFlexDirectionRow;
}
#endif
#pragma mark - DebugStringConvertible
#if RN_DEBUG_STRING_CONVERTIBLE

Просмотреть файл

@ -65,6 +65,11 @@ class ViewProps : public Props,
#pragma mark - Convenience Methods
BorderMetrics resolveBorderMetrics(LayoutMetrics const &layoutMetrics) const;
bool getClipsContentToBounds() const;
#ifdef ANDROID
bool getProbablyMoreHorizontalThanVertical_DEPRECATED() const;
#endif
#pragma mark - DebugStringConvertible

Просмотреть файл

@ -21,10 +21,10 @@ bool ViewShadowNode::isLayoutOnly() const {
// Accessibility Props
!viewProps.accessible &&
// Style Props
viewProps.yogaStyle.overflow() == YGOverflowVisible &&
viewProps.opacity == 1.0 && !viewProps.backgroundColor &&
!viewProps.foregroundColor && !viewProps.shadowColor &&
viewProps.transform == Transform{} && viewProps.zIndex == 0 &&
!viewProps.getClipsContentToBounds() &&
// Layout Metrics
getLayoutMetrics().borderWidth == EdgeInsets{};
}

Просмотреть файл

@ -29,12 +29,17 @@ class YogaStylableProps {
#pragma mark - Props
protected:
friend class YogaLayoutableShadowNode;
const YGStyle yogaStyle{};
#if RN_DEBUG_STRING_CONVERTIBLE
#pragma mark - DebugStringConvertible (Partial)
#if RN_DEBUG_STRING_CONVERTIBLE
public:
SharedDebugStringConvertibleList getDebugProps() const;
#endif
};