Commit cb90b21f authored by Jaroslav Sevcik's avatar Jaroslav Sevcik Committed by V8 LUCI CQ

[inspector] Remove the code for computing node description

That code should be dead now that we compute the description in Blink
(see crbug.com/1048143).

Bug: chromium:1275591
Change-Id: I6e8c4dec27eb981807ab4eba75572635ee655a3b
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3310837
Auto-Submit: Jaroslav Sevcik <jarin@chromium.org>
Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/main@{#78195}
parent 286747bb
...@@ -1474,103 +1474,15 @@ std::vector<PrivatePropertyMirror> ValueMirror::getPrivateProperties( ...@@ -1474,103 +1474,15 @@ std::vector<PrivatePropertyMirror> ValueMirror::getPrivateProperties(
return mirrors; return mirrors;
} }
String16 descriptionForNode(v8::Local<v8::Context> context,
v8::Local<v8::Value> value) {
if (!value->IsObject()) return String16();
v8::Local<v8::Object> object = value.As<v8::Object>();
v8::Isolate* isolate = context->GetIsolate();
v8::TryCatch tryCatch(isolate);
v8::Local<v8::Value> nodeName;
if (!object->Get(context, toV8String(isolate, "nodeName"))
.ToLocal(&nodeName)) {
return String16();
}
String16 description;
v8::Local<v8::Function> toLowerCase =
v8::debug::GetBuiltin(isolate, v8::debug::kStringToLowerCase);
if (nodeName->IsString()) {
if (!toLowerCase->Call(context, nodeName, 0, nullptr).ToLocal(&nodeName))
return String16();
if (nodeName->IsString()) {
description = toProtocolString(isolate, nodeName.As<v8::String>());
}
}
if (!description.length()) {
v8::Local<v8::Value> constructor;
if (!object->Get(context, toV8String(isolate, "constructor"))
.ToLocal(&constructor) ||
!constructor->IsObject()) {
return String16();
}
if (!value.As<v8::Object>()
->Get(context, toV8String(isolate, "name"))
.ToLocal(&value) ||
!value->IsString()) {
return String16();
}
description = toProtocolString(isolate, value.As<v8::String>());
}
v8::Local<v8::Value> nodeType;
if (!object->Get(context, toV8String(isolate, "nodeType"))
.ToLocal(&nodeType) ||
!nodeType->IsInt32()) {
return description;
}
if (nodeType.As<v8::Int32>()->Value() == 1) {
v8::Local<v8::Value> idValue;
if (!object->Get(context, toV8String(isolate, "id")).ToLocal(&idValue)) {
return description;
}
if (idValue->IsString()) {
String16 id = toProtocolString(isolate, idValue.As<v8::String>());
if (id.length()) {
description = String16::concat(description, '#', id);
}
}
v8::Local<v8::Value> classNameValue;
if (!object->Get(context, toV8String(isolate, "className"))
.ToLocal(&classNameValue)) {
return description;
}
if (classNameValue->IsString() &&
classNameValue.As<v8::String>()->Length()) {
String16 classes =
toProtocolString(isolate, classNameValue.As<v8::String>());
String16Builder output;
bool previousIsDot = false;
for (size_t i = 0; i < classes.length(); ++i) {
if (classes[i] == ' ') {
if (!previousIsDot) {
output.append('.');
previousIsDot = true;
}
} else {
output.append(classes[i]);
previousIsDot = classes[i] == '.';
}
}
description = String16::concat(description, '.', output.toString());
}
} else if (nodeType.As<v8::Int32>()->Value() == 1) {
return String16::concat("<!DOCTYPE ", description, '>');
}
return description;
}
std::unique_ptr<ValueMirror> clientMirror(v8::Local<v8::Context> context, std::unique_ptr<ValueMirror> clientMirror(v8::Local<v8::Context> context,
v8::Local<v8::Value> value, v8::Local<v8::Value> value,
const String16& subtype) { const String16& subtype) {
// TODO(alph): description and length retrieval should move to embedder.
auto descriptionForValueSubtype = auto descriptionForValueSubtype =
clientFor(context)->descriptionForValueSubtype(context, value); clientFor(context)->descriptionForValueSubtype(context, value);
if (descriptionForValueSubtype) { if (descriptionForValueSubtype) {
return std::make_unique<ObjectMirror>( return std::make_unique<ObjectMirror>(
value, subtype, toString16(descriptionForValueSubtype->string())); value, subtype, toString16(descriptionForValueSubtype->string()));
} }
if (subtype == "node") {
return std::make_unique<ObjectMirror>(value, subtype,
descriptionForNode(context, value));
}
if (subtype == "error") { if (subtype == "error") {
return std::make_unique<ObjectMirror>( return std::make_unique<ObjectMirror>(
value, RemoteObject::SubtypeEnum::Error, value, RemoteObject::SubtypeEnum::Error,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment