Skip to content

Commit

Permalink
Code refactor in PdfAccessibilityTree
Browse files Browse the repository at this point in the history
This CL does code refactoring to make the intent of PdfAccessibilityTree
.zoom variable clear. It stores the product of pdf zoom and system dpi.
This change renames it to zoom_device_scale_factor.

This change also refactors the zoom variable name in
PP_PrivateAccessibilityViewportInfo to zoom_device_scale_factor.

Corresponding change is also made in OutOfProcessInstance to reflect
the variable name change.

Bug: 1007169
Change-Id: I0a9c22f386fb4859afc80d9f281f41a15935bb09
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1823337
Reviewed-by: Jochen Eisinger <jochen@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Ian Prest <iapres@microsoft.com>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Virender Singh <virens@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#705947}
  • Loading branch information
virenms authored and Commit Bot committed Oct 15, 2019
1 parent 6983e9f commit 161c31a
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 17 deletions.
20 changes: 8 additions & 12 deletions components/pdf/renderer/pdf_accessibility_tree.cc
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -208,13 +208,9 @@ bool IsObjectInTextRun(const std::vector<T>& objects,


} // namespace } // namespace


PdfAccessibilityTree::PdfAccessibilityTree( PdfAccessibilityTree::PdfAccessibilityTree(content::RendererPpapiHost* host,
content::RendererPpapiHost* host, PP_Instance instance)
PP_Instance instance) : host_(host), instance_(instance) {}
: host_(host),
instance_(instance),
zoom_(1.0) {
}


PdfAccessibilityTree::~PdfAccessibilityTree() { PdfAccessibilityTree::~PdfAccessibilityTree() {
content::RenderAccessibility* render_accessibility = GetRenderAccessibility(); content::RenderAccessibility* render_accessibility = GetRenderAccessibility();
Expand Down Expand Up @@ -265,12 +261,12 @@ bool PdfAccessibilityTree::IsDataFromPluginValid(


void PdfAccessibilityTree::SetAccessibilityViewportInfo( void PdfAccessibilityTree::SetAccessibilityViewportInfo(
const PP_PrivateAccessibilityViewportInfo& viewport_info) { const PP_PrivateAccessibilityViewportInfo& viewport_info) {
zoom_ = viewport_info.zoom; zoom_device_scale_factor_ = viewport_info.zoom_device_scale_factor;
CHECK_GT(zoom_, 0); CHECK_GT(zoom_device_scale_factor_, 0);
scroll_ = ToVector2dF(viewport_info.scroll); scroll_ = ToVector2dF(viewport_info.scroll);
scroll_.Scale(1.0 / zoom_); scroll_.Scale(1.0 / zoom_device_scale_factor_);
offset_ = ToVector2dF(viewport_info.offset); offset_ = ToVector2dF(viewport_info.offset);
offset_.Scale(1.0 / zoom_); offset_.Scale(1.0 / zoom_device_scale_factor_);


selection_start_page_index_ = viewport_info.selection_start_page_index; selection_start_page_index_ = viewport_info.selection_start_page_index;
selection_start_char_index_ = viewport_info.selection_start_char_index; selection_start_char_index_ = viewport_info.selection_start_char_index;
Expand Down Expand Up @@ -830,7 +826,7 @@ content::RenderAccessibility* PdfAccessibilityTree::GetRenderAccessibility() {


gfx::Transform* PdfAccessibilityTree::MakeTransformFromViewInfo() { gfx::Transform* PdfAccessibilityTree::MakeTransformFromViewInfo() {
gfx::Transform* transform = new gfx::Transform(); gfx::Transform* transform = new gfx::Transform();
float scale_factor = zoom_ / GetDeviceScaleFactor(); float scale_factor = zoom_device_scale_factor_ / GetDeviceScaleFactor();
transform->Scale(scale_factor, scale_factor); transform->Scale(scale_factor, scale_factor);
transform->Translate(offset_); transform->Translate(offset_);
transform->Translate(-scroll_); transform->Translate(-scroll_);
Expand Down
2 changes: 1 addition & 1 deletion components/pdf/renderer/pdf_accessibility_tree.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ class PdfAccessibilityTree : public content::PluginAXTreeSource {
ui::AXTree tree_; ui::AXTree tree_;
content::RendererPpapiHost* host_; content::RendererPpapiHost* host_;
PP_Instance instance_; PP_Instance instance_;
double zoom_; double zoom_device_scale_factor_ = 1.0;
gfx::Vector2dF scroll_; gfx::Vector2dF scroll_;
gfx::Vector2dF offset_; gfx::Vector2dF offset_;
uint32_t selection_start_page_index_ = 0; uint32_t selection_start_page_index_ = 0;
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class PdfAccessibilityTreeTest : public content::RenderViewTest {
ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath( ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath(
pak_file, ui::SCALE_FACTOR_NONE); pak_file, ui::SCALE_FACTOR_NONE);


viewport_info_.zoom = 1.0; viewport_info_.zoom_device_scale_factor = 1.0;
viewport_info_.scroll = {0, 0}; viewport_info_.scroll = {0, 0};
viewport_info_.offset = {0, 0}; viewport_info_.offset = {0, 0};
viewport_info_.selection_start_page_index = 0; viewport_info_.selection_start_page_index = 0;
Expand Down
2 changes: 1 addition & 1 deletion pdf/out_of_process_instance.cc
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -995,7 +995,7 @@ void OutOfProcessInstance::SendAccessibilityViewportInfo() {
viewport_info.scroll.y = viewport_info.scroll.y =
-top_toolbar_height_in_viewport_coords_ * device_scale_; -top_toolbar_height_in_viewport_coords_ * device_scale_;
viewport_info.offset = available_area_.point(); viewport_info.offset = available_area_.point();
viewport_info.zoom = zoom_ * device_scale_; viewport_info.zoom_device_scale_factor = zoom_ * device_scale_;


engine_->GetSelection(&viewport_info.selection_start_page_index, engine_->GetSelection(&viewport_info.selection_start_page_index,
&viewport_info.selection_start_char_index, &viewport_info.selection_start_char_index,
Expand Down
2 changes: 1 addition & 1 deletion ppapi/c/private/ppb_pdf.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct PP_PrivateFindResult {
}; };


struct PP_PrivateAccessibilityViewportInfo { struct PP_PrivateAccessibilityViewportInfo {
double zoom; double zoom_device_scale_factor;
struct PP_Point scroll; struct PP_Point scroll;
struct PP_Point offset; struct PP_Point offset;
uint32_t selection_start_page_index; uint32_t selection_start_page_index;
Expand Down
2 changes: 1 addition & 1 deletion ppapi/proxy/ppapi_messages.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ IPC_STRUCT_TRAITS_BEGIN(PP_PdfPrintSettings_Dev)
IPC_STRUCT_TRAITS_END() IPC_STRUCT_TRAITS_END()


IPC_STRUCT_TRAITS_BEGIN(PP_PrivateAccessibilityViewportInfo) IPC_STRUCT_TRAITS_BEGIN(PP_PrivateAccessibilityViewportInfo)
IPC_STRUCT_TRAITS_MEMBER(zoom) IPC_STRUCT_TRAITS_MEMBER(zoom_device_scale_factor)
IPC_STRUCT_TRAITS_MEMBER(scroll) IPC_STRUCT_TRAITS_MEMBER(scroll)
IPC_STRUCT_TRAITS_MEMBER(offset) IPC_STRUCT_TRAITS_MEMBER(offset)
IPC_STRUCT_TRAITS_MEMBER(selection_start_page_index) IPC_STRUCT_TRAITS_MEMBER(selection_start_page_index)
Expand Down

0 comments on commit 161c31a

Please sign in to comment.