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 FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_SECURITY_COMPONENT_HANDLER_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_SECURITY_COMPONENT_HANDLER_H 18 #include "core/components_ng/base/frame_node.h" 19 #include "core/components_ng/pattern/security_component/security_component_pattern.h" 20 #include "core/components_ng/pattern/security_component/security_component_probe.h" 21 #include "location_button.h" 22 #include "paste_button.h" 23 #include "save_button.h" 24 #include "sec_comp_err.h" 25 #include "sec_comp_kit.h" 26 27 namespace OHOS::Ace::NG { 28 class SecurityComponentHandler { 29 public: 30 static int32_t RegisterSecurityComponent(RefPtr<FrameNode>& node, int32_t& scId); 31 static int32_t UpdateSecurityComponent(RefPtr<FrameNode>& node, int32_t& scId); 32 static int32_t UnregisterSecurityComponent(int32_t& scId); 33 static int32_t ReportSecurityComponentClickEvent(int32_t& scId, RefPtr<FrameNode>& node, GestureEvent& event); 34 static int32_t ReportSecurityComponentClickEvent(int32_t& scId, RefPtr<FrameNode>& node, const KeyEvent& event); 35 static bool InitButtonInfo(std::string& componentInfo, 36 RefPtr<FrameNode>& node, Security::SecurityComponent::SecCompType& scType); 37 static bool GetDisplayOffset(RefPtr<FrameNode>& node, double& offsetX, double& offsetY); 38 static bool GetWindowRect(RefPtr<FrameNode>& node, OHOS::Security::SecurityComponent::SecCompRect& winRect); 39 static OHOS::Security::SecurityComponent::SecCompUiRegister uiRegister; 40 static SecurityComponentProbe probe; 41 static int32_t ReportSecurityComponentClickEventInner(int32_t& scId, 42 RefPtr<FrameNode>& node, Security::SecurityComponent::SecCompClickEvent& event); 43 44 private: 45 static bool CheckOpacity(const RefPtr<FrameNode>& node, const RefPtr<RenderContext>& renderContext); 46 static bool CheckBrightness(const RefPtr<FrameNode>& node, const RefPtr<RenderContext>& renderContext); 47 static bool CheckVisibility(const RefPtr<FrameNode>& node, RefPtr<LayoutProperty>& layoutProperty); 48 static bool CheckBlur(const RefPtr<FrameNode>& node, const RefPtr<RenderContext>& renderContext); 49 static bool CheckGrayScale(const RefPtr<FrameNode>& node, const RefPtr<RenderContext>& renderContext); 50 static bool CheckSaturate(const RefPtr<FrameNode>& node, const RefPtr<RenderContext>& renderContext); 51 static bool CheckContrast(const RefPtr<FrameNode>& node, const RefPtr<RenderContext>& renderContext); 52 static bool CheckInvert(const RefPtr<FrameNode>& node, const RefPtr<RenderContext>& renderContext); 53 static bool CheckSepia(const RefPtr<FrameNode>& node, const RefPtr<RenderContext>& renderContext); 54 static bool CheckHueRotate(const RefPtr<FrameNode>& node, const RefPtr<RenderContext>& renderContext); 55 static bool CheckColorBlend(const RefPtr<FrameNode>& node, const RefPtr<RenderContext>& renderContext); 56 static bool CheckClipMask(const RefPtr<FrameNode>& node, const RefPtr<RenderContext>& renderContext); 57 static bool CheckForegroundColor(const RefPtr<FrameNode>& node, const RefPtr<RenderContext>& renderContext); 58 static bool CheckSphericalEffect(const RefPtr<FrameNode>& node, const RefPtr<RenderContext>& renderContext); 59 static bool CheckLightUpEffect(const RefPtr<FrameNode>& node, const RefPtr<RenderContext>& renderContext); 60 static bool CheckPixelStretchEffect(const RefPtr<FrameNode>& node, const RefPtr<RenderContext>& renderContext); 61 static bool CheckRenderEffect(RefPtr<FrameNode>& node); 62 static bool CheckParentNodesEffect(RefPtr<FrameNode>& node); 63 static void GetVisibleRect(RefPtr<FrameNode>& node, RectF& visibleRect); 64 static double CalculateCurrentVisibleRatio(const RectF& visibleRect, const RectF& renderRect); 65 static bool InitBaseInfo(OHOS::Security::SecurityComponent::SecCompBase& buttonInfo, RefPtr<FrameNode>& node); 66 static bool InitChildInfo(OHOS::Security::SecurityComponent::SecCompBase& buttonInfo, RefPtr<FrameNode>& node); 67 }; 68 } // namespace OHOS::Ace 69 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_SECURITY_COMPONENT_HANDLER_H 70