Chromium Code Reviews| 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/pdfium/pdfium_engine.h" | 5 #include "pdf/pdfium/pdfium_engine.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 1611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1622 // Only one page but didn't start midway. | 1622 // Only one page but didn't start midway. |
| 1623 ((pages_.size() == 1 && last_character_index_to_search_ == -1) || | 1623 ((pages_.size() == 1 && last_character_index_to_search_ == -1) || |
| 1624 // Started midway, but only 1 page and we already looped around. | 1624 // Started midway, but only 1 page and we already looped around. |
| 1625 (pages_.size() == 1 && !first_search) || | 1625 (pages_.size() == 1 && !first_search) || |
| 1626 // Started midway, and we've just looped around. | 1626 // Started midway, and we've just looped around. |
| 1627 (pages_.size() > 1 && current_page == next_page_to_search_)); | 1627 (pages_.size() > 1 && current_page == next_page_to_search_)); |
| 1628 | 1628 |
| 1629 if (end_of_search) { | 1629 if (end_of_search) { |
| 1630 // Send the final notification. | 1630 // Send the final notification. |
| 1631 client_->NotifyNumberOfFindResultsChanged(find_results_.size(), true); | 1631 client_->NotifyNumberOfFindResultsChanged(find_results_.size(), true); |
| 1632 | |
| 1633 // Restore find result state when find is started after rotation. | |
| 1634 if (find_result_state_.find_index_ != -1) { | |
|
raymes
2014/09/24 03:57:50
It doesn't look like we need a new struct, it look
Nikhil
2014/09/29 08:22:11
Thanks, I've modified the code accordingly. Please
| |
| 1635 current_find_index_ = find_result_state_.find_index_ - 1; | |
| 1636 SelectFindResult(true); | |
| 1637 find_result_state_ = FindResultState(); | |
| 1638 } | |
| 1632 } else { | 1639 } else { |
| 1633 pp::CompletionCallback callback = | 1640 pp::CompletionCallback callback = |
| 1634 find_factory_.NewCallback(&PDFiumEngine::ContinueFind); | 1641 find_factory_.NewCallback(&PDFiumEngine::ContinueFind); |
| 1635 pp::Module::Get()->core()->CallOnMainThread( | 1642 pp::Module::Get()->core()->CallOnMainThread( |
| 1636 0, callback, case_sensitive ? 1 : 0); | 1643 0, callback, case_sensitive ? 1 : 0); |
| 1637 } | 1644 } |
| 1638 } | 1645 } |
| 1639 | 1646 |
| 1640 void PDFiumEngine::SearchUsingPDFium(const base::string16& term, | 1647 void PDFiumEngine::SearchUsingPDFium(const base::string16& term, |
| 1641 bool case_sensitive, | 1648 bool case_sensitive, |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1825 CancelPaints(); | 1832 CancelPaints(); |
| 1826 | 1833 |
| 1827 current_zoom_ = new_zoom_level; | 1834 current_zoom_ = new_zoom_level; |
| 1828 | 1835 |
| 1829 CalculateVisiblePages(); | 1836 CalculateVisiblePages(); |
| 1830 UpdateTickMarks(); | 1837 UpdateTickMarks(); |
| 1831 } | 1838 } |
| 1832 | 1839 |
| 1833 void PDFiumEngine::RotateClockwise() { | 1840 void PDFiumEngine::RotateClockwise() { |
| 1834 current_rotation_ = (current_rotation_ + 1) % 4; | 1841 current_rotation_ = (current_rotation_ + 1) % 4; |
| 1842 find_result_state_ = FindResultState(current_find_text_, current_find_index_); | |
| 1843 | |
| 1835 InvalidateAllPages(); | 1844 InvalidateAllPages(); |
| 1845 | |
| 1846 // Restore find state if needed. | |
|
raymes
2014/09/24 03:57:50
// Store the current find index so that we can res
Nikhil
2014/09/29 08:22:11
Done.
| |
| 1847 if (!find_result_state_.find_text_.empty()) | |
| 1848 StartFind(find_result_state_.find_text_.c_str(), false); | |
|
raymes
2014/09/22 05:16:45
I don't fully understand the find stuff but can we
Nikhil
2014/09/23 12:18:08
The problem that I faced earlier with this code fl
raymes
2014/09/24 03:57:50
Ah I see how StartFind is asynchronous now, thanks
Nikhil
2014/09/29 08:22:11
Acknowledged.
| |
| 1836 } | 1849 } |
| 1837 | 1850 |
| 1838 void PDFiumEngine::RotateCounterclockwise() { | 1851 void PDFiumEngine::RotateCounterclockwise() { |
| 1839 current_rotation_ = (current_rotation_ - 1) % 4; | 1852 current_rotation_ = (current_rotation_ - 1) % 4; |
| 1853 find_result_state_ = FindResultState(current_find_text_, current_find_index_); | |
| 1854 | |
| 1840 InvalidateAllPages(); | 1855 InvalidateAllPages(); |
| 1856 | |
| 1857 // Restore find state if needed. | |
| 1858 if (!find_result_state_.find_text_.empty()) | |
| 1859 StartFind(find_result_state_.find_text_.c_str(), false); | |
| 1841 } | 1860 } |
| 1842 | 1861 |
| 1843 void PDFiumEngine::InvalidateAllPages() { | 1862 void PDFiumEngine::InvalidateAllPages() { |
| 1844 selection_.clear(); | 1863 selection_.clear(); |
| 1845 find_results_.clear(); | 1864 find_results_.clear(); |
|
raymes
2014/09/24 03:57:50
These two lines and UpdateTickMarks() are already
Nikhil
2014/09/29 08:22:11
Done.
| |
| 1846 | 1865 |
| 1866 StopFind(); | |
|
raymes
2014/09/24 03:57:50
You might want to move this after CancelPaints() t
Nikhil
2014/09/29 08:22:11
Done.
| |
| 1847 CancelPaints(); | 1867 CancelPaints(); |
| 1848 LoadPageInfo(true); | 1868 LoadPageInfo(true); |
| 1849 UpdateTickMarks(); | 1869 UpdateTickMarks(); |
| 1850 client_->Invalidate(pp::Rect(plugin_size_)); | 1870 client_->Invalidate(pp::Rect(plugin_size_)); |
| 1851 } | 1871 } |
| 1852 | 1872 |
| 1853 std::string PDFiumEngine::GetSelectedText() { | 1873 std::string PDFiumEngine::GetSelectedText() { |
| 1854 base::string16 result; | 1874 base::string16 result; |
| 1855 for (size_t i = 0; i < selection_.size(); ++i) { | 1875 for (size_t i = 0; i < selection_.size(); ++i) { |
| 1856 if (i > 0 && | 1876 if (i > 0 && |
| (...skipping 1569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3426 double* height) { | 3446 double* height) { |
| 3427 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL); | 3447 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL); |
| 3428 if (!doc) | 3448 if (!doc) |
| 3429 return false; | 3449 return false; |
| 3430 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; | 3450 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; |
| 3431 FPDF_CloseDocument(doc); | 3451 FPDF_CloseDocument(doc); |
| 3432 return success; | 3452 return success; |
| 3433 } | 3453 } |
| 3434 | 3454 |
| 3435 } // namespace chrome_pdf | 3455 } // namespace chrome_pdf |
| OLD | NEW |