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

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

Issue 1953053002: Add private PPAPI interfaces for PDFium accessibility. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address feedback and run git cl format Created 4 years, 6 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') | pdf/pdfium/pdfium_page.h » ('j') | 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 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 2252 matching lines...) Expand 10 before | Expand all | Expand 10 after
2263 return most_visible_page_; 2263 return most_visible_page_;
2264 } 2264 }
2265 2265
2266 pp::Rect PDFiumEngine::GetPageRect(int index) { 2266 pp::Rect PDFiumEngine::GetPageRect(int index) {
2267 pp::Rect rc(pages_[index]->rect()); 2267 pp::Rect rc(pages_[index]->rect());
2268 rc.Inset(-kPageShadowLeft, -kPageShadowTop, 2268 rc.Inset(-kPageShadowLeft, -kPageShadowTop,
2269 -kPageShadowRight, -kPageShadowBottom); 2269 -kPageShadowRight, -kPageShadowBottom);
2270 return rc; 2270 return rc;
2271 } 2271 }
2272 2272
2273 pp::Rect PDFiumEngine::GetPageBoundsRect(int index) {
2274 return pages_[index]->rect();
2275 }
2276
2273 pp::Rect PDFiumEngine::GetPageContentsRect(int index) { 2277 pp::Rect PDFiumEngine::GetPageContentsRect(int index) {
2274 return GetScreenRect(pages_[index]->rect()); 2278 return GetScreenRect(pages_[index]->rect());
2275 } 2279 }
2276 2280
2277 void PDFiumEngine::SetGrayscale(bool grayscale) { 2281 void PDFiumEngine::SetGrayscale(bool grayscale) {
2278 render_grayscale_ = grayscale; 2282 render_grayscale_ = grayscale;
2279 } 2283 }
2280 2284
2281 void PDFiumEngine::OnCallback(int id) { 2285 void PDFiumEngine::OnCallback(int id) {
2282 if (!timers_.count(id)) 2286 if (!timers_.count(id))
(...skipping 13 matching lines...) Expand all
2296 if (index < 0 || static_cast<size_t>(index) > pages_.size() - 1) 2300 if (index < 0 || static_cast<size_t>(index) > pages_.size() - 1)
2297 return "{}"; 2301 return "{}";
2298 2302
2299 std::unique_ptr<base::Value> node( 2303 std::unique_ptr<base::Value> node(
2300 pages_[index]->GetAccessibleContentAsValue(current_rotation_)); 2304 pages_[index]->GetAccessibleContentAsValue(current_rotation_));
2301 std::string page_json; 2305 std::string page_json;
2302 base::JSONWriter::Write(*node, &page_json); 2306 base::JSONWriter::Write(*node, &page_json);
2303 return page_json; 2307 return page_json;
2304 } 2308 }
2305 2309
2310 int PDFiumEngine::GetCharCount(int page_index) {
2311 DCHECK(page_index >= 0 && page_index < static_cast<int>(pages_.size()));
2312 return pages_[page_index]->GetCharCount();
2313 }
2314
2315 double PDFiumEngine::GetCharWidth(int page_index, int char_index) {
2316 DCHECK(page_index >= 0 && page_index < static_cast<int>(pages_.size()));
2317 return pages_[page_index]->GetCharWidth(char_index);
2318 }
2319
2320 uint32_t PDFiumEngine::GetCharUnicode(int page_index, int char_index) {
2321 DCHECK(page_index >= 0 && page_index < static_cast<int>(pages_.size()));
2322 return pages_[page_index]->GetCharUnicode(char_index);
2323 }
2324
2325 void PDFiumEngine::GetTextRunInfo(int page_index,
2326 int start_char_index,
2327 uint32_t* out_len,
2328 double* out_font_size,
2329 pp::FloatRect* out_bounds) {
2330 DCHECK(page_index >= 0 && page_index < static_cast<int>(pages_.size()));
2331 return pages_[page_index]->GetTextRunInfo(start_char_index, out_len,
2332 out_font_size, out_bounds);
2333 }
2334
2306 bool PDFiumEngine::GetPrintScaling() { 2335 bool PDFiumEngine::GetPrintScaling() {
2307 return !!FPDF_VIEWERREF_GetPrintScaling(doc_); 2336 return !!FPDF_VIEWERREF_GetPrintScaling(doc_);
2308 } 2337 }
2309 2338
2310 int PDFiumEngine::GetCopiesToPrint() { 2339 int PDFiumEngine::GetCopiesToPrint() {
2311 return FPDF_VIEWERREF_GetNumCopies(doc_); 2340 return FPDF_VIEWERREF_GetNumCopies(doc_);
2312 } 2341 }
2313 2342
2314 int PDFiumEngine::GetDuplexType() { 2343 int PDFiumEngine::GetDuplexType() {
2315 return static_cast<int>(FPDF_VIEWERREF_GetDuplex(doc_)); 2344 return static_cast<int>(FPDF_VIEWERREF_GetDuplex(doc_));
(...skipping 1554 matching lines...) Expand 10 before | Expand all | Expand 10 after
3870 FPDF_DOCUMENT doc = 3899 FPDF_DOCUMENT doc =
3871 FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, nullptr); 3900 FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, nullptr);
3872 if (!doc) 3901 if (!doc)
3873 return false; 3902 return false;
3874 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; 3903 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0;
3875 FPDF_CloseDocument(doc); 3904 FPDF_CloseDocument(doc);
3876 return success; 3905 return success;
3877 } 3906 }
3878 3907
3879 } // namespace chrome_pdf 3908 } // namespace chrome_pdf
OLDNEW
« no previous file with comments | « pdf/pdfium/pdfium_engine.h ('k') | pdf/pdfium/pdfium_page.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698