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

Side by Side Diff: pdf/out_of_process_instance.cc

Issue 2371483002: Update PDF accessibility when zoom level changes (Closed)
Patch Set: Renamed PDF -> Plugin in content/renderer/ Created 4 years, 2 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/out_of_process_instance.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/out_of_process_instance.h" 5 #include "pdf/out_of_process_instance.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> // for min/max() 10 #include <algorithm> // for min/max()
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 engine_->HasPermission(PDFEngine::PERMISSION_COPY)); 619 engine_->HasPermission(PDFEngine::PERMISSION_COPY));
620 620
621 pp::PDF::SetAccessibilityDocInfo(GetPluginInstance(), &doc_info); 621 pp::PDF::SetAccessibilityDocInfo(GetPluginInstance(), &doc_info);
622 622
623 // If the document contents isn't accessible, don't send anything more. 623 // If the document contents isn't accessible, don't send anything more.
624 if (!(engine_->HasPermission(PDFEngine::PERMISSION_COPY) || 624 if (!(engine_->HasPermission(PDFEngine::PERMISSION_COPY) ||
625 engine_->HasPermission(PDFEngine::PERMISSION_COPY_ACCESSIBLE))) { 625 engine_->HasPermission(PDFEngine::PERMISSION_COPY_ACCESSIBLE))) {
626 return; 626 return;
627 } 627 }
628 628
629 PP_PrivateAccessibilityViewportInfo viewport_info; 629 SendAccessibilityViewportInfo();
630 viewport_info.scroll.x = 0;
631 viewport_info.scroll.y = -top_toolbar_height_ * device_scale_;
632 viewport_info.offset = available_area_.point();
633 viewport_info.zoom = zoom_ * device_scale_;
634 pp::PDF::SetAccessibilityViewportInfo(GetPluginInstance(), &viewport_info);
635 630
636 // Schedule loading the first page. 631 // Schedule loading the first page.
637 pp::CompletionCallback callback = timer_factory_.NewCallback( 632 pp::CompletionCallback callback = timer_factory_.NewCallback(
638 &OutOfProcessInstance::SendNextAccessibilityPage); 633 &OutOfProcessInstance::SendNextAccessibilityPage);
639 pp::Module::Get()->core()->CallOnMainThread(kAccessibilityPageDelayMs, 634 pp::Module::Get()->core()->CallOnMainThread(kAccessibilityPageDelayMs,
640 callback, 0); 635 callback, 0);
641 } 636 }
642 637
643 void OutOfProcessInstance::SendNextAccessibilityPage(int32_t page_index) { 638 void OutOfProcessInstance::SendNextAccessibilityPage(int32_t page_index) {
644 int page_count = engine_->GetNumberOfPages(); 639 int page_count = engine_->GetNumberOfPages();
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 pp::PDF::SetAccessibilityPageInfo(GetPluginInstance(), &page_info, 689 pp::PDF::SetAccessibilityPageInfo(GetPluginInstance(), &page_info,
695 text_runs.data(), chars.data()); 690 text_runs.data(), chars.data());
696 691
697 // Schedule loading the next page. 692 // Schedule loading the next page.
698 pp::CompletionCallback callback = timer_factory_.NewCallback( 693 pp::CompletionCallback callback = timer_factory_.NewCallback(
699 &OutOfProcessInstance::SendNextAccessibilityPage); 694 &OutOfProcessInstance::SendNextAccessibilityPage);
700 pp::Module::Get()->core()->CallOnMainThread(kAccessibilityPageDelayMs, 695 pp::Module::Get()->core()->CallOnMainThread(kAccessibilityPageDelayMs,
701 callback, page_index + 1); 696 callback, page_index + 1);
702 } 697 }
703 698
699 void OutOfProcessInstance::SendAccessibilityViewportInfo() {
700 PP_PrivateAccessibilityViewportInfo viewport_info;
701 viewport_info.scroll.x = 0;
702 viewport_info.scroll.y = -top_toolbar_height_ * device_scale_;
703 viewport_info.offset = available_area_.point();
704 viewport_info.zoom = zoom_ * device_scale_;
705 pp::PDF::SetAccessibilityViewportInfo(GetPluginInstance(), &viewport_info);
706 }
707
704 pp::Var OutOfProcessInstance::GetLinkAtPosition( 708 pp::Var OutOfProcessInstance::GetLinkAtPosition(
705 const pp::Point& point) { 709 const pp::Point& point) {
706 pp::Point offset_point(point); 710 pp::Point offset_point(point);
707 ScalePoint(device_scale_, &offset_point); 711 ScalePoint(device_scale_, &offset_point);
708 offset_point.set_x(offset_point.x() - available_area_.x()); 712 offset_point.set_x(offset_point.x() - available_area_.x());
709 return engine_->GetLinkAtPosition(offset_point); 713 return engine_->GetLinkAtPosition(offset_point);
710 } 714 }
711 715
712 uint32_t OutOfProcessInstance::QuerySupportedPrintOutputFormats() { 716 uint32_t OutOfProcessInstance::QuerySupportedPrintOutputFormats() {
713 return engine_->QuerySupportedPrintOutputFormats(); 717 return engine_->QuerySupportedPrintOutputFormats();
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after
1411 if (bottom_of_document < available_area_.height()) 1415 if (bottom_of_document < available_area_.height())
1412 available_area_.set_height(bottom_of_document); 1416 available_area_.set_height(bottom_of_document);
1413 1417
1414 CalculateBackgroundParts(); 1418 CalculateBackgroundParts();
1415 engine_->PageOffsetUpdated(available_area_.point()); 1419 engine_->PageOffsetUpdated(available_area_.point());
1416 engine_->PluginSizeUpdated(available_area_.size()); 1420 engine_->PluginSizeUpdated(available_area_.size());
1417 1421
1418 if (document_size_.IsEmpty()) 1422 if (document_size_.IsEmpty())
1419 return; 1423 return;
1420 paint_manager_.InvalidateRect(pp::Rect(pp::Point(), plugin_size_)); 1424 paint_manager_.InvalidateRect(pp::Rect(pp::Point(), plugin_size_));
1425
1426 if (accessibility_state_ == ACCESSIBILITY_STATE_LOADED)
1427 SendAccessibilityViewportInfo();
1421 } 1428 }
1422 1429
1423 void OutOfProcessInstance::LoadUrl(const std::string& url) { 1430 void OutOfProcessInstance::LoadUrl(const std::string& url) {
1424 LoadUrlInternal(url, &embed_loader_, &OutOfProcessInstance::DidOpen); 1431 LoadUrlInternal(url, &embed_loader_, &OutOfProcessInstance::DidOpen);
1425 } 1432 }
1426 1433
1427 void OutOfProcessInstance::LoadPreviewUrl(const std::string& url) { 1434 void OutOfProcessInstance::LoadPreviewUrl(const std::string& url) {
1428 LoadUrlInternal(url, &embed_preview_loader_, 1435 LoadUrlInternal(url, &embed_preview_loader_,
1429 &OutOfProcessInstance::DidOpenPreview); 1436 &OutOfProcessInstance::DidOpenPreview);
1430 } 1437 }
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
1527 const pp::FloatPoint& scroll_offset) { 1534 const pp::FloatPoint& scroll_offset) {
1528 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); 1535 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width();
1529 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); 1536 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f);
1530 float min_y = -top_toolbar_height_; 1537 float min_y = -top_toolbar_height_;
1531 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); 1538 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height();
1532 float y = std::max(std::min(scroll_offset.y(), max_y), min_y); 1539 float y = std::max(std::min(scroll_offset.y(), max_y), min_y);
1533 return pp::FloatPoint(x, y); 1540 return pp::FloatPoint(x, y);
1534 } 1541 }
1535 1542
1536 } // namespace chrome_pdf 1543 } // namespace chrome_pdf
OLDNEW
« no previous file with comments | « pdf/out_of_process_instance.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698