#include "chrome/renderer/accessibility/ax_tree_distiller.h"
#include <memory>
#include <queue>
#include <utility>
#include <vector>
#include "base/containers/contains.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
#include "content/public/renderer/render_frame.h"
#include "content/public/renderer/render_thread.h"
#include "services/metrics/public/cpp/mojo_ukm_recorder.h"
#include "services/metrics/public/cpp/ukm_builders.h"
#include "third_party/blink/public/platform/browser_interface_broker_proxy.h"
#include "ui/accessibility/accessibility_features.h"
#include "ui/accessibility/ax_computed_node_data.h"
#include "ui/accessibility/ax_enums.mojom-shared.h"
#include "ui/accessibility/ax_node.h"
#include "ui/accessibility/ax_serializable_tree.h"
#include "ui/accessibility/ax_tree.h"
namespace {
static const ax::mojom::Role kContentRoles[]{ … };
static const ax::mojom::Role kRolesToSkip[]{ … };
void GetContentRootNodes(const ui::AXTree& tree,
std::vector<const ui::AXNode*>* content_root_nodes) { … }
void AddContentNodesToVector(const ui::AXNode* node,
std::vector<ui::AXNodeID>* content_node_ids) { … }
}
AXTreeDistiller::AXTreeDistiller(
content::RenderFrame* render_frame,
OnAXTreeDistilledCallback on_ax_tree_distilled_callback)
: … { … }
AXTreeDistiller::~AXTreeDistiller() = default;
void AXTreeDistiller::Distill(const ui::AXTree& tree,
const ui::AXTreeUpdate& snapshot,
const ukm::SourceId ukm_source_id) { … }
void AXTreeDistiller::DistillViaAlgorithm(
const ui::AXTree& tree,
const ukm::SourceId ukm_source_id,
std::vector<ui::AXNodeID>* content_node_ids) { … }
void AXTreeDistiller::RecordRulesMetrics(ukm::SourceId ukm_source_id,
base::TimeDelta elapsed_time,
bool success) { … }
void AXTreeDistiller::DistillViaScreen2x(
const ui::AXTree& tree,
const ui::AXTreeUpdate& snapshot,
const ukm::SourceId ukm_source_id,
base::TimeTicks start_time,
std::vector<ui::AXNodeID>* content_node_ids_algorithm) { … }
void AXTreeDistiller::ProcessScreen2xResult(
const ui::AXTreeID& tree_id,
const ukm::SourceId ukm_source_id,
base::TimeTicks start_time,
std::vector<ui::AXNodeID> content_node_ids_algorithm,
const std::vector<ui::AXNodeID>& content_node_ids_screen2x) { … }
void AXTreeDistiller::ScreenAIServiceReady() { … }
void AXTreeDistiller::OnMainContentExtractorDisconnected() { … }
void AXTreeDistiller::RecordMergedMetrics(ukm::SourceId ukm_source_id,
base::TimeDelta elapsed_time,
bool success) { … }