summaryrefslogtreecommitdiff
path: root/chromium/ppapi/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/ppapi/cpp')
-rw-r--r--chromium/ppapi/cpp/private/pdf.cc70
-rw-r--r--chromium/ppapi/cpp/private/pdf.h70
2 files changed, 136 insertions, 4 deletions
diff --git a/chromium/ppapi/cpp/private/pdf.cc b/chromium/ppapi/cpp/private/pdf.cc
index d91f54ecb55..ddfbde65f16 100644
--- a/chromium/ppapi/cpp/private/pdf.cc
+++ b/chromium/ppapi/cpp/private/pdf.cc
@@ -88,6 +88,48 @@ void ConvertPrivateAccessibilityTextFieldInfo(
info->bounds = text_field.bounds;
}
+void ConvertPrivateAccessibilityChoiceFieldInfo(
+ const PDF::PrivateAccessibilityChoiceFieldInfo& choice_field,
+ PP_PrivateAccessibilityChoiceFieldInfo* info,
+ std::vector<PP_PrivateAccessibilityChoiceFieldOptionInfo>* option_info) {
+ info->name = choice_field.name.c_str();
+ info->name_length = choice_field.name.size();
+
+ option_info->resize(choice_field.options.size());
+ info->options = option_info->data();
+ for (size_t i = 0; i < choice_field.options.size(); i++) {
+ info->options[i].name = choice_field.options[i].name.c_str();
+ info->options[i].name_length = choice_field.options[i].name.size();
+ info->options[i].is_selected = choice_field.options[i].is_selected;
+ info->options[i].bounds = choice_field.options[i].bounds;
+ }
+ info->options_length = choice_field.options.size();
+ info->type = choice_field.type;
+ info->is_read_only = choice_field.is_read_only;
+ info->is_multi_select = choice_field.is_multi_select;
+ info->has_editable_text_box = choice_field.has_editable_text_box;
+ info->index_in_page = choice_field.index_in_page;
+ info->text_run_index = choice_field.text_run_index;
+ info->bounds = choice_field.bounds;
+}
+
+void ConvertPrivateAccessibilityButtonInfo(
+ const PDF::PrivateAccessibilityButtonInfo& button,
+ PP_PrivateAccessibilityButtonInfo* info) {
+ info->name = button.name.c_str();
+ info->name_length = button.name.size();
+ info->value = button.value.c_str();
+ info->value_length = button.value.size();
+ info->type = button.type;
+ info->is_read_only = button.is_read_only;
+ info->is_checked = button.is_checked;
+ info->control_count = button.control_count;
+ info->control_index = button.control_index;
+ info->index_in_page = button.index_in_page;
+ info->text_run_index = button.text_run_index;
+ info->bounds = button.bounds;
+}
+
} // namespace
// static
@@ -299,7 +341,7 @@ void PDF::SetAccessibilityPageInfo(
}
const std::vector<PrivateAccessibilityTextFieldInfo>& text_fields =
- page_objects.text_fields;
+ page_objects.form_fields.text_fields;
std::vector<PP_PrivateAccessibilityTextFieldInfo> text_field_info(
text_fields.size());
for (size_t i = 0; i < text_fields.size(); ++i) {
@@ -307,6 +349,24 @@ void PDF::SetAccessibilityPageInfo(
&text_field_info[i]);
}
+ const std::vector<PrivateAccessibilityChoiceFieldInfo>& choice_fields =
+ page_objects.form_fields.choice_fields;
+ std::vector<PP_PrivateAccessibilityChoiceFieldInfo> choice_field_info(
+ choice_fields.size());
+ std::vector<std::vector<PP_PrivateAccessibilityChoiceFieldOptionInfo> >
+ choice_field_option_info(choice_fields.size());
+ for (size_t i = 0; i < choice_fields.size(); ++i) {
+ ConvertPrivateAccessibilityChoiceFieldInfo(choice_fields[i],
+ &choice_field_info[i],
+ &choice_field_option_info[i]);
+ }
+
+ const std::vector<PrivateAccessibilityButtonInfo>& buttons =
+ page_objects.form_fields.buttons;
+ std::vector<PP_PrivateAccessibilityButtonInfo> button_info(buttons.size());
+ for (size_t i = 0; i < buttons.size(); ++i)
+ ConvertPrivateAccessibilityButtonInfo(buttons[i], &button_info[i]);
+
PP_PrivateAccessibilityPageObjects pp_page_objects;
pp_page_objects.links = link_info.data();
pp_page_objects.link_count = link_info.size();
@@ -314,8 +374,12 @@ void PDF::SetAccessibilityPageInfo(
pp_page_objects.image_count = image_info.size();
pp_page_objects.highlights = highlight_info.data();
pp_page_objects.highlight_count = highlight_info.size();
- pp_page_objects.text_fields = text_field_info.data();
- pp_page_objects.text_field_count = text_field_info.size();
+ pp_page_objects.form_fields.text_fields = text_field_info.data();
+ pp_page_objects.form_fields.text_field_count = text_field_info.size();
+ pp_page_objects.form_fields.choice_fields = choice_field_info.data();
+ pp_page_objects.form_fields.choice_field_count = choice_field_info.size();
+ pp_page_objects.form_fields.buttons = button_info.data();
+ pp_page_objects.form_fields.button_count = button_info.size();
get_interface<PPB_PDF>()->SetAccessibilityPageInfo(
instance.pp_instance(), page_info, text_run_info.data(), chars.data(),
diff --git a/chromium/ppapi/cpp/private/pdf.h b/chromium/ppapi/cpp/private/pdf.h
index 03881cea825..0853430d828 100644
--- a/chromium/ppapi/cpp/private/pdf.h
+++ b/chromium/ppapi/cpp/private/pdf.h
@@ -98,13 +98,81 @@ class PDF {
FloatRect bounds;
};
+ // C++ version of PP_PrivateAccessibilityChoiceFieldOptionInfo.
+ // Needs to stay in sync with the C version.
+ struct PrivateAccessibilityChoiceFieldOptionInfo {
+ std::string name;
+ bool is_selected;
+ FloatRect bounds;
+ };
+
+ // C++ version of PP_PrivateAccessibilityChoiceFieldInfo.
+ // Needs to stay in sync with the C version.
+ struct PrivateAccessibilityChoiceFieldInfo {
+ std::string name;
+ std::vector<PrivateAccessibilityChoiceFieldOptionInfo> options;
+ PP_PrivateChoiceFieldType type;
+ // Represents if the choice field is non-editable.
+ bool is_read_only;
+ // Represents if the choice field is multi-selectable.
+ bool is_multi_select;
+ // Represents if the choice field includes an editable text box.
+ bool has_editable_text_box;
+ // Index of this choice field in the collection of choice fields in the
+ // page.
+ uint32_t index_in_page;
+ // We anchor the choice field to a text run index, this denotes the text run
+ // before which the choice field should be inserted in the accessibility
+ // tree.
+ uint32_t text_run_index;
+ FloatRect bounds;
+ };
+
+ // C++ version of PP_PrivateAccessibilityButtonInfo.
+ // Needs to stay in sync with the C version.
+ struct PrivateAccessibilityButtonInfo {
+ std::string name;
+ std::string value;
+ // Represents the button type.
+ PP_PrivateButtonType type;
+ // Represents if the button is non-editable.
+ bool is_read_only;
+ // Represents if the radio button or check box is checked or not.
+ bool is_checked;
+ // Represents count of controls in the control group. A group of interactive
+ // form annotations is collectively called a form control group. Here, an
+ // interactive form annotation, should be either a radio button or a
+ // checkbox. Value of |control_count| is >= 1.
+ uint32_t control_count;
+ // Represents index of the control in the control group. A group of
+ // interactive form annotations is collectively called a form control group.
+ // Here, an interactive form annotation, should be either a radio button or
+ // a checkbox. Value of |control_index| should always be less than
+ // |control_count|.
+ uint32_t control_index;
+ // Index of this button in the collection of buttons in the page.
+ uint32_t index_in_page;
+ // We anchor the button to a text run index, this denotes the text run
+ // before which the button should be inserted in the accessibility tree.
+ uint32_t text_run_index;
+ FloatRect bounds;
+ };
+
+ // C++ version of PP_PrivateAccessibilityFormFieldInfo.
+ // Needs to stay in sync with the C version.
+ struct PrivateAccessibilityFormFieldInfo {
+ std::vector<PrivateAccessibilityTextFieldInfo> text_fields;
+ std::vector<PrivateAccessibilityChoiceFieldInfo> choice_fields;
+ std::vector<PrivateAccessibilityButtonInfo> buttons;
+ };
+
// C++ version of PP_PrivateAccessibilityPageObjects.
// Needs to stay in sync with the C version.
struct PrivateAccessibilityPageObjects {
std::vector<PrivateAccessibilityLinkInfo> links;
std::vector<PrivateAccessibilityImageInfo> images;
std::vector<PrivateAccessibilityHighlightInfo> highlights;
- std::vector<PrivateAccessibilityTextFieldInfo> text_fields;
+ PrivateAccessibilityFormFieldInfo form_fields;
};
// Returns true if the required interface is available.