Commit 6dfdcd70 authored by Hui Yingst's avatar Hui Yingst Committed by Chromium LUCI CQ

Migrate some pp::Point/pp::Size to gfx::Point/gfx::Size in pdf/.

This CL migrates `plugin_size_`, `plugin_dip_size_` and `plugin_offset_`
in OutOfProcessInstance from using pp::Point/pp::Size to their gfx::
equivalents, so that they can be migrated into PdfViewPluginBase later.

Bug: 1101101
Change-Id: I5c36d6fcb99f9f4f92edeeb044fd6f2f04287565
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2616488Reviewed-by: default avatarK. Moon <kmoon@chromium.org>
Commit-Queue: Hui Yingst <nigi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#841673}
parent cf6852c4
...@@ -758,24 +758,24 @@ bool OutOfProcessInstance::HandleInputEvent(const pp::InputEvent& event) { ...@@ -758,24 +758,24 @@ bool OutOfProcessInstance::HandleInputEvent(const pp::InputEvent& event) {
} }
void OutOfProcessInstance::DidChangeView(const pp::View& view) { void OutOfProcessInstance::DidChangeView(const pp::View& view) {
pp::Rect view_rect(view.GetRect()); gfx::Rect view_rect = RectFromPPRect(view.GetRect());
float old_device_scale = device_scale(); float old_device_scale = device_scale();
float new_device_scale = view.GetDeviceScale(); float new_device_scale = view.GetDeviceScale();
pp::Size view_device_size(view_rect.width() * new_device_scale, gfx::Size view_device_size(view_rect.width() * new_device_scale,
view_rect.height() * new_device_scale); view_rect.height() * new_device_scale);
if (view_device_size != plugin_size_ || new_device_scale != device_scale() || if (view_device_size != plugin_size_ || new_device_scale != device_scale() ||
view_rect.point() != plugin_offset_) { view_rect.origin() != plugin_offset_) {
set_device_scale(new_device_scale); set_device_scale(new_device_scale);
plugin_dip_size_ = view_rect.size(); plugin_dip_size_ = view_rect.size();
plugin_size_ = view_device_size; plugin_size_ = view_device_size;
plugin_offset_ = view_rect.point(); plugin_offset_ = view_rect.origin();
paint_manager().SetSize(SizeFromPPSize(view_device_size), device_scale()); paint_manager().SetSize(view_device_size, device_scale());
const gfx::Size old_image_data_size = SizeFromPPSize(image_data_.size()); const gfx::Size old_image_data_size = SizeFromPPSize(image_data_.size());
gfx::Size new_image_data_size = PaintManager::GetNewContextSize( gfx::Size new_image_data_size =
old_image_data_size, SizeFromPPSize(plugin_size_)); PaintManager::GetNewContextSize(old_image_data_size, plugin_size_);
if (new_image_data_size != old_image_data_size) { if (new_image_data_size != old_image_data_size) {
image_data_ = pp::ImageData(this, PP_IMAGEDATAFORMAT_BGRA_PREMUL, image_data_ = pp::ImageData(this, PP_IMAGEDATAFORMAT_BGRA_PREMUL,
PPSizeFromSize(new_image_data_size), false); PPSizeFromSize(new_image_data_size), false);
...@@ -1133,8 +1133,7 @@ void OutOfProcessInstance::DoPaint(const std::vector<gfx::Rect>& paint_rects, ...@@ -1133,8 +1133,7 @@ void OutOfProcessInstance::DoPaint(const std::vector<gfx::Rect>& paint_rects,
for (const auto& paint_rect : paint_rects) { for (const auto& paint_rect : paint_rects) {
// Intersect with plugin area since there could be pending invalidates from // Intersect with plugin area since there could be pending invalidates from
// when the plugin area was larger. // when the plugin area was larger.
gfx::Rect rect = gfx::IntersectRects( gfx::Rect rect = gfx::IntersectRects(paint_rect, gfx::Rect(plugin_size_));
paint_rect, gfx::Rect(SizeFromPPSize(plugin_size_)));
if (rect.IsEmpty()) if (rect.IsEmpty())
continue; continue;
...@@ -1835,7 +1834,7 @@ void OutOfProcessInstance::HandleResetPrintPreviewModeMessage( ...@@ -1835,7 +1834,7 @@ void OutOfProcessInstance::HandleResetPrintPreviewModeMessage(
engine()->SetGrayscale(dict.Get(pp::Var(kJSPrintPreviewGrayscale)).AsBool()); engine()->SetGrayscale(dict.Get(pp::Var(kJSPrintPreviewGrayscale)).AsBool());
engine()->New(url_.c_str(), /*headers=*/nullptr); engine()->New(url_.c_str(), /*headers=*/nullptr);
paint_manager().InvalidateRect(gfx::Rect(SizeFromPPSize(plugin_size_))); paint_manager().InvalidateRect(gfx::Rect(plugin_size_));
} }
void OutOfProcessInstance::HandleSaveAttachmentMessage( void OutOfProcessInstance::HandleSaveAttachmentMessage(
...@@ -2092,7 +2091,7 @@ void OutOfProcessInstance::DocumentLoadFailed() { ...@@ -2092,7 +2091,7 @@ void OutOfProcessInstance::DocumentLoadFailed() {
} }
document_load_state_ = LOAD_STATE_FAILED; document_load_state_ = LOAD_STATE_FAILED;
paint_manager().InvalidateRect(gfx::Rect(SizeFromPPSize(plugin_size_))); paint_manager().InvalidateRect(gfx::Rect(plugin_size_));
// Send a progress value of -1 to indicate a failure. // Send a progress value of -1 to indicate a failure.
SendLoadingProgress(-1); SendLoadingProgress(-1);
...@@ -2183,7 +2182,7 @@ void OutOfProcessInstance::OnGeometryChanged(double old_zoom, ...@@ -2183,7 +2182,7 @@ void OutOfProcessInstance::OnGeometryChanged(double old_zoom,
if (zoom() != old_zoom || device_scale() != old_device_scale) if (zoom() != old_zoom || device_scale() != old_device_scale)
engine()->ZoomUpdated(zoom() * device_scale()); engine()->ZoomUpdated(zoom() * device_scale());
available_area_ = gfx::Rect(SizeFromPPSize(plugin_size_)); available_area_ = gfx::Rect(plugin_size_);
int doc_width = GetDocumentPixelWidth(); int doc_width = GetDocumentPixelWidth();
if (doc_width < available_area_.width()) { if (doc_width < available_area_.width()) {
available_area_.Offset((available_area_.width() - doc_width) / 2, 0); available_area_.Offset((available_area_.width() - doc_width) / 2, 0);
...@@ -2201,7 +2200,7 @@ void OutOfProcessInstance::OnGeometryChanged(double old_zoom, ...@@ -2201,7 +2200,7 @@ void OutOfProcessInstance::OnGeometryChanged(double old_zoom,
if (document_size().IsEmpty()) if (document_size().IsEmpty())
return; return;
paint_manager().InvalidateRect(gfx::Rect(SizeFromPPSize(plugin_size_))); paint_manager().InvalidateRect(gfx::Rect(plugin_size_));
if (accessibility_state_ == ACCESSIBILITY_STATE_LOADED) if (accessibility_state_ == ACCESSIBILITY_STATE_LOADED)
SendAccessibilityViewportInfo(); SendAccessibilityViewportInfo();
......
...@@ -348,14 +348,14 @@ class OutOfProcessInstance : public PdfViewPluginBase, ...@@ -348,14 +348,14 @@ class OutOfProcessInstance : public PdfViewPluginBase,
PP_CursorType_Dev cursor_ = PP_CURSORTYPE_POINTER; PP_CursorType_Dev cursor_ = PP_CURSORTYPE_POINTER;
// Size, in pixels, of plugin rectangle. // Size, in pixels, of plugin rectangle.
pp::Size plugin_size_; gfx::Size plugin_size_;
// Size, in DIPs, of plugin rectangle. // Size, in DIPs, of plugin rectangle.
pp::Size plugin_dip_size_; gfx::Size plugin_dip_size_;
// Remaining area, in pixels, to render the pdf in after accounting for // Remaining area, in pixels, to render the pdf in after accounting for
// horizontal centering. // horizontal centering.
gfx::Rect available_area_; gfx::Rect available_area_;
// Positional offset, in CSS pixels, of the plugin rectangle. // Positional offset, in CSS pixels, of the plugin rectangle.
pp::Point plugin_offset_; gfx::Point plugin_offset_;
// The scroll offset in CSS pixels. // The scroll offset in CSS pixels.
pp::Point scroll_offset_; pp::Point scroll_offset_;
......
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