1 /* 2 * Copyright (c) 2022-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_PATTERNS_WEB_WEB_PATTERN_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_WEB_WEB_PATTERN_H 18 19 #include <optional> 20 #include <string> 21 #include <tuple> 22 #include <utility> 23 24 #include "base/memory/referenced.h" 25 #include "base/thread/cancelable_callback.h" 26 #include "base/utils/utils.h" 27 #include "base/geometry/axis.h" 28 #include "base/view_data/hint_to_type_wrap.h" 29 #include "core/common/ai/data_detector_mgr.h" 30 #include "core/common/ai/data_detector_adapter.h" 31 #include "core/common/recorder/web_event_recorder.h" 32 #include "core/common/udmf/unified_data.h" 33 #include "core/components/common/layout/constants.h" 34 #include "core/components/dialog/dialog_properties.h" 35 #include "core/components/dialog/dialog_theme.h" 36 #include "core/components/web/web_event.h" 37 #include "core/components/web/web_property.h" 38 #include "core/components_ng/gestures/recognizers/pan_recognizer.h" 39 #include "core/components_ng/manager/select_overlay/select_overlay_manager.h" 40 #include "core/components_ng/manager/select_overlay/select_overlay_proxy.h" 41 #include "core/components_ng/manager/select_overlay/selection_host.h" 42 #include "core/components_ng/pattern/pattern.h" 43 #include "core/components_ng/pattern/scrollable/nestable_scroll_container.h" 44 #include "core/components_ng/pattern/web/touch_event_listener.h" 45 #include "core/components_ng/pattern/web/web_accessibility_event_report.h" 46 #include "core/components_ng/pattern/web/web_accessibility_property.h" 47 #include "core/components_ng/pattern/web/web_context_select_overlay.h" 48 #include "core/components_ng/pattern/web/web_event_hub.h" 49 #include "core/components_ng/pattern/web/web_layout_algorithm.h" 50 #include "core/components_ng/pattern/web/web_paint_property.h" 51 #include "core/components_ng/pattern/web/web_pattern_property.h" 52 #include "core/components_ng/pattern/web/web_paint_method.h" 53 #include "core/components_ng/property/property.h" 54 #include "core/components_ng/render/adapter/rosen_render_context.h" 55 #include "core/components_ng/render/render_surface.h" 56 #include "core/components_ng/pattern/scroll/scroll_pattern.h" 57 #include "core/components_ng/gestures/pinch_gesture.h" 58 #include "core/components_ng/pattern/select_overlay/magnifier.h" 59 #include "core/components_ng/pattern/select_overlay/magnifier_controller.h" 60 #include "core/components_ng/pattern/web/web_data_detector_adapter.h" 61 #include "ui/rs_surface_node.h" 62 #include "core/components_ng/pattern/web/web_select_overlay.h" 63 #include "core/components_ng/pattern/text_field/text_select_controller.h" 64 #include "core/common/ai/ai_write_adapter.h" 65 #include "core/common/ime/text_input_client.h" 66 #include "core/text/text_emoji_processor.h" 67 68 namespace OHOS::Ace { 69 class WebDelegateObserver; 70 class ImageAnalyzerManager; 71 } 72 73 namespace OHOS::NWeb { 74 class NWebQuickMenuParams; 75 class NWebQuickMenuCallback; 76 class NWebTouchHandleState; 77 class NWebCursorInfo; 78 class NWebSelectPopupMenuParam; 79 class NWebDateTimeChooser; 80 class NWebDateTimeSuggestion; 81 class NWebSelectPopupMenuCallback; 82 class NWebDateTimeChooserCallback; 83 class NWebAccessibilityNodeInfo; 84 class NWebMessage; 85 class NWebHapValue; 86 class NWebKeyEvent; 87 class NWebSelectMenuBound; 88 class NWebUpdateScrollUpdateData; 89 class NWebNestedScrollUpdateDataImpl; 90 enum class CursorType; 91 } 92 namespace OHOS::Ace::NG { 93 class WebAccessibilityChildTreeCallback; 94 class ViewDataCommon; 95 class TransitionalNodeInfo; 96 97 namespace { 98 99 struct MouseClickInfo { 100 double x = -1; 101 double y = -1; 102 TimeStamp start; 103 }; 104 105 struct TouchInfo { 106 double x = -1; 107 double y = -1; 108 int32_t id = -1; 109 }; 110 } // namespace 111 112 enum class WebInfoType : int32_t { 113 TYPE_MOBILE, 114 TYPE_TABLET, 115 TYPE_2IN1, 116 TYPE_UNKNOWN 117 }; 118 119 struct PipInfo { 120 uint32_t mainWindowId; 121 int delegateId; 122 int childId; 123 int frameRoutingId; 124 int width; 125 int height; 126 }; 127 128 using CursorStyleInfo = std::tuple<OHOS::NWeb::CursorType, std::shared_ptr<OHOS::NWeb::NWebCursorInfo>>; 129 class WebPattern : public NestableScrollContainer, 130 public TextBase, 131 public Magnifier, 132 public Recorder::WebEventRecorder { 133 DECLARE_ACE_TYPE(WebPattern, NestableScrollContainer, TextBase, Magnifier, Recorder::WebEventRecorder); 134 135 public: 136 using SetWebIdCallback = std::function<void(int32_t)>; 137 using SetWebDetachCallback = std::function<void(int32_t)>; 138 using SetHapPathCallback = std::function<void(const std::string&)>; 139 using JsProxyCallback = std::function<void()>; 140 using OnControllerAttachedCallback = std::function<void()>; 141 using PermissionClipboardCallback = std::function<void(const std::shared_ptr<BaseEventInfo>&)>; 142 using OnOpenAppLinkCallback = std::function<void(const std::shared_ptr<BaseEventInfo>&)>; 143 using SetFaviconCallback = std::function<void(const std::shared_ptr<BaseEventInfo>&)>; 144 using DefaultFileSelectorShowCallback = std::function<void(const std::shared_ptr<BaseEventInfo>&)>; 145 using WebNodeInfoCallback = const std::function<void(std::shared_ptr<JsonValue>& jsonNodeArray, int32_t webId)>; 146 using TextBlurCallback = std::function<void(int64_t, const std::string)>; 147 using WebComponentClickCallback = std::function<void(int64_t, const std::string)>; 148 WebPattern(); 149 WebPattern(const std::string& webSrc, const RefPtr<WebController>& webController, 150 RenderMode type = RenderMode::ASYNC_RENDER, bool incognitoMode = false, 151 const std::string& sharedRenderProcessToken = ""); 152 WebPattern(const std::string& webSrc, const SetWebIdCallback& setWebIdCallback, 153 RenderMode type = RenderMode::ASYNC_RENDER, bool incognitoMode = false, 154 const std::string& sharedRenderProcessToken = ""); 155 156 ~WebPattern() override; 157 158 enum class VkState { 159 VK_NONE, 160 VK_SHOW, 161 VK_HIDE 162 }; 163 164 enum class WebAccessibilityType : int32_t { 165 ID = 0, 166 SEL_START, 167 SEL_END, 168 INPUT_TYPE, 169 LIVE_REGION, 170 HINT, 171 CONTENT, 172 ERROR, 173 CHILD_IDS, 174 PARENT_ID, 175 GRID_ROWS, 176 GRID_COLS, 177 GRID_SEL_MODE, 178 GRID_ITEM_ROW, 179 GRID_ITEM_ROW_SPAN, 180 GRID_ITEM_COL, 181 GRID_ITEM_COL_SPAN, 182 PAGE_ID, 183 RECTX, 184 RECTY, 185 RECT_WIDTH, 186 RECT_HEIGHT, 187 HEADING, 188 CHECKED, 189 EDITABLE, 190 ENABLED, 191 FOCUSED, 192 SELECTED, 193 CHECKABLE, 194 CLICKABLE, 195 FOCUSABLE, 196 SCROLLABLE, 197 PASSWORD, 198 VISIBLE, 199 PLURAL_LINE, 200 POPUP, 201 DELETABLE, 202 FOCUS, 203 NODE_TAG, 204 }; 205 206 RefPtr<NodePaintMethod> CreateNodePaintMethod() override; 207 IsAtomicNode()208 bool IsAtomicNode() const override 209 { 210 return true; 211 } 212 213 bool NeedSoftKeyboard() const override; 214 CreateEventHub()215 RefPtr<EventHub> CreateEventHub() override 216 { 217 return MakeRefPtr<WebEventHub>(); 218 } 219 CreateAccessibilityProperty()220 RefPtr<AccessibilityProperty> CreateAccessibilityProperty() override 221 { 222 return MakeRefPtr<WebAccessibilityProperty>(); 223 } 224 225 226 void OnModifyDone() override; 227 228 void DumpViewDataPageNode(RefPtr<ViewDataWrap> viewDataWrap, bool needsRecordData = false) override; 229 230 void NotifyFillRequestSuccess(RefPtr<ViewDataWrap> viewDataWrap, 231 RefPtr<PageNodeInfoWrap> nodeWrap, AceAutoFillType autoFillType) override; 232 233 void NotifyFillRequestFailed(int32_t errCode, const std::string& fillContent = "", bool isPopup = false) override; 234 235 Color GetDefaultBackgroundColor(); 236 SetWebSrc(const std::string & webSrc)237 void SetWebSrc(const std::string& webSrc) 238 { 239 if (webSrc_ != webSrc_) { 240 OnWebSrcUpdate(); 241 webSrc_ = webSrc; 242 } 243 if (webPaintProperty_) { 244 webPaintProperty_->SetWebPaintData(webSrc); 245 } 246 } 247 GetWebSrc()248 const std::optional<std::string>& GetWebSrc() const 249 { 250 return webSrc_; 251 } 252 SetPopup(bool popup)253 void SetPopup(bool popup) 254 { 255 isPopup_ = popup; 256 } 257 SetParentNWebId(int32_t parentNWebId)258 void SetParentNWebId(int32_t parentNWebId) 259 { 260 parentNWebId_ = parentNWebId; 261 } 262 SetWebData(const std::string & webData)263 void SetWebData(const std::string& webData) 264 { 265 if (webData_ != webData) { 266 webData_ = webData; 267 OnWebDataUpdate(); 268 } 269 if (webPaintProperty_) { 270 webPaintProperty_->SetWebPaintData(webData); 271 } 272 } 273 GetWebData()274 const std::optional<std::string>& GetWebData() const 275 { 276 return webData_; 277 } 278 SetCustomScheme(const std::string & scheme)279 void SetCustomScheme(const std::string& scheme) 280 { 281 customScheme_ = scheme; 282 } 283 GetCustomScheme()284 const std::optional<std::string>& GetCustomScheme() const 285 { 286 return customScheme_; 287 } 288 SetWebController(const RefPtr<WebController> & webController)289 void SetWebController(const RefPtr<WebController>& webController) 290 { 291 webController_ = webController; 292 } 293 GetWebController()294 RefPtr<WebController> GetWebController() const 295 { 296 return webController_; 297 } 298 SetSetWebIdCallback(SetWebIdCallback && SetIdCallback)299 void SetSetWebIdCallback(SetWebIdCallback&& SetIdCallback) 300 { 301 setWebIdCallback_ = std::move(SetIdCallback); 302 } 303 GetSetWebIdCallback()304 SetWebIdCallback GetSetWebIdCallback() const 305 { 306 return setWebIdCallback_; 307 } 308 SetSetWebDetachCallback(SetWebDetachCallback && callback)309 void SetSetWebDetachCallback(SetWebDetachCallback&& callback) 310 { 311 setWebDetachCallback_ = std::move(callback); 312 } 313 GetSetWebDetachCallback()314 SetWebDetachCallback GetSetWebDetachCallback() const 315 { 316 return setWebDetachCallback_; 317 } 318 SetPermissionClipboardCallback(PermissionClipboardCallback && Callback)319 void SetPermissionClipboardCallback(PermissionClipboardCallback&& Callback) 320 { 321 permissionClipboardCallback_ = std::move(Callback); 322 } 323 SetDefaultFileSelectorShowCallback(DefaultFileSelectorShowCallback && Callback)324 void SetDefaultFileSelectorShowCallback(DefaultFileSelectorShowCallback&& Callback) 325 { 326 defaultFileSelectorShowCallback_ = std::move(Callback); 327 } 328 GetDefaultFileSelectorShowCallback()329 DefaultFileSelectorShowCallback GetDefaultFileSelectorShowCallback() 330 { 331 return defaultFileSelectorShowCallback_; 332 } 333 GetPermissionClipboardCallback()334 PermissionClipboardCallback GetPermissionClipboardCallback() const 335 { 336 return permissionClipboardCallback_; 337 } 338 SetOnOpenAppLinkCallback(OnOpenAppLinkCallback && callback)339 void SetOnOpenAppLinkCallback(OnOpenAppLinkCallback&& callback) 340 { 341 onOpenAppLinkCallback_ = std::move(callback); 342 } 343 GetOnOpenAppLinkCallback()344 OnOpenAppLinkCallback GetOnOpenAppLinkCallback() const 345 { 346 return onOpenAppLinkCallback_; 347 } 348 SetFaviconFunction(SetFaviconCallback && callback)349 void SetFaviconFunction(SetFaviconCallback&& callback) 350 { 351 setFaviconCallback_ = std::move(callback); 352 } 353 GetSetFaviconFunction()354 SetFaviconCallback GetSetFaviconFunction() const 355 { 356 return setFaviconCallback_; 357 } 358 359 void SetRenderMode(RenderMode renderMode); 360 GetRenderMode()361 RenderMode GetRenderMode() 362 { 363 return renderMode_; 364 } 365 SetIncognitoMode(bool incognitoMode)366 void SetIncognitoMode(bool incognitoMode) 367 { 368 incognitoMode_ = incognitoMode; 369 } 370 GetIncognitoMode()371 bool GetIncognitoMode() const 372 { 373 return incognitoMode_; 374 } 375 SetSharedRenderProcessToken(const std::string & sharedRenderProcessToken)376 void SetSharedRenderProcessToken(const std::string& sharedRenderProcessToken) 377 { 378 sharedRenderProcessToken_ = sharedRenderProcessToken; 379 } 380 GetSharedRenderProcessToken()381 const std::optional<std::string>& GetSharedRenderProcessToken() const 382 { 383 return sharedRenderProcessToken_; 384 } 385 SetOnControllerAttachedCallback(OnControllerAttachedCallback && callback)386 void SetOnControllerAttachedCallback(OnControllerAttachedCallback&& callback) 387 { 388 onControllerAttachedCallback_ = std::move(callback); 389 } 390 GetOnControllerAttachedCallback()391 OnControllerAttachedCallback GetOnControllerAttachedCallback() 392 { 393 return onControllerAttachedCallback_; 394 } 395 SetSetHapPathCallback(SetHapPathCallback && callback)396 void SetSetHapPathCallback(SetHapPathCallback&& callback) 397 { 398 setHapPathCallback_ = std::move(callback); 399 } 400 GetSetHapPathCallback()401 SetHapPathCallback GetSetHapPathCallback() const 402 { 403 return setHapPathCallback_; 404 } 405 SetJsProxyCallback(JsProxyCallback && jsProxyCallback)406 void SetJsProxyCallback(JsProxyCallback&& jsProxyCallback) 407 { 408 jsProxyCallback_ = std::move(jsProxyCallback); 409 } 410 CallJsProxyCallback()411 void CallJsProxyCallback() 412 { 413 if (jsProxyCallback_) { 414 jsProxyCallback_(); 415 } 416 } 417 418 RefPtr<WebEventHub> GetWebEventHub(); 419 GetFocusPattern()420 FocusPattern GetFocusPattern() const override 421 { 422 FocusPattern focusPattern = { FocusType::NODE, true, FocusStyleType::FORCE_NONE }; 423 focusPattern.SetIsFocusActiveWhenFocused(true); 424 return focusPattern; 425 } 426 CreatePaintProperty()427 RefPtr<PaintProperty> CreatePaintProperty() override 428 { 429 if (!webPaintProperty_) { 430 webPaintProperty_ = MakeRefPtr<WebPaintProperty>(); 431 if (!webPaintProperty_) { 432 } 433 } 434 return webPaintProperty_; 435 } 436 CreateLayoutAlgorithm()437 RefPtr<LayoutAlgorithm> CreateLayoutAlgorithm() override 438 { 439 return MakeRefPtr<WebLayoutAlgorithm>(); 440 } 441 BetweenSelectedPosition(const Offset & globalOffset)442 bool BetweenSelectedPosition(const Offset& globalOffset) override 443 { 444 return false; 445 } 446 GetDragRecordSize()447 int32_t GetDragRecordSize() override 448 { 449 return 1; 450 } 451 452 /** 453 * NestableScrollContainer implementations 454 */ GetAxis()455 Axis GetAxis() const override 456 { 457 return axis_; 458 } 459 ScrollResult HandleScroll(float offset, int32_t source, NestedState state, float velocity = 0.f) override; 460 ScrollResult HandleScroll(RefPtr<NestableScrollContainer> parent, float offset, int32_t source, NestedState state); 461 bool HandleScrollVelocity(float velocity, const RefPtr<NestableScrollContainer>& child = nullptr) override; 462 bool HandleScrollVelocity(RefPtr<NestableScrollContainer> parent, float velocity); 463 void OnScrollStartRecursive(WeakPtr<NestableScrollContainer> child, float position, float velocity = 0.f) override; 464 void OnScrollStartRecursive(float position); 465 void OnScrollEndRecursive(const std::optional<float>& velocity) override; 466 void OnAttachToBuilderNode(NodeStatus nodeStatus) override; 467 void GetParentAxis(); 468 RefPtr<NestableScrollContainer> SearchParent() override; 469 RefPtr<NestableScrollContainer> SearchParent(Axis scrollAxis); 470 /** 471 * End of NestableScrollContainer implementations 472 */ 473 474 void SetNestedScrollExt(const NestedScrollOptionsExt &nestedScroll); GetNestedScrollExt()475 NestedScrollOptionsExt GetNestedScrollExt() const 476 { 477 return nestedScroll_; 478 } GetWebBypassVsyncCondition()479 WebBypassVsyncCondition GetWebBypassVsyncCondition() const 480 { 481 return webBypassVsyncCondition_; 482 } 483 void OnParentScrollDragEndRecursive(RefPtr<NestableScrollContainer> parent); 484 ACE_DEFINE_PROPERTY_GROUP(WebProperty, WebPatternProperty); 485 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, JsEnabled, bool); 486 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, MediaPlayGestureAccess, bool); 487 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, FileAccessEnabled, bool); 488 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, OnLineImageAccessEnabled, bool); 489 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, DomStorageAccessEnabled, bool); 490 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, ImageAccessEnabled, bool); 491 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, MixedMode, MixedModeContent); 492 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, ZoomAccessEnabled, bool); 493 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, GeolocationAccessEnabled, bool); 494 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, UserAgent, std::string); 495 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, CacheMode, WebCacheMode); 496 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, OverviewModeAccessEnabled, bool); 497 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, FileFromUrlAccessEnabled, bool); 498 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, DatabaseAccessEnabled, bool); 499 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, TextZoomRatio, int32_t); 500 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, WebDebuggingAccessEnabledAndPort, 501 WebPatternProperty::WebDebuggingConfigType); 502 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, BackgroundColor, int32_t); 503 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, InitialScale, float); 504 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, PinchSmoothModeEnabled, bool); 505 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, MultiWindowAccessEnabled, bool); 506 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, AllowWindowOpenMethod, bool); 507 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, WebCursiveFont, std::string); 508 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, WebFantasyFont, std::string); 509 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, WebFixedFont, std::string); 510 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, WebSansSerifFont, std::string); 511 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, WebSerifFont, std::string); 512 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, WebStandardFont, std::string); 513 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, DefaultFixedFontSize, int32_t); 514 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, DefaultFontSize, int32_t); 515 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, DefaultTextEncodingFormat, std::string); 516 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, MinFontSize, int32_t); 517 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, MinLogicalFontSize, int32_t); 518 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, BlockNetwork, bool); 519 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, DarkMode, WebDarkMode); 520 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, ForceDarkAccess, bool); 521 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, AudioResumeInterval, int32_t); 522 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, AudioExclusive, bool); 523 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, AudioSessionType, WebAudioSessionType); 524 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, HorizontalScrollBarAccessEnabled, bool); 525 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, VerticalScrollBarAccessEnabled, bool); 526 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, ScrollBarColor, std::string); 527 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, OverScrollMode, int32_t); 528 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, BlurOnKeyboardHideMode, int32_t); 529 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, CopyOptionMode, int32_t); 530 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, MetaViewport, bool); 531 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, NativeEmbedModeEnabled, bool); 532 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, IntrinsicSizeEnabled, bool); 533 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, CssDisplayChangeEnabled, bool); 534 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, BypassVsyncCondition, WebBypassVsyncCondition); 535 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, NativeEmbedRuleTag, std::string); 536 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, NativeEmbedRuleType, std::string); 537 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, TextAutosizing, bool); 538 using NativeVideoPlayerConfigType = std::tuple<bool, bool>; 539 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, NativeVideoPlayerConfig, NativeVideoPlayerConfigType); 540 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, SelectionMenuOptions, WebMenuOptionsParam); 541 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, OverlayScrollbarEnabled, bool); 542 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, KeyboardAvoidMode, WebKeyboardAvoidMode); 543 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, EnabledHapticFeedback, bool); 544 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, OptimizeParserBudgetEnabled, bool); 545 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, WebMediaAVSessionEnabled, bool); 546 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, EnableDataDetector, bool); 547 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, EnableFollowSystemFontWeight, bool); 548 ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, GestureFocusMode, GestureFocusMode); 549 IsFocus()550 bool IsFocus() const 551 { 552 return isFocus_; 553 } 554 555 void RequestFullScreen(); 556 void ExitFullScreen(); IsFullScreen()557 bool IsFullScreen() const 558 { 559 return isFullScreen_; 560 } 561 void UpdateClippedSelectionBounds(int32_t x, int32_t y, int32_t w, int32_t h); 562 bool RunQuickMenu(std::shared_ptr<OHOS::NWeb::NWebQuickMenuParams> params, 563 std::shared_ptr<OHOS::NWeb::NWebQuickMenuCallback> callback); 564 void OnContextMenuShow(const std::shared_ptr<BaseEventInfo>& info, bool isRichtext = true, bool result = false); 565 void OnContextMenuHide(); 566 void OnQuickMenuDismissed(); 567 void HideHandleAndQuickMenuIfNecessary(bool hide, bool isScroll = false); 568 void ChangeVisibilityOfQuickMenu(); 569 bool ChangeVisibilityOfQuickMenuV2(); 570 bool IsQuickMenuShow(); 571 void OnTouchSelectionChanged(std::shared_ptr<OHOS::NWeb::NWebTouchHandleState> insertHandle, 572 std::shared_ptr<OHOS::NWeb::NWebTouchHandleState> startSelectionHandle, 573 std::shared_ptr<OHOS::NWeb::NWebTouchHandleState> endSelectionHandle); 574 bool OnCursorChange(const OHOS::NWeb::CursorType& type, std::shared_ptr<OHOS::NWeb::NWebCursorInfo> info); 575 void UpdateLocalCursorStyle(int32_t windowId, const OHOS::NWeb::CursorType& type); 576 std::string GetPixelMapName(std::shared_ptr<Media::PixelMap> pixelMap, std::string featureName); 577 void UpdateCustomCursor(int32_t windowId, std::shared_ptr<OHOS::NWeb::NWebCursorInfo> info); 578 std::shared_ptr<OHOS::Media::PixelMap> CreatePixelMapFromString(const std::string& filePath); 579 void OnSelectPopupMenu(std::shared_ptr<OHOS::NWeb::NWebSelectPopupMenuParam> params, 580 std::shared_ptr<OHOS::NWeb::NWebSelectPopupMenuCallback> callback); 581 void OnDateTimeChooserPopup( 582 std::shared_ptr<OHOS::NWeb::NWebDateTimeChooser> chooser, 583 const std::vector<std::shared_ptr<OHOS::NWeb::NWebDateTimeSuggestion>>& suggestions, 584 std::shared_ptr<NWeb::NWebDateTimeChooserCallback> callback); 585 void OnDateTimeChooserClose(); 586 void OnShowAutofillPopup(const float offsetX, const float offsetY, const std::vector<std::string>& menu_items); 587 void OnShowAutofillPopupV2(const float offsetX, const float offsetY, const float height, const float width, 588 const std::vector<std::string>& menu_items); 589 void OnHideAutofillPopup(); 590 RefPtr<FrameNode> CreateDataListFrameNode(const OffsetF& offfset, const float height, const float width); 591 void RemoveDataListNode(); IsOverlayCreating()592 bool IsOverlayCreating() 593 { 594 return overlayCreating_; 595 } SetOverlayCreating(bool overlayCreating)596 void SetOverlayCreating(bool overlayCreating) 597 { 598 overlayCreating_ = overlayCreating; 599 } 600 void UpdateLocale(); 601 void SetDrawRect(int32_t x, int32_t y, int32_t width, int32_t height); SetSelectPopupMenuShowing(bool showing)602 void SetSelectPopupMenuShowing(bool showing) 603 { 604 selectPopupMenuShowing_ = showing; 605 } 606 void ParseViewDataNumber(const std::string& key, int32_t value, 607 RefPtr<PageNodeInfoWrap> node, RectT<float>& rect, float viewScale); 608 void ParseNWebViewDataNode(std::unique_ptr<JsonValue> child, 609 std::vector<RefPtr<PageNodeInfoWrap>>& nodeInfos, int32_t nodeId); 610 void ParseNWebViewDataCommonField(std::unique_ptr<JsonValue> child, 611 const std::shared_ptr<ViewDataCommon>& viewDataCommon); 612 void ParseNWebViewDataJson(const std::string& viewDataJson, 613 std::vector<RefPtr<PageNodeInfoWrap>>& nodeInfos, const std::shared_ptr<ViewDataCommon>& viewDataCommon); 614 AceAutoFillType GetFocusedType(); 615 HintToTypeWrap GetHintTypeAndMetadata(const std::string& attribute, RefPtr<PageNodeInfoWrap> node); 616 bool HandleAutoFillEvent(); 617 bool HandleAutoFillEvent(const std::shared_ptr<OHOS::NWeb::NWebMessage>& viewDataJson); 618 bool HandleAutoFillEvent(const std::shared_ptr<OHOS::NWeb::NWebHapValue>& viewDataJson); 619 bool RequestAutoFill(AceAutoFillType autoFillType); 620 bool RequestAutoFill(AceAutoFillType autoFillType, const std::vector<RefPtr<PageNodeInfoWrap>>& nodeInfos); 621 bool RequestAutoSave(); 622 bool UpdateAutoFillPopup(); 623 bool CloseAutoFillPopup(); 624 void OnCompleteSwapWithNewSize(); 625 void OnResizeNotWork(); 626 void UpdateOnFocusTextField(bool isFocus); 627 bool OnBackPressed() override; 628 bool OnBackPressedForFullScreen() const; 629 void SetFullScreenExitHandler(const std::shared_ptr<FullScreenEnterEvent>& fullScreenExitHandler); 630 bool NotifyStartDragTask(bool isDelayed = false); 631 bool IsImageDrag(); 632 void UpdateJavaScriptOnDocumentStart(); 633 void UpdateJavaScriptOnDocumentEnd(); 634 void JavaScriptOnDocumentStart(const ScriptItems& scriptItems); 635 void JavaScriptOnDocumentEnd(const ScriptItems& scriptItems); 636 void UpdateJavaScriptOnDocumentStartByOrder(); 637 void JavaScriptOnDocumentStartByOrder(const ScriptItems& scriptItems, 638 const ScriptItemsByOrder& scriptItemsByOrder); 639 void UpdateJavaScriptOnDocumentEndByOrder(); 640 void JavaScriptOnDocumentEndByOrder(const ScriptItems& scriptItems, 641 const ScriptItemsByOrder& scriptItemsByOrder); 642 void UpdateJavaScriptOnHeadReadyByOrder(); 643 void JavaScriptOnHeadReadyByOrder(const ScriptItems& scriptItems, 644 const ScriptItemsByOrder& scriptItemsByOrder); 645 void SetTouchEventInfo(const TouchEvent& touchEvent, 646 TouchEventInfo& touchEventInfo, const std::string& embdedId); 647 DragRet GetDragAcceptableStatus(); 648 Offset GetDragOffset() const; 649 void RemovePreviewMenuNode(); 650 void UpdateImagePreviewParam(); 651 void OnOverScrollFlingVelocity(float xVelocity, float yVelocity, bool isFling); 652 void OnScrollState(bool scrollState); 653 void OnScrollStart(const float x, const float y); 654 void SetLayoutMode(WebLayoutMode mode); GetLayoutMode()655 WebLayoutMode GetLayoutMode() const 656 { 657 return layoutMode_; 658 } 659 void OnRootLayerChanged(int width, int height); 660 void ReleaseResizeHold(); 661 bool GetPendingSizeStatus(); GetRootLayerWidth()662 int GetRootLayerWidth() const 663 { 664 return rootLayerWidth_; 665 } GetRootLayerHeight()666 int GetRootLayerHeight() const 667 { 668 return rootLayerHeight_; 669 } GetDrawSize()670 Size GetDrawSize() const 671 { 672 return drawSize_; 673 } 674 SizeF GetDragPixelMapSize() const; IsVirtualKeyBoardShow()675 bool IsVirtualKeyBoardShow() const 676 { 677 return isVirtualKeyBoardShow_ == VkState::VK_SHOW; 678 } 679 bool FilterScrollEvent(const float x, const float y, const float xVelocity, const float yVelocity); 680 bool OnNestedScroll(float& x, float& y, float& xVelocity, float& yVelocity, bool& isAvailable); 681 std::shared_ptr<OHOS::NWeb::NWebAccessibilityNodeInfo> GetAccessibilityNodeById(int64_t accessibilityId); 682 std::shared_ptr<NG::TransitionalNodeInfo> GetFocusedAccessibilityNode(int64_t accessibilityId, 683 bool isAccessibilityFocus); 684 std::shared_ptr<NG::TransitionalNodeInfo> GetTransitionalNodeById(int64_t accessibilityId); 685 std::shared_ptr<NG::TransitionalNodeInfo> GetAccessibilityNodeByFocusMove(int64_t accessibilityId, 686 int32_t direction); 687 bool ExecuteAction(int64_t accessibilityId, AceAction action, 688 const std::map<std::string, std::string>& actionArguments) const; 689 void SetAccessibilityState(bool state, bool isDelayed = false); 690 void UpdateScrollBarWithBorderRadius(); 691 void UpdateFocusedAccessibilityId(int64_t accessibilityId = -1); 692 void ClearFocusedAccessibilityId(); 693 void OnTooltip(const std::string& tooltip); 694 void OnPopupSize(int32_t x, int32_t y, int32_t width, int32_t height); 695 void GetVisibleRectToWeb(int& visibleX, int& visibleY, int& visibleWidth, int& visibleHeight); 696 void RestoreRenderFit(); 697 void OnPopupShow(bool show); 698 bool IsDefaultFocusNodeExist(); 699 bool IsRootNeedExportTexture(); 700 std::vector<int8_t> GetWordSelection(const std::string& text, int8_t offset); 701 bool Backward(); 702 void OnSelectionMenuOptionsUpdate(const WebMenuOptionsParam& webMenuOption); 703 void UpdateEditMenuOptions(const NG::OnCreateMenuCallback&& onCreateMenuCallback, 704 const NG::OnMenuItemClickCallback&& onMenuItemClick, const NG::OnPrepareMenuCallback&& onPrepareMenuCallback); 705 void UpdateDataDetectorConfig(const TextDetectConfig& config); 706 void NotifyForNextTouchEvent() override; 707 void CloseKeyboard(); 708 void CreateOverlay(const RefPtr<OHOS::Ace::PixelMap>& pixelMap, int offsetX, int offsetY, int rectWidth, 709 int rectHeight, int pointX, int pointY); 710 void OnOverlayStateChanged(int offsetX, int offsetY, int rectWidth, int rectHeight); 711 void OnTextSelected(); 712 void DestroyAnalyzerOverlay(); 713 WebInfoType GetWebInfoType(); 714 void RequestFocus(); 715 bool IsCurrentFocus(); SetCustomKeyboardBuilder(std::function<void ()> customKeyboardBuilder)716 void SetCustomKeyboardBuilder(std::function<void()> customKeyboardBuilder) 717 { 718 customKeyboardBuilder_ = customKeyboardBuilder; 719 } 720 void AttachCustomKeyboard(); 721 void CloseCustomKeyboard(); 722 void KeyboardReDispatch(const std::shared_ptr<OHOS::NWeb::NWebKeyEvent>& event, bool isUsed); 723 void EnableSecurityLayer(bool isNeedSecurityLayer); 724 void OnTakeFocus(const std::shared_ptr<OHOS::NWeb::NWebKeyEvent>& event); OnCursorUpdate(double x,double y,double width,double height)725 void OnCursorUpdate(double x, double y, double width, double height) 726 { 727 cursorInfo_ = RectF(x, y, width, height); 728 } GetCaretRect()729 RectF GetCaretRect() const override 730 { 731 return cursorInfo_; 732 } 733 void OnAttachContext(PipelineContext *context) override; 734 void OnDetachContext(PipelineContext *context) override; 735 void SetUpdateInstanceIdCallback(std::function<void(int32_t)> &&callabck); GetWebSurfaceNodeId()736 Rosen::NodeId GetWebSurfaceNodeId() const 737 { 738 auto rosenRenderContext = AceType::DynamicCast<NG::RosenRenderContext>(renderContextForSurface_); 739 CHECK_NULL_RETURN(rosenRenderContext, 0); 740 auto rsNode = rosenRenderContext->GetRSNode(); 741 CHECK_NULL_RETURN(rsNode, 0); 742 auto surfaceNodeId = rsNode->GetId(); 743 TAG_LOGD(AceLogTag::ACE_WEB, "Web surfaceNodeId is %{public}" PRIu64 "", surfaceNodeId); 744 return surfaceNodeId; 745 } 746 std::shared_ptr<Rosen::RSNode> GetSurfaceRSNode() const; 747 748 void GetAllWebAccessibilityNodeInfos(WebNodeInfoCallback cb, int32_t webId, bool needFilter = true); 749 void OnAccessibilityHoverEvent( 750 const NG::PointF& point, SourceType source, NG::AccessibilityHoverEventType eventType, TimeStamp time); 751 std::string GetSurfaceIdByHtmlElementId(const std::string& htmlElementId); 752 int64_t GetWebAccessibilityIdBySurfaceId(const std::string& surfaceId); 753 void RegisterWebComponentClickCallback(WebComponentClickCallback&& callback); 754 void UnregisterWebComponentClickCallback(); GetWebComponentClickCallback()755 WebComponentClickCallback GetWebComponentClickCallback() const { return webComponentClickCallback_; } 756 void DumpInfo() override; 757 void DumpGpuInfo(); 758 void DumpSurfaceInfo(); 759 void OnSetAccessibilityChildTree(int32_t childWindowId, int32_t childTreeId); 760 bool OnAccessibilityChildTreeRegister(); 761 bool OnAccessibilityChildTreeDeregister(); 762 bool GetActiveStatus() const; 763 void StartVibraFeedback(const std::string& vibratorType); GetTreeId()764 int32_t GetTreeId() 765 { 766 return treeId_; 767 } 768 bool CloseImageOverlaySelection(); 769 void SetDrawSize(double width, double height); SetImageOverlaySelectedStatus(bool isSelected)770 void SetImageOverlaySelectedStatus(bool isSelected) 771 { 772 imageOverlayIsSelected_ = isSelected; 773 } 774 // The magnifier needs this to know the web's offset 775 OffsetF GetTextPaintOffset() const override; 776 void OnColorConfigurationUpdate() override; 777 void RecordWebEvent(bool isInit = false) override; 778 bool RunJavascriptAsync(const std::string& jsCode, std::function<void(const std::string&)>&& callback); 779 IsPreviewImageNodeExist()780 bool IsPreviewImageNodeExist() const 781 { 782 return previewImageNodeId_.has_value(); 783 } 784 SetNewDragStyle(bool isNewDragStyle)785 void SetNewDragStyle(bool isNewDragStyle) 786 { 787 isNewDragStyle_ = isNewDragStyle; 788 } 789 IsNewDragStyle()790 bool IsNewDragStyle() const 791 { 792 return isNewDragStyle_; 793 } 794 795 bool isNeedInterceptedTouchEvent_ = false; 796 IsDragging()797 bool IsDragging() const 798 { 799 return isDragging_; 800 } IsDefaultGestureFocusMode()801 bool IsDefaultGestureFocusMode() const 802 { 803 return gestureFocusMode_ == GestureFocusMode::DEFAULT; 804 } 805 806 void SetPreviewSelectionMenu(const std::shared_ptr<WebPreviewSelectionMenuParam>& param); 807 808 std::shared_ptr<WebPreviewSelectionMenuParam> GetPreviewSelectionMenuParams( 809 const WebElementType& type, const ResponseType& responseType); 810 811 bool IsPreviewMenuNotNeedShowPreview(); 812 813 bool GetAccessibilityVisible(int64_t accessibilityId); 814 815 void OnWebMediaAVSessionEnabledUpdate(bool enable); 816 817 void UpdateImageOverlayTouchInfo(int touchPointX, int touchPointY, TouchType touchType); 818 void PushOverlayInfo(float x, float y, int32_t id); 819 void WebOverlayRequestFocus(); 820 821 std::string GetCurrentLanguage() override; 822 void GetTranslateTextCallback(const std::string& result); 823 void RegisterTranslateTextJavaScript(); 824 void InitTranslateText(); 825 void GetTranslateText( 826 std::string extraData, std::function<void(std::string)> callback, bool isContinued) override; 827 void SendTranslateResult(std::vector<std::string> results, std::vector<int32_t> ids) override; 828 void SendTranslateResult(std::string results) override; 829 void EndTranslate() override; 830 void RunJsInit(); 831 832 RefPtr<AccessibilitySessionAdapter> GetAccessibilitySessionAdapter() override; 833 834 void SetSurfaceDensity(double density); 835 void InitSurfaceDensityCallback(const RefPtr<PipelineContext> &context); 836 void UnInitSurfaceDensityCallback(const RefPtr<PipelineContext> &context); 837 838 void InitRotationEventCallback(); 839 void UninitRotationEventCallback(); 840 GetMouseInfoQueue()841 std::queue<MouseInfo>& GetMouseInfoQueue() 842 { 843 return mouseInfoQueue_; 844 } 845 GetMouseInfo()846 MouseInfo GetMouseInfo() 847 { 848 return mouseInfo_; 849 } 850 851 // WebAccessibilityEventReport funcs 852 RefPtr<WebAccessibilityEventReport> GetAccessibilityEventReport(); 853 void SetTextEventAccessibilityEnable(bool enable); 854 855 // Data Detector funcs 856 RefPtr<WebDataDetectorAdapter> GetDataDetectorAdapter(); 857 858 bool GetDataDetectorEnable(); 859 void InitDataDetector(); 860 void InitAIDetectResult(); 861 void CloseDataDetectorMenu(); 862 SetAILinkMenuShow(bool isAILinkMenuShow)863 void SetAILinkMenuShow(bool isAILinkMenuShow) 864 { 865 isAILinkMenuShow_ = isAILinkMenuShow; 866 } 867 868 void CreateSnapshotImageFrameNode(const std::string& snapshotPath); 869 void RemoveSnapshotFrameNode(); 870 871 void OnPip(int status, int delegateId, int childId, int frameRoutingId, int width, int height); 872 void SetPipNativeWindow(int delegateId, int childId, int frameRoutingId, void* window); 873 void SendPipEvent(int delegateId, int childId, int frameRoutingId, int event); 874 void SetDefaultBackgroundColor(); 875 bool CheckVisible(); 876 877 void UpdateSingleHandleVisible(bool isVisible); 878 void OnShowMagnifier(); 879 void OnHideMagnifier(); 880 void SetTouchHandleExistState(bool touchHandleExist); 881 bool IsShowHandle(); 882 883 bool IsShowAIWrite(); 884 int GetSelectStartIndex() const; 885 int GetSelectEndIndex() const; 886 std::string GetAllTextInfo() const; 887 void GetHandleInfo(SelectOverlayInfo& infoHandle); 888 void HandleOnAIWrite(); 889 890 protected: ModifyWebSrc(const std::string & webSrc)891 void ModifyWebSrc(const std::string& webSrc) 892 { 893 webSrc_ = webSrc; 894 } 895 896 void OnWebSrcUpdate(); 897 898 private: 899 friend class WebContextSelectOverlay; 900 friend class WebSelectOverlay; 901 friend class WebDataDetectorAdapter; 902 903 bool Pip(int status, int delegateId, int childId, int frameRoutingId, int width, int height); 904 napi_env CreateEnv(); 905 bool CreatePip(int status, napi_env env, bool& init, uint32_t &pipController, const PipInfo &pipInfo); 906 bool RegisterPip(uint32_t pipController); 907 bool StartPip(uint32_t pipController); 908 void EnablePip(uint32_t pipController); 909 bool StopPip(int delegateId, int childId, int frameRoutingId); 910 bool PlayPip(int delegateId, int childId, int frameRoutingId); 911 bool PausePip(int delegateId, int childId, int frameRoutingId); 912 void GetPreviewImageOffsetAndSize(bool isImage, Offset& previewOffset, SizeF& previewSize); 913 RefPtr<FrameNode> CreatePreviewImageFrameNode(bool isImage); 914 void ShowPreviewMenu(WebElementType type); 915 void ShowContextSelectOverlay(const RectF& firstHandle, const RectF& secondHandle, 916 TextResponseType responseType = TextResponseType::RIGHT_CLICK, bool handleReverse = false); 917 void CloseContextSelectionMenu(); 918 RectF ComputeMouseClippedSelectionBounds(int32_t x, int32_t y, int32_t w, int32_t h); 919 void RegistVirtualKeyBoardListener(const RefPtr<PipelineContext> &context); 920 bool IsNeedResizeVisibleViewport(); 921 bool ProcessVirtualKeyBoardHide(int32_t width, int32_t height, bool safeAreaEnabled); 922 bool ProcessVirtualKeyBoardHideAvoidMenu(int32_t width, int32_t height, bool safeAreaEnabled); 923 bool ProcessVirtualKeyBoardShow(int32_t width, int32_t height, double keyboard, bool safeAreaEnabled); 924 bool ProcessVirtualKeyBoardShowAvoidMenu(int32_t width, int32_t height, double keyboard, bool safeAreaEnabled); 925 bool ProcessVirtualKeyBoard(int32_t width, int32_t height, double keyboard, bool isCustomKeyboard = false); 926 void UpdateWebLayoutSize(int32_t width, int32_t height, bool isKeyboard, bool isUpdate = true); 927 bool UpdateLayoutAfterKeyboard(int32_t width, int32_t height, double keyboard); 928 void UpdateLayoutAfterKeyboardShow(int32_t width, int32_t height, double keyboard, double oldWebHeight); 929 bool OnDirtyLayoutWrapperSwap(const RefPtr<LayoutWrapper>& dirty, const DirtySwapConfig& config) override; 930 void BeforeSyncGeometryProperties(const DirtySwapConfig& config) override; 931 void OnRebuildFrame() override; 932 933 void OnAttachToFrameNode() override; 934 void OnDetachFromFrameNode(FrameNode* frameNode) override; 935 936 void OnWindowShow() override; 937 void OnWindowHide() override; 938 void OnWindowSizeChanged(int32_t width, int32_t height, WindowSizeChangeReason type) override; 939 void OnInActive() override; 940 void OnActive() override; 941 void OnVisibleAreaChange(bool isVisible); 942 void OnAreaChangedInner() override; 943 void OnNotifyMemoryLevel(int32_t level) override; 944 void OnAttachToMainTree() override; 945 void OnDetachFromMainTree() override; 946 947 void OnWebDataUpdate(); 948 void OnJsEnabledUpdate(bool value); 949 void OnMediaPlayGestureAccessUpdate(bool value); 950 void OnFileAccessEnabledUpdate(bool value); 951 void OnOnLineImageAccessEnabledUpdate(bool value); 952 void OnDomStorageAccessEnabledUpdate(bool value); 953 void OnImageAccessEnabledUpdate(bool value); 954 void OnMixedModeUpdate(MixedModeContent value); 955 void OnZoomAccessEnabledUpdate(bool value); 956 void OnGeolocationAccessEnabledUpdate(bool value); 957 void OnUserAgentUpdate(const std::string& value); 958 void OnCacheModeUpdate(WebCacheMode value); 959 void OnOverviewModeAccessEnabledUpdate(bool value); 960 void OnFileFromUrlAccessEnabledUpdate(bool value); 961 void OnDatabaseAccessEnabledUpdate(bool value); 962 void OnTextZoomRatioUpdate(int32_t value); 963 void OnWebDebuggingAccessEnabledAndPortUpdate( 964 const WebPatternProperty::WebDebuggingConfigType& enabled_and_port); 965 void OnPinchSmoothModeEnabledUpdate(bool value); 966 void OnBackgroundColorUpdate(int32_t value); 967 void OnInitialScaleUpdate(float value); 968 void OnMultiWindowAccessEnabledUpdate(bool value); 969 void OnAllowWindowOpenMethodUpdate(bool value); 970 void OnWebCursiveFontUpdate(const std::string& value); 971 void OnWebFantasyFontUpdate(const std::string& value); 972 void OnWebFixedFontUpdate(const std::string& value); 973 void OnWebSerifFontUpdate(const std::string& value); 974 void OnWebSansSerifFontUpdate(const std::string& value); 975 void OnWebStandardFontUpdate(const std::string& value); 976 void OnDefaultFixedFontSizeUpdate(int32_t value); 977 void OnDefaultFontSizeUpdate(int32_t value); 978 void OnDefaultTextEncodingFormatUpdate(const std::string& value); 979 void OnMinFontSizeUpdate(int32_t value); 980 void OnMinLogicalFontSizeUpdate(int32_t value); 981 void OnBlockNetworkUpdate(bool value); 982 void OnDarkModeUpdate(WebDarkMode mode); 983 void OnForceDarkAccessUpdate(bool access); 984 void OnAudioResumeIntervalUpdate(int32_t resumeInterval); 985 void OnAudioExclusiveUpdate(bool audioExclusive); 986 void OnAudioSessionTypeUpdate(WebAudioSessionType value); 987 void OnHorizontalScrollBarAccessEnabledUpdate(bool value); 988 void OnVerticalScrollBarAccessEnabledUpdate(bool value); 989 void OnScrollBarColorUpdate(const std::string& value); 990 void OnOverScrollModeUpdate(const int32_t value); 991 void OnBlurOnKeyboardHideModeUpdate(const int32_t value); 992 void OnCopyOptionModeUpdate(const int32_t value); 993 void OnMetaViewportUpdate(bool value); 994 void OnNativeEmbedModeEnabledUpdate(bool value); 995 void OnIntrinsicSizeEnabledUpdate(bool value); 996 void OnCssDisplayChangeEnabledUpdate(bool value); 997 void OnBypassVsyncConditionUpdate(WebBypassVsyncCondition condition); 998 void OnNativeEmbedRuleTagUpdate(const std::string& tag); 999 void OnNativeEmbedRuleTypeUpdate(const std::string& type); 1000 void OnTextAutosizingUpdate(bool isTextAutosizing); 1001 void OnNativeVideoPlayerConfigUpdate(const std::tuple<bool, bool>& config); 1002 void DragResizeNoMoveTimer(); 1003 void WindowDrag(int32_t width, int32_t height); 1004 void WindowMaximize(); 1005 void OnOverlayScrollbarEnabledUpdate(bool enable); 1006 void OnKeyboardAvoidModeUpdate(const WebKeyboardAvoidMode& mode); 1007 void OnEnabledHapticFeedbackUpdate(bool enable); 1008 void OnOptimizeParserBudgetEnabledUpdate(bool value); 1009 void OnEnableFollowSystemFontWeightUpdate(bool value); 1010 void OnEnableDataDetectorUpdate(bool enable); 1011 void OnGestureFocusModeUpdate(GestureFocusMode mode); 1012 1013 int GetWebId(); 1014 1015 void InitEvent(); 1016 void InitConfigChangeCallback(const RefPtr<PipelineContext>& context); 1017 void InitFeatureParam(); 1018 void InitTouchEvent(const RefPtr<GestureEventHub>& gestureHub); 1019 void InitMouseEvent(const RefPtr<InputEventHub>& inputHub); 1020 void InitHoverEvent(const RefPtr<InputEventHub>& inputHub); 1021 void InitCommonDragDropEvent(const RefPtr<GestureEventHub>& gestureHub); 1022 void InitWebEventHubDragDropStart(const RefPtr<WebEventHub>& eventHub); 1023 void InitWebEventHubDragDropEnd(const RefPtr<WebEventHub>& eventHub); 1024 void InitWebEventHubDragMove(const RefPtr<WebEventHub>& eventHub); 1025 void InitPanEvent(const RefPtr<GestureEventHub>& gestureHub); 1026 void HandleFlingMove(const GestureEvent& event); 1027 void HandleDragMove(const GestureEvent& event); 1028 void InitDragEvent(const RefPtr<GestureEventHub>& gestureHub); 1029 void HandleDragStart(int32_t x, int32_t y); 1030 void HandleDragEnd(int32_t x, int32_t y); 1031 void HandleDragCancel(); 1032 void ClearDragData(); 1033 void SetFakeDragData(const RefPtr<OHOS::Ace::DragEvent>& info); 1034 bool GenerateDragDropInfo(NG::DragDropInfo& dragDropInfo); 1035 void HandleMouseEvent(MouseInfo& info); 1036 void HandleTouchEvent(const TouchEventInfo& info); 1037 void WebOnMouseEvent(const MouseInfo& info); 1038 void WebSendMouseEvent(const MouseInfo& info, int32_t clickNum); 1039 bool HandleDoubleClickEvent(const MouseInfo& info); 1040 void SendDoubleClickEvent(const MouseClickInfo& info); 1041 int32_t HandleMouseClickEvent(const MouseInfo& info); 1042 void InitFocusEvent(const RefPtr<FocusHub>& focusHub); 1043 void HandleFocusEvent(); 1044 void HandleBlurEvent(const BlurReason& blurReason); 1045 bool HandleKeyEvent(const KeyEvent& keyEvent); 1046 bool WebOnKeyEvent(const KeyEvent& keyEvent); 1047 void WebRequestFocus(); 1048 void ResetDragAction(); 1049 void InitSlideUpdateListener(); 1050 void CalculateHorizontalDrawRect(); 1051 void CalculateVerticalDrawRect(); 1052 void InitPinchEvent(const RefPtr<GestureEventHub>& gestureHub); 1053 bool CheckZoomStatus(const double& curScale); 1054 bool ZoomOutAndIn(const double& curScale, double& scale); 1055 void HandleScaleGestureChange(const GestureEvent& event); 1056 void HandleScaleGestureStart(const GestureEvent& event); 1057 void HandleScaleGestureEnd(const GestureEvent& event); 1058 void HandleScaleGestureCancel(const GestureEvent& event); 1059 double getZoomOffset(double& scale) const; 1060 1061 NG::DragDropInfo HandleOnDragStart(const RefPtr<OHOS::Ace::DragEvent>& info); 1062 void HandleOnDragEnter(const RefPtr<OHOS::Ace::DragEvent>& info); 1063 void HandleOnDropMove(const RefPtr<OHOS::Ace::DragEvent>& info); 1064 void HandleOnDragDrop(const RefPtr<OHOS::Ace::DragEvent>& info); 1065 void HandleOnDragDropFile(RefPtr<UnifiedData> aceData); 1066 void HandleOnDragDropLink(RefPtr<UnifiedData> aceData); 1067 void HandleOnDragLeave(int32_t x, int32_t y); 1068 void HandleOnDragEnd(int32_t x, int32_t y); 1069 void ResetDragStateValue(); 1070 void InitTouchEventListener(); 1071 void UninitTouchEventListener(); 1072 void OnDragFileNameStart(const RefPtr<UnifiedData>& aceUnifiedData, const std::string& fileName); 1073 void AdjustRotationRenderFit(WindowSizeChangeReason type); 1074 void RecoverToTopLeft(); 1075 bool needRestoreMenuForDrag_ = false; 1076 int32_t dropX_ = 0; 1077 int32_t dropY_ = 0; 1078 int onDragMoveCnt = 0; 1079 bool isDragEndMenuShow_ = false; 1080 std::chrono::time_point<std::chrono::system_clock> firstMoveInTime; 1081 std::chrono::time_point<std::chrono::system_clock> preMoveInTime; 1082 std::chrono::time_point<std::chrono::system_clock> curMoveInTime; 1083 CancelableCallback<void()> timer_; 1084 int32_t duration_ = 100; // 100: 100ms 1085 void DoRepeat(); 1086 void StartRepeatTimer(); 1087 1088 void HandleTouchDown(const TouchEventInfo& info, bool fromOverlay); 1089 1090 void HandleTouchUp(const TouchEventInfo& info, bool fromOverlay); 1091 1092 void HandleTouchMove(const TouchEventInfo& info, bool fromOverlay); 1093 1094 void HandleTouchCancel(const TouchEventInfo& info); 1095 1096 void HandleTouchClickEventFromOverlay(const GestureEvent& info); 1097 void SuggestionSelected(int32_t index); 1098 void InitializeAccessibility(); 1099 void UninitializeAccessibility(); 1100 void CloseSelectOverlay(); 1101 void DelTouchOverlayInfoByTouchId(int32_t touchId); 1102 std::optional<OffsetF> GetCoordinatePoint(); 1103 static void InitSelectPopupMenuViewOption(const std::vector<RefPtr<FrameNode>>& options, 1104 const std::shared_ptr<OHOS::NWeb::NWebSelectPopupMenuCallback>& callback, 1105 const std::shared_ptr<OHOS::NWeb::NWebSelectPopupMenuParam>& params, 1106 const double& dipScale); 1107 static void InitSelectPopupMenuView(RefPtr<FrameNode>& menuWrapper, 1108 std::shared_ptr<OHOS::NWeb::NWebSelectPopupMenuCallback> callback, 1109 std::shared_ptr<OHOS::NWeb::NWebSelectPopupMenuParam> params, 1110 const double& dipScale); 1111 OffsetF GetSelectPopupPostion(std::shared_ptr<OHOS::NWeb::NWebSelectMenuBound> bound); 1112 bool GetAccessibilityFocusRect(RectT<int32_t>& paintRect, int64_t accessibilityId) const; 1113 void SetTouchLocationInfo(const TouchEvent& touchEvent, const TouchLocationInfo& changedInfo, 1114 const TouchEventInfo& tempTouchInfo, TouchEventInfo& touchEventInfo); 1115 struct TouchInfo { 1116 float x = -1.0f; 1117 float y = -1.0f; 1118 int32_t id = -1; 1119 }; 1120 static bool ParseTouchInfo(const TouchEventInfo& info, std::list<TouchInfo>& touchInfos); 1121 void InitEnhanceSurfaceFlag(); 1122 void UpdateBackgroundColorRightNow(int32_t color); 1123 void UpdateContentOffset(const RefPtr<LayoutWrapper>& dirty); 1124 DialogProperties GetDialogProperties(const RefPtr<DialogTheme>& theme); 1125 bool ShowDateTimeDialog(std::shared_ptr<OHOS::NWeb::NWebDateTimeChooser> chooser, 1126 const std::vector<std::shared_ptr<OHOS::NWeb::NWebDateTimeSuggestion>>& suggestions, 1127 std::shared_ptr<NWeb::NWebDateTimeChooserCallback> callback); 1128 bool ShowTimeDialog(std::shared_ptr<OHOS::NWeb::NWebDateTimeChooser> chooser, 1129 const std::vector<std::shared_ptr<OHOS::NWeb::NWebDateTimeSuggestion>>& suggestions, 1130 std::shared_ptr<NWeb::NWebDateTimeChooserCallback> callback); 1131 bool ShowDateTimeSuggestionDialog(std::shared_ptr<OHOS::NWeb::NWebDateTimeChooser> chooser, 1132 const std::vector<std::shared_ptr<OHOS::NWeb::NWebDateTimeSuggestion>>& suggestions, 1133 std::shared_ptr<NWeb::NWebDateTimeChooserCallback> callback); 1134 void PostTaskToUI(const std::function<void()>&& task, const std::string& name) const; 1135 void LoadUrlInOfflineMode(); 1136 void InitInOfflineMode(); 1137 void OnOverScrollFlingVelocityHandler(float velocity, bool isFling); 1138 bool FilterScrollEventHandleOffset(float offset); 1139 bool CheckParentScroll(const float &directValue, const NestedScrollMode &scrollMode); 1140 bool CheckOverParentScroll(const float &directValue, const NestedScrollMode &scrollMode); 1141 bool FilterScrollEventHandlevVlocity(const float velocity); 1142 void CheckAndSetWebNestedScrollExisted(); 1143 void CalculateTooltipOffset(RefPtr<FrameNode>& tooltipNode, OffsetF& tooltipOfffset); 1144 void HandleShowTooltip(const std::string& tooltip, int64_t tooltipTimestamp); 1145 bool GetShadowFromTheme(ShadowStyle shadowStyle, Shadow& shadow); 1146 void ShowTooltip(const std::string& tooltip, int64_t tooltipTimestamp); 1147 void UpdateTooltipContentColor(const RefPtr<FrameNode>& textNode); 1148 void RegisterVisibleAreaChangeCallback(const RefPtr<PipelineContext> &context); 1149 bool CheckSafeAreaIsExpand(); 1150 bool CheckSafeAreaKeyBoard(); 1151 bool IsDialogNested(); 1152 void SelectCancel() const; 1153 bool IsSelectInfoValid(); 1154 std::optional<RectF> GetViewPort() const; 1155 std::string GetSelectInfo() const; 1156 void UpdateRunQuickMenuSelectInfo(SelectOverlayInfo& selectInfo, 1157 std::shared_ptr<OHOS::NWeb::NWebQuickMenuParams> params, 1158 std::shared_ptr<OHOS::NWeb::NWebTouchHandleState> insertTouchHandle, 1159 std::shared_ptr<OHOS::NWeb::NWebTouchHandleState> beginTouchHandle, 1160 std::shared_ptr<OHOS::NWeb::NWebTouchHandleState> endTouchHandle); 1161 double GetNewScale(double& scale) const; 1162 double GetNewOriginScale(double originScale) const; 1163 void UpdateSlideOffset(); 1164 void ClearKeyEventByKeyCode(int32_t keyCode); 1165 void SetRotation(uint32_t rotation); 1166 Color GetSystemColor() const; UpdateTransformHintChangedCallbackId(std::optional<int32_t> id)1167 void UpdateTransformHintChangedCallbackId(std::optional<int32_t> id) 1168 { 1169 transformHintChangedCallbackId_ = id; 1170 } 1171 HasTransformHintChangedCallbackId()1172 bool HasTransformHintChangedCallbackId() 1173 { 1174 return transformHintChangedCallbackId_.has_value(); 1175 } 1176 1177 void JsonNodePutDefaultValue(std::unique_ptr<OHOS::Ace::JsonValue>& jsonNode, 1178 WebAccessibilityType key, int32_t value, int32_t defaultValue); 1179 void JsonNodePutDefaultValue(std::unique_ptr<OHOS::Ace::JsonValue>& jsonNode, 1180 WebAccessibilityType key, bool value); 1181 void JsonNodePutDefaultValue(std::unique_ptr<OHOS::Ace::JsonValue>& jsonNode, 1182 WebAccessibilityType key, std::string value); 1183 void WebNodeInfoToJsonValue(std::shared_ptr<OHOS::Ace::JsonValue>& jsonNodeArray, 1184 std::shared_ptr<OHOS::NWeb::NWebAccessibilityNodeInfo> webNodeInfo, 1185 std::string& nodeTag, bool isArray = false); 1186 void GetWebAllInfosImpl(WebNodeInfoCallback cb, int32_t webId, bool needFilter = true); 1187 std::string EnumTypeToString(WebAccessibilityType type); 1188 std::string VectorIntToString(std::vector<int64_t>&& vec); 1189 void InitMagnifier(); 1190 void ShowMagnifier(int centerOffsetX, int centerOffsetY); 1191 void HideMagnifier(); 1192 void OnMagnifierHandleMove(const RectF& handleRect, bool isFirst); 1193 int32_t GetBufferSizeByDeviceType(); 1194 void SetActiveStatusInner(bool isActive, bool isForce = false); 1195 void UpdateTouchpadSlidingStatus(const GestureEvent& event); 1196 CursorStyleInfo GetAndUpdateCursorStyleInfo( 1197 const OHOS::NWeb::CursorType& type, std::shared_ptr<OHOS::NWeb::NWebCursorInfo> info); 1198 bool MenuAvoidKeyboard(bool hideOrClose, double height = 0.0f); 1199 int32_t GetVisibleViewportAvoidHeight(); 1200 1201 void HandleAIWriteResult(int32_t start, int32_t end, std::vector<uint8_t>& buffer); 1202 void FormatIndex(int32_t& startIndex, int32_t& endIndex); 1203 std::u16string GetSelectedValue(int32_t startIndex, int32_t endIndex); 1204 RefPtr<TextFieldTheme> GetTheme() const; 1205 void GetAIWriteInfo(AIWriteInfo& info); 1206 1207 std::optional<std::string> webSrc_; 1208 std::optional<std::string> webData_; 1209 std::optional<std::string> customScheme_; 1210 RefPtr<WebController> webController_; 1211 std::optional<int32_t> transformHintChangedCallbackId_; 1212 uint32_t rotation_ = 0; 1213 SetWebIdCallback setWebIdCallback_ = nullptr; 1214 SetWebDetachCallback setWebDetachCallback_ = nullptr; 1215 PermissionClipboardCallback permissionClipboardCallback_ = nullptr; 1216 OnOpenAppLinkCallback onOpenAppLinkCallback_ = nullptr; 1217 SetFaviconCallback setFaviconCallback_ = nullptr; 1218 DefaultFileSelectorShowCallback defaultFileSelectorShowCallback_ = nullptr; 1219 RenderMode renderMode_; 1220 bool incognitoMode_ = false; 1221 SetHapPathCallback setHapPathCallback_ = nullptr; 1222 JsProxyCallback jsProxyCallback_ = nullptr; 1223 OnControllerAttachedCallback onControllerAttachedCallback_ = nullptr; 1224 RefPtr<RenderSurface> renderSurface_ = RenderSurface::Create(); 1225 RefPtr<RenderSurface> popupRenderSurface_ = RenderSurface::Create(); 1226 RefPtr<RenderContext> renderContextForSurface_; 1227 RefPtr<RenderContext> renderContextForPopupSurface_; 1228 RefPtr<TouchEventImpl> touchEvent_; 1229 RefPtr<InputEvent> mouseEvent_; 1230 RefPtr<InputEvent> hoverEvent_; 1231 RefPtr<PanEvent> panEvent_ = nullptr; 1232 bool selectTemporarilyHidden_ = false; 1233 bool selectTemporarilyHiddenByScroll_ = false; 1234 bool nodeAttach_ = false; 1235 RefPtr<SelectOverlayProxy> selectOverlayProxy_ = nullptr; 1236 RefPtr<WebSelectOverlay> webSelectOverlay_ = nullptr; 1237 RefPtr<WebPaintProperty> webPaintProperty_ = nullptr; 1238 RefPtr<DragEvent> dragEvent_; 1239 bool isUrlLoaded_ = false; 1240 std::queue<MouseClickInfo> mouseClickQueue_; 1241 bool isFullScreen_ = false; 1242 std::shared_ptr<FullScreenEnterEvent> fullScreenExitHandler_ = nullptr; 1243 bool needOnFocus_ = false; 1244 Size drawSize_; 1245 Size visibleViewportSize_{-1.0, -1.0}; 1246 bool isKeyboardInSafeArea_ = false; 1247 WebKeyboardAvoidMode keyBoardAvoidMode_ = WebKeyboardAvoidMode::DEFAULT; 1248 Size rootLayerChangeSize_; 1249 Size drawSizeCache_; 1250 Size areaChangeSize_; 1251 bool isNeedReDrawRect_ = false; 1252 bool needUpdateWeb_ = true; 1253 bool isFocus_ = false; 1254 VkState isVirtualKeyBoardShow_ { VkState::VK_NONE }; 1255 bool isDragging_ = false; 1256 bool isReceivedArkDrag_ = false; 1257 bool isW3cDragEvent_ = false; 1258 bool isDragStartFromWeb_ = false; 1259 RefPtr<AccessibilitySessionAdapter> accessibilitySessionAdapter_; 1260 1261 bool isNewDragStyle_ = false; 1262 std::map<std::pair<WebElementType, ResponseType>, 1263 std::shared_ptr<WebPreviewSelectionMenuParam>> previewSelectionMenuMap_; 1264 std::optional<int32_t> previewImageNodeId_ = std::nullopt; 1265 std::optional<int32_t> snapshotImageNodeId_ = std::nullopt; 1266 bool needUpdateImagePreviewParam_ = false; 1267 WebElementType curElementType_ = WebElementType::NONE; 1268 ResponseType curResponseType_ = ResponseType::LONG_PRESS; 1269 bool curContextMenuResult_ = false; 1270 1271 bool isWindowShow_ = true; 1272 bool isActive_ = true; 1273 bool isEnhanceSurface_ = false; 1274 bool isAllowWindowOpenMethod_ = false; 1275 bool isShowAutofillPopup_ = false; 1276 OffsetF webOffset_; 1277 RefPtr<WebContextSelectOverlay> contextSelectOverlay_ = nullptr; 1278 RefPtr<WebContextMenuParam> contextMenuParam_ = nullptr; 1279 RefPtr<ContextMenuResult> contextMenuResult_ = nullptr; 1280 RectF selectArea_; 1281 RectF cursorInfo_; 1282 std::shared_ptr<OHOS::NWeb::NWebQuickMenuCallback> quickMenuCallback_ = nullptr; 1283 bool selectPopupMenuShowing_ = false; 1284 std::list<TouchInfo> touchOverlayInfo_; 1285 bool isPopup_ = false; 1286 int32_t tooltipId_ = -1; 1287 int32_t mouseHoveredX_ = -1; 1288 int32_t mouseHoveredY_ = -1; 1289 int32_t mouseEventDeviceId_ = -1; 1290 int64_t tooltipTimestamp_ = -1; 1291 int32_t parentNWebId_ = -1; 1292 bool isInWindowDrag_ = false; 1293 bool isWaiting_ = false; 1294 bool isDisableDrag_ = false; 1295 bool isMouseEvent_ = false; 1296 bool isHoverExit_ = false; 1297 bool isVisible_ = true; 1298 bool isVisibleActiveEnable_ = true; 1299 bool isMemoryLevelEnable_ = true; 1300 OffsetF fitContentOffset_; 1301 bool isFirstFlingScrollVelocity_ = true; 1302 bool isScrollStarted_ = false; 1303 WebLayoutMode layoutMode_ = WebLayoutMode::NONE; 1304 bool isEmbedModeEnabled_ = false; 1305 bool scrollState_ = false; 1306 Axis axis_ = Axis::FREE; 1307 Axis syncAxis_ = Axis::NONE; 1308 Axis expectedScrollAxis_ = Axis::FREE; 1309 int32_t rootLayerWidth_ = 0; 1310 int32_t rootLayerHeight_ = 0; 1311 int32_t drawRectWidth_ = 0; 1312 int32_t drawRectHeight_ = 0; 1313 std::unordered_map<Axis, WeakPtr<NestableScrollContainer>> parentsMap_; 1314 RefPtr<WebDelegate> delegate_; 1315 RefPtr<WebDelegateObserver> observer_; 1316 std::optional<ScriptItems> onDocumentStartScriptItems_; 1317 std::optional<ScriptItems> onDocumentEndScriptItems_; 1318 std::optional<ScriptItems> onHeadReadyScriptItems_; 1319 std::optional<ScriptItemsByOrder> onDocumentStartScriptItemsByOrder_; 1320 std::optional<ScriptItemsByOrder> onDocumentEndScriptItemsByOrder_; 1321 std::optional<ScriptItemsByOrder> onHeadReadyScriptItemsByOrder_; 1322 1323 bool isAttachedToMainTree_ = false; 1324 bool offlineWebInited_ = false; 1325 bool offlineWebRendered_ = false; 1326 ACE_DISALLOW_COPY_AND_MOVE(WebPattern); 1327 bool accessibilityState_ = false; 1328 TouchEventInfo touchEventInfo_{"touchEvent"}; 1329 std::vector<TouchEventInfo> touchEventInfoList_ {}; 1330 bool isParentReachEdge_ = false; 1331 RefPtr<PinchGesture> pinchGesture_ = nullptr; 1332 std::queue<TouchEventInfo> touchEventQueue_; 1333 std::queue<MouseInfo> mouseInfoQueue_; 1334 std::vector<NG::MenuOptionsParam> menuOptionParam_ {}; 1335 std::list<KeyEvent> webKeyEvent_ {}; 1336 KeyEvent tabKeyEvent_; 1337 double startPinchScale_ = -1.0; 1338 double preScale_ = -1.0; 1339 double pageScale_ = 1.0; 1340 double startPageScale_ = 1.0; 1341 bool isResizeContentAvoid_ = false; 1342 float heightAfterAvoid_ = 0.0; 1343 bool zoomOutSwitch_ = false; 1344 bool isTouchUpEvent_ = false; 1345 int32_t zoomStatus_ = 0; 1346 int32_t zoomErrorCount_ = 0; 1347 std::shared_ptr<ImageAnalyzerManager> imageAnalyzerManager_ = nullptr; 1348 bool overlayCreating_ = false; 1349 bool awaitingOnTextSelected_ = false; 1350 RefPtr<OverlayManager> keyboardOverlay_; 1351 std::function<void()> customKeyboardBuilder_ = nullptr; 1352 std::function<void(int32_t)> updateInstanceIdCallback_; 1353 std::shared_ptr<TouchEventListener> touchEventListener_ = nullptr; 1354 double lastKeyboardHeight_ = 0.0; 1355 bool inspectorAccessibilityEnable_ = false; 1356 std::optional<std::string> sharedRenderProcessToken_; 1357 bool textBlurAccessibilityEnable_ = false; 1358 WebComponentClickCallback webComponentClickCallback_ = nullptr; 1359 uint32_t autoFillSessionId_ = 0; 1360 std::unordered_map<int32_t, std::shared_ptr<WebAccessibilityChildTreeCallback>> accessibilityChildTreeCallback_; 1361 int32_t treeId_ = 0; 1362 int32_t instanceId_ = -1; 1363 int64_t focusedAccessibilityId_ = -1; 1364 std::vector<RefPtr<PageNodeInfoWrap>> pageNodeInfo_; 1365 bool isRenderModeInit_ = false; 1366 bool isAutoFillClosing_ = true; 1367 std::shared_ptr<ViewDataCommon> viewDataCommon_; 1368 OffsetF requestedWebOffset_; 1369 bool isPasswordFill_ = false; 1370 bool isEnabledHapticFeedback_ = true; 1371 bool isTouchpadSliding_ = false; 1372 NestedScrollOptionsExt nestedScroll_ = { 1373 .scrollUp = NestedScrollMode::SELF_ONLY, 1374 .scrollDown = NestedScrollMode::SELF_ONLY, 1375 .scrollLeft = NestedScrollMode::SELF_ONLY, 1376 .scrollRight = NestedScrollMode::SELF_ONLY, 1377 }; 1378 VisibleType componentVisibility_ = VisibleType::VISIBLE; 1379 bool imageOverlayIsSelected_ = false; 1380 bool isLayoutModeChanged_ = false; 1381 bool isDragEnd_ = false; 1382 std::shared_ptr<OHOS::NWeb::NWebCursorInfo> nweb_cursorInfo_; 1383 bool isMouseLocked_ = false; 1384 OHOS::NWeb::CursorType cursorType_; 1385 float touchPointX = 0; 1386 float touchPointY = 0; 1387 bool isUsingCustomKeyboardAvoid_ = false; 1388 int64_t lastHeight_ = 0L; 1389 int64_t lastWidth_ = 0L; 1390 bool dragWindowFlag_ = false; 1391 bool isSetMouseDragMonitorState = false; 1392 double density_ = 0.0; 1393 int32_t densityCallbackId_ = 0; 1394 bool keyboardGetready_ = false; 1395 std::vector<uint32_t> pipController_; 1396 std::optional<int32_t> dataListNodeId_ = std::nullopt; 1397 bool isRegisterJsObject_ = false; 1398 1399 MouseInfo mouseInfo_; 1400 1401 // properties for WebAccessibilityEventReport 1402 RefPtr<WebAccessibilityEventReport> webAccessibilityEventReport_ = nullptr; 1403 1404 // properties for AI data detector 1405 bool isAILinkMenuShow_ = false; 1406 RefPtr<WebDataDetectorAdapter> webDataDetectorAdapter_ = nullptr; 1407 TextDataDetectResult textDetectResult_; 1408 int lastDragOperation_; 1409 1410 bool isRotating_ {false}; 1411 int32_t rotationEndCallbackId_ = 0; 1412 1413 WebBypassVsyncCondition webBypassVsyncCondition_ = WebBypassVsyncCondition::NONE; 1414 bool needSetDefaultBackgroundColor_ = false; 1415 GestureFocusMode gestureFocusMode_ = GestureFocusMode::DEFAULT; 1416 1417 RectF firstInfoHandle_; 1418 RectF secondInfoHandle_; 1419 RefPtr<AIWriteAdapter> aiWriteAdapter_ = MakeRefPtr<AIWriteAdapter>(); 1420 std::u16string content_; 1421 int64_t lastDragTime_ = 0L; 1422 bool dragResizeTimerFlag_ = false; 1423 int32_t dragResizeTimerCount_ = 0; 1424 1425 protected: 1426 OnCreateMenuCallback onCreateMenuCallback_; 1427 OnMenuItemClickCallback onMenuItemClick_; 1428 OnPrepareMenuCallback onPrepareMenuCallback_; 1429 }; 1430 } // namespace OHOS::Ace::NG 1431 1432 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_WEB_WEB_PATTERN_H 1433