Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkPDFTag.h
Go to the documentation of this file.
1/*
2 * Copyright 2018 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef SkPDFTag_DEFINED
9#define SkPDFTag_DEFINED
10
14#include "src/core/SkTHash.h"
15
16class SkPDFDocument;
18struct SkPDFTagNode;
19
21public:
25
26 class Mark {
27 SkPDFTagNode *const fNode;
28 size_t const fMarkIndex;
29 public:
30 Mark(SkPDFTagNode* node, size_t index) : fNode(node), fMarkIndex(index) {}
31 Mark() : Mark(nullptr, 0) {}
32 Mark(const Mark&) = delete;
33 Mark& operator=(const Mark&) = delete;
34 Mark(Mark&&) = default;
35 Mark& operator=(Mark&&) = delete;
36
37 explicit operator bool() const { return fNode; }
38 int id();
39 SkPoint& point();
40 };
41 // Used to allow marked content to refer to its corresponding structure
42 // tree node, via a page entry in the parent tree. Returns a false mark if
43 // nodeId is 0.
44 Mark createMarkIdForNodeId(int nodeId, unsigned pageIndex, SkPoint);
45 // Used to allow annotations to refer to their corresponding structure
46 // tree node, via the struct parent tree. Returns -1 if no struct parent
47 // key.
48 int createStructParentKeyForNodeId(int nodeId, unsigned pageIndex);
49
50 void addNodeAnnotation(int nodeId, SkPDFIndirectReference annotationRef, unsigned pageIndex);
51 void addNodeTitle(int nodeId, SkSpan<const char>);
55
56private:
57 // An entry in a map from a node ID to an indirect reference to its
58 // corresponding structure element node.
59 struct IDTreeEntry {
60 int nodeId;
62 };
63
64 void Copy(SkPDF::StructureElementNode& node,
65 SkPDFTagNode* dst,
66 SkArenaAlloc* arena,
68 bool wantTitle);
69 SkPDFIndirectReference PrepareTagTreeToEmit(SkPDFIndirectReference parent,
70 SkPDFTagNode* node,
71 SkPDFDocument* doc);
72
73 SkArenaAlloc fArena;
75 SkPDFTagNode* fRoot = nullptr;
78 std::vector<IDTreeEntry> fIdTreeEntries;
79 std::vector<int> fParentTreeAnnotationNodeIds;
80
81 SkPDFTagTree(const SkPDFTagTree&) = delete;
82 SkPDFTagTree& operator=(const SkPDFTagTree&) = delete;
83};
84
85#endif
Mark(const Mark &)=delete
Mark & operator=(const Mark &)=delete
Mark(SkPDFTagNode *node, size_t index)
Definition SkPDFTag.h:30
SkPoint & point()
Definition SkPDFTag.cpp:205
Mark & operator=(Mark &&)=delete
Mark(Mark &&)=default
SkPDFIndirectReference makeStructTreeRoot(SkPDFDocument *doc)
Definition SkPDFTag.cpp:355
int createStructParentKeyForNodeId(int nodeId, unsigned pageIndex)
Definition SkPDFTag.cpp:229
void init(SkPDF::StructureElementNode *, SkPDF::Metadata::Outline)
Definition SkPDFTag.cpp:193
SkPDFIndirectReference makeOutline(SkPDFDocument *doc)
Definition SkPDFTag.cpp:550
void addNodeAnnotation(int nodeId, SkPDFIndirectReference annotationRef, unsigned pageIndex)
Definition SkPDFTag.cpp:320
SkString getRootLanguage()
Definition SkPDFTag.cpp:574
Mark createMarkIdForNodeId(int nodeId, unsigned pageIndex, SkPoint)
Definition SkPDFTag.cpp:209
void addNodeTitle(int nodeId, SkSpan< const char >)
Definition SkPDFTag.cpp:335