Skip to content

Commit

Permalink
[unseasoned-pdf] Add AccessibilityActionData
Browse files Browse the repository at this point in the history
Add AccessibilityActionData in pdf/ so that we can replace the usage of
PP_PdfAccessibilityActionData.

The CL only introduces the struct and doesn't use it within pdf/. The
struct will be used in future to replace usage of
PP_PdfAccessibilityActionData within pdf/.

Bug: 1144444
Change-Id: I5ff37feb996a1d7a9a3c9e5e9b5e62250d7852a6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2706381
Commit-Queue: Ankit Kumar 🌪️ <ankk@microsoft.com>
Reviewed-by: Daniel Hosseinian <dhoss@chromium.org>
Cr-Commit-Position: refs/heads/master@{#855849}
  • Loading branch information
ankk0294 authored and Chromium LUCI CQ committed Feb 19, 2021
1 parent 61b91e3 commit bbf4d4d
Show file tree
Hide file tree
Showing 3 changed files with 164 additions and 0 deletions.
29 changes: 29 additions & 0 deletions pdf/accessibility_structs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,33 @@ AccessibilityPageObjects::AccessibilityPageObjects(

AccessibilityPageObjects::~AccessibilityPageObjects() = default;

AccessibilityActionData::AccessibilityActionData() = default;

AccessibilityActionData::AccessibilityActionData(
AccessibilityAction action,
AccessibilityAnnotationType annotation_type,
const gfx::Point& target_point,
const gfx::Rect& target_rect,
uint32_t annotation_index,
uint32_t page_index,
AccessibilityScrollAlignment horizontal_scroll_alignment,
AccessibilityScrollAlignment vertical_scroll_alignment,
const PageCharacterIndex& selection_start_index,
const PageCharacterIndex& selection_end_index)
: action(action),
annotation_type(annotation_type),
target_point(target_point),
target_rect(target_rect),
annotation_index(annotation_index),
page_index(page_index),
horizontal_scroll_alignment(horizontal_scroll_alignment),
vertical_scroll_alignment(vertical_scroll_alignment),
selection_start_index(selection_start_index),
selection_end_index(selection_end_index) {}

AccessibilityActionData::AccessibilityActionData(
const AccessibilityActionData& other) = default;

AccessibilityActionData::~AccessibilityActionData() = default;

} // namespace chrome_pdf
100 changes: 100 additions & 0 deletions pdf/accessibility_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <string>
#include <vector>

#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/rect_f.h"

Expand Down Expand Up @@ -374,6 +375,105 @@ struct AccessibilityViewportInfo {
AccessibilityFocusInfo focus_info;
};

// TODO(crbug.com/702993): Remove next line comment after PDF migrates away
// from Pepper.
// Explicitly set all enum values to match enum values in
// PP_PdfAccessibilityAction.
enum class AccessibilityAction {
// No action specified.
kNone = 0,
// Invoke the rect to scroll into the viewport.
kScrollToMakeVisible = 1,
// Invoke the default action on a node.
kDoDefaultAction = 2,
// Invoke the global point to scroll into the viewport.
kScrollToGlobalPoint = 3,
// Set the text selection.
kSetSelection = 4,
// Last enum value marker.
kMaxValue = kSetSelection,
};

// TODO(crbug.com/702993): Remove next line comment after PDF migrates away
// from Pepper.
// Explicitly set all enum values to match enum values in
// PP_PdfAccessibilityAnnotationType.
enum class AccessibilityAnnotationType {
// No annotation type defined.
kNone = 0,
// Link annotation.
kLink = 1,
// Last enum value marker.
kMaxValue = kLink,
};

enum class AccessibilityScrollAlignment {
// No scroll alignment specified.
kNone = 0,
// Scroll the point to the center of the viewport.
kCenter,
// Scroll the point to the top of the viewport.
kTop,
// Scroll the point to the bottom of the viewport.
kBottom,
// Scroll the point to the left of the viewport.
kLeft,
// Scroll the point to the right of the viewport.
kRight,
// Scroll the point to the closest edge of the viewport.
kClosestToEdge,
// Last enum value marker.
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 AccessibilityActionData {
AccessibilityActionData();
AccessibilityActionData(
AccessibilityAction action,
AccessibilityAnnotationType annotation_type,
const gfx::Point& target_point,
const gfx::Rect& target_rect,
uint32_t annotation_index,
uint32_t page_index,
AccessibilityScrollAlignment horizontal_scroll_alignment,
AccessibilityScrollAlignment vertical_scroll_alignment,
const PageCharacterIndex& selection_start_index,
const PageCharacterIndex& selection_end_index);
AccessibilityActionData(const AccessibilityActionData& other);
~AccessibilityActionData();

// Accessibility action type.
AccessibilityAction action = AccessibilityAction::kNone;
// Annotation type on which the action is to be performed.
AccessibilityAnnotationType annotation_type =
AccessibilityAnnotationType::kNone;
// Target point on which the action is to be performed.
gfx::Point target_point;
// Target rect on which the action is to be performed.
gfx::Rect target_rect;
// Index of annotation in page.
uint32_t annotation_index = 0;
// Page index on which the link is present.
uint32_t page_index = 0;
// Horizontal scroll alignment with respect to the viewport
AccessibilityScrollAlignment horizontal_scroll_alignment =
AccessibilityScrollAlignment::kNone;
// Vertical scroll alignment with respect to the viewport
AccessibilityScrollAlignment vertical_scroll_alignment =
AccessibilityScrollAlignment::kNone;
// Page and character index of start of selection.
PageCharacterIndex selection_start_index;
// Page and character index of exclusive end of selection.
PageCharacterIndex selection_end_index;
};

} // namespace chrome_pdf

#endif // PDF_ACCESSIBILITY_STRUCTS_H_
35 changes: 35 additions & 0 deletions pdf/pdfium/pdfium_assert_matching_enums.cc
Original file line number Diff line number Diff line change
Expand Up @@ -359,3 +359,38 @@ STATIC_ASSERT_ENUM(chrome_pdf::FocusObjectType::kTextField,
PP_PRIVATEFOCUSOBJECT_TEXT_FIELD);
STATIC_ASSERT_ENUM(chrome_pdf::FocusObjectType::kMaxValue,
PP_PRIVATEFOCUSOBJECT_LAST);

STATIC_ASSERT_ENUM(chrome_pdf::AccessibilityAction::kNone, PP_PDF_ACTION_NONE);
STATIC_ASSERT_ENUM(chrome_pdf::AccessibilityAction::kScrollToMakeVisible,
PP_PDF_SCROLL_TO_MAKE_VISIBLE);
STATIC_ASSERT_ENUM(chrome_pdf::AccessibilityAction::kDoDefaultAction,
PP_PDF_DO_DEFAULT_ACTION);
STATIC_ASSERT_ENUM(chrome_pdf::AccessibilityAction::kScrollToGlobalPoint,
PP_PDF_SCROLL_TO_GLOBAL_POINT);
STATIC_ASSERT_ENUM(chrome_pdf::AccessibilityAction::kSetSelection,
PP_PDF_SET_SELECTION);
STATIC_ASSERT_ENUM(chrome_pdf::AccessibilityAction::kMaxValue,
PP_PDF_ACCESSIBILITYACTION_LAST);

STATIC_ASSERT_ENUM(chrome_pdf::AccessibilityAnnotationType::kNone,
PP_PDF_TYPE_NONE);
STATIC_ASSERT_ENUM(chrome_pdf::AccessibilityAnnotationType::kLink, PP_PDF_LINK);
STATIC_ASSERT_ENUM(chrome_pdf::AccessibilityAnnotationType::kMaxValue,
PP_PDF_ACCESSIBILITY_ANNOTATIONTYPE_LAST);

STATIC_ASSERT_ENUM(chrome_pdf::AccessibilityScrollAlignment::kNone,
PP_PDF_SCROLL_NONE);
STATIC_ASSERT_ENUM(chrome_pdf::AccessibilityScrollAlignment::kCenter,
PP_PDF_SCROLL_ALIGNMENT_CENTER);
STATIC_ASSERT_ENUM(chrome_pdf::AccessibilityScrollAlignment::kTop,
PP_PDF_SCROLL_ALIGNMENT_TOP);
STATIC_ASSERT_ENUM(chrome_pdf::AccessibilityScrollAlignment::kBottom,
PP_PDF_SCROLL_ALIGNMENT_BOTTOM);
STATIC_ASSERT_ENUM(chrome_pdf::AccessibilityScrollAlignment::kLeft,
PP_PDF_SCROLL_ALIGNMENT_LEFT);
STATIC_ASSERT_ENUM(chrome_pdf::AccessibilityScrollAlignment::kRight,
PP_PDF_SCROLL_ALIGNMENT_RIGHT);
STATIC_ASSERT_ENUM(chrome_pdf::AccessibilityScrollAlignment::kClosestToEdge,
PP_PDF_SCROLL_ALIGNMENT_CLOSEST_EDGE);
STATIC_ASSERT_ENUM(chrome_pdf::AccessibilityScrollAlignment::kMaxValue,
PP_PDF_ACCESSIBILITYSCROLLALIGNMENT_LAST);

0 comments on commit bbf4d4d

Please sign in to comment.