OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "pdf/out_of_process_instance.h" | 5 #include "pdf/out_of_process_instance.h" |
6 | 6 |
7 #include <algorithm> // for min/max() | 7 #include <algorithm> // for min/max() |
8 #define _USE_MATH_DEFINES // for M_PI | 8 #define _USE_MATH_DEFINES // for M_PI |
9 #include <cmath> // for log() and pow() | 9 #include <cmath> // for log() and pow() |
10 #include <math.h> | 10 #include <math.h> |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 } | 280 } |
281 | 281 |
282 bool OutOfProcessInstance::Init(uint32_t argc, | 282 bool OutOfProcessInstance::Init(uint32_t argc, |
283 const char* argn[], | 283 const char* argn[], |
284 const char* argv[]) { | 284 const char* argv[]) { |
285 v8::StartupData natives; | 285 v8::StartupData natives; |
286 v8::StartupData snapshot; | 286 v8::StartupData snapshot; |
287 pp::PDF::GetV8ExternalSnapshotData(this, &natives.data, &natives.raw_size, | 287 pp::PDF::GetV8ExternalSnapshotData(this, &natives.data, &natives.raw_size, |
288 &snapshot.data, &snapshot.raw_size); | 288 &snapshot.data, &snapshot.raw_size); |
289 if (natives.data) { | 289 if (natives.data) { |
290 natives.compressed_size = natives.raw_size; | |
291 snapshot.compressed_size = snapshot.raw_size; | |
292 v8::V8::SetNativesDataBlob(&natives); | 290 v8::V8::SetNativesDataBlob(&natives); |
293 v8::V8::SetSnapshotDataBlob(&snapshot); | 291 v8::V8::SetSnapshotDataBlob(&snapshot); |
294 } | 292 } |
295 | 293 |
296 // Check if the PDF is being loaded in the PDF chrome extension. We only allow | 294 // Check if the PDF is being loaded in the PDF chrome extension. We only allow |
297 // the plugin to be put into "full frame" mode when it is being loaded in the | 295 // the plugin to be put into "full frame" mode when it is being loaded in the |
298 // extension because this enables some features that we don't want pages | 296 // extension because this enables some features that we don't want pages |
299 // abusing outside of the extension. | 297 // abusing outside of the extension. |
300 pp::Var document_url_var = pp::URLUtil_Dev::Get()->GetDocumentURL(this); | 298 pp::Var document_url_var = pp::URLUtil_Dev::Get()->GetDocumentURL(this); |
301 std::string document_url = document_url_var.is_string() ? | 299 std::string document_url = document_url_var.is_string() ? |
(...skipping 1096 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1398 pp::FloatPoint OutOfProcessInstance::BoundScrollOffsetToDocument( | 1396 pp::FloatPoint OutOfProcessInstance::BoundScrollOffsetToDocument( |
1399 const pp::FloatPoint& scroll_offset) { | 1397 const pp::FloatPoint& scroll_offset) { |
1400 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); | 1398 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); |
1401 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); | 1399 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); |
1402 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); | 1400 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); |
1403 float y = std::max(std::min(scroll_offset.y(), max_y), 0.0f); | 1401 float y = std::max(std::min(scroll_offset.y(), max_y), 0.0f); |
1404 return pp::FloatPoint(x, y); | 1402 return pp::FloatPoint(x, y); |
1405 } | 1403 } |
1406 | 1404 |
1407 } // namespace chrome_pdf | 1405 } // namespace chrome_pdf |
OLD | NEW |