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