|
2 | 2 | // Created by pkanev on 5/10/2017. |
3 | 3 | // |
4 | 4 |
|
5 | | -#include <sstream> |
6 | | -#include <ArgConverter.h> |
7 | | -#include <NativeScriptAssert.h> |
| 5 | +// #include <sstream> |
| 6 | +// #include <ArgConverter.h> |
| 7 | +// #include <NativeScriptAssert.h> |
8 | 8 |
|
9 | | -#include <v8_inspector/src/inspector/protocol/Protocol.h> |
10 | | -#include <v8_inspector/src/inspector/string-util.h> |
11 | | -#include <v8_inspector/third_party/inspector_protocol/crdtp/error_support.h> |
12 | | -#include <v8_inspector/third_party/inspector_protocol/crdtp/json.h> |
| 9 | +// #include <v8_inspector/src/inspector/protocol/Protocol.h> |
| 10 | +// #include <v8_inspector/src/inspector/string-util.h> |
| 11 | +// #include <v8_inspector/third_party/inspector_protocol/crdtp/error_support.h> |
| 12 | +// #include <v8_inspector/third_party/inspector_protocol/crdtp/json.h> |
13 | 13 |
|
14 | 14 | #include "DOMDomainCallbackHandlers.h" |
15 | 15 |
|
16 | 16 | using namespace tns; |
17 | 17 |
|
18 | 18 | void DOMDomainCallbackHandlers::DocumentUpdatedCallback(const v8::FunctionCallbackInfo<v8::Value>& args) { |
19 | | - auto domAgentInstance = DOMAgentImpl::Instance; |
| 19 | + // auto domAgentInstance = DOMAgentImpl::Instance; |
20 | 20 |
|
21 | | - if (!domAgentInstance) { |
22 | | - return; |
23 | | - } |
| 21 | + // if (!domAgentInstance) { |
| 22 | + // return; |
| 23 | + // } |
24 | 24 |
|
25 | | - domAgentInstance->m_frontend.documentUpdated(); |
| 25 | + // domAgentInstance->m_frontend.documentUpdated(); |
26 | 26 | } |
27 | 27 |
|
28 | 28 | void DOMDomainCallbackHandlers::ChildNodeInsertedCallback(const v8::FunctionCallbackInfo<v8::Value>& args) { |
29 | | - try { |
30 | | - auto domAgentInstance = DOMAgentImpl::Instance; |
31 | | - |
32 | | - if (!domAgentInstance) { |
33 | | - return; |
34 | | - } |
35 | | - |
36 | | - auto isolate = args.GetIsolate(); |
37 | | - |
38 | | - v8::HandleScope scope(isolate); |
39 | | - |
40 | | - if (args.Length() != 3 || !(args[0]->IsNumber() && args[1]->IsNumber() && args[2]->IsString())) { |
41 | | - throw NativeScriptException("Calling ChildNodeInserted with invalid arguments. Required params: parentId: number, lastId: number, node: JSON String"); |
42 | | - } |
43 | | - |
44 | | - auto context = isolate->GetCurrentContext(); |
45 | | - auto parentId = args[0]->ToNumber(context).ToLocalChecked(); |
46 | | - auto lastId = args[1]->ToNumber(context).ToLocalChecked(); |
47 | | - auto node = args[2]->ToString(context).ToLocalChecked(); |
48 | | - |
49 | | - auto resultString = DOMAgentImpl::AddBackendNodeIdProperty(isolate, node); |
50 | | - auto nodeUtf16Data = resultString.data(); |
51 | | - const v8_inspector::String16& nodeString16 = v8_inspector::String16((const uint16_t*) nodeUtf16Data); |
52 | | - std::vector<uint8_t> cbor; |
53 | | - v8_crdtp::json::ConvertJSONToCBOR(v8_crdtp::span<uint16_t>(nodeString16.characters16(), nodeString16.length()), &cbor); |
54 | | - std::unique_ptr<protocol::Value> protocolNodeJson = protocol::Value::parseBinary(cbor.data(), cbor.size()); |
55 | | - |
56 | | - v8_crdtp::ErrorSupport errorSupport; |
57 | | - auto domNode = protocol::DOM::Node::fromValue(protocolNodeJson.get(), &errorSupport); |
58 | | - |
59 | | - std::vector<uint8_t> json; |
60 | | - v8_crdtp::json::ConvertCBORToJSON(errorSupport.Errors(), &json); |
61 | | - auto errorSupportString = String16(reinterpret_cast<const char*>(json.data()), json.size()).utf8(); |
62 | | - if (!errorSupportString.empty()) { |
63 | | - auto errorMessage = "Error while parsing debug `DOM Node` object. "; |
64 | | - DEBUG_WRITE_FORCE("%s Error: %s", errorMessage, errorSupportString.c_str()); |
65 | | - return; |
66 | | - } |
67 | | - |
68 | | - domAgentInstance->m_frontend.childNodeInserted(parentId->Int32Value(context).ToChecked(), lastId->Int32Value(context).ToChecked(), std::move(domNode)); |
69 | | - } catch (NativeScriptException& e) { |
70 | | - e.ReThrowToV8(); |
71 | | - } catch (std::exception e) { |
72 | | - std::stringstream ss; |
73 | | - ss << "Error: c exception: " << e.what() << std::endl; |
74 | | - NativeScriptException nsEx(ss.str()); |
75 | | - nsEx.ReThrowToV8(); |
76 | | - } catch (...) { |
77 | | - NativeScriptException nsEx(std::string("Error: c exception!")); |
78 | | - nsEx.ReThrowToV8(); |
79 | | - } |
| 29 | + // try { |
| 30 | + // auto domAgentInstance = DOMAgentImpl::Instance; |
| 31 | + |
| 32 | + // if (!domAgentInstance) { |
| 33 | + // return; |
| 34 | + // } |
| 35 | + |
| 36 | + // auto isolate = args.GetIsolate(); |
| 37 | + |
| 38 | + // v8::HandleScope scope(isolate); |
| 39 | + |
| 40 | + // if (args.Length() != 3 || !(args[0]->IsNumber() && args[1]->IsNumber() && args[2]->IsString())) { |
| 41 | + // throw NativeScriptException("Calling ChildNodeInserted with invalid arguments. Required params: parentId: number, lastId: number, node: JSON String"); |
| 42 | + // } |
| 43 | + |
| 44 | + // auto context = isolate->GetCurrentContext(); |
| 45 | + // auto parentId = args[0]->ToNumber(context).ToLocalChecked(); |
| 46 | + // auto lastId = args[1]->ToNumber(context).ToLocalChecked(); |
| 47 | + // auto node = args[2]->ToString(context).ToLocalChecked(); |
| 48 | + |
| 49 | + // auto resultString = DOMAgentImpl::AddBackendNodeIdProperty(isolate, node); |
| 50 | + // auto nodeUtf16Data = resultString.data(); |
| 51 | + // const v8_inspector::String16& nodeString16 = v8_inspector::String16((const uint16_t*) nodeUtf16Data); |
| 52 | + // std::vector<uint8_t> cbor; |
| 53 | + // v8_crdtp::json::ConvertJSONToCBOR(v8_crdtp::span<uint16_t>(nodeString16.characters16(), nodeString16.length()), &cbor); |
| 54 | + // std::unique_ptr<protocol::Value> protocolNodeJson = protocol::Value::parseBinary(cbor.data(), cbor.size()); |
| 55 | + |
| 56 | + // v8_crdtp::ErrorSupport errorSupport; |
| 57 | + // auto domNode = protocol::DOM::Node::fromValue(protocolNodeJson.get(), &errorSupport); |
| 58 | + |
| 59 | + // std::vector<uint8_t> json; |
| 60 | + // v8_crdtp::json::ConvertCBORToJSON(errorSupport.Errors(), &json); |
| 61 | + // auto errorSupportString = String16(reinterpret_cast<const char*>(json.data()), json.size()).utf8(); |
| 62 | + // if (!errorSupportString.empty()) { |
| 63 | + // auto errorMessage = "Error while parsing debug `DOM Node` object. "; |
| 64 | + // DEBUG_WRITE_FORCE("%s Error: %s", errorMessage, errorSupportString.c_str()); |
| 65 | + // return; |
| 66 | + // } |
| 67 | + |
| 68 | + // domAgentInstance->m_frontend.childNodeInserted(parentId->Int32Value(context).ToChecked(), lastId->Int32Value(context).ToChecked(), std::move(domNode)); |
| 69 | + // } catch (NativeScriptException& e) { |
| 70 | + // e.ReThrowToV8(); |
| 71 | + // } catch (std::exception e) { |
| 72 | + // std::stringstream ss; |
| 73 | + // ss << "Error: c exception: " << e.what() << std::endl; |
| 74 | + // NativeScriptException nsEx(ss.str()); |
| 75 | + // nsEx.ReThrowToV8(); |
| 76 | + // } catch (...) { |
| 77 | + // NativeScriptException nsEx(std::string("Error: c exception!")); |
| 78 | + // nsEx.ReThrowToV8(); |
| 79 | + // } |
80 | 80 | } |
81 | 81 |
|
82 | 82 | void DOMDomainCallbackHandlers::ChildNodeRemovedCallback(const v8::FunctionCallbackInfo<v8::Value>& args) { |
83 | | - try { |
84 | | - auto domAgentInstance = DOMAgentImpl::Instance; |
85 | | - |
86 | | - if (!domAgentInstance) { |
87 | | - return; |
88 | | - } |
89 | | - |
90 | | - auto isolate = args.GetIsolate(); |
91 | | - |
92 | | - v8::HandleScope scope(isolate); |
93 | | - |
94 | | - if (args.Length() != 2 || !(args[0]->IsNumber() && args[1]->IsNumber())) { |
95 | | - throw NativeScriptException("Calling ChildNodeRemoved with invalid arguments. Required params: parentId: number, nodeId: number"); |
96 | | - } |
97 | | - |
98 | | - auto context = isolate->GetCurrentContext(); |
99 | | - auto parentId = args[0]->ToNumber(context).ToLocalChecked(); |
100 | | - auto nodeId = args[1]->ToNumber(context).ToLocalChecked(); |
101 | | - |
102 | | - domAgentInstance->m_frontend.childNodeRemoved(parentId->Int32Value(context).ToChecked(), nodeId->Int32Value(context).ToChecked()); |
103 | | - } catch (NativeScriptException& e) { |
104 | | - e.ReThrowToV8(); |
105 | | - } catch (std::exception e) { |
106 | | - std::stringstream ss; |
107 | | - ss << "Error: c exception: " << e.what() << std::endl; |
108 | | - NativeScriptException nsEx(ss.str()); |
109 | | - nsEx.ReThrowToV8(); |
110 | | - } catch (...) { |
111 | | - NativeScriptException nsEx(std::string("Error: c exception!")); |
112 | | - nsEx.ReThrowToV8(); |
113 | | - } |
| 83 | + // try { |
| 84 | + // auto domAgentInstance = DOMAgentImpl::Instance; |
| 85 | + |
| 86 | + // if (!domAgentInstance) { |
| 87 | + // return; |
| 88 | + // } |
| 89 | + |
| 90 | + // auto isolate = args.GetIsolate(); |
| 91 | + |
| 92 | + // v8::HandleScope scope(isolate); |
| 93 | + |
| 94 | + // if (args.Length() != 2 || !(args[0]->IsNumber() && args[1]->IsNumber())) { |
| 95 | + // throw NativeScriptException("Calling ChildNodeRemoved with invalid arguments. Required params: parentId: number, nodeId: number"); |
| 96 | + // } |
| 97 | + |
| 98 | + // auto context = isolate->GetCurrentContext(); |
| 99 | + // auto parentId = args[0]->ToNumber(context).ToLocalChecked(); |
| 100 | + // auto nodeId = args[1]->ToNumber(context).ToLocalChecked(); |
| 101 | + |
| 102 | + // domAgentInstance->m_frontend.childNodeRemoved(parentId->Int32Value(context).ToChecked(), nodeId->Int32Value(context).ToChecked()); |
| 103 | + // } catch (NativeScriptException& e) { |
| 104 | + // e.ReThrowToV8(); |
| 105 | + // } catch (std::exception e) { |
| 106 | + // std::stringstream ss; |
| 107 | + // ss << "Error: c exception: " << e.what() << std::endl; |
| 108 | + // NativeScriptException nsEx(ss.str()); |
| 109 | + // nsEx.ReThrowToV8(); |
| 110 | + // } catch (...) { |
| 111 | + // NativeScriptException nsEx(std::string("Error: c exception!")); |
| 112 | + // nsEx.ReThrowToV8(); |
| 113 | + // } |
114 | 114 | } |
115 | 115 |
|
116 | 116 | void DOMDomainCallbackHandlers::AttributeModifiedCallback(const v8::FunctionCallbackInfo<v8::Value>& args) { |
117 | | - try { |
118 | | - auto domAgentInstance = DOMAgentImpl::Instance; |
119 | | - |
120 | | - if (!domAgentInstance) { |
121 | | - return; |
122 | | - } |
123 | | - |
124 | | - auto isolate = args.GetIsolate(); |
125 | | - |
126 | | - v8::HandleScope scope(isolate); |
127 | | - |
128 | | - if (args.Length() != 3 || !(args[0]->IsNumber() && args[1]->IsString() && args[2]->IsString())) { |
129 | | - throw NativeScriptException("Calling AttributeModified with invalid arguments. Required params: nodeId: number, name: string, value: string"); |
130 | | - } |
131 | | - |
132 | | - auto context = isolate->GetCurrentContext(); |
133 | | - auto nodeId = args[0]->ToNumber(context).ToLocalChecked(); |
134 | | - auto attributeName = args[1]->ToString(context).ToLocalChecked(); |
135 | | - auto attributeValue = args[2]->ToString(context).ToLocalChecked(); |
136 | | - |
137 | | - domAgentInstance->m_frontend.attributeModified(nodeId->Int32Value(context).ToChecked(), |
138 | | - v8_inspector::toProtocolString(isolate, attributeName), |
139 | | - v8_inspector::toProtocolString(isolate, attributeValue)); |
140 | | - } catch (NativeScriptException& e) { |
141 | | - e.ReThrowToV8(); |
142 | | - } catch (std::exception e) { |
143 | | - std::stringstream ss; |
144 | | - ss << "Error: c exception: " << e.what() << std::endl; |
145 | | - NativeScriptException nsEx(ss.str()); |
146 | | - nsEx.ReThrowToV8(); |
147 | | - } catch (...) { |
148 | | - NativeScriptException nsEx(std::string("Error: c exception!")); |
149 | | - nsEx.ReThrowToV8(); |
150 | | - } |
| 117 | + // try { |
| 118 | + // auto domAgentInstance = DOMAgentImpl::Instance; |
| 119 | + |
| 120 | + // if (!domAgentInstance) { |
| 121 | + // return; |
| 122 | + // } |
| 123 | + |
| 124 | + // auto isolate = args.GetIsolate(); |
| 125 | + |
| 126 | + // v8::HandleScope scope(isolate); |
| 127 | + |
| 128 | + // if (args.Length() != 3 || !(args[0]->IsNumber() && args[1]->IsString() && args[2]->IsString())) { |
| 129 | + // throw NativeScriptException("Calling AttributeModified with invalid arguments. Required params: nodeId: number, name: string, value: string"); |
| 130 | + // } |
| 131 | + |
| 132 | + // auto context = isolate->GetCurrentContext(); |
| 133 | + // auto nodeId = args[0]->ToNumber(context).ToLocalChecked(); |
| 134 | + // auto attributeName = args[1]->ToString(context).ToLocalChecked(); |
| 135 | + // auto attributeValue = args[2]->ToString(context).ToLocalChecked(); |
| 136 | + |
| 137 | + // domAgentInstance->m_frontend.attributeModified(nodeId->Int32Value(context).ToChecked(), |
| 138 | + // v8_inspector::toProtocolString(isolate, attributeName), |
| 139 | + // v8_inspector::toProtocolString(isolate, attributeValue)); |
| 140 | + // } catch (NativeScriptException& e) { |
| 141 | + // e.ReThrowToV8(); |
| 142 | + // } catch (std::exception e) { |
| 143 | + // std::stringstream ss; |
| 144 | + // ss << "Error: c exception: " << e.what() << std::endl; |
| 145 | + // NativeScriptException nsEx(ss.str()); |
| 146 | + // nsEx.ReThrowToV8(); |
| 147 | + // } catch (...) { |
| 148 | + // NativeScriptException nsEx(std::string("Error: c exception!")); |
| 149 | + // nsEx.ReThrowToV8(); |
| 150 | + // } |
151 | 151 | } |
152 | 152 |
|
153 | 153 | void DOMDomainCallbackHandlers::AttributeRemovedCallback(const v8::FunctionCallbackInfo<v8::Value>& args) { |
154 | | - try { |
155 | | - auto domAgentInstance = DOMAgentImpl::Instance; |
156 | | - |
157 | | - if (!domAgentInstance) { |
158 | | - return; |
159 | | - } |
160 | | - auto isolate = args.GetIsolate(); |
161 | | - |
162 | | - v8::HandleScope scope(isolate); |
163 | | - |
164 | | - if (args.Length() != 2 || !(args[0]->IsNumber() && args[1]->IsString())) { |
165 | | - throw NativeScriptException("Calling AttributeRemoved with invalid arguments. Required params: nodeId: number, name: string"); |
166 | | - } |
167 | | - |
168 | | - auto context = isolate->GetCurrentContext(); |
169 | | - auto nodeId = args[0]->ToNumber(context).ToLocalChecked(); |
170 | | - auto attributeName = args[1]->ToString(context).ToLocalChecked(); |
171 | | - |
172 | | - domAgentInstance->m_frontend.attributeRemoved(nodeId->Int32Value(context).ToChecked(), |
173 | | - v8_inspector::toProtocolString(isolate, attributeName)); |
174 | | - } catch (NativeScriptException& e) { |
175 | | - e.ReThrowToV8(); |
176 | | - } catch (std::exception e) { |
177 | | - std::stringstream ss; |
178 | | - ss << "Error: c exception: " << e.what() << std::endl; |
179 | | - NativeScriptException nsEx(ss.str()); |
180 | | - nsEx.ReThrowToV8(); |
181 | | - } catch (...) { |
182 | | - NativeScriptException nsEx(std::string("Error: c exception!")); |
183 | | - nsEx.ReThrowToV8(); |
184 | | - } |
| 154 | + // try { |
| 155 | + // auto domAgentInstance = DOMAgentImpl::Instance; |
| 156 | + |
| 157 | + // if (!domAgentInstance) { |
| 158 | + // return; |
| 159 | + // } |
| 160 | + // auto isolate = args.GetIsolate(); |
| 161 | + |
| 162 | + // v8::HandleScope scope(isolate); |
| 163 | + |
| 164 | + // if (args.Length() != 2 || !(args[0]->IsNumber() && args[1]->IsString())) { |
| 165 | + // throw NativeScriptException("Calling AttributeRemoved with invalid arguments. Required params: nodeId: number, name: string"); |
| 166 | + // } |
| 167 | + |
| 168 | + // auto context = isolate->GetCurrentContext(); |
| 169 | + // auto nodeId = args[0]->ToNumber(context).ToLocalChecked(); |
| 170 | + // auto attributeName = args[1]->ToString(context).ToLocalChecked(); |
| 171 | + |
| 172 | + // domAgentInstance->m_frontend.attributeRemoved(nodeId->Int32Value(context).ToChecked(), |
| 173 | + // v8_inspector::toProtocolString(isolate, attributeName)); |
| 174 | + // } catch (NativeScriptException& e) { |
| 175 | + // e.ReThrowToV8(); |
| 176 | + // } catch (std::exception e) { |
| 177 | + // std::stringstream ss; |
| 178 | + // ss << "Error: c exception: " << e.what() << std::endl; |
| 179 | + // NativeScriptException nsEx(ss.str()); |
| 180 | + // nsEx.ReThrowToV8(); |
| 181 | + // } catch (...) { |
| 182 | + // NativeScriptException nsEx(std::string("Error: c exception!")); |
| 183 | + // nsEx.ReThrowToV8(); |
| 184 | + // } |
185 | 185 | } |
0 commit comments