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.

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

mercurial