Update AccessibilityViewportInfo to use Selection struct.
This CL does not change any behavior, just clean up. Bug: 387387738 Change-Id: I66b01b4d68fb5c88b41d4dd16cbf4c52cb35196e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6221302 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Ramin Halavati <rhalavati@chromium.org> Cr-Commit-Position: refs/heads/main@{#1414762}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
fbb93e42a6
commit
1e8ec3e2ef
@ -436,10 +436,7 @@ void PdfAccessibilityTree::DoSetAccessibilityViewportInfo(
|
|||||||
scroll_ = gfx::PointF(viewport_info.scroll).OffsetFromOrigin();
|
scroll_ = gfx::PointF(viewport_info.scroll).OffsetFromOrigin();
|
||||||
offset_ = gfx::PointF(viewport_info.offset).OffsetFromOrigin();
|
offset_ = gfx::PointF(viewport_info.offset).OffsetFromOrigin();
|
||||||
orientation_ = viewport_info.orientation;
|
orientation_ = viewport_info.orientation;
|
||||||
selection_start_page_index_ = viewport_info.selection_start_page_index;
|
selection_ = viewport_info.selection;
|
||||||
selection_start_char_index_ = viewport_info.selection_start_char_index;
|
|
||||||
selection_end_page_index_ = viewport_info.selection_end_page_index;
|
|
||||||
selection_end_char_index_ = viewport_info.selection_end_char_index;
|
|
||||||
|
|
||||||
auto obj = GetPluginContainerAXObject();
|
auto obj = GetPluginContainerAXObject();
|
||||||
if (obj && tree_.size() > 1) {
|
if (obj && tree_.size() > 1) {
|
||||||
@ -840,17 +837,17 @@ void PdfAccessibilityTree::UpdateAXTreeDataFromSelection() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tree_data_.sel_is_backward = false;
|
tree_data_.sel_is_backward = false;
|
||||||
if (selection_start_page_index_ > selection_end_page_index_) {
|
if (selection_.start.page_index > selection_.end.page_index) {
|
||||||
tree_data_.sel_is_backward = true;
|
tree_data_.sel_is_backward = true;
|
||||||
} else if (selection_start_page_index_ == selection_end_page_index_ &&
|
} else if (selection_.start.page_index == selection_.end.page_index &&
|
||||||
selection_start_char_index_ > selection_end_char_index_) {
|
selection_.start.char_index > selection_.end.char_index) {
|
||||||
tree_data_.sel_is_backward = true;
|
tree_data_.sel_is_backward = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
FindNodeOffset(selection_start_page_index_, selection_start_char_index_,
|
FindNodeOffset(selection_.start.page_index, selection_.start.char_index,
|
||||||
&tree_data_.sel_anchor_object_id,
|
&tree_data_.sel_anchor_object_id,
|
||||||
&tree_data_.sel_anchor_offset);
|
&tree_data_.sel_anchor_offset);
|
||||||
FindNodeOffset(selection_end_page_index_, selection_end_char_index_,
|
FindNodeOffset(selection_.end.page_index, selection_.end.char_index,
|
||||||
&tree_data_.sel_focus_object_id, &tree_data_.sel_focus_offset);
|
&tree_data_.sel_focus_object_id, &tree_data_.sel_focus_offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,10 +266,7 @@ class PdfAccessibilityTree : public ui::AXTreeSource<const ui::AXNode*,
|
|||||||
int32_t orientation_ = 0;
|
int32_t orientation_ = 0;
|
||||||
gfx::Vector2dF scroll_;
|
gfx::Vector2dF scroll_;
|
||||||
gfx::Vector2dF offset_;
|
gfx::Vector2dF offset_;
|
||||||
uint32_t selection_start_page_index_ = 0;
|
chrome_pdf::Selection selection_;
|
||||||
uint32_t selection_start_char_index_ = 0;
|
|
||||||
uint32_t selection_end_page_index_ = 0;
|
|
||||||
uint32_t selection_end_char_index_ = 0;
|
|
||||||
uint32_t page_count_ = 0;
|
uint32_t page_count_ = 0;
|
||||||
bool is_tagged_ = false;
|
bool is_tagged_ = false;
|
||||||
std::unique_ptr<ui::AXNodeData> doc_node_;
|
std::unique_ptr<ui::AXNodeData> doc_node_;
|
||||||
|
@ -360,10 +360,6 @@ class PdfAccessibilityTreeTest : public content::RenderViewTest {
|
|||||||
viewport_info_.scale = 1.0;
|
viewport_info_.scale = 1.0;
|
||||||
viewport_info_.scroll = gfx::Point(0, 0);
|
viewport_info_.scroll = gfx::Point(0, 0);
|
||||||
viewport_info_.offset = gfx::Point(0, 0);
|
viewport_info_.offset = gfx::Point(0, 0);
|
||||||
viewport_info_.selection_start_page_index = 0u;
|
|
||||||
viewport_info_.selection_start_char_index = 0u;
|
|
||||||
viewport_info_.selection_end_page_index = 0u;
|
|
||||||
viewport_info_.selection_end_char_index = 0u;
|
|
||||||
doc_info_.is_tagged = false;
|
doc_info_.is_tagged = false;
|
||||||
doc_info_.text_accessible = true;
|
doc_info_.text_accessible = true;
|
||||||
doc_info_.text_copyable = true;
|
doc_info_.text_copyable = true;
|
||||||
|
@ -17,6 +17,18 @@
|
|||||||
|
|
||||||
namespace chrome_pdf {
|
namespace chrome_pdf {
|
||||||
|
|
||||||
|
struct PageCharacterIndex {
|
||||||
|
// Index of PDF page.
|
||||||
|
uint32_t page_index = 0;
|
||||||
|
// Index of character within the PDF page.
|
||||||
|
uint32_t char_index = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Selection {
|
||||||
|
PageCharacterIndex start;
|
||||||
|
PageCharacterIndex end;
|
||||||
|
};
|
||||||
|
|
||||||
struct AccessibilityDocInfo {
|
struct AccessibilityDocInfo {
|
||||||
bool operator==(const AccessibilityDocInfo& other) const;
|
bool operator==(const AccessibilityDocInfo& other) const;
|
||||||
bool operator!=(const AccessibilityDocInfo& other) const;
|
bool operator!=(const AccessibilityDocInfo& other) const;
|
||||||
@ -381,10 +393,7 @@ struct AccessibilityViewportInfo {
|
|||||||
gfx::Point scroll;
|
gfx::Point scroll;
|
||||||
gfx::Point offset;
|
gfx::Point offset;
|
||||||
uint32_t orientation = 0;
|
uint32_t orientation = 0;
|
||||||
uint32_t selection_start_page_index = 0;
|
Selection selection;
|
||||||
uint32_t selection_start_char_index = 0;
|
|
||||||
uint32_t selection_end_page_index = 0;
|
|
||||||
uint32_t selection_end_char_index = 0;
|
|
||||||
AccessibilityFocusInfo focus_info;
|
AccessibilityFocusInfo focus_info;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -431,18 +440,6 @@ enum class AccessibilityScrollAlignment {
|
|||||||
kMaxValue = kClosestToEdge,
|
kMaxValue = kClosestToEdge,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PageCharacterIndex {
|
|
||||||
// Index of PDF page.
|
|
||||||
uint32_t page_index = 0;
|
|
||||||
// Index of character within the PDF page.
|
|
||||||
uint32_t char_index = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Selection {
|
|
||||||
PageCharacterIndex start;
|
|
||||||
PageCharacterIndex end;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct AccessibilityActionData {
|
struct AccessibilityActionData {
|
||||||
AccessibilityActionData();
|
AccessibilityActionData();
|
||||||
AccessibilityActionData(
|
AccessibilityActionData(
|
||||||
|
@ -2883,10 +2883,7 @@ void PdfViewWebPlugin::PrepareAndSetAccessibilityViewportInfo() {
|
|||||||
|
|
||||||
std::optional<Selection> selection = engine_->GetSelection();
|
std::optional<Selection> selection = engine_->GetSelection();
|
||||||
if (selection.has_value()) {
|
if (selection.has_value()) {
|
||||||
viewport_info.selection_start_page_index = selection->start.page_index;
|
viewport_info.selection = *selection;
|
||||||
viewport_info.selection_start_char_index = selection->start.char_index;
|
|
||||||
viewport_info.selection_end_page_index = selection->end.page_index;
|
|
||||||
viewport_info.selection_end_char_index = selection->end.char_index;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pdf_accessibility_data_handler_->SetAccessibilityViewportInfo(
|
pdf_accessibility_data_handler_->SetAccessibilityViewportInfo(
|
||||||
|
Reference in New Issue
Block a user