react-native-windows 0.0.0-canary.488 → 0.0.0-canary.491
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Chakra/ChakraHelpers.cpp +0 -1
- package/Libraries/Components/Button.windows.js +1 -0
- package/Libraries/Pressability/Pressability.windows.js +13 -2
- package/Libraries/StyleSheet/processTransform.windows.js +2 -2
- package/Microsoft.ReactNative/DynamicReader.cpp +3 -3
- package/Microsoft.ReactNative/Fabric/DWriteHelpers.cpp +19 -0
- package/Microsoft.ReactNative/Fabric/DWriteHelpers.h +13 -0
- package/Microsoft.ReactNative/Fabric/ParagraphComponentView.cpp +36 -10
- package/Microsoft.ReactNative/Fabric/SliderComponentView.h +1 -1
- package/Microsoft.ReactNative/Fabric/SwitchComponentView.h +1 -1
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/TextLayoutManager.cpp +107 -57
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/TextLayoutManager.h +8 -2
- package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj +1 -0
- package/Microsoft.ReactNative/Modules/CreateModules.cpp +3 -3
- package/Microsoft.ReactNative/ReactHost/ReactNativeHeaders.h +1 -1
- package/Microsoft.ReactNative/Views/ControlViewManager.cpp +32 -0
- package/Microsoft.ReactNative/Views/ControlViewManager.h +11 -0
- package/Microsoft.ReactNative/Views/DevMenu.cpp +2 -2
- package/Microsoft.ReactNative/Views/FrameworkElementViewManager.cpp +59 -4
- package/Microsoft.ReactNative/Views/Image/Microsoft.UI.Composition.Effects_Impl.h +5 -11
- package/Microsoft.ReactNative/Views/Image/ReactImage.cpp +2 -1
- package/Microsoft.ReactNative/Views/ViewViewManager.cpp +21 -0
- package/Microsoft.ReactNative.Cxx/DesktopWindowBridge.h +1 -1
- package/Microsoft.ReactNative.Cxx/JSI/JsiAbiApi.cpp +1 -1
- package/Microsoft.ReactNative.Cxx/JSI/NodeApiJsiRuntime.cpp +10 -14
- package/Microsoft.ReactNative.Cxx/JSI/NodeApiJsiRuntime.h +4 -0
- package/Microsoft.ReactNative.Cxx/JSValueReader.h +2 -2
- package/Microsoft.ReactNative.Cxx/JSValueWriter.h +5 -5
- package/Microsoft.ReactNative.Cxx/NativeModules.h +1 -1
- package/Microsoft.ReactNative.Cxx/ReactContext.h +3 -3
- package/Microsoft.ReactNative.Cxx/ReactNonAbiValue.h +3 -3
- package/Microsoft.ReactNative.Managed/packages.lock.json +1 -1
- package/Mso/activeObject/activeObject.h +2 -2
- package/Mso/compilerAdapters/cppMacros.h +3 -5
- package/Mso/errorCode/errorProvider.h +2 -2
- package/Mso/errorCode/maybe.h +4 -4
- package/Mso/functional/functor.h +6 -6
- package/Mso/functional/functorRef.h +2 -2
- package/Mso/future/details/executor.h +2 -2
- package/Mso/future/details/futureFuncInl.h +4 -4
- package/Mso/future/details/ifuture.h +3 -3
- package/Mso/future/details/maybeInvoker.h +6 -6
- package/Mso/future/details/promiseGroupInl.h +4 -4
- package/Mso/future/details/promiseInl.h +4 -4
- package/Mso/future/details/resultTraits.h +4 -4
- package/Mso/future/details/whenAllInl.h +1 -1
- package/Mso/future/future.h +13 -13
- package/Mso/guid/msoGuidDetails.h +1 -1
- package/Mso/memoryApi/memoryApi.h +13 -7
- package/Mso/motifCpp/gTestAdapter.h +1 -1
- package/Mso/motifCpp/testInfo.h +7 -9
- package/Mso/object/make.h +8 -8
- package/Mso/object/objectRefCount.h +3 -5
- package/Mso/object/objectWithWeakRef.h +10 -14
- package/Mso/object/queryCast.h +4 -4
- package/Mso/object/refCountedObject.h +4 -4
- package/Mso/object/unknownObject.h +7 -7
- package/Mso/platformAdapters/windowsFirst.h +1 -1
- package/Mso/smartPtr/cntPtr.h +8 -8
- package/Mso/src/future/futureImpl.h +1 -1
- package/Mso/src/memoryApi/memoryApi.cpp +4 -4
- package/PropertySheets/Generated/PackageVersion.g.props +1 -1
- package/PropertySheets/JSEngine.props +1 -1
- package/ReactCommon/ReactCommon.vcxproj +0 -3
- package/Scripts/OfficeReact.Win32.nuspec +1 -1
- package/Shared/AbiSafe.h +3 -3
- package/Shared/BaseScriptStoreImpl.cpp +1 -1
- package/Shared/CppRuntimeOptions.h +50 -0
- package/Shared/InspectorPackagerConnection.cpp +7 -5
- package/Shared/InspectorPackagerConnection.h +2 -2
- package/Shared/JSI/ChakraApi.cpp +0 -1
- package/Shared/JSI/ChakraRuntime.cpp +1 -2
- package/Shared/JSI/NapiJsiV8RuntimeHolder.h +1 -1
- package/Shared/Modules/HttpModule.cpp +1 -1
- package/Shared/Modules/HttpModule.h +2 -2
- package/Shared/Modules/WebSocketModule.cpp +1 -1
- package/Shared/Modules/WebSocketModule.h +8 -5
- package/Shared/{IHttpResource.h → Networking/IHttpResource.h} +4 -4
- package/Shared/{IWebSocketResource.h → Networking/IWebSocketResource.h} +3 -3
- package/Shared/Networking/OriginPolicy.h +15 -0
- package/Shared/Networking/OriginPolicyHttpFilter.cpp +746 -0
- package/Shared/Networking/OriginPolicyHttpFilter.h +112 -0
- package/Shared/{WinRTHttpResource.cpp → Networking/WinRTHttpResource.cpp} +129 -99
- package/Shared/{WinRTHttpResource.h → Networking/WinRTHttpResource.h} +8 -12
- package/Shared/Networking/WinRTTypes.h +30 -0
- package/Shared/{WinRTWebSocketResource.cpp → Networking/WinRTWebSocketResource.cpp} +18 -3
- package/Shared/{WinRTWebSocketResource.h → Networking/WinRTWebSocketResource.h} +3 -3
- package/Shared/OInstance.cpp +1 -1
- package/Shared/RuntimeOptions.cpp +93 -15
- package/Shared/RuntimeOptions.h +22 -9
- package/Shared/Shared.vcxitems +11 -6
- package/Shared/Shared.vcxitems.filters +39 -18
- package/Shared/Threading/BatchingQueueThread.cpp +1 -1
- package/Shared/tracing/fbsystrace.h +2 -2
- package/package.json +5 -5
- package/rntypes/index.d.ts +5 -6
package/Chakra/ChakraHelpers.cpp
CHANGED
|
@@ -342,6 +342,7 @@ class Button extends React.Component<
|
|
|
342
342
|
if (Platform.OS === 'windows') {
|
|
343
343
|
return (
|
|
344
344
|
<Touchable
|
|
345
|
+
accessible={accessible}
|
|
345
346
|
accessibilityLabel={accessibilityLabel}
|
|
346
347
|
accessibilityHint={accessibilityHint}
|
|
347
348
|
accessibilityLanguage={accessibilityLanguage}
|
|
@@ -721,6 +721,11 @@ export default class Pressability {
|
|
|
721
721
|
}
|
|
722
722
|
}
|
|
723
723
|
|
|
724
|
+
// [Windows]
|
|
725
|
+
_isDefaultPressButton(button) {
|
|
726
|
+
return !button; // Treat 0 or undefined as default press
|
|
727
|
+
}
|
|
728
|
+
|
|
724
729
|
/**
|
|
725
730
|
* Performs a transition between touchable states and identify any activations
|
|
726
731
|
* or deactivations (and callback invocations).
|
|
@@ -771,7 +776,10 @@ export default class Pressability {
|
|
|
771
776
|
}
|
|
772
777
|
const {onLongPress, onPress, android_disableSound} = this._config;
|
|
773
778
|
|
|
774
|
-
if (
|
|
779
|
+
if (
|
|
780
|
+
onPress != null &&
|
|
781
|
+
this._isDefaultPressButton(getTouchFromPressEvent(event).button)
|
|
782
|
+
) {
|
|
775
783
|
const isPressCanceledByLongPress =
|
|
776
784
|
onLongPress != null &&
|
|
777
785
|
prevState === 'RESPONDER_ACTIVE_LONG_PRESS_IN' &&
|
|
@@ -800,7 +808,10 @@ export default class Pressability {
|
|
|
800
808
|
|
|
801
809
|
_deactivate(event: PressEvent): void {
|
|
802
810
|
const {onPressOut} = this._config;
|
|
803
|
-
if (
|
|
811
|
+
if (
|
|
812
|
+
onPressOut != null &&
|
|
813
|
+
this._isDefaultPressButton(getTouchFromPressEvent(event).button)
|
|
814
|
+
) {
|
|
804
815
|
const minPressDuration = normalizeDelay(
|
|
805
816
|
this._config.minPressDuration,
|
|
806
817
|
0,
|
|
@@ -44,7 +44,7 @@ function processTransform(
|
|
|
44
44
|
|
|
45
45
|
const result = MatrixMath.createIdentityMatrix();
|
|
46
46
|
|
|
47
|
-
transform.forEach(
|
|
47
|
+
transform.forEach(transformation => {
|
|
48
48
|
const key = Object.keys(transformation)[0];
|
|
49
49
|
const value = transformation[key];
|
|
50
50
|
|
|
@@ -141,7 +141,7 @@ function _convertToRadians(value: string): number {
|
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
function _validateTransforms(transform: Array<Object>): void {
|
|
144
|
-
transform.forEach(
|
|
144
|
+
transform.forEach(transformation => {
|
|
145
145
|
const keys = Object.keys(transformation);
|
|
146
146
|
invariant(
|
|
147
147
|
keys.length === 1,
|
|
@@ -140,9 +140,9 @@ bool DynamicReader::GetBoolean() noexcept {
|
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
int64_t DynamicReader::GetInt64() noexcept {
|
|
143
|
-
return (m_current->type() == folly::dynamic::Type::INT64)
|
|
144
|
-
? m_current->
|
|
145
|
-
|
|
143
|
+
return (m_current->type() == folly::dynamic::Type::INT64) ? m_current->getInt()
|
|
144
|
+
: (m_current->type() == folly::dynamic::Type::DOUBLE) ? static_cast<int64_t>(m_current->getDouble())
|
|
145
|
+
: 0;
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
double DynamicReader::GetDouble() noexcept {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
#pragma once
|
|
5
|
+
|
|
6
|
+
#include "DWriteHelpers.h"
|
|
7
|
+
|
|
8
|
+
namespace Microsoft::ReactNative {
|
|
9
|
+
|
|
10
|
+
winrt::com_ptr<::IDWriteFactory> DWriteFactory() noexcept {
|
|
11
|
+
static winrt::com_ptr<::IDWriteFactory> s_dwriteFactory;
|
|
12
|
+
if (!s_dwriteFactory) {
|
|
13
|
+
winrt::check_hresult(::DWriteCreateFactory(
|
|
14
|
+
DWRITE_FACTORY_TYPE_SHARED, __uuidof(s_dwriteFactory), reinterpret_cast<::IUnknown **>(s_dwriteFactory.put())));
|
|
15
|
+
}
|
|
16
|
+
return s_dwriteFactory;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
} // namespace Microsoft::ReactNative
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT License.
|
|
4
|
+
|
|
5
|
+
#pragma once
|
|
6
|
+
|
|
7
|
+
#include <dwrite.h>
|
|
8
|
+
|
|
9
|
+
namespace Microsoft::ReactNative {
|
|
10
|
+
|
|
11
|
+
winrt::com_ptr<::IDWriteFactory> DWriteFactory() noexcept;
|
|
12
|
+
|
|
13
|
+
} // namespace Microsoft::ReactNative
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
#include "ParagraphComponentView.h"
|
|
8
8
|
|
|
9
9
|
#include <UI.Xaml.Controls.h>
|
|
10
|
+
#include <UI.Xaml.Documents.h>
|
|
10
11
|
#include <Utils/ValueUtils.h>
|
|
11
12
|
#include <dwrite.h>
|
|
12
13
|
#include <react/renderer/components/text/ParagraphShadowNode.h>
|
|
@@ -30,14 +31,12 @@ void ParagraphComponentView::mountChildComponentView(
|
|
|
30
31
|
uint32_t index) noexcept {
|
|
31
32
|
auto v = static_cast<const ParagraphComponentView &>(childComponentView);
|
|
32
33
|
assert(false);
|
|
33
|
-
// m_element.Children().InsertAt(index, v.Element());
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
void ParagraphComponentView::unmountChildComponentView(
|
|
37
37
|
const IComponentView &childComponentView,
|
|
38
38
|
uint32_t index) noexcept {
|
|
39
39
|
assert(false);
|
|
40
|
-
// m_element.Children().RemoveAt(index);
|
|
41
40
|
}
|
|
42
41
|
|
|
43
42
|
void ParagraphComponentView::updateProps(
|
|
@@ -99,11 +98,40 @@ void ParagraphComponentView::updateState(
|
|
|
99
98
|
facebook::react::State::Shared const &oldState) noexcept {
|
|
100
99
|
const auto &newState = *std::static_pointer_cast<facebook::react::ParagraphShadowNode::ConcreteState const>(state);
|
|
101
100
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
101
|
+
m_element.Inlines().Clear();
|
|
102
|
+
|
|
103
|
+
for (const auto &fragment : newState.getData().attributedString.getFragments()) {
|
|
104
|
+
auto inlines = m_element.Inlines();
|
|
105
|
+
|
|
106
|
+
if (auto tdlt = fragment.textAttributes.textDecorationLineType; tdlt &&
|
|
107
|
+
(*tdlt == facebook::react::TextDecorationLineType::Underline ||
|
|
108
|
+
*tdlt == facebook::react::TextDecorationLineType::UnderlineStrikethrough)) {
|
|
109
|
+
auto underline = xaml::Documents::Underline();
|
|
110
|
+
inlines.Append(underline);
|
|
111
|
+
inlines = underline.Inlines();
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (fragment.textAttributes.fontStyle == facebook::react::FontStyle::Italic ||
|
|
115
|
+
fragment.textAttributes.fontStyle == facebook::react::FontStyle::Oblique) {
|
|
116
|
+
auto italic = xaml::Documents::Italic();
|
|
117
|
+
inlines.Append(italic);
|
|
118
|
+
inlines = italic.Inlines();
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
auto run = xaml::Documents::Run();
|
|
122
|
+
run.Text(winrt::to_hstring(fragment.string));
|
|
123
|
+
run.FontFamily(xaml::Media::FontFamily(
|
|
124
|
+
fragment.textAttributes.fontFamily.empty() ? L"Segoe UI"
|
|
125
|
+
: winrt::to_hstring(fragment.textAttributes.fontFamily)));
|
|
126
|
+
|
|
127
|
+
run.FontWeight(
|
|
128
|
+
winrt::Windows::UI::Text::FontWeight{static_cast<uint16_t>(fragment.textAttributes.fontWeight.value_or(
|
|
129
|
+
static_cast<facebook::react::FontWeight>(DWRITE_FONT_WEIGHT_REGULAR)))});
|
|
130
|
+
|
|
131
|
+
run.FontSize(fragment.textAttributes.fontSize);
|
|
132
|
+
run.Foreground(fragment.textAttributes.foregroundColor.AsWindowsBrush());
|
|
133
|
+
inlines.Append(run);
|
|
134
|
+
}
|
|
107
135
|
}
|
|
108
136
|
void ParagraphComponentView::updateLayoutMetrics(
|
|
109
137
|
facebook::react::LayoutMetrics const &layoutMetrics,
|
|
@@ -118,9 +146,7 @@ void ParagraphComponentView::updateLayoutMetrics(
|
|
|
118
146
|
m_element.Width(layoutMetrics.frame.size.width);
|
|
119
147
|
m_element.Height(layoutMetrics.frame.size.height);
|
|
120
148
|
}
|
|
121
|
-
void ParagraphComponentView::finalizeUpdates(RNComponentViewUpdateMask updateMask) noexcept {
|
|
122
|
-
// m_element.FinalizeProperties();
|
|
123
|
-
}
|
|
149
|
+
void ParagraphComponentView::finalizeUpdates(RNComponentViewUpdateMask updateMask) noexcept {}
|
|
124
150
|
void ParagraphComponentView::prepareForRecycle() noexcept {}
|
|
125
151
|
facebook::react::SharedProps ParagraphComponentView::props() noexcept {
|
|
126
152
|
assert(false);
|
package/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/TextLayoutManager.cpp
CHANGED
|
@@ -5,72 +5,125 @@
|
|
|
5
5
|
|
|
6
6
|
#include "pch.h"
|
|
7
7
|
|
|
8
|
+
#include <Fabric/DWriteHelpers.h>
|
|
9
|
+
#include <dwrite.h>
|
|
8
10
|
#include "TextLayoutManager.h"
|
|
9
11
|
|
|
10
12
|
#include <unicode.h>
|
|
11
13
|
|
|
12
14
|
namespace facebook::react {
|
|
13
15
|
|
|
14
|
-
TextLayoutManager
|
|
16
|
+
void TextLayoutManager::GetTextLayout(
|
|
17
|
+
AttributedStringBox attributedStringBox,
|
|
18
|
+
ParagraphAttributes paragraphAttributes,
|
|
19
|
+
LayoutConstraints layoutConstraints,
|
|
20
|
+
const std::optional<TextAlignment> &textAlignment,
|
|
21
|
+
winrt::com_ptr<IDWriteTextLayout> &spTextLayout) noexcept {
|
|
22
|
+
if (attributedStringBox.getValue().isEmpty())
|
|
23
|
+
return;
|
|
24
|
+
|
|
25
|
+
auto fragments = attributedStringBox.getValue().getFragments();
|
|
26
|
+
auto outerFragment = fragments[0];
|
|
27
|
+
|
|
28
|
+
DWRITE_FONT_STYLE style = DWRITE_FONT_STYLE_NORMAL;
|
|
29
|
+
if (outerFragment.textAttributes.fontStyle == facebook::react::FontStyle::Italic)
|
|
30
|
+
style = DWRITE_FONT_STYLE_ITALIC;
|
|
31
|
+
else if (outerFragment.textAttributes.fontStyle == facebook::react::FontStyle::Oblique)
|
|
32
|
+
style = DWRITE_FONT_STYLE_OBLIQUE;
|
|
33
|
+
|
|
34
|
+
winrt::com_ptr<IDWriteTextFormat> spTextFormat;
|
|
35
|
+
winrt::check_hresult(Microsoft::ReactNative::DWriteFactory()->CreateTextFormat(
|
|
36
|
+
outerFragment.textAttributes.fontFamily.empty()
|
|
37
|
+
? L"Segoe UI"
|
|
38
|
+
: Microsoft::Common::Unicode::Utf8ToUtf16(outerFragment.textAttributes.fontFamily).c_str(),
|
|
39
|
+
nullptr, // Font collection (nullptr sets it to use the system font collection).
|
|
40
|
+
static_cast<DWRITE_FONT_WEIGHT>(outerFragment.textAttributes.fontWeight.value_or(
|
|
41
|
+
static_cast<facebook::react::FontWeight>(DWRITE_FONT_WEIGHT_REGULAR))),
|
|
42
|
+
style,
|
|
43
|
+
DWRITE_FONT_STRETCH_NORMAL,
|
|
44
|
+
outerFragment.textAttributes.fontSize,
|
|
45
|
+
L"",
|
|
46
|
+
spTextFormat.put()));
|
|
47
|
+
|
|
48
|
+
DWRITE_TEXT_ALIGNMENT alignment = DWRITE_TEXT_ALIGNMENT_LEADING;
|
|
49
|
+
if (textAlignment) {
|
|
50
|
+
switch (*textAlignment) {
|
|
51
|
+
case facebook::react::TextAlignment::Center:
|
|
52
|
+
alignment = DWRITE_TEXT_ALIGNMENT_CENTER;
|
|
53
|
+
break;
|
|
54
|
+
case facebook::react::TextAlignment::Justified:
|
|
55
|
+
alignment = DWRITE_TEXT_ALIGNMENT_JUSTIFIED;
|
|
56
|
+
break;
|
|
57
|
+
case facebook::react::TextAlignment::Left:
|
|
58
|
+
alignment = DWRITE_TEXT_ALIGNMENT_LEADING;
|
|
59
|
+
break;
|
|
60
|
+
case facebook::react::TextAlignment::Right:
|
|
61
|
+
alignment = DWRITE_TEXT_ALIGNMENT_TRAILING;
|
|
62
|
+
break;
|
|
63
|
+
// TODO use LTR values
|
|
64
|
+
case facebook::react::TextAlignment::Natural:
|
|
65
|
+
alignment = DWRITE_TEXT_ALIGNMENT_LEADING;
|
|
66
|
+
break;
|
|
67
|
+
default:
|
|
68
|
+
assert(false);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
winrt::check_hresult(spTextFormat->SetTextAlignment(alignment));
|
|
72
|
+
|
|
73
|
+
auto str = Microsoft::Common::Unicode::Utf8ToUtf16(attributedStringBox.getValue().getString());
|
|
74
|
+
|
|
75
|
+
winrt::check_hresult(Microsoft::ReactNative::DWriteFactory()->CreateTextLayout(
|
|
76
|
+
str.c_str(), // The string to be laid out and formatted.
|
|
77
|
+
static_cast<UINT32>(str.length()), // The length of the string.
|
|
78
|
+
spTextFormat.get(), // The text format to apply to the string (contains font information, etc).
|
|
79
|
+
layoutConstraints.maximumSize.width, // The width of the layout box.
|
|
80
|
+
layoutConstraints.maximumSize.height, // The height of the layout box.
|
|
81
|
+
spTextLayout.put() // The IDWriteTextLayout interface pointer.
|
|
82
|
+
));
|
|
83
|
+
|
|
84
|
+
unsigned int position = 0;
|
|
85
|
+
unsigned int length = 0;
|
|
86
|
+
for (const auto &fragment : fragments) {
|
|
87
|
+
length = static_cast<UINT32>(fragment.string.length());
|
|
88
|
+
DWRITE_TEXT_RANGE range = {position, length};
|
|
89
|
+
TextAttributes attributes = fragment.textAttributes;
|
|
90
|
+
DWRITE_FONT_STYLE fragmentStyle = DWRITE_FONT_STYLE_NORMAL;
|
|
91
|
+
if (attributes.fontStyle == facebook::react::FontStyle::Italic)
|
|
92
|
+
fragmentStyle = DWRITE_FONT_STYLE_ITALIC;
|
|
93
|
+
else if (attributes.fontStyle == facebook::react::FontStyle::Oblique)
|
|
94
|
+
fragmentStyle = DWRITE_FONT_STYLE_OBLIQUE;
|
|
95
|
+
|
|
96
|
+
winrt::check_hresult(spTextLayout->SetFontFamilyName(
|
|
97
|
+
attributes.fontFamily.empty() ? L"Segoe UI"
|
|
98
|
+
: Microsoft::Common::Unicode::Utf8ToUtf16(attributes.fontFamily).c_str(),
|
|
99
|
+
range));
|
|
100
|
+
winrt::check_hresult(spTextLayout->SetFontWeight(
|
|
101
|
+
static_cast<DWRITE_FONT_WEIGHT>(
|
|
102
|
+
attributes.fontWeight.value_or(static_cast<facebook::react::FontWeight>(DWRITE_FONT_WEIGHT_REGULAR))),
|
|
103
|
+
range));
|
|
104
|
+
winrt::check_hresult(spTextLayout->SetFontStyle(fragmentStyle, range));
|
|
105
|
+
winrt::check_hresult(spTextLayout->SetFontSize(attributes.fontSize, range));
|
|
106
|
+
|
|
107
|
+
position += length;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
15
110
|
|
|
16
111
|
TextMeasurement TextLayoutManager::measure(
|
|
17
112
|
AttributedStringBox attributedStringBox,
|
|
18
113
|
ParagraphAttributes paragraphAttributes,
|
|
19
114
|
LayoutConstraints layoutConstraints) const {
|
|
20
|
-
winrt::com_ptr<
|
|
115
|
+
winrt::com_ptr<IDWriteTextLayout> spTextLayout;
|
|
21
116
|
|
|
22
|
-
|
|
23
|
-
DWriteCreateFactory(
|
|
24
|
-
DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory), reinterpret_cast<IUnknown **>(m_spDWriteFactory.put()));
|
|
25
|
-
}
|
|
117
|
+
GetTextLayout(attributedStringBox, paragraphAttributes, layoutConstraints, TextAlignment::Left, spTextLayout);
|
|
26
118
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
style = DWRITE_FONT_STYLE_OBLIQUE;
|
|
33
|
-
|
|
34
|
-
winrt::com_ptr<IDWriteTextFormat> spTextFormat;
|
|
35
|
-
m_spDWriteFactory->CreateTextFormat(
|
|
36
|
-
fragment.textAttributes.fontFamily.empty()
|
|
37
|
-
? L"Segoe UI"
|
|
38
|
-
: Microsoft::Common::Unicode::Utf8ToUtf16(fragment.textAttributes.fontFamily).c_str(),
|
|
39
|
-
nullptr, // Font collection (nullptr sets it to use the system font collection).
|
|
40
|
-
static_cast<DWRITE_FONT_WEIGHT>(fragment.textAttributes.fontWeight.value_or(
|
|
41
|
-
static_cast<facebook::react::FontWeight>(DWRITE_FONT_WEIGHT_REGULAR))),
|
|
42
|
-
style,
|
|
43
|
-
DWRITE_FONT_STRETCH_NORMAL,
|
|
44
|
-
fragment.textAttributes.fontSize * fragment.textAttributes.fontSizeMultiplier,
|
|
45
|
-
L"en-us",
|
|
46
|
-
spTextFormat.put());
|
|
47
|
-
|
|
48
|
-
auto str = Microsoft::Common::Unicode::Utf8ToUtf16(fragment.string);
|
|
49
|
-
|
|
50
|
-
winrt::com_ptr<IDWriteTextLayout> spTextLayout;
|
|
51
|
-
// TODO - For now assuming fragment.textAttributes.fontSizeMultiplier is the same as the pointScaleFactor
|
|
52
|
-
m_spDWriteFactory->CreateTextLayout(
|
|
53
|
-
str.c_str(), // The string to be laid out and formatted.
|
|
54
|
-
static_cast<UINT32>(str.length()), // The length of the string.
|
|
55
|
-
spTextFormat.get(), // The text format to apply to the string (contains font information, etc).
|
|
56
|
-
layoutConstraints.maximumSize.width *
|
|
57
|
-
fragment.textAttributes.fontSizeMultiplier, // The width of the layout box.
|
|
58
|
-
layoutConstraints.maximumSize.height *
|
|
59
|
-
fragment.textAttributes.fontSizeMultiplier, // The height of the layout box.
|
|
60
|
-
spTextLayout.put() // The IDWriteTextLayout interface pointer.
|
|
61
|
-
);
|
|
62
|
-
|
|
63
|
-
TextMeasurement tm;
|
|
64
|
-
DWRITE_TEXT_METRICS dtm;
|
|
65
|
-
spTextLayout->GetMetrics(&dtm);
|
|
66
|
-
tm.size = {
|
|
67
|
-
dtm.width / fragment.textAttributes.fontSizeMultiplier,
|
|
68
|
-
dtm.height / fragment.textAttributes.fontSizeMultiplier};
|
|
69
|
-
return tm;
|
|
119
|
+
TextMeasurement tm{};
|
|
120
|
+
if (spTextLayout) {
|
|
121
|
+
DWRITE_TEXT_METRICS dtm{};
|
|
122
|
+
winrt::check_hresult(spTextLayout->GetMetrics(&dtm));
|
|
123
|
+
tm.size = {dtm.width, dtm.height};
|
|
70
124
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
};
|
|
125
|
+
return tm;
|
|
126
|
+
}
|
|
74
127
|
|
|
75
128
|
/**
|
|
76
129
|
* Measures an AttributedString on the platform, as identified by some
|
|
@@ -81,8 +134,7 @@ TextMeasurement TextLayoutManager::measureCachedSpannableById(
|
|
|
81
134
|
ParagraphAttributes const ¶graphAttributes,
|
|
82
135
|
LayoutConstraints layoutConstraints) const {
|
|
83
136
|
assert(false);
|
|
84
|
-
|
|
85
|
-
return tm;
|
|
137
|
+
return {};
|
|
86
138
|
}
|
|
87
139
|
|
|
88
140
|
LinesMeasurements TextLayoutManager::measureLines(
|
|
@@ -90,9 +142,7 @@ LinesMeasurements TextLayoutManager::measureLines(
|
|
|
90
142
|
ParagraphAttributes paragraphAttributes,
|
|
91
143
|
Size size) const {
|
|
92
144
|
assert(false);
|
|
93
|
-
|
|
94
|
-
std::vector<LineMeasurement> paragraphLines{};
|
|
95
|
-
return paragraphLines;
|
|
145
|
+
return {};
|
|
96
146
|
}
|
|
97
147
|
|
|
98
148
|
void *TextLayoutManager::getNativeTextLayoutManager() const {
|
package/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/TextLayoutManager.h
CHANGED
|
@@ -28,7 +28,7 @@ class TextLayoutManager {
|
|
|
28
28
|
|
|
29
29
|
#pragma region required interface from core cxx cross platform impl
|
|
30
30
|
TextLayoutManager(const ContextContainer::Shared &contextContainer) : m_contextContainer(contextContainer){};
|
|
31
|
-
~TextLayoutManager();
|
|
31
|
+
~TextLayoutManager() = default;
|
|
32
32
|
|
|
33
33
|
/*
|
|
34
34
|
* Measures `attributedStringBox` using native text rendering infrastructure.
|
|
@@ -60,11 +60,17 @@ class TextLayoutManager {
|
|
|
60
60
|
*/
|
|
61
61
|
void *getNativeTextLayoutManager() const;
|
|
62
62
|
|
|
63
|
+
static void GetTextLayout(
|
|
64
|
+
AttributedStringBox attributedStringBox,
|
|
65
|
+
ParagraphAttributes paragraphAttributes,
|
|
66
|
+
LayoutConstraints layoutConstraints,
|
|
67
|
+
const std::optional<TextAlignment> &textAlignment,
|
|
68
|
+
winrt::com_ptr<IDWriteTextLayout> &spTextLayout) noexcept;
|
|
69
|
+
|
|
63
70
|
#pragma endregion
|
|
64
71
|
|
|
65
72
|
private:
|
|
66
73
|
ContextContainer::Shared m_contextContainer;
|
|
67
|
-
mutable winrt::com_ptr<IDWriteFactory> m_spDWriteFactory;
|
|
68
74
|
};
|
|
69
75
|
|
|
70
76
|
} // namespace react
|
|
@@ -507,6 +507,7 @@
|
|
|
507
507
|
<ClCompile Include="$(ReactNativeWindowsDir)codegen\react\components\rnwcore\ShadowNodes.cpp" />
|
|
508
508
|
<ClCompile Include="Fabric\ActivityIndicatorComponentView.cpp" />
|
|
509
509
|
<ClCompile Include="Fabric\ComponentViewRegistry.cpp" />
|
|
510
|
+
<ClCompile Include="Fabric\DWriteHelpers.cpp" />
|
|
510
511
|
<ClCompile Include="Fabric\FabricUIManagerModule.cpp" />
|
|
511
512
|
<ClCompile Include="Fabric\ImageComponentView.cpp" />
|
|
512
513
|
<ClCompile Include="Fabric\ImageManager.cpp" />
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
3
|
|
|
4
4
|
#include <CreateModules.h>
|
|
5
|
+
#include <Networking/WinRTWebSocketResource.h>
|
|
5
6
|
#include <QuirkSettings.h>
|
|
6
7
|
#include <React.h>
|
|
7
8
|
#include <ReactPropertyBag.h>
|
|
8
|
-
#include <WinRTWebSocketResource.h>
|
|
9
9
|
|
|
10
10
|
// React Native
|
|
11
11
|
#include <cxxreact/CxxModule.h>
|
|
@@ -17,11 +17,11 @@ using winrt::Microsoft::ReactNative::ReactPropertyBag;
|
|
|
17
17
|
using winrt::Microsoft::ReactNative::ReactPropertyId;
|
|
18
18
|
using winrt::Microsoft::ReactNative::implementation::QuirkSettings;
|
|
19
19
|
|
|
20
|
-
namespace Microsoft::React {
|
|
20
|
+
namespace Microsoft::React::Networking {
|
|
21
21
|
|
|
22
22
|
std::shared_ptr<IWebSocketResource> IWebSocketResource::Make() {
|
|
23
23
|
std::vector<winrt::Windows::Security::Cryptography::Certificates::ChainValidationResult> certExceptions;
|
|
24
24
|
return std::make_shared<WinRTWebSocketResource>(std::move(certExceptions));
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
} // namespace Microsoft::React
|
|
27
|
+
} // namespace Microsoft::React::Networking
|
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
#include <JSValueWriter.h>
|
|
13
13
|
#include <Utils/PropertyUtils.h>
|
|
14
14
|
|
|
15
|
+
#include <UI.Xaml.Automation.Peers.h>
|
|
16
|
+
|
|
15
17
|
#ifdef USE_WINUI3
|
|
16
18
|
#define TAB_INDEX_PROPERTY xaml::UIElement::TabIndexProperty
|
|
17
19
|
#define TAB_STOP_PROPERTY xaml::UIElement::IsTabStopProperty
|
|
@@ -80,11 +82,18 @@ bool ControlViewManager::UpdateProperty(
|
|
|
80
82
|
}
|
|
81
83
|
} else if (propertyName == "focusable") {
|
|
82
84
|
if (propertyValue.Type() == winrt::Microsoft::ReactNative::JSValueType::Boolean) {
|
|
85
|
+
IsFocusable(propertyValue.AsBoolean());
|
|
83
86
|
control.IsTabStop(propertyValue.AsBoolean());
|
|
84
87
|
} else if (propertyValue.IsNull()) {
|
|
85
88
|
control.ClearValue(TAB_STOP_PROPERTY());
|
|
89
|
+
IsFocusable(false);
|
|
86
90
|
}
|
|
87
91
|
} else {
|
|
92
|
+
if (propertyName == "accessible") {
|
|
93
|
+
if (propertyValue.Type() == winrt::Microsoft::ReactNative::JSValueType::Boolean) {
|
|
94
|
+
IsAccessible(propertyValue.AsBoolean());
|
|
95
|
+
}
|
|
96
|
+
}
|
|
88
97
|
ret = Super::UpdateProperty(nodeToUpdate, propertyName, propertyValue);
|
|
89
98
|
}
|
|
90
99
|
}
|
|
@@ -96,6 +105,16 @@ bool ControlViewManager::UpdateProperty(
|
|
|
96
105
|
return ret;
|
|
97
106
|
}
|
|
98
107
|
|
|
108
|
+
void ControlViewManager::OnPropertiesUpdated(ShadowNodeBase *node) {
|
|
109
|
+
auto control(node->GetView().as<xaml::Controls::Control>());
|
|
110
|
+
|
|
111
|
+
if (IsAccessible() != IsFocusable()) {
|
|
112
|
+
control.IsTabStop(false);
|
|
113
|
+
xaml::Automation::AutomationProperties::SetAccessibilityView(
|
|
114
|
+
control, xaml::Automation::Peers::AccessibilityView::Raw);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
99
118
|
void ControlViewManager::OnViewCreated(XamlView view) {
|
|
100
119
|
// Set the default cornerRadius to 0 for Control: WinUI usually default cornerRadius to 2
|
|
101
120
|
// Only works on >= RS5 because Control.CornerRadius is only supported >= RS5
|
|
@@ -104,4 +123,17 @@ void ControlViewManager::OnViewCreated(XamlView view) {
|
|
|
104
123
|
}
|
|
105
124
|
}
|
|
106
125
|
|
|
126
|
+
void ControlViewManager::IsAccessible(bool accessible) {
|
|
127
|
+
m_isAccessible = accessible;
|
|
128
|
+
}
|
|
129
|
+
bool ControlViewManager::IsAccessible() {
|
|
130
|
+
return m_isAccessible;
|
|
131
|
+
}
|
|
132
|
+
void ControlViewManager::IsFocusable(bool focusable) {
|
|
133
|
+
m_isFocusable = focusable;
|
|
134
|
+
}
|
|
135
|
+
bool ControlViewManager::IsFocusable() {
|
|
136
|
+
return m_isFocusable;
|
|
137
|
+
}
|
|
138
|
+
|
|
107
139
|
} // namespace Microsoft::ReactNative
|
|
@@ -24,6 +24,17 @@ class REACTWINDOWS_EXPORT ControlViewManager : public FrameworkElementViewManage
|
|
|
24
24
|
|
|
25
25
|
protected:
|
|
26
26
|
void OnViewCreated(XamlView view) override;
|
|
27
|
+
|
|
28
|
+
void OnPropertiesUpdated(ShadowNodeBase *node) override;
|
|
29
|
+
|
|
30
|
+
private:
|
|
31
|
+
void IsAccessible(bool accessible);
|
|
32
|
+
bool IsAccessible();
|
|
33
|
+
void IsFocusable(bool focusable);
|
|
34
|
+
bool IsFocusable();
|
|
35
|
+
|
|
36
|
+
bool m_isAccessible = true;
|
|
37
|
+
bool m_isFocusable = true;
|
|
27
38
|
};
|
|
28
39
|
|
|
29
40
|
} // namespace Microsoft::ReactNative
|
|
@@ -205,8 +205,8 @@ void DevMenuManager::CreateAndShowUI() noexcept {
|
|
|
205
205
|
if (Mso::React::ReactOptions::JsiEngine(m_context->Properties()) == Mso::React::JSIEngine::Hermes) {
|
|
206
206
|
m_samplingProfilerRevoker = devMenu.SamplingProfiler().Click(
|
|
207
207
|
winrt::auto_revoke,
|
|
208
|
-
[wkThis = weak_from_this()](
|
|
209
|
-
|
|
208
|
+
[wkThis = weak_from_this()](auto & /*sender*/, xaml::RoutedEventArgs const & /*args*/) noexcept
|
|
209
|
+
-> winrt::fire_and_forget {
|
|
210
210
|
if (auto strongThis = wkThis.lock()) {
|
|
211
211
|
strongThis->Hide();
|
|
212
212
|
if (!Microsoft::ReactNative::HermesSamplingProfiler::IsStarted()) {
|