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

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

Issue 1255403002: Add a scroll offset to PDF documents to account for the top material design toolbar. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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 | « pdf/pdfium/pdfium_engine.h ('k') | 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/i18n/icu_encoding_detection.h" 9 #include "base/i18n/icu_encoding_detection.h"
10 #include "base/i18n/icu_string_conversions.h" 10 #include "base/i18n/icu_string_conversions.h"
(...skipping 1053 matching lines...) Expand 10 before | Expand all | Expand 10 after
1064 // Convert the current page's rectangle to screen rectangle. We do this 1064 // Convert the current page's rectangle to screen rectangle. We do this
1065 // instead of the reverse (converting the dirty rectangle from screen to 1065 // instead of the reverse (converting the dirty rectangle from screen to
1066 // page coordinates) because then we'd have to convert back to screen 1066 // page coordinates) because then we'd have to convert back to screen
1067 // coordinates, and the rounding errors sometime leave pixels dirty or even 1067 // coordinates, and the rounding errors sometime leave pixels dirty or even
1068 // move the text up or down a pixel when zoomed. 1068 // move the text up or down a pixel when zoomed.
1069 pp::Rect page_rect_in_screen = GetPageScreenRect(index); 1069 pp::Rect page_rect_in_screen = GetPageScreenRect(index);
1070 pp::Rect dirty_in_screen = page_rect_in_screen.Intersect(leftover); 1070 pp::Rect dirty_in_screen = page_rect_in_screen.Intersect(leftover);
1071 if (dirty_in_screen.IsEmpty()) 1071 if (dirty_in_screen.IsEmpty())
1072 continue; 1072 continue;
1073 1073
1074 // Compute the leftover dirty region. The first page may have blank space
1075 // above it, in which case we also need to subtract that space from the
1076 // dirty region.
1077 if (i == 0) {
1078 pp::Rect blank_space_in_screen = dirty_in_screen;
1079 blank_space_in_screen.set_y(0);
1080 blank_space_in_screen.set_height(dirty_in_screen.y());
1081 leftover = leftover.Subtract(blank_space_in_screen);
1082 }
1074 leftover = leftover.Subtract(dirty_in_screen); 1083 leftover = leftover.Subtract(dirty_in_screen);
1075 1084
1076 if (pages_[index]->available()) { 1085 if (pages_[index]->available()) {
1077 int progressive = GetProgressiveIndex(index); 1086 int progressive = GetProgressiveIndex(index);
1078 if (progressive != -1) { 1087 if (progressive != -1) {
1079 DCHECK_GE(progressive, 0); 1088 DCHECK_GE(progressive, 0);
1080 DCHECK_LT(static_cast<size_t>(progressive), progressive_paints_.size()); 1089 DCHECK_LT(static_cast<size_t>(progressive), progressive_paints_.size());
1081 if (progressive_paints_[progressive].rect != dirty_in_screen) { 1090 if (progressive_paints_[progressive].rect != dirty_in_screen) {
1082 // The PDFium code can only handle one progressive paint at a time, so 1091 // The PDFium code can only handle one progressive paint at a time, so
1083 // queue this up. Previously we used to merge the rects when this 1092 // queue this up. Previously we used to merge the rects when this
(...skipping 2959 matching lines...) Expand 10 before | Expand all | Expand 10 after
4043 double* height) { 4052 double* height) {
4044 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL); 4053 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL);
4045 if (!doc) 4054 if (!doc)
4046 return false; 4055 return false;
4047 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; 4056 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0;
4048 FPDF_CloseDocument(doc); 4057 FPDF_CloseDocument(doc);
4049 return success; 4058 return success;
4050 } 4059 }
4051 4060
4052 } // namespace chrome_pdf 4061 } // namespace chrome_pdf
OLDNEW
« no previous file with comments | « pdf/pdfium/pdfium_engine.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698