1 /* 2 * Copyright (C) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef OPENHARMONY_TEXT_INPUT_AI_CHECKER_H 17 #define OPENHARMONY_TEXT_INPUT_AI_CHECKER_H 18 #include <string> 19 20 #include "base/geometry/ng/offset_t.h" 21 #include "base/geometry/ng/rect_t.h" 22 #include "core/components_ng/pattern/text_field/text_selector.h" 23 24 namespace OHOS::Ace { 25 class ACE_FORCE_EXPORT InputAIChecker { 26 public: 27 constexpr static float FLOAT_DIFF_COMPARE = 1.0f; 28 constexpr static uint32_t SECONDS_TO_MILLISECONDS = 1000; 29 constexpr static float AIPOS_RECTIFIED_INTERVAL_MS = 1000.0f; 30 31 static bool NeedAIAnalysis(const std::string& content, NG::CaretUpdateType targetType, 32 std::chrono::duration<float, std::ratio<1, SECONDS_TO_MILLISECONDS>> timeout); 33 34 static bool IsSingleClickAtBoundary(int32_t position, int32_t textLength); 35 36 static bool IsMultiClickAtBoundary(const NG::OffsetF& handleOffset, const NG::RectF& textRect); 37 }; 38 } // namespace OHOS::Ace 39 40 #endif // OPENHARMONY_TEXT_INPUT_AI_CHECKER_H 41