Skip to content
Permalink
Browse files

Code refactor in PdfAccessibilityTree

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
Virender Singh Commit Bot
Virender Singh authored and Commit Bot committed Oct 15, 2019
1 parent 6983e9f commit 161c31a9f0c7c7df2fa41c6e40beb246942784ba
@@ -208,13 +208,9 @@ bool IsObjectInTextRun(const std::vector<T>& objects,

} // namespace

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

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

void PdfAccessibilityTree::SetAccessibilityViewportInfo(
const PP_PrivateAccessibilityViewportInfo& viewport_info) {
zoom_ = viewport_info.zoom;
CHECK_GT(zoom_, 0);
zoom_device_scale_factor_ = viewport_info.zoom_device_scale_factor;
CHECK_GT(zoom_device_scale_factor_, 0);
scroll_ = ToVector2dF(viewport_info.scroll);
scroll_.Scale(1.0 / zoom_);
scroll_.Scale(1.0 / zoom_device_scale_factor_);
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_char_index_ = viewport_info.selection_start_char_index;
@@ -830,7 +826,7 @@ content::RenderAccessibility* PdfAccessibilityTree::GetRenderAccessibility() {

gfx::Transform* PdfAccessibilityTree::MakeTransformFromViewInfo() {
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->Translate(offset_);
transform->Translate(-scroll_);
@@ -164,7 +164,7 @@ class PdfAccessibilityTree : public content::PluginAXTreeSource {
ui::AXTree tree_;
content::RendererPpapiHost* host_;
PP_Instance instance_;
double zoom_;
double zoom_device_scale_factor_ = 1.0;
gfx::Vector2dF scroll_;
gfx::Vector2dF offset_;
uint32_t selection_start_page_index_ = 0;
@@ -157,7 +157,7 @@ class PdfAccessibilityTreeTest : public content::RenderViewTest {
ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath(
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_.offset = {0, 0};
viewport_info_.selection_start_page_index = 0;
@@ -995,7 +995,7 @@ void OutOfProcessInstance::SendAccessibilityViewportInfo() {
viewport_info.scroll.y =
-top_toolbar_height_in_viewport_coords_ * device_scale_;
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,
&viewport_info.selection_start_char_index,
@@ -34,7 +34,7 @@ struct PP_PrivateFindResult {
};

struct PP_PrivateAccessibilityViewportInfo {
double zoom;
double zoom_device_scale_factor;
struct PP_Point scroll;
struct PP_Point offset;
uint32_t selection_start_page_index;
@@ -255,7 +255,7 @@ IPC_STRUCT_TRAITS_BEGIN(PP_PdfPrintSettings_Dev)
IPC_STRUCT_TRAITS_END()

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(offset)
IPC_STRUCT_TRAITS_MEMBER(selection_start_page_index)

0 comments on commit 161c31a

Please sign in to comment.
You can’t perform that action at this time.