1 /*
2  * Copyright (c) 2024 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 FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_WEB_WEB_CONTEXT_SELECT_OVERLAY_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_WEB_WEB_CONTEXT_SELECT_OVERLAY_H
18 
19 #include <optional>
20 
21 #include "base/geometry/ng/rect_t.h"
22 #include "base/memory/ace_type.h"
23 #include "base/memory/referenced.h"
24 #include "core/components_ng/pattern/text/base_text_select_overlay.h"
25 #include "core/components_ng/pattern/text/text_base.h"
26 
27 namespace OHOS::Ace::NG {
28 
29 class WebContextSelectOverlay : public BaseTextSelectOverlay {
30     DECLARE_ACE_TYPE(WebContextSelectOverlay, BaseTextSelectOverlay);
31 
32 public:
WebContextSelectOverlay(const WeakPtr<TextBase> & textBase)33     explicit WebContextSelectOverlay(const WeakPtr<TextBase>& textBase) : BaseTextSelectOverlay(textBase) {}
34     ~WebContextSelectOverlay() = default;
35 
36     // override BaseTextSelectOverlay
37     bool PreProcessOverlay(const OverlayRequest& request) override;
38     bool CheckHandleVisible(const RectF& paintRect) override;
OnResetTextSelection()39     void OnResetTextSelection() override {}
AfterCloseOverlay()40     void AfterCloseOverlay() override {}
41     // override BaseTextSelectOverlay end
42 
43     // override SelectOverlayHolder
44     void OnUpdateSelectOverlayInfo(SelectOverlayInfo& selectInfo, int32_t requestCode) override;
45     std::optional<SelectHandleInfo> GetFirstHandleInfo() override;
46     std::optional<SelectHandleInfo> GetSecondHandleInfo() override;
47     void OnUpdateMenuInfo(SelectMenuInfo& menuInfo, SelectOverlayDirtyFlag dirtyFlag) override;
48     RectF GetSelectArea() override;
49     std::string GetSelectedText() override;
50     // override SelectOverlayHolder end
51 
52     // override SelectOverlayCallback
53     void OnMenuItemAction(OptionMenuActionId id, OptionMenuType type) override;
OnHandleMove(const RectF & rect,bool isFirst)54     void OnHandleMove(const RectF& rect, bool isFirst) override {}
55     void OnHandleMoveDone(const RectF& rect, bool isFirst) override;
56     void OnCloseOverlay(OptionMenuType menuType, CloseReason reason, RefPtr<OverlayInfo> info = nullptr) override;
57     void OnHandleGlobalTouchEvent(SourceType sourceType, TouchType touchType, bool touchInside = true) override;
58     // override SelectOverlayCallback end
59 
60 private:
61     bool hasText_ = false;
62     bool hasImage_ = false;
63 
64     ACE_DISALLOW_COPY_AND_MOVE(WebContextSelectOverlay);
65 };
66 } // namespace OHOS::Ace::NG
67 
68 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_WEB_WEB_CONTEXT_SELECT_OVERLAY_H
69