Commit e390bd6d authored by Ankit Kumar's avatar Ankit Kumar Committed by Commit Bot

Add contents of popup note associated with a highlight in PDF plugin

This CL populates the data of a popup note associated with a highlight.
The populated data is sent from plugin to mimehandler. The pepper
interfaces are already structured to pass along the popup note text
data. The CL also modifies the structures related to highlight in the
plugin layer to store the note text, which is then passed on to the
pepper layer while sending highlight related data.

Unit test has been modified to validate the popup note text value.

Bug: 1008775
Change-Id: I0e83b7d04d23922daa20ccd3e5c8e602c6ac5077
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2208318
Commit-Queue: Ankit Kumar 🌪️ <ankk@microsoft.com>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Reviewed-by: default avatarKevin Babbitt <kbabbitt@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#771323}
parent 49b7e4ba
......@@ -123,6 +123,7 @@ void GetAccessibilityHighlightInfo(
highlight_info.index_in_page = i;
highlight_info.bounds = std::move(cur_highlight_info.bounds);
highlight_info.color = cur_highlight_info.color;
highlight_info.note_text = std::move(cur_highlight_info.note_text);
if (!GetEnclosingTextRunRangeForCharRange(
text_runs, cur_highlight_info.start_char_index,
......
......@@ -288,6 +288,7 @@ class PDFEngine {
int char_count;
pp::FloatRect bounds;
uint32_t color;
std::string note_text;
};
struct AccessibilityTextFieldInfo {
......
......@@ -485,7 +485,7 @@ TEST_F(AccessibilityTest, GetAccessibilityHighlightInfo) {
constexpr uint32_t kHighlightNoColor = MakeARGB(0, 0, 0, 0);
static const pp::PDF::PrivateAccessibilityHighlightInfo
kExpectedHighlightInfo[] = {
{"", 0, 0, 1, {{5, 196}, {49, 26}}, kHighlightDefaultColor},
{"Text Note", 0, 0, 1, {{5, 196}, {49, 26}}, kHighlightDefaultColor},
{"", 1, 2, 1, {{110, 196}, {77, 26}}, kHighlightRedColor},
{"", 2, 3, 1, {{192, 196}, {13, 26}}, kHighlightNoColor}};
......@@ -520,6 +520,7 @@ TEST_F(AccessibilityTest, GetAccessibilityHighlightInfo) {
EXPECT_EQ(highlight_info.text_run_count,
kExpectedHighlightInfo[i].text_run_count);
EXPECT_EQ(highlight_info.color, kExpectedHighlightInfo[i].color);
EXPECT_EQ(highlight_info.note_text, kExpectedHighlightInfo[i].note_text);
}
}
......
......@@ -670,6 +670,7 @@ PDFiumPage::GetHighlightInfo() {
highlight.bounding_rect.x(), highlight.bounding_rect.y(),
highlight.bounding_rect.width(), highlight.bounding_rect.height());
cur_info.color = highlight.color;
cur_info.note_text = highlight.note_text;
highlight_info.push_back(std::move(cur_info));
}
return highlight_info;
......@@ -1216,6 +1217,14 @@ void PDFiumPage::PopulateHighlight(FPDF_ANNOTATION annot) {
highlight.color = MakeARGB(255, 255, 255, 0);
}
// Retrieve the contents of the popup note associated with highlight.
// See table 164 in ISO 32000-1 standard for more details around "Contents"
// key in a highlight annotation.
static constexpr char kContents[] = "Contents";
highlight.note_text = base::UTF16ToUTF8(CallPDFiumWideStringBufferApi(
base::BindRepeating(&FPDFAnnot_GetStringValue, annot, kContents),
/*check_expected_size=*/true));
highlights_.push_back(std::move(highlight));
}
......
......@@ -284,6 +284,9 @@ class PDFiumPage {
// Color of the highlight in ARGB. Alpha is stored in the first 8 MSBs. RGB
// follows after it with each using 8 bytes.
uint32_t color;
// Text of the popup note associated with highlight.
std::string note_text;
};
// Represents a text field within the page.
......
......@@ -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
......@@ -68,6 +70,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.
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