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 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 // As char_index starts from 0 so char count should be set one more than |
|
Lei Zhang
2015/01/16 07:01:23
I would write this as:
The selection's char_index
Deepak
2015/01/16 07:10:39
Done.
| |
| 1867 // char_index. | |
| 1868 selection_[last].SetCharCount(-(selection_[last].char_index() + 1)); | |
| 1867 | 1869 |
| 1868 // First make sure that there are no gaps in selection, i.e. if mousedown on | 1870 // 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. | 1871 // 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) { | 1872 for (int i = selection_[last].page_index() - 1; i > page_index; --i) { |
| 1871 selection_.push_back(PDFiumRange(pages_[i], 0, | 1873 selection_.push_back(PDFiumRange(pages_[i], 0, |
| 1872 pages_[i]->GetCharCount())); | 1874 pages_[i]->GetCharCount())); |
| 1873 } | 1875 } |
| 1874 | 1876 |
| 1875 int count = pages_[page_index]->GetCharCount(); | 1877 int count = pages_[page_index]->GetCharCount(); |
| 1876 selection_.push_back( | 1878 selection_.push_back( |
| (...skipping 2038 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3915 double* height) { | 3917 double* height) { |
| 3916 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL); | 3918 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL); |
| 3917 if (!doc) | 3919 if (!doc) |
| 3918 return false; | 3920 return false; |
| 3919 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; | 3921 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; |
| 3920 FPDF_CloseDocument(doc); | 3922 FPDF_CloseDocument(doc); |
| 3921 return success; | 3923 return success; |
| 3922 } | 3924 } |
| 3923 | 3925 |
| 3924 } // namespace chrome_pdf | 3926 } // namespace chrome_pdf |
| OLD | NEW |