react-native-windows 0.0.0-canary.643 → 0.0.0-canary.645
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/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +7 -4
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputProps.cpp +1 -0
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputProps.h +1 -0
- package/Microsoft.ReactNative/Views/TextInputViewManager.cpp +26 -8
- package/PropertySheets/Generated/PackageVersion.g.props +2 -2
- package/Shared/Networking/OriginPolicyHttpFilter.cpp +17 -13
- package/Shared/Networking/OriginPolicyHttpFilter.h +12 -11
- package/package.json +1 -1
package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp
CHANGED
|
@@ -628,6 +628,13 @@ void WindowsTextInputComponentView::updateProps(
|
|
|
628
628
|
}
|
|
629
629
|
}
|
|
630
630
|
|
|
631
|
+
if (oldTextInputProps.editable != newTextInputProps.editable) {
|
|
632
|
+
propBitsMask |= TXTBIT_READONLY;
|
|
633
|
+
if (!newTextInputProps.editable) {
|
|
634
|
+
propBits |= TXTBIT_READONLY;
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
|
|
631
638
|
/*
|
|
632
639
|
if (oldTextInputProps.textAttributes.foregroundColor != newTextInputProps.textAttributes.foregroundColor) {
|
|
633
640
|
if (newTextInputProps.textAttributes.foregroundColor)
|
|
@@ -668,10 +675,6 @@ void WindowsTextInputComponentView::updateProps(
|
|
|
668
675
|
m_element.PlaceholderText(winrt::to_hstring(newTextInputProps.placeholder));
|
|
669
676
|
}
|
|
670
677
|
|
|
671
|
-
if (oldTextInputProps.editable != newTextInputProps.editable) {
|
|
672
|
-
m_element.IsReadOnly(!newTextInputProps.editable);
|
|
673
|
-
}
|
|
674
|
-
|
|
675
678
|
if (oldTextInputProps.selection.start != newTextInputProps.selection.start ||
|
|
676
679
|
oldTextInputProps.selection.end != newTextInputProps.selection.end) {
|
|
677
680
|
m_element.Select(
|
|
@@ -32,6 +32,7 @@ WindowsTextInputProps::WindowsTextInputProps(
|
|
|
32
32
|
placeholderTextColor(
|
|
33
33
|
convertRawProp(context, rawProps, "placeholderTextColor", sourceProps.placeholderTextColor, {})),
|
|
34
34
|
scrollEnabled(convertRawProp(context, rawProps, "scrollEnabled", sourceProps.scrollEnabled, {true})),
|
|
35
|
+
cursorColor(convertRawProp(context, rawProps, "cursorColor", sourceProps.cursorColor, {})),
|
|
35
36
|
selection(convertRawProp(context, rawProps, "selection", sourceProps.selection, {})),
|
|
36
37
|
selectionColor(convertRawProp(context, rawProps, "selectionColor", sourceProps.selectionColor, {})),
|
|
37
38
|
selectTextOnFocus(convertRawProp(context, rawProps, "selectTextOnFocus", sourceProps.selectTextOnFocus, {false})),
|
|
@@ -103,6 +103,7 @@ class WindowsTextInputProps final : public ViewProps, public BaseTextProps {
|
|
|
103
103
|
std::string placeholder{};
|
|
104
104
|
SharedColor placeholderTextColor{};
|
|
105
105
|
bool scrollEnabled{true};
|
|
106
|
+
SharedColor cursorColor{};
|
|
106
107
|
CompWindowsTextInputSelectionStruct selection{};
|
|
107
108
|
SharedColor selectionColor{};
|
|
108
109
|
bool selectTextOnFocus{false};
|
|
@@ -127,7 +127,7 @@ class TextInputShadowNode : public ShadowNodeBase {
|
|
|
127
127
|
void dispatchTextInputChangeEvent(winrt::hstring newText);
|
|
128
128
|
void registerEvents();
|
|
129
129
|
void registerPreviewKeyDown();
|
|
130
|
-
void
|
|
130
|
+
void UpdateCaretColorOrHideIfNeeded();
|
|
131
131
|
void setPasswordBoxPlaceholderForeground(
|
|
132
132
|
xaml::Controls::PasswordBox passwordBox,
|
|
133
133
|
const winrt::Microsoft::ReactNative::JSValue &color);
|
|
@@ -144,6 +144,8 @@ class TextInputShadowNode : public ShadowNodeBase {
|
|
|
144
144
|
bool m_hideCaret = false;
|
|
145
145
|
bool m_shouldClearTextOnSubmit = false;
|
|
146
146
|
|
|
147
|
+
winrt::Microsoft::ReactNative::JSValue m_cursorColor;
|
|
148
|
+
|
|
147
149
|
winrt::Microsoft::ReactNative::JSValue m_placeholderTextColor;
|
|
148
150
|
std::vector<HandledKeyboardEvent> m_submitKeyEvents{};
|
|
149
151
|
|
|
@@ -260,7 +262,7 @@ void TextInputShadowNode::registerEvents() {
|
|
|
260
262
|
control.as<xaml::Controls::PasswordBox>().SelectAll();
|
|
261
263
|
}
|
|
262
264
|
}
|
|
263
|
-
|
|
265
|
+
UpdateCaretColorOrHideIfNeeded();
|
|
264
266
|
|
|
265
267
|
folly::dynamic eventData = folly::dynamic::object("target", tag);
|
|
266
268
|
if (!m_updating)
|
|
@@ -330,7 +332,7 @@ void TextInputShadowNode::registerEvents() {
|
|
|
330
332
|
}
|
|
331
333
|
});
|
|
332
334
|
}
|
|
333
|
-
|
|
335
|
+
UpdateCaretColorOrHideIfNeeded();
|
|
334
336
|
});
|
|
335
337
|
|
|
336
338
|
if (control.try_as<xaml::IUIElement7>()) {
|
|
@@ -448,14 +450,24 @@ bool TextInputShadowNode::IsTextBox() {
|
|
|
448
450
|
return !!GetView().try_as<xaml::Controls::TextBox>();
|
|
449
451
|
}
|
|
450
452
|
|
|
451
|
-
// hacking solution to hide the caret
|
|
452
|
-
void TextInputShadowNode::
|
|
453
|
+
// hacking solution to hide the caret or change its color
|
|
454
|
+
void TextInputShadowNode::UpdateCaretColorOrHideIfNeeded() {
|
|
455
|
+
bool updateRequired = false;
|
|
456
|
+
xaml::Media::SolidColorBrush color;
|
|
457
|
+
|
|
453
458
|
if (m_hideCaret) {
|
|
459
|
+
updateRequired = true;
|
|
460
|
+
color = xaml::Media::SolidColorBrush(winrt::Colors::Transparent());
|
|
461
|
+
} else if (!m_cursorColor.IsNull()) {
|
|
462
|
+
updateRequired = true;
|
|
463
|
+
color = SolidColorBrushFrom(m_cursorColor);
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
if (updateRequired) {
|
|
454
467
|
auto control = GetView().as<xaml::Controls::Control>();
|
|
455
468
|
if (auto caret = FindCaret(control)) {
|
|
456
469
|
caret.CompositeMode(xaml::Media::ElementCompositeMode::Inherit);
|
|
457
|
-
|
|
458
|
-
caret.Fill(transparentColor);
|
|
470
|
+
caret.Fill(color);
|
|
459
471
|
}
|
|
460
472
|
}
|
|
461
473
|
}
|
|
@@ -520,7 +532,7 @@ void TextInputShadowNode::updateProperties(winrt::Microsoft::ReactNative::JSValu
|
|
|
520
532
|
} else if (propertyName == "caretHidden") {
|
|
521
533
|
if (propertyValue.Type() == winrt::Microsoft::ReactNative::JSValueType::Boolean) {
|
|
522
534
|
m_hideCaret = propertyValue.AsBoolean();
|
|
523
|
-
|
|
535
|
+
UpdateCaretColorOrHideIfNeeded();
|
|
524
536
|
}
|
|
525
537
|
} else if (propertyName == "focusable") {
|
|
526
538
|
// parent class also sets isTabStop
|
|
@@ -581,6 +593,11 @@ void TextInputShadowNode::updateProperties(winrt::Microsoft::ReactNative::JSValu
|
|
|
581
593
|
isTextBox ? xaml::Controls::TextBox::PlaceholderTextProperty()
|
|
582
594
|
: xaml::Controls::PasswordBox::PlaceholderTextProperty());
|
|
583
595
|
}
|
|
596
|
+
} else if (propertyName == "cursorColor") {
|
|
597
|
+
m_cursorColor = nullptr;
|
|
598
|
+
if (IsValidColorValue(propertyValue)) {
|
|
599
|
+
m_cursorColor = propertyValue.Copy();
|
|
600
|
+
}
|
|
584
601
|
} else if (propertyName == "selectionColor") {
|
|
585
602
|
if (IsValidColorValue(propertyValue)) {
|
|
586
603
|
control.SetValue(
|
|
@@ -822,6 +839,7 @@ void TextInputViewManager::GetNativeProps(const winrt::Microsoft::ReactNative::I
|
|
|
822
839
|
React::WriteProperty(writer, L"placeholder", L"string");
|
|
823
840
|
React::WriteProperty(writer, L"placeholderTextColor", L"Color");
|
|
824
841
|
React::WriteProperty(writer, L"scrollEnabled", L"boolean");
|
|
842
|
+
React::WriteProperty(writer, L"cursorColor", L"Color");
|
|
825
843
|
React::WriteProperty(writer, L"selection", L"Map");
|
|
826
844
|
React::WriteProperty(writer, L"selectionColor", L"Color");
|
|
827
845
|
React::WriteProperty(writer, L"selectTextOnFocus", L"boolean");
|
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
-->
|
|
11
11
|
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
12
12
|
<PropertyGroup>
|
|
13
|
-
<ReactNativeWindowsVersion>0.0.0-canary.
|
|
13
|
+
<ReactNativeWindowsVersion>0.0.0-canary.645</ReactNativeWindowsVersion>
|
|
14
14
|
<ReactNativeWindowsMajor>0</ReactNativeWindowsMajor>
|
|
15
15
|
<ReactNativeWindowsMinor>0</ReactNativeWindowsMinor>
|
|
16
16
|
<ReactNativeWindowsPatch>0</ReactNativeWindowsPatch>
|
|
17
17
|
<ReactNativeWindowsCanary>true</ReactNativeWindowsCanary>
|
|
18
|
-
<ReactNativeWindowsCommitId>
|
|
18
|
+
<ReactNativeWindowsCommitId>84b7f820be4deceb26a7baed1a5897dee6d68316</ReactNativeWindowsCommitId>
|
|
19
19
|
</PropertyGroup>
|
|
20
20
|
</Project>
|
|
@@ -37,22 +37,26 @@ namespace Microsoft::React::Networking {
|
|
|
37
37
|
|
|
38
38
|
#pragma region OriginPolicyHttpFilter
|
|
39
39
|
|
|
40
|
-
#pragma region
|
|
40
|
+
#pragma region CaseInsensitiveComparer
|
|
41
41
|
|
|
42
|
-
bool OriginPolicyHttpFilter::
|
|
42
|
+
bool OriginPolicyHttpFilter::CaseInsensitiveComparer::operator()(const wchar_t *a, const wchar_t *b) const {
|
|
43
43
|
return _wcsicmp(a, b) < 0;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
bool OriginPolicyHttpFilter::CaseInsensitiveComparer::operator()(const wstring &a, const wstring &b) const {
|
|
47
|
+
return _wcsicmp(a.c_str(), b.c_str()) < 0;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
#pragma endregion CaseInsensitiveComparer
|
|
47
51
|
|
|
48
52
|
// https://fetch.spec.whatwg.org/#forbidden-method
|
|
49
|
-
/*static*/ set<const wchar_t *, OriginPolicyHttpFilter::
|
|
50
|
-
{L"CONNECT", L"TRACE", L"TRACK"};
|
|
53
|
+
/*static*/ set<const wchar_t *, OriginPolicyHttpFilter::CaseInsensitiveComparer>
|
|
54
|
+
OriginPolicyHttpFilter::s_forbiddenMethods = {L"CONNECT", L"TRACE", L"TRACK"};
|
|
51
55
|
|
|
52
|
-
/*static*/ set<const wchar_t *, OriginPolicyHttpFilter::
|
|
56
|
+
/*static*/ set<const wchar_t *, OriginPolicyHttpFilter::CaseInsensitiveComparer>
|
|
53
57
|
OriginPolicyHttpFilter::s_simpleCorsMethods = {L"GET", L"HEAD", L"POST"};
|
|
54
58
|
|
|
55
|
-
/*static*/ set<const wchar_t *, OriginPolicyHttpFilter::
|
|
59
|
+
/*static*/ set<const wchar_t *, OriginPolicyHttpFilter::CaseInsensitiveComparer>
|
|
56
60
|
OriginPolicyHttpFilter::s_simpleCorsRequestHeaderNames = {
|
|
57
61
|
L"Accept",
|
|
58
62
|
L"Accept-Language",
|
|
@@ -64,11 +68,11 @@ bool OriginPolicyHttpFilter::ConstWcharComparer::operator()(const wchar_t *a, co
|
|
|
64
68
|
L"Viewport-Width",
|
|
65
69
|
L"Width"};
|
|
66
70
|
|
|
67
|
-
/*static*/ set<const wchar_t *, OriginPolicyHttpFilter::
|
|
71
|
+
/*static*/ set<const wchar_t *, OriginPolicyHttpFilter::CaseInsensitiveComparer>
|
|
68
72
|
OriginPolicyHttpFilter::s_simpleCorsResponseHeaderNames =
|
|
69
73
|
{L"Cache-Control", L"Content-Language", L"Content-Type", L"Expires", L"Last-Modified", L"Pragma"};
|
|
70
74
|
|
|
71
|
-
/*static*/ set<const wchar_t *, OriginPolicyHttpFilter::
|
|
75
|
+
/*static*/ set<const wchar_t *, OriginPolicyHttpFilter::CaseInsensitiveComparer>
|
|
72
76
|
OriginPolicyHttpFilter::s_simpleCorsContentTypeValues = {
|
|
73
77
|
L"application/x-www-form-urlencoded",
|
|
74
78
|
L"multipart/form-data",
|
|
@@ -76,7 +80,7 @@ bool OriginPolicyHttpFilter::ConstWcharComparer::operator()(const wchar_t *a, co
|
|
|
76
80
|
|
|
77
81
|
// https://fetch.spec.whatwg.org/#forbidden-header-name
|
|
78
82
|
// Chromium still bans "User-Agent" due to https://crbug.com/571722
|
|
79
|
-
/*static*/ set<const wchar_t *, OriginPolicyHttpFilter::
|
|
83
|
+
/*static*/ set<const wchar_t *, OriginPolicyHttpFilter::CaseInsensitiveComparer>
|
|
80
84
|
OriginPolicyHttpFilter::s_corsForbiddenRequestHeaderNames = {
|
|
81
85
|
L"Accept-Charset",
|
|
82
86
|
L"Accept-Encoding",
|
|
@@ -99,13 +103,13 @@ bool OriginPolicyHttpFilter::ConstWcharComparer::operator()(const wchar_t *a, co
|
|
|
99
103
|
L"Upgrade",
|
|
100
104
|
L"Via"};
|
|
101
105
|
|
|
102
|
-
/*static*/ set<const wchar_t *, OriginPolicyHttpFilter::
|
|
106
|
+
/*static*/ set<const wchar_t *, OriginPolicyHttpFilter::CaseInsensitiveComparer>
|
|
103
107
|
OriginPolicyHttpFilter::s_cookieSettingResponseHeaders = {
|
|
104
108
|
L"Set-Cookie",
|
|
105
109
|
L"Set-Cookie2", // Deprecated by the spec, but probably still used
|
|
106
110
|
};
|
|
107
111
|
|
|
108
|
-
/*static*/ set<const wchar_t *, OriginPolicyHttpFilter::
|
|
112
|
+
/*static*/ set<const wchar_t *, OriginPolicyHttpFilter::CaseInsensitiveComparer>
|
|
109
113
|
OriginPolicyHttpFilter::s_corsForbiddenRequestHeaderNamePrefixes = {L"Proxy-", L"Sec-"};
|
|
110
114
|
|
|
111
115
|
/*static*/ Uri OriginPolicyHttpFilter::s_origin{nullptr};
|
|
@@ -293,7 +297,7 @@ bool OriginPolicyHttpFilter::ConstWcharComparer::operator()(const wchar_t *a, co
|
|
|
293
297
|
}
|
|
294
298
|
|
|
295
299
|
/*static*/ OriginPolicyHttpFilter::AccessControlValues OriginPolicyHttpFilter::ExtractAccessControlValues(
|
|
296
|
-
|
|
300
|
+
IMap<hstring, hstring> const &headers) {
|
|
297
301
|
using std::wregex;
|
|
298
302
|
using std::wsregex_token_iterator;
|
|
299
303
|
|
|
@@ -22,19 +22,20 @@ class OriginPolicyHttpFilter
|
|
|
22
22
|
: public winrt::
|
|
23
23
|
implements<OriginPolicyHttpFilter, winrt::Windows::Web::Http::Filters::IHttpFilter, IRedirectEventSource> {
|
|
24
24
|
public:
|
|
25
|
-
struct
|
|
25
|
+
struct CaseInsensitiveComparer {
|
|
26
26
|
bool operator()(const wchar_t *, const wchar_t *) const;
|
|
27
|
+
bool operator()(const std::wstring &, const std::wstring &) const;
|
|
27
28
|
};
|
|
28
29
|
|
|
29
30
|
private:
|
|
30
|
-
static std::set<const wchar_t *,
|
|
31
|
-
static std::set<const wchar_t *,
|
|
32
|
-
static std::set<const wchar_t *,
|
|
33
|
-
static std::set<const wchar_t *,
|
|
34
|
-
static std::set<const wchar_t *,
|
|
35
|
-
static std::set<const wchar_t *,
|
|
36
|
-
static std::set<const wchar_t *,
|
|
37
|
-
static std::set<const wchar_t *,
|
|
31
|
+
static std::set<const wchar_t *, CaseInsensitiveComparer> s_forbiddenMethods;
|
|
32
|
+
static std::set<const wchar_t *, CaseInsensitiveComparer> s_simpleCorsMethods;
|
|
33
|
+
static std::set<const wchar_t *, CaseInsensitiveComparer> s_simpleCorsRequestHeaderNames;
|
|
34
|
+
static std::set<const wchar_t *, CaseInsensitiveComparer> s_simpleCorsResponseHeaderNames;
|
|
35
|
+
static std::set<const wchar_t *, CaseInsensitiveComparer> s_simpleCorsContentTypeValues;
|
|
36
|
+
static std::set<const wchar_t *, CaseInsensitiveComparer> s_corsForbiddenRequestHeaderNames;
|
|
37
|
+
static std::set<const wchar_t *, CaseInsensitiveComparer> s_corsForbiddenRequestHeaderNamePrefixes;
|
|
38
|
+
static std::set<const wchar_t *, CaseInsensitiveComparer> s_cookieSettingResponseHeaders;
|
|
38
39
|
|
|
39
40
|
// NOTE: Assumes static origin through owning client/resource/module/(React) instance's lifetime.
|
|
40
41
|
static winrt::Windows::Foundation::Uri s_origin;
|
|
@@ -42,9 +43,9 @@ class OriginPolicyHttpFilter
|
|
|
42
43
|
struct AccessControlValues {
|
|
43
44
|
winrt::hstring AllowedOrigin;
|
|
44
45
|
winrt::hstring AllowedCredentials;
|
|
45
|
-
std::set<std::wstring> AllowedHeaders;
|
|
46
|
+
std::set<std::wstring, CaseInsensitiveComparer> AllowedHeaders;
|
|
46
47
|
std::set<std::wstring> AllowedMethods;
|
|
47
|
-
std::set<std::wstring> ExposedHeaders;
|
|
48
|
+
std::set<std::wstring, CaseInsensitiveComparer> ExposedHeaders;
|
|
48
49
|
size_t MaxAge;
|
|
49
50
|
};
|
|
50
51
|
|