4
4
5
5
#include < NativeScriptAssert.h>
6
6
#include < ArgConverter.h>
7
+ #include < v8_inspector/src/inspector/utils/v8-inspector-common.h>
7
8
#include " v8-css-agent-impl.h"
8
9
9
10
namespace v8_inspector {
@@ -65,7 +66,6 @@ namespace v8_inspector {
65
66
.build ();
66
67
67
68
// // out_attributesStyle
68
-
69
69
auto attrArr = protocol::Array<protocol::CSS::CSSProperty>::create ();
70
70
auto attributeStyle = protocol::CSS::CSSStyle::create ()
71
71
.setCssProperties (std::move (attrArr))
@@ -144,37 +144,41 @@ namespace v8_inspector {
144
144
std::unique_ptr<protocol::Array<protocol::CSS::CSSComputedStyleProperty>> *out_computedStyle) {
145
145
auto computedStylePropertyArr = protocol::Array<protocol::CSS::CSSComputedStyleProperty>::create ();
146
146
147
- auto getComputedStylesForNodeString = " __getComputedStylesForNode " ;
147
+ auto getComputedStylesForNodeString = " getComputedStylesForNode " ;
148
148
// TODO: Pete: Find a better way to get a hold of the isolate
149
149
auto isolate = v8::Isolate::GetCurrent ();
150
150
auto context = isolate->GetCurrentContext ();
151
151
auto global = context->Global ();
152
- auto getComputedStylesForNode = global->Get (ArgConverter::ConvertToV8String (isolate, getComputedStylesForNodeString));
153
152
154
- if (!getComputedStylesForNode.IsEmpty () && getComputedStylesForNode->IsFunction ()) {
155
- auto getComputedStylesForNodeFunc = getComputedStylesForNode.As <v8::Function>();
156
- v8::Local<v8::Value> args[] = { v8::Number::New (isolate, in_nodeId) };
157
- auto maybeResult = getComputedStylesForNodeFunc->Call (context, global, 1 , args);
158
- v8::Local<v8::Value> outResult;
153
+ auto globalInspectorObject = utils::Common::getGlobalInspectorObject (isolate);
154
+
155
+ if (!globalInspectorObject.IsEmpty ()) {
156
+ auto getComputedStylesForNode = globalInspectorObject->Get (ArgConverter::ConvertToV8String (isolate, getComputedStylesForNodeString));
159
157
160
- maybeResult.ToLocal (&outResult);
158
+ if (!getComputedStylesForNode.IsEmpty () && getComputedStylesForNode->IsFunction ()) {
159
+ auto getComputedStylesForNodeFunc = getComputedStylesForNode.As <v8::Function>();
160
+ v8::Local<v8::Value> args[] = {v8::Number::New (isolate, in_nodeId)};
161
+ auto maybeResult = getComputedStylesForNodeFunc->Call (context, global, 1 , args);
162
+ v8::Local<v8::Value> outResult;
161
163
162
- if (!outResult. IsEmpty ( )) {
163
- auto resultString = ArgConverter::ConvertToString (outResult->ToString ());
164
- auto resultCStr = resultString.c_str ();
165
- auto resultJson = protocol::parseJSON (resultCStr);
164
+ if (maybeResult. ToLocal (&outResult )) {
165
+ auto resultString = ArgConverter::ConvertToString (outResult->ToString ());
166
+ auto resultCStr = resultString.c_str ();
167
+ auto resultJson = protocol::parseJSON (resultCStr);
166
168
167
- protocol::ErrorSupport errorSupport;
168
- auto computedStyles = protocol::Array<protocol::CSS::CSSComputedStyleProperty>::parse (resultJson.get (), &errorSupport);
169
+ protocol::ErrorSupport errorSupport;
170
+ auto computedStyles = protocol::Array<protocol::CSS::CSSComputedStyleProperty>::parse (
171
+ resultJson.get (), &errorSupport);
169
172
170
- auto errorSupportString = errorSupport.errors ().utf8 ();
171
- if (!errorSupportString.empty ()) {
172
- auto errorMessage = " Error while parsing CSSComputedStyleProperty object. " ;
173
- DEBUG_WRITE_FORCE (" %s Error: %s" , errorMessage, errorSupportString.c_str ());
174
- } else {
175
- *out_computedStyle = std::move (computedStyles);
173
+ auto errorSupportString = errorSupport.errors ().utf8 ();
174
+ if (!errorSupportString.empty ()) {
175
+ auto errorMessage = " Error while parsing CSSComputedStyleProperty object. " ;
176
+ DEBUG_WRITE_FORCE (" %s Error: %s" , errorMessage, errorSupportString.c_str ());
177
+ } else {
178
+ *out_computedStyle = std::move (computedStyles);
176
179
177
- return ;
180
+ return ;
181
+ }
178
182
}
179
183
}
180
184
}
@@ -185,7 +189,12 @@ namespace v8_inspector {
185
189
void V8CSSAgentImpl::getPlatformFontsForNode (ErrorString *, int in_nodeId,
186
190
std::unique_ptr<protocol::Array<protocol::CSS::PlatformFontUsage>> *out_fonts) {
187
191
auto fontsArr = protocol::Array<protocol::CSS::PlatformFontUsage>::create ();
188
- fontsArr->addItem (std::move (protocol::CSS::PlatformFontUsage::create ().setFamilyName (" System Font" ).setGlyphCount (1 ).setIsCustomFont (false ).build ()));
192
+ auto defaultFont = " System Font" ;
193
+ fontsArr->addItem (std::move (protocol::CSS::PlatformFontUsage::create ()
194
+ .setFamilyName (defaultFont)
195
+ .setGlyphCount (1 )
196
+ .setIsCustomFont (false )
197
+ .build ()));
189
198
*out_fonts = std::move (fontsArr);
190
199
}
191
200
0 commit comments