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 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
324 GetLocalizedString(PP_RESOURCESTRING_PDFLOADING)); | 324 GetLocalizedString(PP_RESOURCESTRING_PDFLOADING)); |
325 translated_strings.Set(kJSLoadFailedString, | 325 translated_strings.Set(kJSLoadFailedString, |
326 GetLocalizedString(PP_RESOURCESTRING_PDFLOAD_FAILED)); | 326 GetLocalizedString(PP_RESOURCESTRING_PDFLOAD_FAILED)); |
327 PostMessage(translated_strings); | 327 PostMessage(translated_strings); |
328 | 328 |
329 text_input_.reset(new pp::TextInput_Dev(this)); | 329 text_input_.reset(new pp::TextInput_Dev(this)); |
330 | 330 |
331 const char* stream_url = NULL; | 331 const char* stream_url = NULL; |
332 const char* original_url = NULL; | 332 const char* original_url = NULL; |
333 const char* headers = NULL; | 333 const char* headers = NULL; |
334 const char* isMaterial = NULL; | |
raymes
2015/01/29 05:26:32
is_material
Alexandre Carlton
2015/01/29 06:05:17
Done.
| |
334 for (uint32_t i = 0; i < argc; ++i) { | 335 for (uint32_t i = 0; i < argc; ++i) { |
335 if (strcmp(argn[i], "src") == 0) | 336 if (strcmp(argn[i], "src") == 0) |
336 original_url = argv[i]; | 337 original_url = argv[i]; |
337 else if (strcmp(argn[i], "stream-url") == 0) | 338 else if (strcmp(argn[i], "stream-url") == 0) |
338 stream_url = argv[i]; | 339 stream_url = argv[i]; |
339 else if (strcmp(argn[i], "headers") == 0) | 340 else if (strcmp(argn[i], "headers") == 0) |
340 headers = argv[i]; | 341 headers = argv[i]; |
342 else if (strcmp(argn[i], "is-material") == 0) | |
343 isMaterial = argv[i]; | |
raymes
2015/01/29 05:26:32
Can we just have a bool here? is_material = true
Alexandre Carlton
2015/01/29 06:05:17
Done.
| |
341 } | 344 } |
342 | 345 |
346 if (strcmp(isMaterial, "true") == 0) | |
raymes
2015/01/29 05:26:32
if (is_material)
Alexandre Carlton
2015/01/29 06:05:17
Done.
| |
347 engine_->SetBackgroundColor(kBackgroundColorMaterial); | |
348 | |
343 // TODO(raymes): This is a hack to ensure that if no headers are passed in | 349 // TODO(raymes): This is a hack to ensure that if no headers are passed in |
344 // then we get the right MIME type. When the in process plugin is removed we | 350 // then we get the right MIME type. When the in process plugin is removed we |
345 // can fix the document loader properly and remove this hack. | 351 // can fix the document loader properly and remove this hack. |
346 if (!headers || strcmp(headers, "") == 0) | 352 if (!headers || strcmp(headers, "") == 0) |
347 headers = "content-type: application/pdf"; | 353 headers = "content-type: application/pdf"; |
348 | 354 |
349 if (!original_url) | 355 if (!original_url) |
350 return false; | 356 return false; |
351 | 357 |
352 if (!stream_url) | 358 if (!stream_url) |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
655 const std::vector<pp::Rect>& paint_rects, | 661 const std::vector<pp::Rect>& paint_rects, |
656 std::vector<PaintManager::ReadyRect>* ready, | 662 std::vector<PaintManager::ReadyRect>* ready, |
657 std::vector<pp::Rect>* pending) { | 663 std::vector<pp::Rect>* pending) { |
658 if (image_data_.is_null()) { | 664 if (image_data_.is_null()) { |
659 DCHECK(plugin_size_.IsEmpty()); | 665 DCHECK(plugin_size_.IsEmpty()); |
660 return; | 666 return; |
661 } | 667 } |
662 if (first_paint_) { | 668 if (first_paint_) { |
663 first_paint_ = false; | 669 first_paint_ = false; |
664 pp::Rect rect = pp::Rect(pp::Point(), image_data_.size()); | 670 pp::Rect rect = pp::Rect(pp::Point(), image_data_.size()); |
665 FillRect(rect, kBackgroundColor); | 671 FillRect(rect, engine_->GetBackgroundColor()); |
666 ready->push_back(PaintManager::ReadyRect(rect, image_data_, true)); | 672 ready->push_back(PaintManager::ReadyRect(rect, image_data_, true)); |
667 } | 673 } |
668 | 674 |
669 if (!received_viewport_message_) | 675 if (!received_viewport_message_) |
670 return; | 676 return; |
671 | 677 |
672 engine_->PrePaint(); | 678 engine_->PrePaint(); |
673 | 679 |
674 for (size_t i = 0; i < paint_rects.size(); i++) { | 680 for (size_t i = 0; i < paint_rects.size(); i++) { |
675 // Intersect with plugin area since there could be pending invalidates from | 681 // Intersect with plugin area since there could be pending invalidates from |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
748 background_parts_.clear(); | 754 background_parts_.clear(); |
749 int left_width = available_area_.x(); | 755 int left_width = available_area_.x(); |
750 int right_start = available_area_.right(); | 756 int right_start = available_area_.right(); |
751 int right_width = abs(plugin_size_.width() - available_area_.right()); | 757 int right_width = abs(plugin_size_.width() - available_area_.right()); |
752 int bottom = std::min(available_area_.bottom(), plugin_size_.height()); | 758 int bottom = std::min(available_area_.bottom(), plugin_size_.height()); |
753 | 759 |
754 // Add the left, right, and bottom rectangles. Note: we assume only | 760 // Add the left, right, and bottom rectangles. Note: we assume only |
755 // horizontal centering. | 761 // horizontal centering. |
756 BackgroundPart part = { | 762 BackgroundPart part = { |
757 pp::Rect(0, 0, left_width, bottom), | 763 pp::Rect(0, 0, left_width, bottom), |
758 kBackgroundColor | 764 engine_->GetBackgroundColor() |
759 }; | 765 }; |
760 if (!part.location.IsEmpty()) | 766 if (!part.location.IsEmpty()) |
761 background_parts_.push_back(part); | 767 background_parts_.push_back(part); |
762 part.location = pp::Rect(right_start, 0, right_width, bottom); | 768 part.location = pp::Rect(right_start, 0, right_width, bottom); |
763 if (!part.location.IsEmpty()) | 769 if (!part.location.IsEmpty()) |
764 background_parts_.push_back(part); | 770 background_parts_.push_back(part); |
765 part.location = pp::Rect( | 771 part.location = pp::Rect( |
766 0, bottom, plugin_size_.width(), plugin_size_.height() - bottom); | 772 0, bottom, plugin_size_.width(), plugin_size_.height() - bottom); |
767 if (!part.location.IsEmpty()) | 773 if (!part.location.IsEmpty()) |
768 background_parts_.push_back(part); | 774 background_parts_.push_back(part); |
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1375 pp::FloatPoint OutOfProcessInstance::BoundScrollOffsetToDocument( | 1381 pp::FloatPoint OutOfProcessInstance::BoundScrollOffsetToDocument( |
1376 const pp::FloatPoint& scroll_offset) { | 1382 const pp::FloatPoint& scroll_offset) { |
1377 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); | 1383 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); |
1378 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); | 1384 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); |
1379 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); | 1385 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); |
1380 float y = std::max(std::min(scroll_offset.y(), max_y), 0.0f); | 1386 float y = std::max(std::min(scroll_offset.y(), max_y), 0.0f); |
1381 return pp::FloatPoint(x, y); | 1387 return pp::FloatPoint(x, y); |
1382 } | 1388 } |
1383 | 1389 |
1384 } // namespace chrome_pdf | 1390 } // namespace chrome_pdf |
OLD | NEW |