| 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 1665 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1676     OnSingleClick(page_index, char_index); | 1676     OnSingleClick(page_index, char_index); | 
| 1677   } else if (event.GetClickCount() == 2 || | 1677   } else if (event.GetClickCount() == 2 || | 
| 1678              event.GetClickCount() == 3) { | 1678              event.GetClickCount() == 3) { | 
| 1679     OnMultipleClick(event.GetClickCount(), page_index, char_index); | 1679     OnMultipleClick(event.GetClickCount(), page_index, char_index); | 
| 1680   } | 1680   } | 
| 1681 | 1681 | 
| 1682   return true; | 1682   return true; | 
| 1683 } | 1683 } | 
| 1684 | 1684 | 
| 1685 void PDFiumEngine::OnSingleClick(int page_index, int char_index) { | 1685 void PDFiumEngine::OnSingleClick(int page_index, int char_index) { | 
| 1686   selecting_ = true; | 1686   SetSelecting(true); | 
| 1687   selection_.push_back(PDFiumRange(pages_[page_index], char_index, 0)); | 1687   selection_.push_back(PDFiumRange(pages_[page_index], char_index, 0)); | 
| 1688 } | 1688 } | 
| 1689 | 1689 | 
| 1690 void PDFiumEngine::OnMultipleClick(int click_count, | 1690 void PDFiumEngine::OnMultipleClick(int click_count, | 
| 1691                                    int page_index, | 1691                                    int page_index, | 
| 1692                                    int char_index) { | 1692                                    int char_index) { | 
| 1693   // It would be more efficient if the SDK could support finding a space, but | 1693   // It would be more efficient if the SDK could support finding a space, but | 
| 1694   // now it doesn't. | 1694   // now it doesn't. | 
| 1695   int start_index = char_index; | 1695   int start_index = char_index; | 
| 1696   do { | 1696   do { | 
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1739     double page_x, page_y; | 1739     double page_x, page_y; | 
| 1740     pp::Point point = event.GetPosition(); | 1740     pp::Point point = event.GetPosition(); | 
| 1741     DeviceToPage(page_index, point.x(), point.y(), &page_x, &page_y); | 1741     DeviceToPage(page_index, point.x(), point.y(), &page_x, &page_y); | 
| 1742     FORM_OnLButtonUp( | 1742     FORM_OnLButtonUp( | 
| 1743         form_, pages_[page_index]->GetPage(), 0, page_x, page_y); | 1743         form_, pages_[page_index]->GetPage(), 0, page_x, page_y); | 
| 1744   } | 1744   } | 
| 1745 | 1745 | 
| 1746   if (!selecting_) | 1746   if (!selecting_) | 
| 1747     return false; | 1747     return false; | 
| 1748 | 1748 | 
| 1749   selecting_ = false; | 1749   SetSelecting(false); | 
| 1750   return true; | 1750   return true; | 
| 1751 } | 1751 } | 
| 1752 | 1752 | 
| 1753 bool PDFiumEngine::OnMouseMove(const pp::MouseInputEvent& event) { | 1753 bool PDFiumEngine::OnMouseMove(const pp::MouseInputEvent& event) { | 
| 1754   int page_index = -1; | 1754   int page_index = -1; | 
| 1755   int char_index = -1; | 1755   int char_index = -1; | 
| 1756   PDFiumPage::LinkTarget target; | 1756   PDFiumPage::LinkTarget target; | 
| 1757   PDFiumPage::Area area = | 1757   PDFiumPage::Area area = | 
| 1758       GetCharIndex(event, &page_index, &char_index, &target); | 1758       GetCharIndex(event, &page_index, &char_index, &target); | 
| 1759 | 1759 | 
| (...skipping 1601 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3361 | 3361 | 
| 3362   InvalidateAllPages(); | 3362   InvalidateAllPages(); | 
| 3363 | 3363 | 
| 3364   if (!current_find_text.empty()) { | 3364   if (!current_find_text.empty()) { | 
| 3365     // Clear the UI. | 3365     // Clear the UI. | 
| 3366     client_->NotifyNumberOfFindResultsChanged(0, false); | 3366     client_->NotifyNumberOfFindResultsChanged(0, false); | 
| 3367     StartFind(current_find_text.c_str(), false); | 3367     StartFind(current_find_text.c_str(), false); | 
| 3368   } | 3368   } | 
| 3369 } | 3369 } | 
| 3370 | 3370 | 
|  | 3371 void PDFiumEngine::SetSelecting(bool selecting) { | 
|  | 3372   bool was_selecting = selecting_; | 
|  | 3373   selecting_ = selecting; | 
|  | 3374   if (selecting_ != was_selecting) | 
|  | 3375     engine->client_->IsSelectingChanged(selecting); | 
|  | 3376 } | 
|  | 3377 | 
| 3371 void PDFiumEngine::Form_Invalidate(FPDF_FORMFILLINFO* param, | 3378 void PDFiumEngine::Form_Invalidate(FPDF_FORMFILLINFO* param, | 
| 3372                                    FPDF_PAGE page, | 3379                                    FPDF_PAGE page, | 
| 3373                                    double left, | 3380                                    double left, | 
| 3374                                    double top, | 3381                                    double top, | 
| 3375                                    double right, | 3382                                    double right, | 
| 3376                                    double bottom) { | 3383                                    double bottom) { | 
| 3377   PDFiumEngine* engine = static_cast<PDFiumEngine*>(param); | 3384   PDFiumEngine* engine = static_cast<PDFiumEngine*>(param); | 
| 3378   int page_index = engine->GetVisiblePageIndex(page); | 3385   int page_index = engine->GetVisiblePageIndex(page); | 
| 3379   if (page_index == -1) { | 3386   if (page_index == -1) { | 
| 3380     // This can sometime happen when the page is closed because it went off | 3387     // This can sometime happen when the page is closed because it went off | 
| (...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3916     double* height) { | 3923     double* height) { | 
| 3917   FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL); | 3924   FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL); | 
| 3918   if (!doc) | 3925   if (!doc) | 
| 3919     return false; | 3926     return false; | 
| 3920   bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; | 3927   bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; | 
| 3921   FPDF_CloseDocument(doc); | 3928   FPDF_CloseDocument(doc); | 
| 3922   return success; | 3929   return success; | 
| 3923 } | 3930 } | 
| 3924 | 3931 | 
| 3925 }  // namespace chrome_pdf | 3932 }  // namespace chrome_pdf | 
| OLD | NEW | 
|---|