Commit 1fa6852c authored by Ankit Kumar 🌪️'s avatar Ankit Kumar 🌪️ Committed by Commit Bot

Migrate all direct instances of pp::Size to gfx::Size

Update PDFEngine layer and below to use gfx::Size instead of pp::Size
in case of direct calls. Indirect calls like using pp::Size to create
pp::Rect are the only places where pp::Size is still present.

Bug: 1101101
Change-Id: Ica2a815ec1b85a3fb12cd0def5fa27cc3d042f1c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2324681
Commit-Queue: Ankit Kumar 🌪️ <ankk@microsoft.com>
Reviewed-by: default avatarK. Moon <kmoon@chromium.org>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#793097}
parent a0aee285
...@@ -737,10 +737,10 @@ void OutOfProcessInstance::GetPrintPresetOptionsFromDocument( ...@@ -737,10 +737,10 @@ void OutOfProcessInstance::GetPrintPresetOptionsFromDocument(
options->duplex = options->duplex =
static_cast<PP_PrivateDuplexMode_Dev>(engine_->GetDuplexType()); static_cast<PP_PrivateDuplexMode_Dev>(engine_->GetDuplexType());
options->copies = engine_->GetCopiesToPrint(); options->copies = engine_->GetCopiesToPrint();
pp::Size uniform_page_size; gfx::Size uniform_page_size;
options->is_page_size_uniform = options->is_page_size_uniform =
PP_FromBool(engine_->GetPageSizeAndUniformity(&uniform_page_size)); PP_FromBool(engine_->GetPageSizeAndUniformity(&uniform_page_size));
options->uniform_page_size = uniform_page_size; options->uniform_page_size = PPSizeFromSize(uniform_page_size);
} }
void OutOfProcessInstance::EnableAccessibility() { void OutOfProcessInstance::EnableAccessibility() {
...@@ -1994,7 +1994,7 @@ void OutOfProcessInstance::OnGeometryChanged(double old_zoom, ...@@ -1994,7 +1994,7 @@ void OutOfProcessInstance::OnGeometryChanged(double old_zoom,
CalculateBackgroundParts(); CalculateBackgroundParts();
engine_->PageOffsetUpdated(available_area_.point()); engine_->PageOffsetUpdated(available_area_.point());
engine_->PluginSizeUpdated(available_area_.size()); engine_->PluginSizeUpdated(SizeFromPPSize(available_area_.size()));
if (document_size_.IsEmpty()) if (document_size_.IsEmpty())
return; return;
......
...@@ -329,7 +329,7 @@ class PDFEngine { ...@@ -329,7 +329,7 @@ class PDFEngine {
// name, so not repeating the description here unless it's different. // name, so not repeating the description here unless it's different.
virtual bool New(const char* url, const char* headers) = 0; virtual bool New(const char* url, const char* headers) = 0;
virtual void PageOffsetUpdated(const pp::Point& page_offset) = 0; virtual void PageOffsetUpdated(const pp::Point& page_offset) = 0;
virtual void PluginSizeUpdated(const pp::Size& size) = 0; virtual void PluginSizeUpdated(const gfx::Size& size) = 0;
virtual void ScrolledToXPosition(int position) = 0; virtual void ScrolledToXPosition(int position) = 0;
virtual void ScrolledToYPosition(int position) = 0; virtual void ScrolledToYPosition(int position) = 0;
// Paint is called a series of times. Before these n calls are made, PrePaint // Paint is called a series of times. Before these n calls are made, PrePaint
...@@ -446,7 +446,7 @@ class PDFEngine { ...@@ -446,7 +446,7 @@ class PDFEngine {
// Returns the duplex setting. // Returns the duplex setting.
virtual int GetDuplexType() = 0; virtual int GetDuplexType() = 0;
// Returns true if all the pages are the same size. // Returns true if all the pages are the same size.
virtual bool GetPageSizeAndUniformity(pp::Size* size) = 0; virtual bool GetPageSizeAndUniformity(gfx::Size* size) = 0;
// Returns a VarArray of Bookmarks, each a VarDictionary containing the // Returns a VarArray of Bookmarks, each a VarDictionary containing the
// following key/values: // following key/values:
......
...@@ -503,7 +503,7 @@ void PDFiumEngine::PageOffsetUpdated(const pp::Point& page_offset) { ...@@ -503,7 +503,7 @@ void PDFiumEngine::PageOffsetUpdated(const pp::Point& page_offset) {
page_offset_ = page_offset; page_offset_ = page_offset;
} }
void PDFiumEngine::PluginSizeUpdated(const pp::Size& size) { void PDFiumEngine::PluginSizeUpdated(const gfx::Size& size) {
CancelPaints(); CancelPaints();
plugin_size_ = size; plugin_size_ = size;
...@@ -654,11 +654,11 @@ void PDFiumEngine::AppendPage(PDFEngine* engine, int index) { ...@@ -654,11 +654,11 @@ void PDFiumEngine::AppendPage(PDFEngine* engine, int index) {
// Unload and delete the blank page before appending. // Unload and delete the blank page before appending.
pages_[index]->Unload(); pages_[index]->Unload();
pages_[index]->set_calculated_links(false); pages_[index]->set_calculated_links(false);
pp::Size curr_page_size = GetPageSize(index); gfx::Size curr_page_size = GetPageSize(index);
FPDFPage_Delete(doc(), index); FPDFPage_Delete(doc(), index);
FPDF_ImportPages(doc(), static_cast<PDFiumEngine*>(engine)->doc(), "1", FPDF_ImportPages(doc(), static_cast<PDFiumEngine*>(engine)->doc(), "1",
index); index);
pp::Size new_page_size = GetPageSize(index); gfx::Size new_page_size = GetPageSize(index);
if (curr_page_size != new_page_size) { if (curr_page_size != new_page_size) {
DCHECK(document_loaded_); DCHECK(document_loaded_);
LoadPageInfo(); LoadPageInfo();
...@@ -2045,7 +2045,7 @@ void PDFiumEngine::InvalidateAllPages() { ...@@ -2045,7 +2045,7 @@ void PDFiumEngine::InvalidateAllPages() {
StopFind(); StopFind();
DCHECK(document_loaded_); DCHECK(document_loaded_);
RefreshCurrentDocumentLayout(); RefreshCurrentDocumentLayout();
client_->Invalidate(pp::Rect(plugin_size_)); client_->Invalidate(pp::Rect(PPSizeFromSize(plugin_size_)));
} }
std::string PDFiumEngine::GetSelectedText() { std::string PDFiumEngine::GetSelectedText() {
...@@ -2464,11 +2464,11 @@ int PDFiumEngine::GetDuplexType() { ...@@ -2464,11 +2464,11 @@ int PDFiumEngine::GetDuplexType() {
return static_cast<int>(FPDF_VIEWERREF_GetDuplex(doc())); return static_cast<int>(FPDF_VIEWERREF_GetDuplex(doc()));
} }
bool PDFiumEngine::GetPageSizeAndUniformity(pp::Size* size) { bool PDFiumEngine::GetPageSizeAndUniformity(gfx::Size* size) {
if (pages_.empty()) if (pages_.empty())
return false; return false;
pp::Size page_size = GetPageSize(0); gfx::Size page_size = GetPageSize(0);
for (size_t i = 1; i < pages_.size(); ++i) { for (size_t i = 1; i < pages_.size(); ++i) {
if (page_size != GetPageSize(i)) if (page_size != GetPageSize(i))
return false; return false;
...@@ -2498,7 +2498,7 @@ void PDFiumEngine::AppendBlankPages(size_t num_pages) { ...@@ -2498,7 +2498,7 @@ void PDFiumEngine::AppendBlankPages(size_t num_pages) {
} }
// Create blank pages with the same size as the first page. // Create blank pages with the same size as the first page.
pp::Size page_0_size = GetPageSize(0); gfx::Size page_0_size = GetPageSize(0);
double page_0_width_in_points = double page_0_width_in_points =
ConvertUnitDouble(page_0_size.width(), kPixelsPerInch, kPointsPerInch); ConvertUnitDouble(page_0_size.width(), kPixelsPerInch, kPointsPerInch);
double page_0_height_in_points = double page_0_height_in_points =
...@@ -2696,10 +2696,10 @@ std::vector<gfx::Size> PDFiumEngine::LoadPageSizes( ...@@ -2696,10 +2696,10 @@ std::vector<gfx::Size> PDFiumEngine::LoadPageSizes(
// TODO(crbug.com/1013800): It'd be better if page size were independent of // TODO(crbug.com/1013800): It'd be better if page size were independent of
// layout options, and handled in the layout code. // layout options, and handled in the layout code.
pp::Size size = page_available ? GetPageSizeForLayout(i, layout_options) gfx::Size size = page_available ? GetPageSizeForLayout(i, layout_options)
: default_page_size_; : default_page_size_;
EnlargePage(layout_options, i, new_page_count, &size); EnlargePage(layout_options, i, new_page_count, &size);
page_sizes.push_back(SizeFromPPSize(size)); page_sizes.push_back(size);
} }
// Add new pages. If |document_loaded_| == false, do not mark page as // Add new pages. If |document_loaded_| == false, do not mark page as
...@@ -2801,7 +2801,7 @@ void PDFiumEngine::CalculateVisiblePages() { ...@@ -2801,7 +2801,7 @@ void PDFiumEngine::CalculateVisiblePages() {
doc_loader_->ClearPendingRequests(); doc_loader_->ClearPendingRequests();
visible_pages_.clear(); visible_pages_.clear();
pp::Rect visible_rect(plugin_size_); pp::Rect visible_rect(PPSizeFromSize(plugin_size_));
for (int i = 0; i < static_cast<int>(pages_.size()); ++i) { for (int i = 0; i < static_cast<int>(pages_.size()); ++i) {
// Check an entire PageScreenRect, since we might need to repaint side // Check an entire PageScreenRect, since we might need to repaint side
// borders and shadows even if the page itself is not visible. // borders and shadows even if the page itself is not visible.
...@@ -2871,14 +2871,14 @@ bool PDFiumEngine::CheckPageAvailable(int index, std::vector<int>* pending) { ...@@ -2871,14 +2871,14 @@ bool PDFiumEngine::CheckPageAvailable(int index, std::vector<int>* pending) {
return true; return true;
} }
pp::Size PDFiumEngine::GetPageSize(int index) { gfx::Size PDFiumEngine::GetPageSize(int index) {
return GetPageSizeForLayout(index, layout_.options()); return GetPageSizeForLayout(index, layout_.options());
} }
pp::Size PDFiumEngine::GetPageSizeForLayout( gfx::Size PDFiumEngine::GetPageSizeForLayout(
int index, int index,
const DocumentLayout::Options& layout_options) { const DocumentLayout::Options& layout_options) {
pp::Size size; gfx::Size size;
double width_in_points = 0; double width_in_points = 0;
double height_in_points = 0; double height_in_points = 0;
int rv = FPDF_GetPageSizeByIndex(doc(), index, &width_in_points, int rv = FPDF_GetPageSizeByIndex(doc(), index, &width_in_points,
...@@ -2902,7 +2902,7 @@ pp::Size PDFiumEngine::GetPageSizeForLayout( ...@@ -2902,7 +2902,7 @@ pp::Size PDFiumEngine::GetPageSizeForLayout(
break; break;
} }
size = pp::Size(width_in_pixels, height_in_pixels); size = gfx::Size(width_in_pixels, height_in_pixels);
} }
return size; return size;
} }
...@@ -2925,7 +2925,7 @@ draw_utils::PageInsetSizes PDFiumEngine::GetInsetSizes( ...@@ -2925,7 +2925,7 @@ draw_utils::PageInsetSizes PDFiumEngine::GetInsetSizes(
void PDFiumEngine::EnlargePage(const DocumentLayout::Options& layout_options, void PDFiumEngine::EnlargePage(const DocumentLayout::Options& layout_options,
size_t page_index, size_t page_index,
size_t num_of_pages, size_t num_of_pages,
pp::Size* page_size) const { gfx::Size* page_size) const {
draw_utils::PageInsetSizes inset_sizes = draw_utils::PageInsetSizes inset_sizes =
GetInsetSizes(layout_options, page_index, num_of_pages); GetInsetSizes(layout_options, page_index, num_of_pages);
page_size->Enlarge(inset_sizes.left + inset_sizes.right, page_size->Enlarge(inset_sizes.left + inset_sizes.right,
...@@ -3521,8 +3521,8 @@ void PDFiumEngine::GetRegion(const pp::Point& location, ...@@ -3521,8 +3521,8 @@ void PDFiumEngine::GetRegion(const pp::Point& location,
pp::Point offset_location = location + page_offset_; pp::Point offset_location = location + page_offset_;
// TODO: update this when we support BIDI and scrollbars can be on the left. // TODO: update this when we support BIDI and scrollbars can be on the left.
if (!buffer || if (!buffer || !pp::Rect(page_offset_, PPSizeFromSize(plugin_size_))
!pp::Rect(page_offset_, plugin_size_).Contains(offset_location)) { .Contains(offset_location)) {
region = nullptr; region = nullptr;
return; return;
} }
......
...@@ -83,7 +83,7 @@ class PDFiumEngine : public PDFEngine, ...@@ -83,7 +83,7 @@ class PDFiumEngine : public PDFEngine,
// PDFEngine implementation. // PDFEngine implementation.
bool New(const char* url, const char* headers) override; bool New(const char* url, const char* headers) override;
void PageOffsetUpdated(const pp::Point& page_offset) override; void PageOffsetUpdated(const pp::Point& page_offset) override;
void PluginSizeUpdated(const pp::Size& size) override; void PluginSizeUpdated(const gfx::Size& size) override;
void ScrolledToXPosition(int position) override; void ScrolledToXPosition(int position) override;
void ScrolledToYPosition(int position) override; void ScrolledToYPosition(int position) override;
void PrePaint() override; void PrePaint() override;
...@@ -153,7 +153,7 @@ class PDFiumEngine : public PDFEngine, ...@@ -153,7 +153,7 @@ class PDFiumEngine : public PDFEngine,
bool GetPrintScaling() override; bool GetPrintScaling() override;
int GetCopiesToPrint() override; int GetCopiesToPrint() override;
int GetDuplexType() override; int GetDuplexType() override;
bool GetPageSizeAndUniformity(pp::Size* size) override; bool GetPageSizeAndUniformity(gfx::Size* size) override;
void AppendBlankPages(size_t num_pages) override; void AppendBlankPages(size_t num_pages) override;
void AppendPage(PDFEngine* engine, int index) override; void AppendPage(PDFEngine* engine, int index) override;
std::vector<uint8_t> GetSaveData() override; std::vector<uint8_t> GetSaveData() override;
...@@ -322,9 +322,9 @@ class PDFiumEngine : public PDFEngine, ...@@ -322,9 +322,9 @@ class PDFiumEngine : public PDFEngine,
// Helper function to get a given page's size in pixels. This is not part of // Helper function to get a given page's size in pixels. This is not part of
// PDFiumPage because we might not have that structure when we need this. // PDFiumPage because we might not have that structure when we need this.
pp::Size GetPageSize(int index); gfx::Size GetPageSize(int index);
pp::Size GetPageSizeForLayout(int index, gfx::Size GetPageSizeForLayout(int index,
const DocumentLayout::Options& layout_options); const DocumentLayout::Options& layout_options);
// Helper function for getting the inset sizes for the current layout. If // Helper function for getting the inset sizes for the current layout. If
// two-up view is enabled, the configuration of inset sizes depends on // two-up view is enabled, the configuration of inset sizes depends on
...@@ -341,7 +341,7 @@ class PDFiumEngine : public PDFEngine, ...@@ -341,7 +341,7 @@ class PDFiumEngine : public PDFEngine,
void EnlargePage(const DocumentLayout::Options& layout_options, void EnlargePage(const DocumentLayout::Options& layout_options,
size_t page_index, size_t page_index,
size_t num_of_pages, size_t num_of_pages,
pp::Size* page_size) const; gfx::Size* page_size) const;
// Similar to EnlargePage(), but insets a |rect|. Also multiplies the inset // Similar to EnlargePage(), but insets a |rect|. Also multiplies the inset
// sizes by |multiplier|, using the ceiling of the result. // sizes by |multiplier|, using the ceiling of the result.
...@@ -646,7 +646,7 @@ class PDFiumEngine : public PDFEngine, ...@@ -646,7 +646,7 @@ class PDFiumEngine : public PDFEngine,
// The offset of the page into the viewport. // The offset of the page into the viewport.
pp::Point page_offset_; pp::Point page_offset_;
// The plugin size in screen coordinates. // The plugin size in screen coordinates.
pp::Size plugin_size_; gfx::Size plugin_size_;
double current_zoom_ = 1.0; double current_zoom_ = 1.0;
std::unique_ptr<DocumentLoader> doc_loader_; // Main document's loader. std::unique_ptr<DocumentLoader> doc_loader_; // Main document's loader.
...@@ -728,7 +728,7 @@ class PDFiumEngine : public PDFEngine, ...@@ -728,7 +728,7 @@ class PDFiumEngine : public PDFEngine,
std::unique_ptr<PDFiumPermissions> permissions_; std::unique_ptr<PDFiumPermissions> permissions_;
pp::Size default_page_size_; gfx::Size default_page_size_;
// Timer for touch long press detection. // Timer for touch long press detection.
base::OneShotTimer touch_timer_; base::OneShotTimer touch_timer_;
......
...@@ -851,7 +851,7 @@ TEST_F(PDFiumEngineTabbingTest, MaintainViewportWhenFocusIsUpdated) { ...@@ -851,7 +851,7 @@ TEST_F(PDFiumEngineTabbingTest, MaintainViewportWhenFocusIsUpdated) {
&client, FILE_PATH_LITERAL("annotation_form_fields.pdf")); &client, FILE_PATH_LITERAL("annotation_form_fields.pdf"));
ASSERT_TRUE(engine); ASSERT_TRUE(engine);
ASSERT_EQ(2, engine->GetNumberOfPages()); ASSERT_EQ(2, engine->GetNumberOfPages());
engine->PluginSizeUpdated(pp::Size(60, 40)); engine->PluginSizeUpdated(gfx::Size(60, 40));
{ {
InSequence sequence; InSequence sequence;
...@@ -904,7 +904,7 @@ TEST_F(PDFiumEngineTabbingTest, ScrollFocusedAnnotationIntoView) { ...@@ -904,7 +904,7 @@ TEST_F(PDFiumEngineTabbingTest, ScrollFocusedAnnotationIntoView) {
&client, FILE_PATH_LITERAL("annotation_form_fields.pdf")); &client, FILE_PATH_LITERAL("annotation_form_fields.pdf"));
ASSERT_TRUE(engine); ASSERT_TRUE(engine);
ASSERT_EQ(2, engine->GetNumberOfPages()); ASSERT_EQ(2, engine->GetNumberOfPages());
engine->PluginSizeUpdated(pp::Size(60, 40)); engine->PluginSizeUpdated(gfx::Size(60, 40));
{ {
InSequence sequence; InSequence sequence;
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "ppapi/c/pp_point.h" #include "ppapi/c/pp_point.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
#include "third_party/pdfium/public/fpdf_annot.h" #include "third_party/pdfium/public/fpdf_annot.h"
#include "ui/gfx/geometry/size.h"
using testing::InSequence; using testing::InSequence;
...@@ -131,7 +132,7 @@ TEST_F(FormFillerTest, FormOnFocusChange) { ...@@ -131,7 +132,7 @@ TEST_F(FormFillerTest, FormOnFocusChange) {
&client, FILE_PATH_LITERAL("annotation_form_fields.pdf")); &client, FILE_PATH_LITERAL("annotation_form_fields.pdf"));
ASSERT_TRUE(engine); ASSERT_TRUE(engine);
ASSERT_EQ(2, engine->GetNumberOfPages()); ASSERT_EQ(2, engine->GetNumberOfPages());
engine->PluginSizeUpdated(pp::Size(60, 40)); engine->PluginSizeUpdated(gfx::Size(60, 40));
{ {
InSequence sequence; InSequence sequence;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment