Commit 56d27510 authored by Ankit Kumar 🌪️'s avatar Ankit Kumar 🌪️ Committed by Commit Bot

Migrate pp::Rect to gfx::Rect in PDFiumEngine

Update PDFiumEngine to use gfx::Rect instead of pp::Rect. Update
callers to expect gfx::Rect as return value instead of pp::Rect.

Noteworthy points:
- In pp::Rect, Subtract() is a utility methods which takes in two
rects and returns the subtracted rect. Whereas in gfx::Rect, Subtract()
is a member method which modifies the rect in-place. All usage of
Subtract() which are replaced in the CL modify the rect in-place.
- In pp::Rect, Intersect() is a utility method which takes in two
rects and returns the intersected rect. The counterpart in gfx::Rect
is IntersectRects() and not Intersect().

Bug: 1101101
Change-Id: Ib071e3a987c2c234b8e2348744700f9cf07edc96
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2379397Reviewed-by: default avatarK. Moon <kmoon@chromium.org>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Commit-Queue: Ankit Kumar 🌪️ <ankk@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#804462}
parent f2875ba4
...@@ -835,10 +835,10 @@ void OutOfProcessInstance::SendAccessibilityViewportInfo() { ...@@ -835,10 +835,10 @@ void OutOfProcessInstance::SendAccessibilityViewportInfo() {
pp::PDF::SetAccessibilityViewportInfo(GetPluginInstance(), &viewport_info); pp::PDF::SetAccessibilityViewportInfo(GetPluginInstance(), &viewport_info);
} }
void OutOfProcessInstance::SelectionChanged(const pp::Rect& left, void OutOfProcessInstance::SelectionChanged(const gfx::Rect& left,
const pp::Rect& right) { const gfx::Rect& right) {
pp::Point l(left.point().x() + available_area_.x(), left.point().y()); pp::Point l(left.x() + available_area_.x(), left.y());
pp::Point r(right.x() + available_area_.x(), right.point().y()); pp::Point r(right.x() + available_area_.x(), right.y());
float inverse_scale = 1.0f / device_scale_; float inverse_scale = 1.0f / device_scale_;
ScalePoint(inverse_scale, &l); ScalePoint(inverse_scale, &l);
...@@ -1033,16 +1033,18 @@ void OutOfProcessInstance::OnPaint(const std::vector<gfx::Rect>& paint_rects, ...@@ -1033,16 +1033,18 @@ void OutOfProcessInstance::OnPaint(const std::vector<gfx::Rect>& paint_rects,
if (!pdf_rect.IsEmpty()) { if (!pdf_rect.IsEmpty()) {
pdf_rect.Offset(available_area_.x() * -1, 0); pdf_rect.Offset(available_area_.x() * -1, 0);
std::vector<pp::Rect> pdf_ready; std::vector<gfx::Rect> pdf_ready;
std::vector<pp::Rect> pdf_pending; std::vector<gfx::Rect> pdf_pending;
engine()->Paint(pdf_rect, skia_image_data_, pdf_ready, pdf_pending); engine()->Paint(RectFromPPRect(pdf_rect), skia_image_data_, pdf_ready,
pdf_pending);
for (auto& ready_rect : pdf_ready) { for (auto& ready_rect : pdf_ready) {
ready_rect.Offset(available_area_.point()); ready_rect.Offset(VectorFromPPPoint(available_area_.point()));
ready->push_back(PaintReadyRect(ready_rect, image_data_)); ready->push_back(
PaintReadyRect(PPRectFromRect(ready_rect), image_data_));
} }
for (auto& pending_rect : pdf_pending) { for (auto& pending_rect : pdf_pending) {
pending_rect.Offset(available_area_.point()); pending_rect.Offset(VectorFromPPPoint(available_area_.point()));
pending->push_back(RectFromPPRect(pending_rect)); pending->push_back(pending_rect);
} }
} }
...@@ -1185,15 +1187,15 @@ void OutOfProcessInstance::ProposeDocumentLayout(const DocumentLayout& layout) { ...@@ -1185,15 +1187,15 @@ void OutOfProcessInstance::ProposeDocumentLayout(const DocumentLayout& layout) {
PostMessage(dimensions); PostMessage(dimensions);
} }
void OutOfProcessInstance::Invalidate(const pp::Rect& rect) { void OutOfProcessInstance::Invalidate(const gfx::Rect& rect) {
if (in_paint_) { if (in_paint_) {
deferred_invalidates_.push_back(rect); deferred_invalidates_.push_back(rect);
return; return;
} }
pp::Rect offset_rect(rect); gfx::Rect offset_rect(rect);
offset_rect.Offset(available_area_.point()); offset_rect.Offset(VectorFromPPPoint(available_area_.point()));
paint_manager_.InvalidateRect(RectFromPPRect(offset_rect)); paint_manager_.InvalidateRect(offset_rect);
} }
void OutOfProcessInstance::DidScroll(const gfx::Vector2d& offset) { void OutOfProcessInstance::DidScroll(const gfx::Vector2d& offset) {
...@@ -2324,7 +2326,7 @@ void OutOfProcessInstance::OnPrint(int32_t /*unused_but_required*/) { ...@@ -2324,7 +2326,7 @@ void OutOfProcessInstance::OnPrint(int32_t /*unused_but_required*/) {
void OutOfProcessInstance::InvalidateAfterPaintDone( void OutOfProcessInstance::InvalidateAfterPaintDone(
int32_t /*unused_but_required*/) { int32_t /*unused_but_required*/) {
DCHECK(!in_paint_); DCHECK(!in_paint_);
for (const pp::Rect& rect : deferred_invalidates_) for (const gfx::Rect& rect : deferred_invalidates_)
Invalidate(rect); Invalidate(rect);
deferred_invalidates_.clear(); deferred_invalidates_.clear();
} }
......
...@@ -111,7 +111,7 @@ class OutOfProcessInstance : public PdfViewPluginBase, ...@@ -111,7 +111,7 @@ class OutOfProcessInstance : public PdfViewPluginBase,
// PdfViewPluginBase implementation. // PdfViewPluginBase implementation.
void ProposeDocumentLayout(const DocumentLayout& layout) override; void ProposeDocumentLayout(const DocumentLayout& layout) override;
void Invalidate(const pp::Rect& rect) override; void Invalidate(const gfx::Rect& rect) override;
void DidScroll(const gfx::Vector2d& offset) override; void DidScroll(const gfx::Vector2d& offset) override;
void ScrollToX(int x_in_screen_coords) override; void ScrollToX(int x_in_screen_coords) override;
void ScrollToY(int y_in_screen_coords, bool compensate_for_toolbar) override; void ScrollToY(int y_in_screen_coords, bool compensate_for_toolbar) override;
...@@ -159,7 +159,7 @@ class OutOfProcessInstance : public PdfViewPluginBase, ...@@ -159,7 +159,7 @@ class OutOfProcessInstance : public PdfViewPluginBase,
bool IsPrintPreview() override; bool IsPrintPreview() override;
uint32_t GetBackgroundColor() override; uint32_t GetBackgroundColor() override;
void IsSelectingChanged(bool is_selecting) override; void IsSelectingChanged(bool is_selecting) override;
void SelectionChanged(const pp::Rect& left, const pp::Rect& right) override; void SelectionChanged(const gfx::Rect& left, const gfx::Rect& right) override;
void EnteredEditMode() override; void EnteredEditMode() override;
float GetToolbarHeightInScreenCoords() override; float GetToolbarHeightInScreenCoords() override;
void DocumentFocusChanged(bool document_has_focus) override; void DocumentFocusChanged(bool document_has_focus) override;
...@@ -393,7 +393,7 @@ class OutOfProcessInstance : public PdfViewPluginBase, ...@@ -393,7 +393,7 @@ class OutOfProcessInstance : public PdfViewPluginBase,
// Whether OnPaint() is in progress or not. // Whether OnPaint() is in progress or not.
bool in_paint_ = false; bool in_paint_ = false;
// Deferred invalidates while |in_paint_| is true. // Deferred invalidates while |in_paint_| is true.
std::vector<pp::Rect> deferred_invalidates_; std::vector<gfx::Rect> deferred_invalidates_;
struct BackgroundPart { struct BackgroundPart {
pp::Rect location; pp::Rect location;
......
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
#include "ppapi/c/dev/ppp_printing_dev.h" #include "ppapi/c/dev/ppp_printing_dev.h"
#include "ppapi/cpp/completion_callback.h" #include "ppapi/cpp/completion_callback.h"
#include "ppapi/cpp/private/pdf.h" #include "ppapi/cpp/private/pdf.h"
#include "ppapi/cpp/size.h"
#include "ppapi/cpp/url_loader.h" #include "ppapi/cpp/url_loader.h"
#include "ppapi/cpp/var_array.h" #include "ppapi/cpp/var_array.h"
#include "ui/base/window_open_disposition.h" #include "ui/base/window_open_disposition.h"
...@@ -52,7 +51,6 @@ class Vector2d; ...@@ -52,7 +51,6 @@ class Vector2d;
} // namespace gfx } // namespace gfx
namespace pp { namespace pp {
class Rect;
class VarDictionary; class VarDictionary;
} // namespace pp } // namespace pp
...@@ -134,7 +132,7 @@ class PDFEngine { ...@@ -134,7 +132,7 @@ class PDFEngine {
virtual void ProposeDocumentLayout(const DocumentLayout& layout) = 0; virtual void ProposeDocumentLayout(const DocumentLayout& layout) = 0;
// Informs the client that the given rect needs to be repainted. // Informs the client that the given rect needs to be repainted.
virtual void Invalidate(const pp::Rect& rect) {} virtual void Invalidate(const gfx::Rect& rect) {}
// Informs the client to scroll the plugin area by the given offset. // Informs the client to scroll the plugin area by the given offset.
virtual void DidScroll(const gfx::Vector2d& offset) {} virtual void DidScroll(const gfx::Vector2d& offset) {}
...@@ -262,8 +260,8 @@ class PDFEngine { ...@@ -262,8 +260,8 @@ class PDFEngine {
// Sets selection status. // Sets selection status.
virtual void IsSelectingChanged(bool is_selecting) {} virtual void IsSelectingChanged(bool is_selecting) {}
virtual void SelectionChanged(const pp::Rect& left, const pp::Rect& right) { virtual void SelectionChanged(const gfx::Rect& left,
} const gfx::Rect& right) {}
// Notifies the client that the PDF has been edited. // Notifies the client that the PDF has been edited.
virtual void EnteredEditMode() {} virtual void EnteredEditMode() {}
...@@ -333,10 +331,10 @@ class PDFEngine { ...@@ -333,10 +331,10 @@ class PDFEngine {
// 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
// is called once. After Paint is called n times, PostPaint is called once. // is called once. After Paint is called n times, PostPaint is called once.
virtual void PrePaint() = 0; virtual void PrePaint() = 0;
virtual void Paint(const pp::Rect& rect, virtual void Paint(const gfx::Rect& rect,
SkBitmap& image_data, SkBitmap& image_data,
std::vector<pp::Rect>& ready, std::vector<gfx::Rect>& ready,
std::vector<pp::Rect>& pending) = 0; std::vector<gfx::Rect>& pending) = 0;
virtual void PostPaint() = 0; virtual void PostPaint() = 0;
virtual bool HandleDocumentLoad(scoped_refptr<UrlLoader> loader) = 0; virtual bool HandleDocumentLoad(scoped_refptr<UrlLoader> loader) = 0;
virtual bool HandleEvent(const InputEvent& event) = 0; virtual bool HandleEvent(const InputEvent& event) = 0;
...@@ -411,7 +409,7 @@ class PDFEngine { ...@@ -411,7 +409,7 @@ class PDFEngine {
virtual gfx::Rect GetPageContentsRect(int index) = 0; virtual gfx::Rect GetPageContentsRect(int index) = 0;
// Returns a page's rect in screen coordinates, as well as its surrounding // Returns a page's rect in screen coordinates, as well as its surrounding
// border areas and bottom separator. // border areas and bottom separator.
virtual pp::Rect GetPageScreenRect(int page_index) const = 0; virtual gfx::Rect GetPageScreenRect(int page_index) const = 0;
// Gets the offset of the vertical scrollbar from the top in document // Gets the offset of the vertical scrollbar from the top in document
// coordinates. // coordinates.
virtual int GetVerticalScrollbarYPosition() = 0; virtual int GetVerticalScrollbarYPosition() = 0;
......
...@@ -141,7 +141,7 @@ void PdfViewWebPlugin::DidFailLoading(const blink::WebURLError& error) {} ...@@ -141,7 +141,7 @@ void PdfViewWebPlugin::DidFailLoading(const blink::WebURLError& error) {}
void PdfViewWebPlugin::ProposeDocumentLayout(const DocumentLayout& layout) {} void PdfViewWebPlugin::ProposeDocumentLayout(const DocumentLayout& layout) {}
void PdfViewWebPlugin::Invalidate(const pp::Rect& rect) {} void PdfViewWebPlugin::Invalidate(const gfx::Rect& rect) {}
void PdfViewWebPlugin::DidScroll(const gfx::Vector2d& offset) {} void PdfViewWebPlugin::DidScroll(const gfx::Vector2d& offset) {}
...@@ -245,8 +245,8 @@ uint32_t PdfViewWebPlugin::GetBackgroundColor() { ...@@ -245,8 +245,8 @@ uint32_t PdfViewWebPlugin::GetBackgroundColor() {
void PdfViewWebPlugin::IsSelectingChanged(bool is_selecting) {} void PdfViewWebPlugin::IsSelectingChanged(bool is_selecting) {}
void PdfViewWebPlugin::SelectionChanged(const pp::Rect& left, void PdfViewWebPlugin::SelectionChanged(const gfx::Rect& left,
const pp::Rect& right) {} const gfx::Rect& right) {}
void PdfViewWebPlugin::EnteredEditMode() {} void PdfViewWebPlugin::EnteredEditMode() {}
......
...@@ -45,7 +45,7 @@ class PdfViewWebPlugin final : public PdfViewPluginBase, ...@@ -45,7 +45,7 @@ class PdfViewWebPlugin final : public PdfViewPluginBase,
// PdfViewPluginBase: // PdfViewPluginBase:
void ProposeDocumentLayout(const DocumentLayout& layout) override; void ProposeDocumentLayout(const DocumentLayout& layout) override;
void Invalidate(const pp::Rect& rect) override; void Invalidate(const gfx::Rect& rect) override;
void DidScroll(const gfx::Vector2d& offset) override; void DidScroll(const gfx::Vector2d& offset) override;
void ScrollToX(int x_in_screen_coords) override; void ScrollToX(int x_in_screen_coords) override;
void ScrollToY(int y_in_screen_coords, bool compensate_for_toolbar) override; void ScrollToY(int y_in_screen_coords, bool compensate_for_toolbar) override;
...@@ -93,7 +93,7 @@ class PdfViewWebPlugin final : public PdfViewPluginBase, ...@@ -93,7 +93,7 @@ class PdfViewWebPlugin final : public PdfViewPluginBase,
bool IsPrintPreview() override; bool IsPrintPreview() override;
uint32_t GetBackgroundColor() override; uint32_t GetBackgroundColor() override;
void IsSelectingChanged(bool is_selecting) override; void IsSelectingChanged(bool is_selecting) override;
void SelectionChanged(const pp::Rect& left, const pp::Rect& right) override; void SelectionChanged(const gfx::Rect& left, const gfx::Rect& right) override;
void EnteredEditMode() override; void EnteredEditMode() override;
float GetToolbarHeightInScreenCoords() override; float GetToolbarHeightInScreenCoords() override;
void DocumentFocusChanged(bool document_has_focus) override; void DocumentFocusChanged(bool document_has_focus) override;
......
...@@ -545,11 +545,11 @@ void PDFiumEngine::PrePaint() { ...@@ -545,11 +545,11 @@ void PDFiumEngine::PrePaint() {
paint.set_painted(false); paint.set_painted(false);
} }
void PDFiumEngine::Paint(const pp::Rect& rect, void PDFiumEngine::Paint(const gfx::Rect& rect,
SkBitmap& image_data, SkBitmap& image_data,
std::vector<pp::Rect>& ready, std::vector<gfx::Rect>& ready,
std::vector<pp::Rect>& pending) { std::vector<gfx::Rect>& pending) {
pp::Rect leftover = rect; gfx::Rect leftover = rect;
for (size_t i = 0; i < visible_pages_.size(); ++i) { for (size_t i = 0; i < visible_pages_.size(); ++i) {
int index = visible_pages_[i]; int index = visible_pages_[i];
// Convert the current page's rectangle to screen rectangle. We do this // Convert the current page's rectangle to screen rectangle. We do this
...@@ -557,8 +557,9 @@ void PDFiumEngine::Paint(const pp::Rect& rect, ...@@ -557,8 +557,9 @@ void PDFiumEngine::Paint(const pp::Rect& rect,
// page coordinates) because then we'd have to convert back to screen // page coordinates) because then we'd have to convert back to screen
// coordinates, and the rounding errors sometime leave pixels dirty or even // coordinates, and the rounding errors sometime leave pixels dirty or even
// move the text up or down a pixel when zoomed. // move the text up or down a pixel when zoomed.
pp::Rect page_rect_in_screen = GetPageScreenRect(index); gfx::Rect page_rect_in_screen = GetPageScreenRect(index);
pp::Rect dirty_in_screen = page_rect_in_screen.Intersect(leftover); gfx::Rect dirty_in_screen =
gfx::IntersectRects(page_rect_in_screen, leftover);
if (dirty_in_screen.IsEmpty()) if (dirty_in_screen.IsEmpty())
continue; continue;
...@@ -570,13 +571,13 @@ void PDFiumEngine::Paint(const pp::Rect& rect, ...@@ -570,13 +571,13 @@ void PDFiumEngine::Paint(const pp::Rect& rect,
// rectangle. // rectangle.
if (!layout_.options().two_up_view_enabled()) { if (!layout_.options().two_up_view_enabled()) {
if (i == 0) { if (i == 0) {
pp::Rect blank_space_in_screen = dirty_in_screen; gfx::Rect blank_space_in_screen = dirty_in_screen;
blank_space_in_screen.set_y(0); blank_space_in_screen.set_y(0);
blank_space_in_screen.set_height(dirty_in_screen.y()); blank_space_in_screen.set_height(dirty_in_screen.y());
leftover = leftover.Subtract(blank_space_in_screen); leftover.Subtract(blank_space_in_screen);
} }
leftover = leftover.Subtract(dirty_in_screen); leftover.Subtract(dirty_in_screen);
} }
if (pages_[index]->available()) { if (pages_[index]->available()) {
...@@ -1320,8 +1321,8 @@ bool PDFiumEngine::OnRightMouseDown(const MouseInputEvent& event) { ...@@ -1320,8 +1321,8 @@ bool PDFiumEngine::OnRightMouseDown(const MouseInputEvent& event) {
if (selection_.empty()) if (selection_.empty())
return false; return false;
std::vector<gfx::Rect> selection_rect_vector = GetAllScreenRectsUnion( std::vector<gfx::Rect> selection_rect_vector =
selection_, PointFromPPPoint(GetVisibleRect().point())); GetAllScreenRectsUnion(selection_, GetVisibleRect().origin());
for (const auto& rect : selection_rect_vector) { for (const auto& rect : selection_rect_vector) {
if (rect.Contains(point)) if (rect.Contains(point))
return false; return false;
...@@ -1978,7 +1979,7 @@ bool PDFiumEngine::SelectFindResult(bool forward) { ...@@ -1978,7 +1979,7 @@ bool PDFiumEngine::SelectFindResult(bool forward) {
// If the result is not in view, scroll to it. // If the result is not in view, scroll to it.
gfx::Rect bounding_rect; gfx::Rect bounding_rect;
gfx::Rect visible_rect = RectFromPPRect(GetVisibleRect()); gfx::Rect visible_rect = GetVisibleRect();
// TODO(crbug.com/1108574): Remove after fixing the issue. // TODO(crbug.com/1108574): Remove after fixing the issue.
size_t find_results_size = find_results_.size(); size_t find_results_size = find_results_.size();
...@@ -2089,7 +2090,7 @@ void PDFiumEngine::InvalidateAllPages() { ...@@ -2089,7 +2090,7 @@ void PDFiumEngine::InvalidateAllPages() {
StopFind(); StopFind();
DCHECK(document_loaded_); DCHECK(document_loaded_);
RefreshCurrentDocumentLayout(); RefreshCurrentDocumentLayout();
client_->Invalidate(pp::Rect(PPSizeFromSize(plugin_size_))); client_->Invalidate(gfx::Rect(plugin_size_));
} }
std::string PDFiumEngine::GetSelectedText() { std::string PDFiumEngine::GetSelectedText() {
...@@ -2164,7 +2165,7 @@ void PDFiumEngine::HandleAccessibilityAction( ...@@ -2164,7 +2165,7 @@ void PDFiumEngine::HandleAccessibilityAction(
const PP_PdfAccessibilityActionData& action_data) { const PP_PdfAccessibilityActionData& action_data) {
switch (action_data.action) { switch (action_data.action) {
case PP_PdfAccessibilityAction::PP_PDF_SCROLL_TO_MAKE_VISIBLE: { case PP_PdfAccessibilityAction::PP_PDF_SCROLL_TO_MAKE_VISIBLE: {
ScrollBasedOnScrollAlignment(action_data.target_rect, ScrollBasedOnScrollAlignment(RectFromPPRect(action_data.target_rect),
action_data.horizontal_scroll_alignment, action_data.horizontal_scroll_alignment,
action_data.vertical_scroll_alignment); action_data.vertical_scroll_alignment);
break; break;
...@@ -2184,7 +2185,7 @@ void PDFiumEngine::HandleAccessibilityAction( ...@@ -2184,7 +2185,7 @@ void PDFiumEngine::HandleAccessibilityAction(
break; break;
} }
case PP_PdfAccessibilityAction::PP_PDF_SCROLL_TO_GLOBAL_POINT: { case PP_PdfAccessibilityAction::PP_PDF_SCROLL_TO_GLOBAL_POINT: {
ScrollToGlobalPoint(action_data.target_rect, ScrollToGlobalPoint(RectFromPPRect(action_data.target_rect),
PointFromPPPoint(action_data.target_point)); PointFromPPPoint(action_data.target_point));
break; break;
} }
...@@ -2335,11 +2336,10 @@ pp::VarDictionary PDFiumEngine::TraverseBookmarks(FPDF_BOOKMARK bookmark, ...@@ -2335,11 +2336,10 @@ pp::VarDictionary PDFiumEngine::TraverseBookmarks(FPDF_BOOKMARK bookmark,
} }
void PDFiumEngine::ScrollBasedOnScrollAlignment( void PDFiumEngine::ScrollBasedOnScrollAlignment(
const pp::Rect& scroll_rect, const gfx::Rect& scroll_rect,
const PP_PdfAccessibilityScrollAlignment& horizontal_scroll_alignment, const PP_PdfAccessibilityScrollAlignment& horizontal_scroll_alignment,
const PP_PdfAccessibilityScrollAlignment& vertical_scroll_alignment) { const PP_PdfAccessibilityScrollAlignment& vertical_scroll_alignment) {
gfx::Vector2d scroll_offset = gfx::Vector2d scroll_offset = GetScreenRect(scroll_rect).OffsetFromOrigin();
GetScreenRect(RectFromPPRect(scroll_rect)).OffsetFromOrigin();
switch (horizontal_scroll_alignment) { switch (horizontal_scroll_alignment) {
case PP_PdfAccessibilityScrollAlignment::PP_PDF_SCROLL_ALIGNMENT_RIGHT: case PP_PdfAccessibilityScrollAlignment::PP_PDF_SCROLL_ALIGNMENT_RIGHT:
scroll_offset.set_x(scroll_offset.x() - plugin_size_.width()); scroll_offset.set_x(scroll_offset.x() - plugin_size_.width());
...@@ -2391,10 +2391,9 @@ void PDFiumEngine::ScrollBasedOnScrollAlignment( ...@@ -2391,10 +2391,9 @@ void PDFiumEngine::ScrollBasedOnScrollAlignment(
client_->ScrollBy(scroll_offset); client_->ScrollBy(scroll_offset);
} }
void PDFiumEngine::ScrollToGlobalPoint(const pp::Rect& target_rect, void PDFiumEngine::ScrollToGlobalPoint(const gfx::Rect& target_rect,
const gfx::Point& global_point) { const gfx::Point& global_point) {
gfx::Point scroll_offset = gfx::Point scroll_offset = GetScreenRect(target_rect).origin();
GetScreenRect(RectFromPPRect(target_rect)).origin();
client_->ScrollBy(scroll_offset - global_point); client_->ScrollBy(scroll_offset - global_point);
} }
...@@ -2865,7 +2864,7 @@ void PDFiumEngine::CalculateVisiblePages() { ...@@ -2865,7 +2864,7 @@ void PDFiumEngine::CalculateVisiblePages() {
doc_loader_->ClearPendingRequests(); doc_loader_->ClearPendingRequests();
visible_pages_.clear(); visible_pages_.clear();
pp::Rect visible_rect(PPSizeFromSize(plugin_size_)); gfx::Rect visible_rect(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.
...@@ -2896,8 +2895,8 @@ void PDFiumEngine::CalculateVisiblePages() { ...@@ -2896,8 +2895,8 @@ void PDFiumEngine::CalculateVisiblePages() {
pages_[visible_page_index]->rect()); pages_[visible_page_index]->rect());
} }
int most_visible_page = draw_utils::GetMostVisiblePage( int most_visible_page =
visible_pages_rects, RectFromPPRect(GetVisibleRect())); draw_utils::GetMostVisiblePage(visible_pages_rects, GetVisibleRect());
SetCurrentPage(most_visible_page); SetCurrentPage(most_visible_page);
} }
...@@ -3000,10 +2999,10 @@ void PDFiumEngine::InsetPage(const DocumentLayout::Options& layout_options, ...@@ -3000,10 +2999,10 @@ void PDFiumEngine::InsetPage(const DocumentLayout::Options& layout_options,
size_t page_index, size_t page_index,
size_t num_of_pages, size_t num_of_pages,
double multiplier, double multiplier,
pp::Rect* rect) const { gfx::Rect& rect) 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);
rect->Inset(static_cast<int>(ceil(inset_sizes.left * multiplier)), rect.Inset(static_cast<int>(ceil(inset_sizes.left * multiplier)),
static_cast<int>(ceil(inset_sizes.top * multiplier)), static_cast<int>(ceil(inset_sizes.top * multiplier)),
static_cast<int>(ceil(inset_sizes.right * multiplier)), static_cast<int>(ceil(inset_sizes.right * multiplier)),
static_cast<int>(ceil(inset_sizes.bottom * multiplier))); static_cast<int>(ceil(inset_sizes.bottom * multiplier)));
...@@ -3025,7 +3024,7 @@ base::Optional<size_t> PDFiumEngine::GetAdjacentPageIndexForTwoUpView( ...@@ -3025,7 +3024,7 @@ base::Optional<size_t> PDFiumEngine::GetAdjacentPageIndexForTwoUpView(
return adjacent_page_index; return adjacent_page_index;
} }
int PDFiumEngine::StartPaint(int page_index, const pp::Rect& dirty) { int PDFiumEngine::StartPaint(int page_index, const gfx::Rect& dirty) {
// For the first time we hit paint, do nothing and just record the paint for // For the first time we hit paint, do nothing and just record the paint for
// the next callback. This keeps the UI responsive in case the user is doing // the next callback. This keeps the UI responsive in case the user is doing
// a lot of scrolling. // a lot of scrolling.
...@@ -3054,7 +3053,7 @@ bool PDFiumEngine::ContinuePaint(int progressive_index, SkBitmap& image_data) { ...@@ -3054,7 +3053,7 @@ bool PDFiumEngine::ContinuePaint(int progressive_index, SkBitmap& image_data) {
int start_y; int start_y;
int size_x; int size_x;
int size_y; int size_y;
pp::Rect dirty = progressive_paints_[progressive_index].rect(); gfx::Rect dirty = progressive_paints_[progressive_index].rect();
GetPDFiumRect(page_index, dirty, &start_x, &start_y, &size_x, &size_y); GetPDFiumRect(page_index, dirty, &start_x, &start_y, &size_x, &size_y);
ScopedFPDFBitmap new_bitmap = CreateBitmap(dirty, image_data); ScopedFPDFBitmap new_bitmap = CreateBitmap(dirty, image_data);
...@@ -3075,8 +3074,7 @@ void PDFiumEngine::FinishPaint(int progressive_index, SkBitmap& image_data) { ...@@ -3075,8 +3074,7 @@ void PDFiumEngine::FinishPaint(int progressive_index, SkBitmap& image_data) {
DCHECK_LT(static_cast<size_t>(progressive_index), progressive_paints_.size()); DCHECK_LT(static_cast<size_t>(progressive_index), progressive_paints_.size());
int page_index = progressive_paints_[progressive_index].page_index(); int page_index = progressive_paints_[progressive_index].page_index();
const pp::Rect& dirty_in_screen = gfx::Rect dirty_in_screen = progressive_paints_[progressive_index].rect();
progressive_paints_[progressive_index].rect();
int start_x; int start_x;
int start_y; int start_y;
...@@ -3116,8 +3114,7 @@ void PDFiumEngine::FillPageSides(int progressive_index) { ...@@ -3116,8 +3114,7 @@ void PDFiumEngine::FillPageSides(int progressive_index) {
DCHECK_LT(static_cast<size_t>(progressive_index), progressive_paints_.size()); DCHECK_LT(static_cast<size_t>(progressive_index), progressive_paints_.size());
int page_index = progressive_paints_[progressive_index].page_index(); int page_index = progressive_paints_[progressive_index].page_index();
gfx::Rect dirty_in_screen = gfx::Rect dirty_in_screen = progressive_paints_[progressive_index].rect();
RectFromPPRect(progressive_paints_[progressive_index].rect());
FPDF_BITMAP bitmap = progressive_paints_[progressive_index].bitmap(); FPDF_BITMAP bitmap = progressive_paints_[progressive_index].bitmap();
draw_utils::PageInsetSizes inset_sizes = draw_utils::PageInsetSizes inset_sizes =
GetInsetSizes(layout_.options(), page_index, pages_.size()); GetInsetSizes(layout_.options(), page_index, pages_.size());
...@@ -3180,21 +3177,20 @@ void PDFiumEngine::PaintPageShadow(int progressive_index, ...@@ -3180,21 +3177,20 @@ void PDFiumEngine::PaintPageShadow(int progressive_index,
DCHECK_LT(static_cast<size_t>(progressive_index), progressive_paints_.size()); DCHECK_LT(static_cast<size_t>(progressive_index), progressive_paints_.size());
int page_index = progressive_paints_[progressive_index].page_index(); int page_index = progressive_paints_[progressive_index].page_index();
const pp::Rect& dirty_in_screen = gfx::Rect dirty_in_screen = progressive_paints_[progressive_index].rect();
progressive_paints_[progressive_index].rect(); gfx::Rect page_rect = pages_[page_index]->rect();
pp::Rect page_rect = PPRectFromRect(pages_[page_index]->rect()); gfx::Rect shadow_rect(page_rect);
pp::Rect shadow_rect(page_rect);
InsetPage(layout_.options(), page_index, pages_.size(), /*multiplier=*/-1, InsetPage(layout_.options(), page_index, pages_.size(), /*multiplier=*/-1,
&shadow_rect); shadow_rect);
// Due to the rounding errors of the GetScreenRect it is possible to get // Due to the rounding errors of the GetScreenRect it is possible to get
// different size shadows on the left and right sides even they are defined // different size shadows on the left and right sides even they are defined
// the same. To fix this issue let's calculate shadow rect and then shrink // the same. To fix this issue let's calculate shadow rect and then shrink
// it by the size of the shadows. // it by the size of the shadows.
shadow_rect = PPRectFromRect(GetScreenRect(RectFromPPRect(shadow_rect))); shadow_rect = GetScreenRect(shadow_rect);
page_rect = shadow_rect; page_rect = shadow_rect;
InsetPage(layout_.options(), page_index, pages_.size(), InsetPage(layout_.options(), page_index, pages_.size(),
/*multiplier=*/current_zoom_, &page_rect); /*multiplier=*/current_zoom_, page_rect);
DrawPageShadow(page_rect, shadow_rect, dirty_in_screen, image_data); DrawPageShadow(page_rect, shadow_rect, dirty_in_screen, image_data);
} }
...@@ -3205,21 +3201,20 @@ void PDFiumEngine::DrawSelections(int progressive_index, ...@@ -3205,21 +3201,20 @@ void PDFiumEngine::DrawSelections(int progressive_index,
DCHECK_LT(static_cast<size_t>(progressive_index), progressive_paints_.size()); DCHECK_LT(static_cast<size_t>(progressive_index), progressive_paints_.size());
int page_index = progressive_paints_[progressive_index].page_index(); int page_index = progressive_paints_[progressive_index].page_index();
gfx::Rect dirty_in_screen = gfx::Rect dirty_in_screen = progressive_paints_[progressive_index].rect();
RectFromPPRect(progressive_paints_[progressive_index].rect());
void* region = nullptr; void* region = nullptr;
int stride; int stride;
GetRegion(dirty_in_screen.origin(), image_data, region, stride); GetRegion(dirty_in_screen.origin(), image_data, region, stride);
std::vector<gfx::Rect> highlighted_rects; std::vector<gfx::Rect> highlighted_rects;
pp::Rect visible_rect = GetVisibleRect(); gfx::Rect visible_rect = GetVisibleRect();
for (const auto& range : selection_) { for (const auto& range : selection_) {
if (range.page_index() != page_index) if (range.page_index() != page_index)
continue; continue;
const std::vector<gfx::Rect>& rects = range.GetScreenRects( const std::vector<gfx::Rect>& rects =
PointFromPPPoint(visible_rect.point()), current_zoom_, range.GetScreenRects(visible_rect.origin(), current_zoom_,
layout_.options().default_page_orientation()); layout_.options().default_page_orientation());
for (const auto& rect : rects) { for (const auto& rect : rects) {
gfx::Rect visible_selection = gfx::IntersectRects(rect, dirty_in_screen); gfx::Rect visible_selection = gfx::IntersectRects(rect, dirty_in_screen);
...@@ -3245,7 +3240,7 @@ void PDFiumEngine::DrawSelections(int progressive_index, ...@@ -3245,7 +3240,7 @@ void PDFiumEngine::DrawSelections(int progressive_index,
} }
void PDFiumEngine::PaintUnavailablePage(int page_index, void PDFiumEngine::PaintUnavailablePage(int page_index,
const pp::Rect& dirty, const gfx::Rect& dirty,
SkBitmap& image_data) { SkBitmap& image_data) {
int start_x; int start_x;
int start_y; int start_y;
...@@ -3270,11 +3265,11 @@ int PDFiumEngine::GetProgressiveIndex(int page_index) const { ...@@ -3270,11 +3265,11 @@ int PDFiumEngine::GetProgressiveIndex(int page_index) const {
return -1; return -1;
} }
ScopedFPDFBitmap PDFiumEngine::CreateBitmap(const pp::Rect& rect, ScopedFPDFBitmap PDFiumEngine::CreateBitmap(const gfx::Rect& rect,
SkBitmap& image_data) const { SkBitmap& image_data) const {
void* region; void* region;
int stride; int stride;
GetRegion(PointFromPPPoint(rect.point()), image_data, region, stride); GetRegion(rect.origin(), image_data, region, stride);
if (!region) if (!region)
return nullptr; return nullptr;
return ScopedFPDFBitmap(FPDFBitmap_CreateEx(rect.width(), rect.height(), return ScopedFPDFBitmap(FPDFBitmap_CreateEx(rect.width(), rect.height(),
...@@ -3282,7 +3277,7 @@ ScopedFPDFBitmap PDFiumEngine::CreateBitmap(const pp::Rect& rect, ...@@ -3282,7 +3277,7 @@ ScopedFPDFBitmap PDFiumEngine::CreateBitmap(const pp::Rect& rect,
} }
void PDFiumEngine::GetPDFiumRect(int page_index, void PDFiumEngine::GetPDFiumRect(int page_index,
const pp::Rect& rect, const gfx::Rect& rect,
int* start_x, int* start_x,
int* start_y, int* start_y,
int* size_x, int* size_x,
...@@ -3307,8 +3302,8 @@ int PDFiumEngine::GetRenderingFlags() const { ...@@ -3307,8 +3302,8 @@ int PDFiumEngine::GetRenderingFlags() const {
return flags; return flags;
} }
pp::Rect PDFiumEngine::GetVisibleRect() const { gfx::Rect PDFiumEngine::GetVisibleRect() const {
pp::Rect rv; gfx::Rect rv;
rv.set_x(static_cast<int>(position_.x() / current_zoom_)); rv.set_x(static_cast<int>(position_.x() / current_zoom_));
rv.set_y(static_cast<int>(position_.y() / current_zoom_)); rv.set_y(static_cast<int>(position_.y() / current_zoom_));
rv.set_width(static_cast<int>(ceil(plugin_size_.width() / current_zoom_))); rv.set_width(static_cast<int>(ceil(plugin_size_.width() / current_zoom_)));
...@@ -3316,8 +3311,8 @@ pp::Rect PDFiumEngine::GetVisibleRect() const { ...@@ -3316,8 +3311,8 @@ pp::Rect PDFiumEngine::GetVisibleRect() const {
return rv; return rv;
} }
pp::Rect PDFiumEngine::GetPageScreenRect(int page_index) const { gfx::Rect PDFiumEngine::GetPageScreenRect(int page_index) const {
pp::Rect page_rect = PPRectFromRect(pages_[page_index]->rect()); gfx::Rect page_rect = pages_[page_index]->rect();
draw_utils::PageInsetSizes inset_sizes = draw_utils::PageInsetSizes inset_sizes =
GetInsetSizes(layout_.options(), page_index, pages_.size()); GetInsetSizes(layout_.options(), page_index, pages_.size());
...@@ -3329,9 +3324,9 @@ pp::Rect PDFiumEngine::GetPageScreenRect(int page_index) const { ...@@ -3329,9 +3324,9 @@ pp::Rect PDFiumEngine::GetPageScreenRect(int page_index) const {
max_page_height, pages_[adjacent_page_index.value()]->rect().height()); max_page_height, pages_[adjacent_page_index.value()]->rect().height());
} }
return PPRectFromRect(GetScreenRect(draw_utils::GetSurroundingRect( return GetScreenRect(draw_utils::GetSurroundingRect(
page_rect.y(), max_page_height, inset_sizes, layout_.size().width(), page_rect.y(), max_page_height, inset_sizes, layout_.size().width(),
DocumentLayout::kBottomSeparator))); DocumentLayout::kBottomSeparator));
} }
gfx::Rect PDFiumEngine::GetScreenRect(const gfx::Rect& rect) const { gfx::Rect PDFiumEngine::GetScreenRect(const gfx::Rect& rect) const {
...@@ -3390,13 +3385,12 @@ void PDFiumEngine::Highlight(void* buffer, ...@@ -3390,13 +3385,12 @@ void PDFiumEngine::Highlight(void* buffer,
PDFiumEngine::SelectionChangeInvalidator::SelectionChangeInvalidator( PDFiumEngine::SelectionChangeInvalidator::SelectionChangeInvalidator(
PDFiumEngine* engine) PDFiumEngine* engine)
: engine_(engine), : engine_(engine),
previous_origin_(PointFromPPPoint(engine_->GetVisibleRect().point())), previous_origin_(engine_->GetVisibleRect().origin()),
old_selections_(GetVisibleSelections()) {} old_selections_(GetVisibleSelections()) {}
PDFiumEngine::SelectionChangeInvalidator::~SelectionChangeInvalidator() { PDFiumEngine::SelectionChangeInvalidator::~SelectionChangeInvalidator() {
// Offset the old selections if the document scrolled since we recorded them. // Offset the old selections if the document scrolled since we recorded them.
gfx::Vector2d offset = gfx::Vector2d offset = previous_origin_ - engine_->GetVisibleRect().origin();
previous_origin_ - RectFromPPRect(engine_->GetVisibleRect()).origin();
for (auto& old_selection : old_selections_) for (auto& old_selection : old_selections_)
old_selection.Offset(offset); old_selection.Offset(offset);
...@@ -3435,8 +3429,7 @@ PDFiumEngine::SelectionChangeInvalidator::~SelectionChangeInvalidator() { ...@@ -3435,8 +3429,7 @@ PDFiumEngine::SelectionChangeInvalidator::~SelectionChangeInvalidator() {
std::vector<gfx::Rect> std::vector<gfx::Rect>
PDFiumEngine::SelectionChangeInvalidator::GetVisibleSelections() const { PDFiumEngine::SelectionChangeInvalidator::GetVisibleSelections() const {
std::vector<gfx::Rect> rects; std::vector<gfx::Rect> rects;
gfx::Point visible_point = gfx::Point visible_point = engine_->GetVisibleRect().origin();
PointFromPPPoint(engine_->GetVisibleRect().point());
for (const auto& range : engine_->selection_) { for (const auto& range : engine_->selection_) {
// Exclude selections on pages that's not currently visible. // Exclude selections on pages that's not currently visible.
if (!engine_->IsPageVisible(range.page_index())) if (!engine_->IsPageVisible(range.page_index()))
...@@ -3454,7 +3447,7 @@ void PDFiumEngine::SelectionChangeInvalidator::Invalidate( ...@@ -3454,7 +3447,7 @@ void PDFiumEngine::SelectionChangeInvalidator::Invalidate(
const gfx::Rect& selection) { const gfx::Rect& selection) {
gfx::Rect expanded_selection = selection; gfx::Rect expanded_selection = selection;
expanded_selection.Inset(-1, -1); expanded_selection.Inset(-1, -1);
engine_->client_->Invalidate(PPRectFromRect(expanded_selection)); engine_->client_->Invalidate(expanded_selection);
} }
PDFiumEngine::MouseDownState::MouseDownState( PDFiumEngine::MouseDownState::MouseDownState(
...@@ -3540,17 +3533,17 @@ void PDFiumEngine::SetCurrentPage(int index) { ...@@ -3540,17 +3533,17 @@ void PDFiumEngine::SetCurrentPage(int index) {
} }
} }
void PDFiumEngine::DrawPageShadow(const pp::Rect& page_rc, void PDFiumEngine::DrawPageShadow(const gfx::Rect& page_rc,
const pp::Rect& shadow_rc, const gfx::Rect& shadow_rc,
const pp::Rect& clip_rc, const gfx::Rect& clip_rc,
SkBitmap& image_data) { SkBitmap& image_data) {
gfx::Rect page_rect(RectFromPPRect(page_rc)); gfx::Rect page_rect(page_rc);
page_rect.Offset(page_offset_); page_rect.Offset(page_offset_);
gfx::Rect shadow_rect(RectFromPPRect(shadow_rc)); gfx::Rect shadow_rect(shadow_rc);
shadow_rect.Offset(page_offset_); shadow_rect.Offset(page_offset_);
gfx::Rect clip_rect(RectFromPPRect(clip_rc)); gfx::Rect clip_rect(clip_rc);
clip_rect.Offset(page_offset_); clip_rect.Offset(page_offset_);
// Page drop shadow parameters. // Page drop shadow parameters.
...@@ -3611,8 +3604,8 @@ void PDFiumEngine::OnSelectionPositionChanged() { ...@@ -3611,8 +3604,8 @@ void PDFiumEngine::OnSelectionPositionChanged() {
std::numeric_limits<int32_t>::max(), 0, 0); std::numeric_limits<int32_t>::max(), 0, 0);
gfx::Rect right; gfx::Rect right;
for (const auto& sel : selection_) { for (const auto& sel : selection_) {
const std::vector<gfx::Rect>& screen_rects = sel.GetScreenRects( const std::vector<gfx::Rect>& screen_rects =
PointFromPPPoint(GetVisibleRect().point()), current_zoom_, sel.GetScreenRects(GetVisibleRect().origin(), current_zoom_,
layout_.options().default_page_orientation()); layout_.options().default_page_orientation());
for (const auto& rect : screen_rects) { for (const auto& rect : screen_rects) {
if (IsAboveOrDirectlyLeftOf(rect, left)) if (IsAboveOrDirectlyLeftOf(rect, left))
...@@ -3626,7 +3619,7 @@ void PDFiumEngine::OnSelectionPositionChanged() { ...@@ -3626,7 +3619,7 @@ void PDFiumEngine::OnSelectionPositionChanged() {
left.set_x(0); left.set_x(0);
left.set_y(0); left.set_y(0);
} }
client_->SelectionChanged(PPRectFromRect(left), PPRectFromRect(right)); client_->SelectionChanged(left, right);
} }
gfx::Size PDFiumEngine::ApplyDocumentLayout( gfx::Size PDFiumEngine::ApplyDocumentLayout(
...@@ -3812,8 +3805,8 @@ void PDFiumEngine::ScrollAnnotationIntoView(FPDF_ANNOTATION annot, ...@@ -3812,8 +3805,8 @@ void PDFiumEngine::ScrollAnnotationIntoView(FPDF_ANNOTATION annot,
annot_rect.right, annot_rect.bottom, annot_rect.right, annot_rect.bottom,
layout_.options().default_page_orientation()); layout_.options().default_page_orientation());
pp::Rect visible_rect = GetVisibleRect(); gfx::Rect visible_rect = GetVisibleRect();
if (visible_rect.Contains(PPRectFromRect(rect))) if (visible_rect.Contains(rect))
return; return;
// Since the focus rect is not already in the visible area, scrolling // Since the focus rect is not already in the visible area, scrolling
// horizontally and/or vertically is required. // horizontally and/or vertically is required.
...@@ -4142,7 +4135,7 @@ void PDFiumEngine::SetLinkUnderCursorForAnnotation(FPDF_ANNOTATION annot, ...@@ -4142,7 +4135,7 @@ void PDFiumEngine::SetLinkUnderCursorForAnnotation(FPDF_ANNOTATION annot,
} }
PDFiumEngine::ProgressivePaint::ProgressivePaint(int index, PDFiumEngine::ProgressivePaint::ProgressivePaint(int index,
const pp::Rect& rect) const gfx::Rect& rect)
: page_index_(index), rect_(rect) {} : page_index_(index), rect_(rect) {}
PDFiumEngine::ProgressivePaint::ProgressivePaint(ProgressivePaint&& that) = PDFiumEngine::ProgressivePaint::ProgressivePaint(ProgressivePaint&& that) =
......
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
#include "pdf/pdfium/pdfium_range.h" #include "pdf/pdfium/pdfium_range.h"
#include "ppapi/c/private/ppp_pdf.h" #include "ppapi/c/private/ppp_pdf.h"
#include "ppapi/cpp/dev/buffer_dev.h" #include "ppapi/cpp/dev/buffer_dev.h"
#include "ppapi/cpp/rect.h"
#include "ppapi/cpp/var_array.h" #include "ppapi/cpp/var_array.h"
#include "third_party/pdfium/public/cpp/fpdf_scopers.h" #include "third_party/pdfium/public/cpp/fpdf_scopers.h"
#include "third_party/pdfium/public/fpdf_formfill.h" #include "third_party/pdfium/public/fpdf_formfill.h"
...@@ -89,10 +88,10 @@ class PDFiumEngine : public PDFEngine, ...@@ -89,10 +88,10 @@ class PDFiumEngine : public PDFEngine,
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;
void Paint(const pp::Rect& rect, void Paint(const gfx::Rect& rect,
SkBitmap& image_data, SkBitmap& image_data,
std::vector<pp::Rect>& ready, std::vector<gfx::Rect>& ready,
std::vector<pp::Rect>& pending) override; std::vector<gfx::Rect>& pending) override;
void PostPaint() override; void PostPaint() override;
bool HandleDocumentLoad(scoped_refptr<UrlLoader> loader) override; bool HandleDocumentLoad(scoped_refptr<UrlLoader> loader) override;
bool HandleEvent(const InputEvent& event) override; bool HandleEvent(const InputEvent& event) override;
...@@ -138,7 +137,7 @@ class PDFiumEngine : public PDFEngine, ...@@ -138,7 +137,7 @@ class PDFiumEngine : public PDFEngine,
int GetMostVisiblePage() override; int GetMostVisiblePage() override;
gfx::Rect GetPageBoundsRect(int index) override; gfx::Rect GetPageBoundsRect(int index) override;
gfx::Rect GetPageContentsRect(int index) override; gfx::Rect GetPageContentsRect(int index) override;
pp::Rect GetPageScreenRect(int page_index) const override; gfx::Rect GetPageScreenRect(int page_index) const override;
int GetVerticalScrollbarYPosition() override; int GetVerticalScrollbarYPosition() override;
void SetGrayscale(bool grayscale) override; void SetGrayscale(bool grayscale) override;
int GetCharCount(int page_index) override; int GetCharCount(int page_index) override;
...@@ -349,7 +348,7 @@ class PDFiumEngine : public PDFEngine, ...@@ -349,7 +348,7 @@ class PDFiumEngine : public PDFEngine,
size_t page_index, size_t page_index,
size_t num_of_pages, size_t num_of_pages,
double multiplier, double multiplier,
pp::Rect* rect) const; gfx::Rect& rect) const;
// If two-up view is enabled, returns the index of the page beside // If two-up view is enabled, returns the index of the page beside
// |page_index| page. Returns base::nullopt if there is no adjacent page or // |page_index| page. Returns base::nullopt if there is no adjacent page or
...@@ -434,7 +433,7 @@ class PDFiumEngine : public PDFEngine, ...@@ -434,7 +433,7 @@ class PDFiumEngine : public PDFEngine,
// Starts a progressive paint operation given a rectangle in screen // Starts a progressive paint operation given a rectangle in screen
// coordinates. Returns the index in progressive_rects_. // coordinates. Returns the index in progressive_rects_.
int StartPaint(int page_index, const pp::Rect& dirty); int StartPaint(int page_index, const gfx::Rect& dirty);
// Continues a paint operation that was started earlier. Returns true if the // Continues a paint operation that was started earlier. Returns true if the
// paint is done, or false if it needs to be continued. // paint is done, or false if it needs to be continued.
...@@ -462,7 +461,7 @@ class PDFiumEngine : public PDFEngine, ...@@ -462,7 +461,7 @@ class PDFiumEngine : public PDFEngine,
// Paints an page that hasn't finished downloading. // Paints an page that hasn't finished downloading.
void PaintUnavailablePage(int page_index, void PaintUnavailablePage(int page_index,
const pp::Rect& dirty, const gfx::Rect& dirty,
SkBitmap& image_data); SkBitmap& image_data);
// Given a page index, returns the corresponding index in progressive_rects_, // Given a page index, returns the corresponding index in progressive_rects_,
...@@ -470,13 +469,13 @@ class PDFiumEngine : public PDFEngine, ...@@ -470,13 +469,13 @@ class PDFiumEngine : public PDFEngine,
int GetProgressiveIndex(int page_index) const; int GetProgressiveIndex(int page_index) const;
// Creates a FPDF_BITMAP from a rectangle in screen coordinates. // Creates a FPDF_BITMAP from a rectangle in screen coordinates.
ScopedFPDFBitmap CreateBitmap(const pp::Rect& rect, ScopedFPDFBitmap CreateBitmap(const gfx::Rect& rect,
SkBitmap& image_data) const; SkBitmap& image_data) const;
// Given a rectangle in screen coordinates, returns the coordinates in the // Given a rectangle in screen coordinates, returns the coordinates in the
// units that PDFium rendering functions expect. // units that PDFium rendering functions expect.
void GetPDFiumRect(int page_index, void GetPDFiumRect(int page_index,
const pp::Rect& rect, const gfx::Rect& rect,
int* start_x, int* start_x,
int* start_y, int* start_y,
int* size_x, int* size_x,
...@@ -486,7 +485,7 @@ class PDFiumEngine : public PDFEngine, ...@@ -486,7 +485,7 @@ class PDFiumEngine : public PDFEngine,
int GetRenderingFlags() const; int GetRenderingFlags() const;
// Returns the currently visible rectangle in document coordinates. // Returns the currently visible rectangle in document coordinates.
pp::Rect GetVisibleRect() const; gfx::Rect GetVisibleRect() const;
// Given |rect| in document coordinates, returns the rectangle in screen // Given |rect| in document coordinates, returns the rectangle in screen
// coordinates. (i.e. 0,0 is top left corner of plugin area) // coordinates. (i.e. 0,0 is top left corner of plugin area)
...@@ -518,9 +517,9 @@ class PDFiumEngine : public PDFEngine, ...@@ -518,9 +517,9 @@ class PDFiumEngine : public PDFEngine,
// triggers as necessary. // triggers as necessary.
void SetCurrentPage(int index); void SetCurrentPage(int index);
void DrawPageShadow(const pp::Rect& page_rect, void DrawPageShadow(const gfx::Rect& page_rect,
const pp::Rect& shadow_rect, const gfx::Rect& shadow_rect,
const pp::Rect& clip_rect, const gfx::Rect& clip_rect,
SkBitmap& image_data); SkBitmap& image_data);
void GetRegion(const gfx::Point& location, void GetRegion(const gfx::Point& location,
...@@ -568,13 +567,13 @@ class PDFiumEngine : public PDFEngine, ...@@ -568,13 +567,13 @@ class PDFiumEngine : public PDFEngine,
unsigned int depth); unsigned int depth);
void ScrollBasedOnScrollAlignment( void ScrollBasedOnScrollAlignment(
const pp::Rect& scroll_rect, const gfx::Rect& scroll_rect,
const PP_PdfAccessibilityScrollAlignment& horizontal_scroll_alignment, const PP_PdfAccessibilityScrollAlignment& horizontal_scroll_alignment,
const PP_PdfAccessibilityScrollAlignment& vertical_scroll_alignment); const PP_PdfAccessibilityScrollAlignment& vertical_scroll_alignment);
// Scrolls top left of a rect in page |target_rect| to |global_point|. // Scrolls top left of a rect in page |target_rect| to |global_point|.
// Global point is point relative to viewport in screen. // Global point is point relative to viewport in screen.
void ScrollToGlobalPoint(const pp::Rect& target_rect, void ScrollToGlobalPoint(const gfx::Rect& target_rect,
const gfx::Point& global_point); const gfx::Point& global_point);
// Set if the document has any local edits. // Set if the document has any local edits.
...@@ -779,13 +778,13 @@ class PDFiumEngine : public PDFEngine, ...@@ -779,13 +778,13 @@ class PDFiumEngine : public PDFEngine,
// Pending progressive paints. // Pending progressive paints.
class ProgressivePaint { class ProgressivePaint {
public: public:
ProgressivePaint(int page_index, const pp::Rect& rect); ProgressivePaint(int page_index, const gfx::Rect& rect);
ProgressivePaint(ProgressivePaint&& that); ProgressivePaint(ProgressivePaint&& that);
ProgressivePaint& operator=(ProgressivePaint&& that); ProgressivePaint& operator=(ProgressivePaint&& that);
~ProgressivePaint(); ~ProgressivePaint();
int page_index() const { return page_index_; } int page_index() const { return page_index_; }
const pp::Rect& rect() const { return rect_; } const gfx::Rect& rect() const { return rect_; }
FPDF_BITMAP bitmap() const { return bitmap_.get(); } FPDF_BITMAP bitmap() const { return bitmap_.get(); }
bool painted() const { return painted_; } bool painted() const { return painted_; }
...@@ -794,7 +793,7 @@ class PDFiumEngine : public PDFEngine, ...@@ -794,7 +793,7 @@ class PDFiumEngine : public PDFEngine,
private: private:
int page_index_; int page_index_;
pp::Rect rect_; // In screen coordinates. gfx::Rect rect_; // In screen coordinates.
SkBitmap image_data_; // Maintains reference while |bitmap_| exists. SkBitmap image_data_; // Maintains reference while |bitmap_| exists.
ScopedFPDFBitmap bitmap_; // Must come after |image_data_|. ScopedFPDFBitmap bitmap_; // Must come after |image_data_|.
// Temporary used to figure out if in a series of Paint() calls whether this // Temporary used to figure out if in a series of Paint() calls whether this
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "pdf/pdfium/pdfium_engine.h" #include "pdf/pdfium/pdfium_engine.h"
#include "pdf/ppapi_migration/geometry_conversions.h"
#include "pdf/ppapi_migration/input_event_conversions.h" #include "pdf/ppapi_migration/input_event_conversions.h"
#include "third_party/pdfium/public/fpdf_annot.h" #include "third_party/pdfium/public/fpdf_annot.h"
#include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/rect.h"
...@@ -125,10 +124,9 @@ void PDFiumFormFiller::Form_Invalidate(FPDF_FORMFILLINFO* param, ...@@ -125,10 +124,9 @@ void PDFiumFormFiller::Form_Invalidate(FPDF_FORMFILLINFO* param,
} }
gfx::Rect rect = engine->pages_[page_index]->PageToScreen( gfx::Rect rect = engine->pages_[page_index]->PageToScreen(
PointFromPPPoint(engine->GetVisibleRect().point()), engine->current_zoom_, engine->GetVisibleRect().origin(), engine->current_zoom_, left, top,
left, top, right, bottom, right, bottom, engine->layout_.options().default_page_orientation());
engine->layout_.options().default_page_orientation()); engine->client_->Invalidate(rect);
engine->client_->Invalidate(PPRectFromRect(rect));
} }
// static // static
...@@ -145,9 +143,8 @@ void PDFiumFormFiller::Form_OutputSelectedRect(FPDF_FORMFILLINFO* param, ...@@ -145,9 +143,8 @@ void PDFiumFormFiller::Form_OutputSelectedRect(FPDF_FORMFILLINFO* param,
return; return;
} }
gfx::Rect rect = engine->pages_[page_index]->PageToScreen( gfx::Rect rect = engine->pages_[page_index]->PageToScreen(
PointFromPPPoint(engine->GetVisibleRect().point()), engine->current_zoom_, engine->GetVisibleRect().origin(), engine->current_zoom_, left, top,
left, top, right, bottom, right, bottom, engine->layout_.options().default_page_orientation());
engine->layout_.options().default_page_orientation());
if (rect.IsEmpty()) if (rect.IsEmpty())
return; return;
......
...@@ -24,7 +24,7 @@ void PreviewModeClient::ProposeDocumentLayout(const DocumentLayout& layout) { ...@@ -24,7 +24,7 @@ void PreviewModeClient::ProposeDocumentLayout(const DocumentLayout& layout) {
// occurs if and only if loading a non-PDF document with more than 1 page. // occurs if and only if loading a non-PDF document with more than 1 page.
} }
void PreviewModeClient::Invalidate(const pp::Rect& rect) { void PreviewModeClient::Invalidate(const gfx::Rect& rect) {
NOTREACHED(); NOTREACHED();
} }
......
...@@ -34,7 +34,7 @@ class PreviewModeClient : public PDFEngine::Client { ...@@ -34,7 +34,7 @@ class PreviewModeClient : public PDFEngine::Client {
// PDFEngine::Client implementation. // PDFEngine::Client implementation.
void ProposeDocumentLayout(const DocumentLayout& layout) override; void ProposeDocumentLayout(const DocumentLayout& layout) override;
void Invalidate(const pp::Rect& rect) override; void Invalidate(const gfx::Rect& rect) override;
void DidScroll(const gfx::Vector2d& offset) override; void DidScroll(const gfx::Vector2d& offset) override;
void ScrollToX(int x_in_screen_coords) override; void ScrollToX(int x_in_screen_coords) override;
void ScrollToY(int y_in_screen_coords, bool compensate_for_toolbar) override; void ScrollToY(int y_in_screen_coords, bool compensate_for_toolbar) override;
......
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