Merge commit 'ca60be8882522b707ddb710bdbda9ba673cdc22f' into 0.67-merge-latest
This commit is contained in:
Коммит
122668d287
|
@ -66,13 +66,7 @@ export type TextProps = $ReadOnly<{|
|
|||
* Set hyphenation strategy on Android.
|
||||
*
|
||||
*/
|
||||
android_hyphenationFrequency?: ?(
|
||||
| 'normal'
|
||||
| 'none'
|
||||
| 'full'
|
||||
| 'high'
|
||||
| 'balanced'
|
||||
),
|
||||
android_hyphenationFrequency?: ?('normal' | 'none' | 'full'),
|
||||
children?: ?Node,
|
||||
|
||||
/**
|
||||
|
|
|
@ -110,10 +110,6 @@ public abstract class ReactTextAnchorViewManager<T extends View, C extends React
|
|||
view.setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NONE);
|
||||
} else if (frequency.equals("full")) {
|
||||
view.setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_FULL);
|
||||
} else if (frequency.equals("balanced")) {
|
||||
view.setHyphenationFrequency(Layout.BREAK_STRATEGY_BALANCED);
|
||||
} else if (frequency.equals("high")) {
|
||||
view.setHyphenationFrequency(Layout.BREAK_STRATEGY_HIGH_QUALITY);
|
||||
} else if (frequency.equals("normal")) {
|
||||
view.setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NORMAL);
|
||||
} else {
|
||||
|
|
|
@ -21,13 +21,15 @@ bool ParagraphAttributes::operator==(const ParagraphAttributes &rhs) const {
|
|||
ellipsizeMode,
|
||||
textBreakStrategy,
|
||||
adjustsFontSizeToFit,
|
||||
includeFontPadding) ==
|
||||
includeFontPadding,
|
||||
android_hyphenationFrequency) ==
|
||||
std::tie(
|
||||
rhs.maximumNumberOfLines,
|
||||
rhs.ellipsizeMode,
|
||||
rhs.textBreakStrategy,
|
||||
rhs.adjustsFontSizeToFit,
|
||||
rhs.includeFontPadding) &&
|
||||
rhs.includeFontPadding,
|
||||
rhs.android_hyphenationFrequency) &&
|
||||
floatEquality(minimumFontSize, rhs.minimumFontSize) &&
|
||||
floatEquality(maximumFontSize, rhs.maximumFontSize);
|
||||
}
|
||||
|
@ -47,7 +49,10 @@ SharedDebugStringConvertibleList ParagraphAttributes::getDebugProps() const {
|
|||
debugStringConvertibleItem("adjustsFontSizeToFit", adjustsFontSizeToFit),
|
||||
debugStringConvertibleItem("minimumFontSize", minimumFontSize),
|
||||
debugStringConvertibleItem("maximumFontSize", maximumFontSize),
|
||||
debugStringConvertibleItem("includeFontPadding", includeFontPadding)};
|
||||
debugStringConvertibleItem("includeFontPadding", includeFontPadding),
|
||||
debugStringConvertibleItem(
|
||||
"android_hyphenationFrequency",
|
||||
android_hyphenationFrequency)};
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -42,6 +42,9 @@ class ParagraphAttributes : public DebugStringConvertible {
|
|||
*/
|
||||
EllipsizeMode ellipsizeMode{};
|
||||
|
||||
/*
|
||||
* (Android only) Break strategy for breaking paragraphs into lines.
|
||||
*/
|
||||
TextBreakStrategy textBreakStrategy{};
|
||||
|
||||
/*
|
||||
|
@ -55,6 +58,11 @@ class ParagraphAttributes : public DebugStringConvertible {
|
|||
*/
|
||||
bool includeFontPadding{true};
|
||||
|
||||
/*
|
||||
* (Android only) Frequency of automatic hyphenation to use when determining word breaks.
|
||||
*/
|
||||
HyphenationFrequency android_hyphenationFrequency{};
|
||||
|
||||
/*
|
||||
* In case of font size adjustment enabled, defines minimum and maximum
|
||||
* font sizes.
|
||||
|
@ -89,7 +97,8 @@ struct hash<facebook::react::ParagraphAttributes> {
|
|||
attributes.adjustsFontSizeToFit,
|
||||
attributes.minimumFontSize,
|
||||
attributes.maximumFontSize,
|
||||
attributes.includeFontPadding);
|
||||
attributes.includeFontPadding,
|
||||
attributes.android_hyphenationFrequency);
|
||||
}
|
||||
};
|
||||
} // namespace std
|
||||
|
|
|
@ -712,6 +712,48 @@ inline void fromRawValue(
|
|||
result = AccessibilityRole::None;
|
||||
}
|
||||
|
||||
inline std::string toString(const HyphenationFrequency &hyphenationFrequency) {
|
||||
switch (hyphenationFrequency) {
|
||||
case HyphenationFrequency::None:
|
||||
return "none";
|
||||
case HyphenationFrequency::Normal:
|
||||
return "normal";
|
||||
case HyphenationFrequency::Full:
|
||||
return "full";
|
||||
}
|
||||
|
||||
LOG(ERROR) << "Unsupported HyphenationFrequency value";
|
||||
react_native_assert(false);
|
||||
return "none";
|
||||
}
|
||||
|
||||
inline void fromRawValue(
|
||||
const PropsParserContext &context,
|
||||
const RawValue &value,
|
||||
HyphenationFrequency &result) {
|
||||
react_native_assert(value.hasType<std::string>());
|
||||
if (value.hasType<std::string>()) {
|
||||
auto string = (std::string)value;
|
||||
if (string == "none") {
|
||||
result = HyphenationFrequency::None;
|
||||
} else if (string == "normal") {
|
||||
result = HyphenationFrequency::Normal;
|
||||
} else if (string == "full") {
|
||||
result = HyphenationFrequency::Full;
|
||||
} else {
|
||||
// sane default
|
||||
LOG(ERROR) << "Unsupported HyphenationFrequency value: " << string;
|
||||
react_native_assert(false);
|
||||
result = HyphenationFrequency::None;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
LOG(ERROR) << "Unsupported HyphenationFrequency type";
|
||||
react_native_assert(false);
|
||||
result = HyphenationFrequency::None;
|
||||
}
|
||||
|
||||
inline ParagraphAttributes convertRawProp(
|
||||
const PropsParserContext &context,
|
||||
RawProps const &rawProps,
|
||||
|
@ -761,6 +803,12 @@ inline ParagraphAttributes convertRawProp(
|
|||
"includeFontPadding",
|
||||
sourceParagraphAttributes.includeFontPadding,
|
||||
defaultParagraphAttributes.includeFontPadding);
|
||||
paragraphAttributes.android_hyphenationFrequency = convertRawProp(
|
||||
context,
|
||||
rawProps,
|
||||
"android_hyphenationFrequency",
|
||||
sourceParagraphAttributes.android_hyphenationFrequency,
|
||||
defaultParagraphAttributes.android_hyphenationFrequency);
|
||||
|
||||
return paragraphAttributes;
|
||||
}
|
||||
|
@ -796,6 +844,9 @@ inline folly::dynamic toDynamic(
|
|||
values("textBreakStrategy", toString(paragraphAttributes.textBreakStrategy));
|
||||
values("adjustsFontSizeToFit", paragraphAttributes.adjustsFontSizeToFit);
|
||||
values("includeFontPadding", paragraphAttributes.includeFontPadding);
|
||||
values(
|
||||
"android_hyphenationFrequency",
|
||||
toString(paragraphAttributes.android_hyphenationFrequency));
|
||||
|
||||
return values;
|
||||
}
|
||||
|
|
|
@ -53,7 +53,11 @@ enum class EllipsizeMode {
|
|||
Middle // Truncate middle of line: "ab...yz".
|
||||
};
|
||||
|
||||
enum class TextBreakStrategy { Simple, Balanced, HighQuality };
|
||||
enum class TextBreakStrategy {
|
||||
Simple, // Simple strategy.
|
||||
Balanced, // Balances line lengths.
|
||||
HighQuality // High-quality strategy, including hyphenation.
|
||||
};
|
||||
|
||||
enum class TextAlignment {
|
||||
Natural, // Indicates the default alignment for script.
|
||||
|
@ -126,6 +130,12 @@ enum class TextTransform {
|
|||
Unset,
|
||||
};
|
||||
|
||||
enum class HyphenationFrequency {
|
||||
None, // No hyphenation.
|
||||
Normal, // Less frequent hyphenation.
|
||||
Full // Standard amount of hyphenation.
|
||||
};
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
||||
|
||||
|
@ -213,4 +223,11 @@ struct hash<facebook::react::TextTransform> {
|
|||
return hash<int>()(static_cast<int>(v));
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct hash<facebook::react::HyphenationFrequency> {
|
||||
size_t operator()(const facebook::react::HyphenationFrequency &v) const {
|
||||
return hash<int>()(static_cast<int>(v));
|
||||
}
|
||||
};
|
||||
} // namespace std
|
||||
|
|
|
@ -17,27 +17,27 @@
|
|||
*/
|
||||
declare var global: {
|
||||
// setUpGlobals
|
||||
+window: typeof global;
|
||||
+self: typeof global;
|
||||
+window: typeof global,
|
||||
+self: typeof global,
|
||||
|
||||
// setXHR
|
||||
+XMLHttpRequest: typeof XMLHttpRequest;
|
||||
+FormData: typeof FormData;
|
||||
+fetch: typeof fetch;
|
||||
+Headers: typeof Headers;
|
||||
+Request: typeof Request;
|
||||
+Response: typeof Response;
|
||||
+WebSocket: typeof WebSocket;
|
||||
+Blob: typeof Blob;
|
||||
+File: typeof File;
|
||||
+FileReader: typeof FileReader;
|
||||
+URL: typeof URL;
|
||||
+URLSearchParams: typeof URLSearchParams;
|
||||
+AbortController: typeof AbortController;
|
||||
+AbortSignal: typeof AbortSignal;
|
||||
+XMLHttpRequest: typeof XMLHttpRequest,
|
||||
+FormData: typeof FormData,
|
||||
+fetch: typeof fetch,
|
||||
+Headers: typeof Headers,
|
||||
+Request: typeof Request,
|
||||
+Response: typeof Response,
|
||||
+WebSocket: typeof WebSocket,
|
||||
+Blob: typeof Blob,
|
||||
+File: typeof File,
|
||||
+FileReader: typeof FileReader,
|
||||
+URL: typeof URL,
|
||||
+URLSearchParams: typeof URLSearchParams,
|
||||
+AbortController: typeof AbortController,
|
||||
+AbortSignal: typeof AbortSignal,
|
||||
|
||||
// setUpAlert
|
||||
+alert: typeof alert;
|
||||
+alert: typeof alert,
|
||||
|
||||
// setUpTimers
|
||||
+clearInterval: typeof clearInterval,
|
||||
|
@ -52,7 +52,7 @@ declare var global: {
|
|||
// TODO(T97509743): use `typeof` when the next Flow release is available.
|
||||
+queueMicrotask: <TArguments: Array<mixed>>(
|
||||
jobCallback: (...args: TArguments) => mixed,
|
||||
) => void;
|
||||
) => void,
|
||||
|
||||
+console: typeof console,
|
||||
|
||||
|
|
|
@ -216,23 +216,15 @@ class TextExample extends React.Component<{...}> {
|
|||
<RNTesterBlock title="Hyphenation">
|
||||
<Text android_hyphenationFrequency="normal">
|
||||
<Text style={{color: 'red'}}>Normal: </Text>
|
||||
WillHaveAnHyphenWhenBreakingForNewLine
|
||||
WillHaveAHyphenWhenBreakingForNewLine
|
||||
</Text>
|
||||
<Text android_hyphenationFrequency="none">
|
||||
<Text style={{color: 'red'}}>None: </Text>
|
||||
WillNotHaveAnHyphenWhenBreakingForNewLine
|
||||
WillNotHaveAHyphenWhenBreakingForNewLine
|
||||
</Text>
|
||||
<Text android_hyphenationFrequency="full">
|
||||
<Text style={{color: 'red'}}>Full: </Text>
|
||||
WillHaveAnHyphenWhenBreakingForNewLine
|
||||
</Text>
|
||||
<Text android_hyphenationFrequency="high">
|
||||
<Text style={{color: 'red'}}>High: </Text>
|
||||
WillHaveAnHyphenWhenBreakingForNewLine
|
||||
</Text>
|
||||
<Text android_hyphenationFrequency="balanced">
|
||||
<Text style={{color: 'red'}}>Balanced: </Text>
|
||||
WillHaveAnHyphenWhenBreakingForNewLine
|
||||
WillHaveAHyphenWhenBreakingForNewLine
|
||||
</Text>
|
||||
</RNTesterBlock>
|
||||
<RNTesterBlock title="Padding">
|
||||
|
|
Загрузка…
Ссылка в новой задаче