Commit 9c48a1c1 authored by Ankit Kumar's avatar Ankit Kumar Committed by Commit Bot

Add contents of popup note associated with a highlight in PDF accessibility tree

This CL adds the note text data associated with a highlight to the
accessibility tree. The CL makes the content of the note text accessible
to users via screen readers.

Tests have been modified to validate the addition of note text data to
the accessibility tree.

Bug: 1008775
Change-Id: I086d039b9296d0b8ac1b13926835375a7943f8c9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2208832Reviewed-by: default avatarKevin Babbitt <kbabbitt@microsoft.com>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Commit-Queue: Ankit Kumar 🌪️ <ankk@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#779008}
parent 7ce70f8a
......@@ -4,6 +4,7 @@
++++++[paragraph]
++++++++[push button] name='Hello'
++++++++++[static] name='Hello'
++++++++++[comment] name='Text Note'
++++++++[static] name=', nice '
++++++++[push button] name='meeting'
++++++++++[static] name='meeting'
......
......@@ -5,6 +5,7 @@ embeddedObject
++++++++pdfActionableHighlight name='Hello' roleDescription='Highlight' restriction=readOnly
++++++++++staticText name='Hello' restriction=readOnly
++++++++++++inlineTextBox name='Hello' restriction=readOnly
++++++++++note name='Text Note' roleDescription='Note' restriction=readOnly
++++++++staticText name=', nice ' restriction=readOnly
++++++++++inlineTextBox name=', nice ' restriction=readOnly
++++++++pdfActionableHighlight name='meeting' roleDescription='Highlight' restriction=readOnly
......
......@@ -4,6 +4,7 @@ AXGroup AXDescription='PDF document containing 1 page'
++++++AXGroup
++++++++AXButton AXDescription='Hello'
++++++++++AXStaticText AXValue='Hello'
++++++++++AXGroup AXDescription='Text Note'
++++++++AXStaticText AXValue=', nice '
++++++++AXButton AXDescription='meeting'
++++++++++AXStaticText AXValue='meeting'
......
......@@ -4,6 +4,7 @@ Pane
++++++Group IsControlElement=false
++++++++Custom Name='Hello'
++++++++++Text Name='Hello' IsControlElement=false
++++++++++Group Name='Text Note'
++++++++Text Name=', nice '
++++++++Custom Name='meeting'
++++++++++Text Name='meeting' IsControlElement=false
......
......@@ -4,6 +4,7 @@ IA2_ROLE_SECTION UNAVAILABLE FOCUSABLE
++++++IA2_ROLE_PARAGRAPH READONLY
++++++++ROLE_SYSTEM_PUSHBUTTON name='Hello' READONLY
++++++++++ROLE_SYSTEM_STATICTEXT name='Hello' READONLY
++++++++++IA2_ROLE_NOTE name='Text Note' READONLY
++++++++ROLE_SYSTEM_STATICTEXT name=', nice ' READONLY
++++++++ROLE_SYSTEM_PUSHBUTTON name='meeting' READONLY
++++++++++ROLE_SYSTEM_STATICTEXT name='meeting' READONLY
......
......@@ -20,7 +20,7 @@ endobj
>>
>>
/Contents 5 0 R
/Annots [6 0 R 7 0 R 8 0 R]
/Annots [6 0 R 7 0 R 8 0 R 9 0 R]
>>
endobj
{{object 4 0}} <<
......@@ -43,6 +43,8 @@ endobj
{{object 6 0}} <<
/Type /Annot
/Subtype /Highlight
/Popup 9 0 R
/Contents (Text Note)
/QuadPoints [0 55 36 59 0 36 36 36]
/Rect [0 36 36 55]
/P 3 0 R
......@@ -64,6 +66,13 @@ endobj
/P 3 0 R
>>
endobj
{{object 9 0}} <<
/Type /Annot
/Subtype /Popup
/Parent 6 0 R
/Rect [140 36 149 55]
>>
endobj
{{xref}}
{{trailer}}
{{startxref}}
......
This diff was suppressed by a .gitattributes entry.
......@@ -649,6 +649,23 @@ class PdfAccessibilityTreeBuilder {
return highlight_node;
}
ui::AXNodeData* CreatePopupNoteNode(
const ppapi::PdfAccessibilityHighlightInfo& highlight) {
ui::AXNodeData* popup_note_node =
CreateNode(ax::mojom::Role::kNote, ax::mojom::Restriction::kReadOnly,
render_accessibility_, nodes_);
popup_note_node->AddStringAttribute(
ax::mojom::StringAttribute::kRoleDescription,
l10n_util::GetStringUTF8(IDS_AX_ROLE_DESCRIPTION_PDF_POPUP_NOTE));
popup_note_node->AddStringAttribute(ax::mojom::StringAttribute::kName,
highlight.note_text);
popup_note_node->relative_bounds.bounds =
PpFloatRectToGfxRectF(highlight.bounds);
return popup_note_node;
}
ui::AXNodeData* CreateTextFieldNode(
const ppapi::PdfAccessibilityTextFieldInfo& text_field) {
ax::mojom::Restriction restriction = text_field.is_read_only
......@@ -811,6 +828,11 @@ class PdfAccessibilityTreeBuilder {
AddTextToObjectNode(highlight.text_run_index, highlight.text_run_count,
highlight_node, para_node, previous_on_line_node,
text_run_index);
if (!highlight.note_text.empty()) {
ui::AXNodeData* popup_note_node = CreatePopupNoteNode(highlight);
highlight_node->child_ids.push_back(popup_note_node->id);
}
}
void AddTextFieldToParaNode(
......
......@@ -448,6 +448,7 @@ TEST_F(PdfAccessibilityTreeTest, TestHighlightCreation) {
chrome_pdf::features::kAccessiblePDFHighlight);
constexpr uint32_t kHighlightWhiteColor = MakeARGB(255, 255, 255, 255);
const char kPopupNoteText[] = "Text Note";
text_runs_.emplace_back(kFirstTextRun);
text_runs_.emplace_back(kSecondTextRun);
......@@ -460,6 +461,7 @@ TEST_F(PdfAccessibilityTreeTest, TestHighlightCreation) {
highlight.text_run_index = 0;
highlight.text_run_count = 2;
highlight.color = kHighlightWhiteColor;
highlight.note_text = kPopupNoteText;
page_objects_.highlights.push_back(std::move(highlight));
}
......@@ -486,6 +488,7 @@ TEST_F(PdfAccessibilityTreeTest, TestHighlightCreation) {
* ++++ Paragraph
* ++++++ Highlight
* ++++++++ Static Text
* ++++++++ Note
*/
ui::AXNode* root_node = pdf_accessibility_tree.GetRoot();
......@@ -517,12 +520,23 @@ TEST_F(PdfAccessibilityTreeTest, TestHighlightCreation) {
EXPECT_EQ(kHighlightWhiteColor,
static_cast<uint32_t>(highlight_node->GetIntAttribute(
ax::mojom::IntAttribute::kBackgroundColor)));
ASSERT_EQ(1u, highlight_node->children().size());
ASSERT_EQ(2u, highlight_node->children().size());
ui::AXNode* static_text_node = highlight_node->children()[0];
ASSERT_TRUE(static_text_node);
EXPECT_EQ(ax::mojom::Role::kStaticText, static_text_node->data().role);
ASSERT_EQ(2u, static_text_node->children().size());
ui::AXNode* popup_note_node = highlight_node->children()[1];
ASSERT_TRUE(popup_note_node);
EXPECT_EQ(ax::mojom::Role::kNote, popup_note_node->data().role);
EXPECT_EQ(kPopupNoteText, popup_note_node->GetStringAttribute(
ax::mojom::StringAttribute::kName));
EXPECT_EQ(l10n_util::GetStringUTF8(IDS_AX_ROLE_DESCRIPTION_PDF_POPUP_NOTE),
popup_note_node->GetStringAttribute(
ax::mojom::StringAttribute::kRoleDescription));
EXPECT_EQ(gfx::RectF(1.0f, 1.0f, 5.0f, 6.0f),
popup_note_node->data().relative_bounds.bounds);
}
TEST_F(PdfAccessibilityTreeTest, TestTextFieldNodeCreation) {
......
......@@ -242,5 +242,8 @@
<message name="IDS_AX_ROLE_DESCRIPTION_PDF_HIGHLIGHT" desc="Accessibility role description for PDF highlight">
Highlight
</message>
<message name="IDS_AX_ROLE_DESCRIPTION_PDF_POPUP_NOTE" desc="Accessibility role description for popup note annotation associated with a PDF highlight">
Note
</message>
</if>
</grit-part>
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