Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2637)

Unified Diff: pdf/out_of_process_instance.cc

Issue 685923002: Support non-integer scroll offsets being passed to the PDF plugin. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pdf/out_of_process_instance.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pdf/out_of_process_instance.cc
diff --git a/pdf/out_of_process_instance.cc b/pdf/out_of_process_instance.cc
index d627dc2d7974f90a164714e0ddd0ad568cae8aa9..6f1b23d372c5b804a5d67e1c35c698d477442cad 100644
--- a/pdf/out_of_process_instance.cc
+++ b/pdf/out_of_process_instance.cc
@@ -352,14 +352,14 @@ void OutOfProcessInstance::HandleMessage(const pp::Var& message) {
std::string type = dict.Get(kType).AsString();
if (type == kJSViewportType &&
- dict.Get(pp::Var(kJSXOffset)).is_int() &&
- dict.Get(pp::Var(kJSYOffset)).is_int() &&
+ dict.Get(pp::Var(kJSXOffset)).is_number() &&
+ dict.Get(pp::Var(kJSYOffset)).is_number() &&
dict.Get(pp::Var(kJSZoom)).is_number()) {
received_viewport_message_ = true;
stop_scrolling_ = false;
double zoom = dict.Get(pp::Var(kJSZoom)).AsDouble();
- pp::Point scroll_offset(dict.Get(pp::Var(kJSXOffset)).AsInt(),
- dict.Get(pp::Var(kJSYOffset)).AsInt());
+ pp::FloatPoint scroll_offset(dict.Get(pp::Var(kJSXOffset)).AsDouble(),
+ dict.Get(pp::Var(kJSYOffset)).AsDouble());
// Bound the input parameters.
zoom = std::max(kMinZoom, zoom);
@@ -530,10 +530,12 @@ void OutOfProcessInstance::DidChangeView(const pp::View& view) {
}
if (!stop_scrolling_) {
- pp::Point scroll_offset(
- BoundScrollOffsetToDocument(view.GetScrollOffset()));
- engine_->ScrolledToXPosition(scroll_offset.x() * device_scale_);
- engine_->ScrolledToYPosition(scroll_offset.y() * device_scale_);
+ pp::Point scroll_offset(view.GetScrollOffset());
+ pp::FloatPoint scroll_offset_float(scroll_offset.x(),
+ scroll_offset.y());
+ scroll_offset_float = BoundScrollOffsetToDocument(scroll_offset_float);
+ engine_->ScrolledToXPosition(scroll_offset_float.x() * device_scale_);
+ engine_->ScrolledToYPosition(scroll_offset_float.y() * device_scale_);
}
}
@@ -1357,13 +1359,13 @@ void OutOfProcessInstance::UserMetricsRecordAction(
pp::PDF::UserMetricsRecordAction(this, pp::Var(action));
}
-pp::Point OutOfProcessInstance::BoundScrollOffsetToDocument(
- const pp::Point& scroll_offset) {
- int max_x = document_size_.width() * zoom_ - plugin_dip_size_.width();
- int x = std::max(std::min(scroll_offset.x(), max_x), 0);
- int max_y = document_size_.height() * zoom_ - plugin_dip_size_.height();
- int y = std::max(std::min(scroll_offset.y(), max_y), 0);
- return pp::Point(x, y);
+pp::FloatPoint OutOfProcessInstance::BoundScrollOffsetToDocument(
+ const pp::FloatPoint& scroll_offset) {
+ float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width();
+ float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f);
+ float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height();
+ float y = std::max(std::min(scroll_offset.y(), max_y), 0.0f);
+ return pp::FloatPoint(x, y);
}
} // namespace chrome_pdf
« no previous file with comments | « pdf/out_of_process_instance.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698