gfx/skia/trunk/src/pdf/SkPDFPage.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1
michael@0 2 /*
michael@0 3 * Copyright 2010 The Android Open Source Project
michael@0 4 *
michael@0 5 * Use of this source code is governed by a BSD-style license that can be
michael@0 6 * found in the LICENSE file.
michael@0 7 */
michael@0 8
michael@0 9
michael@0 10 #ifndef SkPDFPage_DEFINED
michael@0 11 #define SkPDFPage_DEFINED
michael@0 12
michael@0 13 #include "SkPDFTypes.h"
michael@0 14 #include "SkPDFStream.h"
michael@0 15 #include "SkRefCnt.h"
michael@0 16 #include "SkTDArray.h"
michael@0 17
michael@0 18 class SkPDFCatalog;
michael@0 19 class SkPDFDevice;
michael@0 20 class SkWStream;
michael@0 21
michael@0 22 /** \class SkPDFPage
michael@0 23
michael@0 24 A SkPDFPage contains meta information about a page, is used in the page
michael@0 25 tree and points to the content of the page.
michael@0 26 */
michael@0 27 class SkPDFPage : public SkPDFDict {
michael@0 28 SK_DECLARE_INST_COUNT(SkPDFPage)
michael@0 29 public:
michael@0 30 /** Create a PDF page with the passed PDF device. The device need not
michael@0 31 * have content on it yet.
michael@0 32 * @param content The page content.
michael@0 33 */
michael@0 34 explicit SkPDFPage(SkPDFDevice* content);
michael@0 35 ~SkPDFPage();
michael@0 36
michael@0 37 /** Before a page and its contents can be sized and emitted, it must
michael@0 38 * be finalized. No changes to the PDFDevice will be honored after
michael@0 39 * finalizePage has been called. This function adds the page content
michael@0 40 * to the passed catalog, so it must be called for each document
michael@0 41 * that the page is part of.
michael@0 42 * @param catalog The catalog to add page content objects to.
michael@0 43 * @param firstPage Indicate if this is the first page of a document.
michael@0 44 * @param newResourceObjects All the resource objects (recursively) used on
michael@0 45 * the page are added to this array. This gives
michael@0 46 * the caller a chance to deduplicate resources
michael@0 47 * across pages.
michael@0 48 * @param knownResourceObjects The set of resources to be ignored.
michael@0 49 */
michael@0 50 void finalizePage(SkPDFCatalog* catalog, bool firstPage,
michael@0 51 const SkTSet<SkPDFObject*>& knownResourceObjects,
michael@0 52 SkTSet<SkPDFObject*>* newResourceObjects);
michael@0 53
michael@0 54 /** Add destinations for this page to the supplied dictionary.
michael@0 55 * @param dict Dictionary to add destinations to.
michael@0 56 */
michael@0 57 void appendDestinations(SkPDFDict* dict);
michael@0 58
michael@0 59 /** Determine the size of the page content and store to the catalog
michael@0 60 * the offsets of all nonresource-indirect objects that make up the page
michael@0 61 * content. This must be called before emitPage(), but after finalizePage.
michael@0 62 * @param catalog The catalog to add the object offsets to.
michael@0 63 * @param fileOffset The file offset where the page content will be
michael@0 64 * emitted.
michael@0 65 */
michael@0 66 off_t getPageSize(SkPDFCatalog* catalog, off_t fileOffset);
michael@0 67
michael@0 68 /** Output the page content to the passed stream.
michael@0 69 * @param stream The writable output stream to send the content to.
michael@0 70 * @param catalog The active object catalog.
michael@0 71 */
michael@0 72 void emitPage(SkWStream* stream, SkPDFCatalog* catalog);
michael@0 73
michael@0 74 /** Generate a page tree for the passed vector of pages. New objects are
michael@0 75 * added to the catalog. The pageTree vector is populated with all of
michael@0 76 * the 'Pages' dictionaries as well as the 'Page' objects. Page trees
michael@0 77 * have both parent and children links, creating reference cycles, so
michael@0 78 * it must be torn down explicitly. The first page is not added to
michael@0 79 * the pageTree dictionary array so the caller can handle it specially.
michael@0 80 * @param pages The ordered vector of page objects.
michael@0 81 * @param catalog The catalog to add new objects into.
michael@0 82 * @param pageTree An output vector with all of the internal and leaf
michael@0 83 * nodes of the pageTree.
michael@0 84 * @param rootNode An output parameter set to the root node.
michael@0 85 */
michael@0 86 static void GeneratePageTree(const SkTDArray<SkPDFPage*>& pages,
michael@0 87 SkPDFCatalog* catalog,
michael@0 88 SkTDArray<SkPDFDict*>* pageTree,
michael@0 89 SkPDFDict** rootNode);
michael@0 90
michael@0 91 /** Get the fonts used on this page.
michael@0 92 */
michael@0 93 const SkTDArray<SkPDFFont*>& getFontResources() const;
michael@0 94
michael@0 95 /** Returns a SkPDFGlyphSetMap which represents glyph usage of every font
michael@0 96 * that shows on this page.
michael@0 97 */
michael@0 98 const SkPDFGlyphSetMap& getFontGlyphUsage() const;
michael@0 99
michael@0 100 private:
michael@0 101 // Multiple pages may reference the content.
michael@0 102 SkAutoTUnref<SkPDFDevice> fDevice;
michael@0 103
michael@0 104 // Once the content is finalized, put it into a stream for output.
michael@0 105 SkAutoTUnref<SkPDFStream> fContentStream;
michael@0 106 typedef SkPDFDict INHERITED;
michael@0 107 };
michael@0 108
michael@0 109 #endif

mercurial