| 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 1845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1856 for (int i = selection_[last].page_index() + 1; i < page_index; ++i) { | 1856 for (int i = selection_[last].page_index() + 1; i < page_index; ++i) { |
| 1857 selection_.push_back(PDFiumRange(pages_[i], 0, | 1857 selection_.push_back(PDFiumRange(pages_[i], 0, |
| 1858 pages_[i]->GetCharCount())); | 1858 pages_[i]->GetCharCount())); |
| 1859 } | 1859 } |
| 1860 | 1860 |
| 1861 int count = pages_[selection_[last].page_index()]->GetCharCount(); | 1861 int count = pages_[selection_[last].page_index()]->GetCharCount(); |
| 1862 selection_[last].SetCharCount(count - selection_[last].char_index()); | 1862 selection_[last].SetCharCount(count - selection_[last].char_index()); |
| 1863 selection_.push_back(PDFiumRange(pages_[page_index], 0, char_index)); | 1863 selection_.push_back(PDFiumRange(pages_[page_index], 0, char_index)); |
| 1864 } else { | 1864 } else { |
| 1865 // Selecting into the previous page. | 1865 // Selecting into the previous page. |
| 1866 selection_[last].SetCharCount(-selection_[last].char_index()); | 1866 // The selection's char_index is 0-based, so the character count is one |
| 1867 // more than the index. The character count needs to be negative to |
| 1868 // indicate a backwards selection. |
| 1869 selection_[last].SetCharCount(-(selection_[last].char_index() + 1)); |
| 1867 | 1870 |
| 1868 // First make sure that there are no gaps in selection, i.e. if mousedown on | 1871 // First make sure that there are no gaps in selection, i.e. if mousedown on |
| 1869 // page three but we only get mousemove over page one, we want page two. | 1872 // page three but we only get mousemove over page one, we want page two. |
| 1870 for (int i = selection_[last].page_index() - 1; i > page_index; --i) { | 1873 for (int i = selection_[last].page_index() - 1; i > page_index; --i) { |
| 1871 selection_.push_back(PDFiumRange(pages_[i], 0, | 1874 selection_.push_back(PDFiumRange(pages_[i], 0, |
| 1872 pages_[i]->GetCharCount())); | 1875 pages_[i]->GetCharCount())); |
| 1873 } | 1876 } |
| 1874 | 1877 |
| 1875 int count = pages_[page_index]->GetCharCount(); | 1878 int count = pages_[page_index]->GetCharCount(); |
| 1876 selection_.push_back( | 1879 selection_.push_back( |
| (...skipping 2038 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3915 double* height) { | 3918 double* height) { |
| 3916 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL); | 3919 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL); |
| 3917 if (!doc) | 3920 if (!doc) |
| 3918 return false; | 3921 return false; |
| 3919 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; | 3922 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; |
| 3920 FPDF_CloseDocument(doc); | 3923 FPDF_CloseDocument(doc); |
| 3921 return success; | 3924 return success; |
| 3922 } | 3925 } |
| 3923 | 3926 |
| 3924 } // namespace chrome_pdf | 3927 } // namespace chrome_pdf |
| OLD | NEW |