Add printing::mojom::GenerateDocumentOutline
Replace GeneratePdfDocumentOutline with a more generic mojo based GenerateDocumentOutline enumeration. This allows consistent use instead of converting to a boolean when sending across mojo interfaces. Change-Id: I1273b1d8b312611e9a539de084a0bd89cdd1908c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5491633 Reviewed-by: Lei Zhang <thestig@chromium.org> Reviewed-by: Joe Mason <joenotcharles@google.com> Commit-Queue: Ben Wagner <bungeman@chromium.org> Cr-Commit-Position: refs/heads/main@{#1293723}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
1e04dcd41a
commit
36fc68adc5
components
printing
services
print_compositor
printing
@ -177,8 +177,11 @@ GetPrintPagesParams(const GURL& page_url,
|
||||
print_pages_params->params->prefer_css_page_size =
|
||||
prefer_css_page_size.value_or(false);
|
||||
print_pages_params->params->generate_tagged_pdf = generate_tagged_pdf;
|
||||
using GenerateDocumentOutline = printing::mojom::GenerateDocumentOutline;
|
||||
print_pages_params->params->generate_document_outline =
|
||||
generate_document_outline.value_or(false);
|
||||
generate_document_outline.value_or(false)
|
||||
? GenerateDocumentOutline::kFromAccessibilityTreeHeaders
|
||||
: GenerateDocumentOutline::kNone;
|
||||
|
||||
CHECK(!print_pages_params->params->page_size.IsEmpty())
|
||||
<< print_pages_params->params->page_size.ToString();
|
||||
|
@ -166,7 +166,7 @@ struct PrintParams {
|
||||
// embedder choice provided by PrintRenderFrameHelper delegate.
|
||||
bool? generate_tagged_pdf;
|
||||
// Whether the document outline should be embedded in the PDF.
|
||||
bool generate_document_outline = false;
|
||||
GenerateDocumentOutline generate_document_outline = kNone;
|
||||
};
|
||||
|
||||
// Parameters for a print setting that has parameters for a print request and an
|
||||
|
@ -2321,9 +2321,7 @@ bool PrintRenderFrameHelper::PrintPagesNative(
|
||||
? &accessibility_tree
|
||||
: &metafile.accessibility_tree());
|
||||
metafile.set_generate_document_outline(
|
||||
print_params.generate_document_outline
|
||||
? GeneratePdfDocumentOutline::kFromHeaders
|
||||
: GeneratePdfDocumentOutline::kNone);
|
||||
print_params.generate_document_outline);
|
||||
}
|
||||
|
||||
blink::WebString title = frame->GetDocument().Title();
|
||||
|
@ -16,6 +16,7 @@ static_library("print_compositor") {
|
||||
"//components/discardable_memory/client",
|
||||
"//content/public/utility",
|
||||
"//printing/common",
|
||||
"//printing/mojom",
|
||||
"//third_party/blink/public:blink_headers",
|
||||
"//ui/accessibility",
|
||||
]
|
||||
|
@ -9,6 +9,7 @@ include_rules = [
|
||||
"+printing/backend",
|
||||
"+printing/buildflags",
|
||||
"+printing/common",
|
||||
"+printing/mojom",
|
||||
"+skia",
|
||||
"+third_party/skia",
|
||||
"+third_party/blink/public/platform", # Test web sandbox support.
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "mojo/public/cpp/bindings/pending_remote.h"
|
||||
#include "mojo/public/cpp/system/platform_handle.h"
|
||||
#include "printing/common/metafile_utils.h"
|
||||
#include "printing/mojom/print.mojom.h"
|
||||
#include "skia/ext/font_utils.h"
|
||||
#include "third_party/blink/public/platform/web_image_generator.h"
|
||||
#include "third_party/skia/include/core/SkCanvas.h"
|
||||
@ -51,7 +52,7 @@ sk_sp<SkDocument> MakeDocument(
|
||||
const std::string& creator,
|
||||
const std::string& title,
|
||||
ui::AXTreeUpdate* accessibility_tree,
|
||||
GeneratePdfDocumentOutline generate_document_outline,
|
||||
mojom::GenerateDocumentOutline generate_document_outline,
|
||||
mojom::PrintCompositor::DocumentType document_type,
|
||||
SkWStream& stream) {
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
@ -228,8 +229,8 @@ void PrintCompositorImpl::FinishDocumentComposition(
|
||||
if (!docinfo_->doc) {
|
||||
docinfo_->doc =
|
||||
MakeDocument(creator_, title_, &accessibility_tree_,
|
||||
GeneratePdfDocumentOutline::kNone, docinfo_->document_type,
|
||||
docinfo_->compositor_stream);
|
||||
mojom::GenerateDocumentOutline::kNone,
|
||||
docinfo_->document_type, docinfo_->compositor_stream);
|
||||
}
|
||||
|
||||
HandleDocumentCompletionRequest();
|
||||
@ -397,9 +398,9 @@ mojom::PrintCompositor::Status PrintCompositorImpl::CompositePages(
|
||||
// document composition is not in effect, i.e. when handling
|
||||
// CompositeDocumentToPdf() call.
|
||||
SkDynamicMemoryWStream wstream;
|
||||
sk_sp<SkDocument> doc =
|
||||
MakeDocument(creator_, title_, docinfo_ ? nullptr : &accessibility_tree_,
|
||||
GeneratePdfDocumentOutline::kNone, document_type, wstream);
|
||||
sk_sp<SkDocument> doc = MakeDocument(
|
||||
creator_, title_, docinfo_ ? nullptr : &accessibility_tree_,
|
||||
mojom::GenerateDocumentOutline::kNone, document_type, wstream);
|
||||
|
||||
for (const auto& page : pages) {
|
||||
TRACE_EVENT0("print", "PrintCompositorImpl::CompositePages draw page");
|
||||
@ -411,7 +412,7 @@ mojom::PrintCompositor::Status PrintCompositorImpl::CompositePages(
|
||||
if (!docinfo_->doc) {
|
||||
docinfo_->doc =
|
||||
MakeDocument(creator_, title_, &accessibility_tree_,
|
||||
GeneratePdfDocumentOutline::kNone,
|
||||
mojom::GenerateDocumentOutline::kNone,
|
||||
docinfo_->document_type, docinfo_->compositor_stream);
|
||||
}
|
||||
|
||||
|
@ -10,10 +10,11 @@ source_set("common") {
|
||||
|
||||
configs += [ "//printing/:strict" ]
|
||||
|
||||
deps = [
|
||||
public_deps = [
|
||||
"//base",
|
||||
"//printing/buildflags",
|
||||
"//printing/mojom",
|
||||
"//skia",
|
||||
"//ui/accessibility",
|
||||
]
|
||||
deps = [ "//printing/buildflags" ]
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "base/time/time.h"
|
||||
#include "build/build_config.h"
|
||||
#include "printing/buildflags/buildflags.h"
|
||||
#include "printing/mojom/print.mojom.h"
|
||||
#include "skia/ext/font_utils.h"
|
||||
#include "third_party/skia/include/codec/SkPngDecoder.h"
|
||||
#include "third_party/skia/include/core/SkCanvas.h"
|
||||
@ -239,7 +240,7 @@ sk_sp<SkDocument> MakePdfDocument(
|
||||
std::string_view creator,
|
||||
std::string_view title,
|
||||
const ui::AXTreeUpdate& accessibility_tree,
|
||||
GeneratePdfDocumentOutline generate_document_outline,
|
||||
mojom::GenerateDocumentOutline generate_document_outline,
|
||||
SkWStream* stream) {
|
||||
SkPDF::Metadata metadata;
|
||||
SkPDF::DateTime now = TimeToSkTime(base::Time::Now());
|
||||
@ -256,9 +257,9 @@ sk_sp<SkDocument> MakePdfDocument(
|
||||
if (RecursiveBuildStructureTree(tree.root(), &tag_root)) {
|
||||
metadata.fStructureElementTreeRoot = &tag_root;
|
||||
metadata.fOutline =
|
||||
generate_document_outline == GeneratePdfDocumentOutline::kFromHeaders
|
||||
? SkPDF::Metadata::Outline::StructureElementHeaders
|
||||
: SkPDF::Metadata::Outline::None;
|
||||
generate_document_outline == mojom::GenerateDocumentOutline::kNone
|
||||
? SkPDF::Metadata::Outline::None
|
||||
: SkPDF::Metadata::Outline::StructureElementHeaders;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "base/containers/flat_set.h"
|
||||
#include "base/unguessable_token.h"
|
||||
#include "build/build_config.h"
|
||||
#include "printing/mojom/print.mojom-forward.h"
|
||||
#include "third_party/skia/include/core/SkDocument.h"
|
||||
#include "third_party/skia/include/core/SkRefCnt.h"
|
||||
#include "third_party/skia/include/core/SkSerialProcs.h"
|
||||
@ -38,16 +39,11 @@ using PictureSerializationContext = ContentToProxyTokenMap;
|
||||
// Stores the set of typeface unique ids used by the picture frame content.
|
||||
using TypefaceSerializationContext = ContentProxySet;
|
||||
|
||||
enum class GeneratePdfDocumentOutline : bool {
|
||||
kNone = false,
|
||||
kFromHeaders = true,
|
||||
};
|
||||
|
||||
sk_sp<SkDocument> MakePdfDocument(
|
||||
std::string_view creator,
|
||||
std::string_view title,
|
||||
const ui::AXTreeUpdate& accessibility_tree,
|
||||
GeneratePdfDocumentOutline generate_document_outline,
|
||||
mojom::GenerateDocumentOutline generate_document_outline,
|
||||
SkWStream* stream);
|
||||
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include "cc/paint/paint_canvas.h"
|
||||
#include "printing/common/metafile_utils.h"
|
||||
#include "printing/metafile.h"
|
||||
#include "printing/mojom/print.mojom-forward.h"
|
||||
#include "printing/mojom/print.mojom.h"
|
||||
#include "skia/ext/platform_canvas.h"
|
||||
#include "third_party/skia/include/core/SkRefCnt.h"
|
||||
#include "ui/accessibility/ax_tree_update.h"
|
||||
@ -127,7 +127,7 @@ class COMPONENT_EXPORT(PRINTING_METAFILE) MetafileSkia : public Metafile {
|
||||
ui::AXTreeUpdate& accessibility_tree() { return accessibility_tree_; }
|
||||
|
||||
void set_generate_document_outline(
|
||||
GeneratePdfDocumentOutline generate_document_outline) {
|
||||
mojom::GenerateDocumentOutline generate_document_outline) {
|
||||
generate_document_outline_ = generate_document_outline;
|
||||
}
|
||||
|
||||
@ -153,8 +153,8 @@ class COMPONENT_EXPORT(PRINTING_METAFILE) MetafileSkia : public Metafile {
|
||||
std::unique_ptr<MetafileSkiaData> data_;
|
||||
|
||||
ui::AXTreeUpdate accessibility_tree_;
|
||||
GeneratePdfDocumentOutline generate_document_outline_ =
|
||||
GeneratePdfDocumentOutline::kNone;
|
||||
mojom::GenerateDocumentOutline generate_document_outline_ =
|
||||
mojom::GenerateDocumentOutline::kNone;
|
||||
std::string title_;
|
||||
};
|
||||
|
||||
|
@ -118,6 +118,12 @@ enum MetafileDataType {
|
||||
kPostScriptEmf,
|
||||
};
|
||||
|
||||
// What kind of document outline to generate.
|
||||
enum GenerateDocumentOutline {
|
||||
kNone,
|
||||
kFromAccessibilityTreeHeaders,
|
||||
};
|
||||
|
||||
// What kind of margins to use.
|
||||
enum MarginType {
|
||||
// Default varies depending on headers being enabled or not
|
||||
|
Reference in New Issue
Block a user