/* * Tencent is pleased to support the open source community by making * Hippy available. * * Copyright (C) 2017-2019 THL A29 Limited, a Tencent company. * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include #include #include #include #include "module/domain/base_domain.h" #include "module/model/dom_model.h" #include "module/request/base_request.h" #include "module/request/dom_node_data_request.h" #include "module/request/dom_node_for_location_request.h" #include "module/request/dom_push_node_by_path_request.h" #include "module/request/dom_push_nodes_request.h" namespace hippy::devtools { /** * @brief DOM domain */ class DomDomain : public BaseDomain, public std::enable_shared_from_this { public: using PushNodePath = std::vector>; using DomDataCallback = std::function; using DomPushNodeByPathDataCallback = std::function relation_nodes)>; using DomDataRequestCallback = std::function; using LocationForNodeDataCallback = std::function; using DomPushNodeByPathCallback = std::function; explicit DomDomain(std::weak_ptr dispatch) : BaseDomain(std::move(dispatch)) {} std::string GetDomainName() override; void RegisterMethods() override; void RegisterCallback() override; inline void SetDomDataRequestCallback(DomDataRequestCallback call_back) { dom_data_call_back_ = call_back; } private: void GetDocument(const BaseRequest& request); void RequestChildNodes(const DomNodeDataRequest& request); void GetBoxModel(const DomNodeDataRequest& request); void GetNodeForLocation(const DomNodeForLocationRequest& request); void RemoveNode(const BaseRequest& request); void SetInspectedNode(const BaseRequest& request); void PushNodesByBackendIdsToFrontend(DomPushNodesRequest& request); void PushNodeByPathToFrontend(DomPushNodeByPathRequest& request); void HandleDocumentUpdate(); void CacheEntireDocumentTree(DomModel root_model); void SetChildNodesEvent(DomModel model); int32_t SearchNearlyCacheNode(nlohmann::json relation_tree); double RemoveScreenScaleFactor(const std::shared_ptr& screen_adapter, double origin_value); // std::map element_node_children_count_cache_; // std::map backend_node_id_map_; DomDataRequestCallback dom_data_call_back_; LocationForNodeDataCallback location_for_node_call_back_; DomPushNodeByPathCallback dom_push_node_by_path_call_back_; }; } // namespace hippy::devtools