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 <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> // for min/max() | 10 #include <algorithm> // for min/max() |
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
740 pp::Module::Get()->core()->CallOnMainThread(kAccessibilityPageDelayMs, | 740 pp::Module::Get()->core()->CallOnMainThread(kAccessibilityPageDelayMs, |
741 callback, 0); | 741 callback, 0); |
742 } | 742 } |
743 | 743 |
744 void OutOfProcessInstance::SendNextAccessibilityPage(int32_t page_index) { | 744 void OutOfProcessInstance::SendNextAccessibilityPage(int32_t page_index) { |
745 int page_count = engine_->GetNumberOfPages(); | 745 int page_count = engine_->GetNumberOfPages(); |
746 if (page_index < 0 || page_index >= page_count) | 746 if (page_index < 0 || page_index >= page_count) |
747 return; | 747 return; |
748 | 748 |
749 int char_count = engine_->GetCharCount(page_index); | 749 int char_count = engine_->GetCharCount(page_index); |
| 750 |
| 751 // Treat a char count of -1 (error) as 0 (an empty page), since |
| 752 // other pages might have valid content. |
| 753 if (char_count < 0) |
| 754 char_count = 0; |
| 755 |
750 PP_PrivateAccessibilityPageInfo page_info; | 756 PP_PrivateAccessibilityPageInfo page_info; |
751 page_info.page_index = page_index; | 757 page_info.page_index = page_index; |
752 page_info.bounds = engine_->GetPageBoundsRect(page_index); | 758 page_info.bounds = engine_->GetPageBoundsRect(page_index); |
753 page_info.char_count = char_count; | 759 page_info.char_count = char_count; |
754 | 760 |
755 std::vector<PP_PrivateAccessibilityCharInfo> chars(page_info.char_count); | 761 std::vector<PP_PrivateAccessibilityCharInfo> chars(page_info.char_count); |
756 for (uint32_t i = 0; i < page_info.char_count; ++i) { | 762 for (uint32_t i = 0; i < page_info.char_count; ++i) { |
757 chars[i].unicode_character = engine_->GetCharUnicode(page_index, i); | 763 chars[i].unicode_character = engine_->GetCharUnicode(page_index, i); |
758 } | 764 } |
759 | 765 |
(...skipping 884 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1644 const pp::FloatPoint& scroll_offset) { | 1650 const pp::FloatPoint& scroll_offset) { |
1645 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); | 1651 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); |
1646 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); | 1652 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); |
1647 float min_y = -top_toolbar_height_; | 1653 float min_y = -top_toolbar_height_; |
1648 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); | 1654 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); |
1649 float y = std::max(std::min(scroll_offset.y(), max_y), min_y); | 1655 float y = std::max(std::min(scroll_offset.y(), max_y), min_y); |
1650 return pp::FloatPoint(x, y); | 1656 return pp::FloatPoint(x, y); |
1651 } | 1657 } |
1652 | 1658 |
1653 } // namespace chrome_pdf | 1659 } // namespace chrome_pdf |
OLD | NEW |