#include "services/screen_ai/proto/visual_annotator_proto_convertor.h"
#include <stdint.h>
#include <iterator>
#include <map>
#include <ranges>
#include <utility>
#include <vector>
#include "base/check_op.h"
#include "base/metrics/histogram_functions.h"
#include "base/notreached.h"
#include "base/numerics/safe_conversions.h"
#include "base/ranges/ranges.h"
#include "base/strings/utf_string_conversions.h"
#include "services/screen_ai/public/mojom/screen_ai_service.mojom.h"
#include "services/strings/grit/services_strings.h"
#include "ui/accessibility/accessibility_features.h"
#include "ui/accessibility/ax_enums.mojom.h"
#include "ui/accessibility/ax_node.h"
#include "ui/accessibility/ax_node_data.h"
#include "ui/accessibility/ax_role_properties.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/rect_f.h"
#include "ui/gfx/geometry/transform.h"
ranges;
namespace {
constexpr int kFirstValidNegativeId = …;
ui::AXNodeID next_negative_node_id{ … };
ui::AXNodeID GetNextNegativeNodeID() { … }
gfx::RectF ToGfxRect(const chrome_screen_ai::Rect& rect) { … }
void UpdateBoundingBoxIfRotated(chrome_screen_ai::Rect* bounding_box) { … }
bool HaveIdenticalFormattingStyle(const chrome_screen_ai::WordBox& word_1,
const chrome_screen_ai::WordBox& word_2) { … }
void SerializeBoundingBox(const chrome_screen_ai::Rect& bounding_box,
const ui::AXNodeID& container_id,
ui::AXNodeData& out_data) { … }
void SerializeDirection(const chrome_screen_ai::Direction& direction,
ui::AXNodeData& out_data) { … }
void SerializeContentType(const chrome_screen_ai::ContentType& content_type,
ui::AXNodeData& out_data) { … }
void UpdateCharacterOffsets(const chrome_screen_ai::WordBox& word_box,
ui::AXNodeData& inline_text_box,
bool space_after_previous_word) { … }
void SerializeWordBox(const chrome_screen_ai::WordBox& word_box,
ui::AXNodeData& inline_text_box,
bool space_after_previous_word) { … }
size_t SerializeWordBoxes(const google::protobuf::RepeatedPtrField<
chrome_screen_ai::WordBox>& word_boxes,
const int start_from_word_index,
const size_t node_index,
ui::AXNodeData& static_text_node,
std::vector<ui::AXNodeData>& node_data) { … }
size_t SerializeLineBox(const chrome_screen_ai::LineBox& line_box,
const size_t index,
ui::AXNodeData& parent_node,
std::vector<ui::AXNodeData>& node_data) { … }
gfx::Rect ProtoToMojo(const chrome_screen_ai::Rect& source) { … }
screen_ai::mojom::Direction ProtoToMojo(chrome_screen_ai::Direction direction) { … }
}
namespace screen_ai {
void ResetNodeIDForTesting() { … }
ui::AXTreeUpdate VisualAnnotationToAXTreeUpdate(
chrome_screen_ai::VisualAnnotation& visual_annotation,
const gfx::Rect& image_rect) { … }
mojom::VisualAnnotationPtr ConvertProtoToVisualAnnotation(
const chrome_screen_ai::VisualAnnotation& annotation_proto) { … }
}