0

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: Lei Zhang <thestig@chromium.org>
Reviewed-by: Kevin Babbitt <kbabbitt@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#771323}
This commit is contained in:
Ankit Kumar
2020-05-22 09:13:33 +00:00
committed by Commit Bot
parent 49b7e4bad3
commit e390bd6d56
7 changed files with 45 additions and 11 deletions

@ -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}}

@ -21,7 +21,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
4 0 obj <<
@ -44,6 +44,8 @@ endobj
6 0 obj <<
/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
@ -69,21 +71,29 @@ endobj
/P 3 0 R
>>
endobj
9 0 obj <<
/Type /Annot
/Subtype /Popup
/Parent 6 0 R
/Rect [140 36 149 55]
>>
endobj
xref
0 9
0 10
0000000000 65535 f
0000000015 00000 n
0000000068 00000 n
0000000157 00000 n
0000000313 00000 n
0000000389 00000 n
0000000493 00000 n
0000000621 00000 n
0000000780 00000 n
0000000319 00000 n
0000000395 00000 n
0000000499 00000 n
0000000666 00000 n
0000000825 00000 n
0000000983 00000 n
trailer <<
/Root 1 0 R
/Size 9
/Size 10
>>
startxref
938
1077
%%EOF