Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,28 @@

#include "TextProps.h"

#include <react/renderer/core/propsConversions.h>

namespace facebook::react {

TextProps::TextProps(
const PropsParserContext& context,
const TextProps& sourceProps,
const RawProps& rawProps)
: Props(context, sourceProps, rawProps),
BaseTextProps::BaseTextProps(context, sourceProps, rawProps) {};
BaseTextProps::BaseTextProps(context, sourceProps, rawProps),
transform(convertRawProp(
context,
rawProps,
"transform",
sourceProps.transform,
{})),
transformOrigin(convertRawProp(
context,
rawProps,
"transformOrigin",
sourceProps.transformOrigin,
{})) {};

void TextProps::setProp(
const PropsParserContext& context,
Expand All @@ -23,6 +37,12 @@ void TextProps::setProp(
const RawValue& value) {
BaseTextProps::setProp(context, hash, propName, value);
Props::setProp(context, hash, propName, value);

static auto defaults = TextProps{};
switch (hash) {
RAW_SET_PROP_SWITCH_CASE_BASIC(transform);
RAW_SET_PROP_SWITCH_CASE_BASIC(transformOrigin);
}
}

#pragma mark - DebugStringConvertible
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <react/renderer/core/Props.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/graphics/Color.h>
#include <react/renderer/graphics/Transform.h>

namespace facebook::react {

Expand All @@ -23,6 +24,10 @@ class TextProps : public Props, public BaseTextProps {
void
setProp(const PropsParserContext &context, RawPropsPropNameHash hash, const char *propName, const RawValue &value);

// View-level props that affect whether this text node needs a backing view
Transform transform{};
TransformOrigin transformOrigin{};

#pragma mark - DebugStringConvertible

#if RN_DEBUG_STRING_CONVERTIBLE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,23 @@ class TextShadowNode : public ConcreteShadowNode<TextComponentName, ShadowNode,
{
orderIndex_ = std::numeric_limits<decltype(orderIndex_)>::max();
}
#else
using BaseShadowNode = ConcreteShadowNode<TextComponentName, ShadowNode, TextProps, TextEventEmitter>;

TextShadowNode(const ShadowNodeFragment &fragment, const ShadowNodeFamily::Shared &family, ShadowNodeTraits traits)
: BaseShadowNode(
fragment,
family,
[&] {
auto textProps = std::static_pointer_cast<const TextProps>(fragment.props);
if (textProps && !textProps->transform.operations.empty()) {
traits.set(ShadowNodeTraits::Trait::FormsView);
}
return traits;
}()),
BaseTextShadowNode()
{
}
#endif
};

Expand Down