Index: chrome/browser/android/vr_shell/ui_scene.cc |
diff --git a/chrome/browser/android/vr_shell/ui_scene.cc b/chrome/browser/android/vr_shell/ui_scene.cc |
index fc46134aae41fea9882d1a4f3dbaea609191bd7b..828cdcd7bc77a1b123f63716dd19629ab2b3d4e5 100644 |
--- a/chrome/browser/android/vr_shell/ui_scene.cc |
+++ b/chrome/browser/android/vr_shell/ui_scene.cc |
@@ -347,6 +347,15 @@ ContentRectangle* UiScene::GetUiElementById(int element_id) { |
return nullptr; |
} |
+ContentRectangle* UiScene::GetUiElementByName(std::string element_name) { |
+ for (auto& element : ui_elements_) { |
+ if (element->name == element_name) { |
+ return element.get(); |
+ } |
+ } |
+ return nullptr; |
+} |
+ |
std::vector<const ContentRectangle*> UiScene::GetWorldElements() const { |
std::vector<const ContentRectangle*> elements; |
for (const auto& element : ui_elements_) { |
@@ -383,6 +392,75 @@ bool UiScene::GetWebVrRenderingEnabled() const { |
return webvr_rendering_enabled_; |
} |
+std::unique_ptr<base::DictionaryValue> UiScene::CreateUiElementInfo( |
+ std::string element_name) { |
+ auto result = base::MakeUnique<base::DictionaryValue>(); |
+ const ContentRectangle* element = GetUiElementByName(element_name); |
+ CHECK_NE(element, nullptr); |
+ |
+ result->SetBoolean("isVisible", element->IsVisible()); |
+ result->SetBoolean("isHitTestable", element->IsHitTestable()); |
+ result->SetInteger("id", element->id); |
+ result->SetInteger("parentId", element->parent_id); |
+ result->SetBoolean("lockToFov", element->lock_to_fov); |
+ result->SetDouble("opacity", element->opacity); |
+ result->SetDouble("computedOpacity", element->computed_opacity); |
+ result->SetBoolean("computedLockToFov", element->computed_lock_to_fov); |
+ result->SetInteger("xAnchoring", element->x_anchoring); |
+ result->SetInteger("yAnchoring", element->y_anchoring); |
+ result->SetInteger("fill", element->fill); |
+ result->SetInteger("gridlineCount", element->gridline_count); |
+ result->SetInteger("drawPhase", element->draw_phase); |
+ |
+ auto temp_dictionary = base::MakeUnique<base::DictionaryValue>(); |
+ temp_dictionary->SetInteger("x", element->copy_rect.x); |
+ temp_dictionary->SetInteger("y", element->copy_rect.y); |
+ temp_dictionary->SetInteger("width", element->copy_rect.width); |
+ temp_dictionary->SetInteger("height", element->copy_rect.height); |
+ result->Set("copyRect", std::move(temp_dictionary)); |
+ |
+ temp_dictionary = base::MakeUnique<base::DictionaryValue>(); |
+ temp_dictionary->SetDouble("x", element->size.x); |
+ temp_dictionary->SetDouble("y", element->size.y); |
+ temp_dictionary->SetDouble("z", element->size.z); |
+ result->Set("size", std::move(temp_dictionary)); |
+ |
+ temp_dictionary = base::MakeUnique<base::DictionaryValue>(); |
+ temp_dictionary->SetDouble("x", element->scale.x); |
+ temp_dictionary->SetDouble("y", element->scale.y); |
+ temp_dictionary->SetDouble("z", element->scale.z); |
+ result->Set("scale", std::move(temp_dictionary)); |
+ |
+ temp_dictionary = base::MakeUnique<base::DictionaryValue>(); |
+ temp_dictionary->SetDouble("x", element->rotation.x); |
+ temp_dictionary->SetDouble("y", element->rotation.y); |
+ temp_dictionary->SetDouble("z", element->rotation.z); |
+ temp_dictionary->SetDouble("angle", element->rotation.angle); |
+ result->Set("rotation", std::move(temp_dictionary)); |
+ |
+ temp_dictionary = base::MakeUnique<base::DictionaryValue>(); |
+ temp_dictionary->SetDouble("x", element->translation.x); |
+ temp_dictionary->SetDouble("y", element->translation.y); |
+ temp_dictionary->SetDouble("z", element->translation.z); |
+ result->Set("translation", std::move(temp_dictionary)); |
+ |
+ temp_dictionary = base::MakeUnique<base::DictionaryValue>(); |
+ temp_dictionary->SetDouble("r", element->edge_color.r); |
+ temp_dictionary->SetDouble("g", element->edge_color.g); |
+ temp_dictionary->SetDouble("b", element->edge_color.b); |
+ temp_dictionary->SetDouble("a", element->edge_color.a); |
+ result->Set("edgeColor", std::move(temp_dictionary)); |
+ |
+ temp_dictionary = base::MakeUnique<base::DictionaryValue>(); |
+ temp_dictionary->SetDouble("r", element->center_color.r); |
+ temp_dictionary->SetDouble("g", element->center_color.g); |
+ temp_dictionary->SetDouble("b", element->center_color.b); |
+ temp_dictionary->SetDouble("a", element->center_color.a); |
+ result->Set("centerColor", std::move(temp_dictionary)); |
+ |
+ return result; |
+} |
+ |
const std::vector<std::unique_ptr<ContentRectangle>>& UiScene::GetUiElements() |
const { |
return ui_elements_; |