Commit 9bf2f55a authored by Dominic Mazzoni's avatar Dominic Mazzoni Committed by Commit Bot

Pass the accessibility tree to the composited PDF document only.

PrintCompositorImpl generates a PDF for each individual page and
then a single composite PDF. The previous patch mistakenly passed
the accessibility tree to the individual page PDFs, which aren't
ultimately exported. Pass the accessibility tree to the composite
PDF document instead.

The accessibility tree isn't available when DocumentInfo is created,
so instead we now create the SkPDFDocument before compositing the
first page rather than in the DocumentInfo constructor.

Bug: 607777
Change-Id: I2164f94b81aa858f542b1df9012896338b507361
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2063897Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Commit-Queue: Dominic Mazzoni <dmazzoni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#744196}
parent b8d675ca
...@@ -181,7 +181,7 @@ void PrintCompositorImpl::CompositeDocumentToPdf( ...@@ -181,7 +181,7 @@ void PrintCompositorImpl::CompositeDocumentToPdf(
void PrintCompositorImpl::PrepareForDocumentToPdf( void PrintCompositorImpl::PrepareForDocumentToPdf(
mojom::PrintCompositor::PrepareForDocumentToPdfCallback callback) { mojom::PrintCompositor::PrepareForDocumentToPdfCallback callback) {
DCHECK(!docinfo_); DCHECK(!docinfo_);
docinfo_ = std::make_unique<DocumentInfo>(creator_); docinfo_ = std::make_unique<DocumentInfo>();
std::move(callback).Run(mojom::PrintCompositor::Status::kSuccess); std::move(callback).Run(mojom::PrintCompositor::Status::kSuccess);
} }
...@@ -192,6 +192,12 @@ void PrintCompositorImpl::CompleteDocumentToPdf( ...@@ -192,6 +192,12 @@ void PrintCompositorImpl::CompleteDocumentToPdf(
DCHECK_GT(page_count, 0U); DCHECK_GT(page_count, 0U);
docinfo_->page_count = page_count; docinfo_->page_count = page_count;
docinfo_->callback = std::move(callback); docinfo_->callback = std::move(callback);
if (!docinfo_->doc) {
docinfo_->doc = MakePdfDocument(creator_, accessibility_tree_,
&docinfo_->compositor_stream);
}
HandleDocumentCompletionRequest(); HandleDocumentCompletionRequest();
} }
...@@ -345,14 +351,20 @@ mojom::PrintCompositor::Status PrintCompositorImpl::CompositeToPdf( ...@@ -345,14 +351,20 @@ mojom::PrintCompositor::Status PrintCompositorImpl::CompositeToPdf(
SkDynamicMemoryWStream wstream; SkDynamicMemoryWStream wstream;
sk_sp<SkDocument> doc = sk_sp<SkDocument> doc =
MakePdfDocument(creator_, accessibility_tree_, &wstream); MakePdfDocument(creator_, ui::AXTreeUpdate(), &wstream);
for (const auto& page : pages) { for (const auto& page : pages) {
SkCanvas* canvas = doc->beginPage(page.fSize.width(), page.fSize.height()); SkCanvas* canvas = doc->beginPage(page.fSize.width(), page.fSize.height());
canvas->drawPicture(page.fPicture); canvas->drawPicture(page.fPicture);
doc->endPage(); doc->endPage();
if (docinfo_) { if (docinfo_) {
// Also collect this page into document PDF. // Create document PDF if needed.
if (!docinfo_->doc) {
docinfo_->doc = MakePdfDocument(creator_, accessibility_tree_,
&docinfo_->compositor_stream);
}
// Collect this page into document PDF.
SkCanvas* canvas_doc = SkCanvas* canvas_doc =
docinfo_->doc->beginPage(page.fSize.width(), page.fSize.height()); docinfo_->doc->beginPage(page.fSize.width(), page.fSize.height());
canvas_doc->drawPicture(page.fPicture); canvas_doc->drawPicture(page.fPicture);
...@@ -455,8 +467,7 @@ PrintCompositorImpl::FrameInfo::FrameInfo() = default; ...@@ -455,8 +467,7 @@ PrintCompositorImpl::FrameInfo::FrameInfo() = default;
PrintCompositorImpl::FrameInfo::~FrameInfo() = default; PrintCompositorImpl::FrameInfo::~FrameInfo() = default;
PrintCompositorImpl::DocumentInfo::DocumentInfo(const std::string& creator) PrintCompositorImpl::DocumentInfo::DocumentInfo() = default;
: doc(MakePdfDocument(creator, ui::AXTreeUpdate(), &compositor_stream)) {}
PrintCompositorImpl::DocumentInfo::~DocumentInfo() = default; PrintCompositorImpl::DocumentInfo::~DocumentInfo() = default;
......
...@@ -176,9 +176,7 @@ class PrintCompositorImpl : public mojom::PrintCompositor { ...@@ -176,9 +176,7 @@ class PrintCompositorImpl : public mojom::PrintCompositor {
// Stores the concurrent document composition information. // Stores the concurrent document composition information.
struct DocumentInfo { struct DocumentInfo {
// Create the DocumentInfo object, which also creates a corresponding Skia DocumentInfo();
// document object.
explicit DocumentInfo(const std::string& creator);
~DocumentInfo(); ~DocumentInfo();
SkDynamicMemoryWStream compositor_stream; SkDynamicMemoryWStream compositor_stream;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment