Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(493)

Side by Side Diff: pdf/pdfium/pdfium_engine.cc

Issue 823523005: PDF: Fix missing character when selecting backwards (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Patch improvement. Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698