gfx/skia/trunk/include/views/SkViewInflate.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     2 /*
     3  * Copyright 2006 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 SkViewInflate_DEFINED
    11 #define SkViewInflate_DEFINED
    13 #include "SkDOM.h"
    14 #include "SkTDict.h"
    15 #include "SkEvent.h"
    17 class SkView;
    19 class SkViewInflate {
    20 public:
    21             SkViewInflate();
    22     virtual ~SkViewInflate();
    24     /** Return the tree of inflated views. If root is null, create the root element
    25         as a view, otherwise assume root is that view, and just "inflate" it.
    27         Returns null if the tree cannot be built.
    28     */
    29     SkView* inflate(const SkDOM& dom, const SkDOM::Node* node, SkView* root = NULL);
    30     SkView* inflate(const char xml[], size_t len, SkView* root = NULL);
    32     /** Given an id attribute value, return the corresponding view, or null
    33         if no match is found.
    34     */
    35     SkView* findViewByID(const char id[]) const;
    37     SkDEBUGCODE(void dump() const;)
    39 protected:
    40     /*  Override this in your subclass to handle instantiating views
    41         Call the inherited version for nodes you don't recognize.
    43         Do not call "inflate" on the view, just return it. This will
    44         get called automatically after createView returns.
    45     */
    46     virtual SkView* createView(const SkDOM& dom, const SkDOM::Node* node);
    47     /** Base implementation calls view->inflate(dom, node). Subclasses may override this
    48         to perform additional initializations to view, either before or after calling
    49         the inherited version.
    50     */
    51     virtual void inflateView(SkView* view, const SkDOM& dom, const SkDOM::Node* node);
    53 private:
    54     enum {
    55         kMinIDStrAlloc = 64
    56     };
    57     SkTDict<SkView*> fIDs;
    59     struct IDStr {
    60         SkView* fView;
    61         char*   fStr;
    62     };
    63     SkTDArray<IDStr>    fListenTo, fBroadcastTo;
    64     SkChunkAlloc        fStrings;
    66     void addIDStr(SkTDArray<IDStr>* list, SkView*, const char* str);
    68     void    rInflate(const SkDOM& dom, const SkDOM::Node* node, SkView* parent);
    69 };
    71 #endif

mercurial