Bug 1725806 - Part 6. Support autocorrect on UIKit backend. r=masayuki

Differential Revision: https://phabricator.services.mozilla.com/D221574
This commit is contained in:
Makoto Kato 2024-10-28 17:06:51 +00:00
parent 68729cfdbb
commit 0f838e0695
3 changed files with 23 additions and 0 deletions

View File

@ -3,6 +3,9 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_widget_UIKitUtils_h__
#define mozilla_widget_UIKitUtils_h__
#import <UIKit/UIKit.h>
#include "IMEData.h"
@ -18,6 +21,10 @@ class UIKitUtils final {
static UIReturnKeyType GetUIReturnKeyType(const InputContext& aContext);
static UITextAutocapitalizationType GetUITextAutocapitalizationType(
const InputContext& aContext);
static UITextAutocorrectionType GetUITextAutocorrectionType(
const InputContext& aContext);
};
} // namespace mozilla::widget
#endif

View File

@ -86,4 +86,11 @@ UITextAutocapitalizationType UIKitUtils::GetUITextAutocapitalizationType(
return UITextAutocapitalizationTypeNone;
}
// static
UITextAutocorrectionType UIKitUtils::GetUITextAutocorrectionType(
const InputContext& aContext) {
return aContext.mAutocorrect ? UITextAutocorrectionTypeYes
: UITextAutocorrectionTypeNo;
}
} // namespace mozilla::widget

View File

@ -552,6 +552,15 @@ class nsAutoRetainUIKitObject {
mGeckoChild->GetInputContext());
}
- (UITextAutocorrectionType)autocorrectionType {
if (!mGeckoChild || mGeckoChild->Destroyed()) {
return UITextAutocorrectionTypeDefault;
}
return UIKitUtils::GetUITextAutocorrectionType(
mGeckoChild->GetInputContext());
}
- (BOOL)isSecureTextEntry {
if (!mGeckoChild || mGeckoChild->Destroyed()) {
return NO;