webengine/wmlengine/src/xhtml/include/XhtmlTableElementHandler.h
branchRCL_3
changeset 49 919f36ff910f
equal deleted inserted replaced
48:79859ed3eea9 49:919f36ff910f
       
     1 /*
       
     2 * Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Handles table elements in XHTML documents.
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef CXHTMLTABLEELEMENTHANDLER__H
       
    19 #define CXHTMLTABLEELEMENTHANDLER__H
       
    20 
       
    21 // INCLUDES
       
    22 #include <e32def.h>
       
    23 #include <e32base.h>
       
    24 
       
    25 #include "nwx_defs.h"
       
    26 #include <nw_dom_node.h>
       
    27 
       
    28 // CONSTANTS
       
    29 
       
    30 // MACROS
       
    31 
       
    32 // DATA TYPES
       
    33 
       
    34 // FUNCTION PROTOTYPES
       
    35 
       
    36 // FORWARD DECLARATIONS
       
    37 #ifdef __cplusplus
       
    38 extern "C" {
       
    39 #endif /* __cplusplus */
       
    40 
       
    41 typedef struct NW_XHTML_ContentHandler_s NW_XHTML_ContentHandler_t;
       
    42 typedef struct NW_XHTML_ElementHandler_s NW_XHTML_ElementHandler_t;
       
    43 typedef struct NW_LMgr_Box_s NW_LMgr_Box_t;
       
    44 typedef struct NW_LMgr_RootBox_s NW_LMgr_RootBox_t;
       
    45 typedef struct NW_LMgr_ContainerBox_s NW_LMgr_ContainerBox_t;
       
    46 
       
    47 #ifdef __cplusplus
       
    48 }
       
    49 #endif /* __cplusplus */
       
    50 
       
    51 // CLASS DECLARATION
       
    52 
       
    53 // TODO: This class should be derived from CElementHandler once the browser is
       
    54 //       converted to c++.
       
    55 
       
    56 class CXHTMLTableElementHandler : public CBase
       
    57   {
       
    58   public:  // Constructors and destructor
       
    59     /**
       
    60     * Two-phased constructor.
       
    61     */
       
    62     static CXHTMLTableElementHandler* NewL(const NW_XHTML_ElementHandler_t* aElementHandler,
       
    63         NW_XHTML_ContentHandler_t* aContentHandler, NW_DOM_ElementNode_t* aElementNode);
       
    64 
       
    65     /**
       
    66     * Destructor.
       
    67     */
       
    68     virtual ~CXHTMLTableElementHandler();
       
    69 
       
    70 
       
    71   public:  // New Methods
       
    72     /**
       
    73     * Initializes the ElementHandler.
       
    74     *
       
    75     * @return status code
       
    76     */
       
    77     virtual TBrowserStatusCode Initialize(void);
       
    78 
       
    79     /**
       
    80     * Creates the box-tree associated with the tag.
       
    81     *
       
    82     * @param aParentBox the parent to attach the new box-tree to.
       
    83     * @return status code
       
    84     */
       
    85     virtual TBrowserStatusCode CreateBoxTree(NW_LMgr_ContainerBox_t& aParentBox);  
       
    86 
       
    87     /**
       
    88     * Returns whether or not grid mode applies to this table.
       
    89     *
       
    90     * @return ETrue or EFalse.
       
    91     */
       
    92     TBool DoesGridModeApply(void);
       
    93 
       
    94 
       
    95   private:  // Private Methods
       
    96     /**
       
    97     * C++ default constructor.
       
    98     */
       
    99     CXHTMLTableElementHandler(const NW_XHTML_ElementHandler_t* aElementHandler,
       
   100         NW_XHTML_ContentHandler_t* aContentHandler, NW_DOM_ElementNode_t* aElementNode);
       
   101 
       
   102     /**
       
   103     * By default Symbian 2nd phase constructor is private.
       
   104     */
       
   105     void ConstructL(void);
       
   106 
       
   107     /**
       
   108     * A simple helper method to create the box-tree.
       
   109     *
       
   110     * @param aElementNode the table's element node.
       
   111     * @param aTableBox the table's box.
       
   112     * @param aTableContainerParent the table's parent's box.
       
   113     *
       
   114     * @return status code
       
   115     */
       
   116     TBrowserStatusCode CreateSubTree(NW_DOM_ElementNode_t* aElementNode,
       
   117         NW_LMgr_Box_t* aTableBox, NW_LMgr_ContainerBox_t* aTableContainerParent);
       
   118 
       
   119     /**
       
   120     * A simple helper method to create the box-tree.
       
   121     *
       
   122     * @param aElementHandler the table's element handler.
       
   123     * @param aElementNode the table's element node.
       
   124     * @param aTableBox the table's box.
       
   125     * @param aTableContainerParent the table's parent's box.
       
   126     *
       
   127     * @return status code
       
   128     */
       
   129     TBrowserStatusCode CreateSubTreeHelper(const NW_XHTML_ElementHandler_t* aElementHandler, 
       
   130         NW_DOM_ElementNode_t* aElementNode, NW_LMgr_Box_t* aTableBox, 
       
   131         NW_LMgr_ContainerBox_t* aTableContainerParent);
       
   132 
       
   133     /**
       
   134     * Returns true if the parent has only one element, ignoring text nodes that
       
   135     * only contain whitespace.
       
   136     *
       
   137     * @return true or false.
       
   138     */
       
   139     NW_Bool HasOnlyOneElementChild(NW_DOM_Node_t* aParentNode);
       
   140 
       
   141     /**
       
   142     * This method is called each time a table chunk arrives.  It is used
       
   143     * to determine whether or not that table should be laid out in grid mode.
       
   144     *
       
   145     * @return status code
       
   146     */
       
   147     TBrowserStatusCode PreEvalTable();
       
   148 
       
   149     /**
       
   150     * This method is called after all of the chunks of a table arrive.  It is used
       
   151     * to determine whether or not that table should be laid out in grid mode.
       
   152     *
       
   153     * @return status code
       
   154     */
       
   155     TBrowserStatusCode PostEvalTable();
       
   156 
       
   157 
       
   158   private:  // Data
       
   159     const NW_XHTML_ElementHandler_t*  iElementHandler;
       
   160     NW_XHTML_ContentHandler_t*        iContentHandler;
       
   161     NW_DOM_ElementNode_t*             iElementNode;
       
   162     NW_LMgr_RootBox_t*                iRootBox;
       
   163     NW_Float32                        iScreenWidth;
       
   164 
       
   165     TInt8                             iIsGridMode;
       
   166     NW_DOM_Node_t*                    iLastEvaluatedElement;
       
   167     TInt32                            iNumberOfElements;
       
   168   };
       
   169 
       
   170 #endif  // CXHTMLTABLEELEMENTHANDLER__H