Changeset 21150 for S60/trunk/WebKit

Show
Ignore:
Timestamp:
04/27/07 12:23:18 (21 months ago)
Author:
zbujtas
Message:

rathnasa, reviewed by zbujtas

DESC: Widget Menu API
http://bugs.webkit.org/show_bug.cgi?id=13494

WARNING: NO TEST CASES ADDED OR CHANGED

  • khtml/ecma/kjs_window.cpp: (Window::get):
Location:
S60/trunk/WebKit
Files:
7 modified

Legend:

Unmodified
Added
Removed
  • S60/trunk/WebKit/BrowserControl/inc/BrCtlInterface.h

    r21101 r21150  
    939939        virtual void SetParamL(TBrCtlDefs::TBrCtlWidgetParams aParam, TUint aValue) = 0; 
    940940 
    941         virtual TBool RightKeyCallback() = 0; 
     941        /** 
     942        * Method to invoke callback function for right soft key 
     943        * @since 3.2 
     944        * @param none 
     945        * @return ETrue if there is a rightsoftkey callback, else EFalse 
     946        */ 
     947        virtual TBool HandleCommandL( TInt aCommandId ) = 0; 
    942948 
    943949    }; 
  • S60/trunk/WebKit/BrowserView/inc/WidgetExtension.h

    r21101 r21150  
    206206        * @since 3.2 
    207207        * @param command ID of the menu item 
    208         * @param command ID of the parent menu item 
    209         * @return none 
    210         */ 
    211         void DeleteMenuItem( TInt aCmdId, TInt aParentCmdId ); 
     208        * @return none 
     209        */ 
     210        void DeleteMenuItem( TInt aCmdId ); 
    212211         
    213212        /** 
     
    232231 
    233232        /** 
    234         * Method GetMenuItem 
     233        * Method MenuItem 
    235234        * @since 3.2 
    236235        * @param text/label for the menu item 
     
    239238        * @return none 
    240239        */ 
    241         void GetMenuItem( TDes& textVal, TInt& cmdId, TBool& dimStat ); 
     240        void MenuItem( TDes& textVal, TInt& cmdId, TBool& dimStat ); 
    242241 
    243242        /** 
     
    266265        * @return callback function 
    267266        */ 
    268         WidgetEventHandler* GetMenuItemObserver( TInt aCmdId ); 
     267        WidgetEventHandler* MenuItemObserver( TInt aCmdId ); 
    269268 
    270269        /** 
     
    282281        * @return callback function 
    283282        */ 
    284         WidgetEventHandler*& GetMenuObserver(); 
     283        WidgetEventHandler* MenuObserver(); 
    285284 
    286285        /** 
     
    292291        void SetRightKeyObserver( WidgetEventHandler* aMenuCallback ); 
    293292         
    294  
    295293        /** 
    296294        * Method GetMenuObserver 
     
    299297        * @return callback function 
    300298        */ 
    301         WidgetEventHandler*& GetRightKeyObserver(); 
     299        WidgetEventHandler* RightKeyObserver(); 
    302300 
    303301        /** 
     
    444442        * @return Tbool 
    445443        */ 
    446         TBool RightKeyCallback(); 
     444        TBool HandleCommandL( TInt aCommandId ); 
    447445 
    448446        /** 
     
    471469 
    472470    private: 
    473          /** 
     471        /** 
    474472        * Method LoadWidgetEngineDllL 
    475473        * @since 3.2 
     
    477475        */ 
    478476        void LoadWidgetEngineDllL(); 
    479  
    480          /** 
    481         * Method CreateAppHashTableL 
    482         * @since 3.2 
    483         * @return void 
    484         */ 
    485         void CreateAppHashTableL(); 
    486  
     477         
    487478        /* 
    488479        * Method LaunchApplicationL 
     
    523514        MWidgetEngineBridge*    iWidgetEngineBridge; 
    524515        MWidgetCallback*        iWidgetCallback; 
    525         RPtrHashMap<TDesC,TInt> iAppUidMap; 
    526516        RLibrary                iLibrary; 
    527517        CMenuItem*              iMenuRoot; 
     
    549539 
    550540        /* 
    551         * Method Insert 
     541        * Method Append 
     542        * @since 3.2 
     543        * @param parent menu item 
     544        * @param menu item to be inserted 
     545        * @return TBool 
     546        */ 
     547        TBool Append( CMenuItem* root, CMenuItem* item ); 
     548 
     549        /* 
     550        * Method AppendSibling 
    552551        * @since 3.2 
    553552        * @param root of the tree 
    554553        * @param menu item to be inserted 
    555         * @param parent command id of the menu item to be inserted 
    556         * @return TBool 
    557         */ 
    558         TBool Insert( CMenuItem* root, CMenuItem* item, TInt parentId ); 
    559  
    560         /* 
    561         * Method InsertSibling 
    562         * @since 3.2 
    563         * @param root of the tree 
    564         * @param menu item to be inserted 
    565         * @return void 
    566         */ 
    567         void InsertSibling( CMenuItem* root, CMenuItem* item ); 
     554        * @return void 
     555        */ 
     556        void AppendSibling( CMenuItem* root, CMenuItem* item ); 
    568557 
    569558        /* 
     
    594583        * Constructor        
    595584        */ 
    596         static CMenuItem* NewL( const TDesC16& aText, TInt aCmdId, void* aObj = NULL ); 
     585        static CMenuItem* NewL( const TDesC16& aText, TInt aCmdId,  
     586            CMenuItem* aParent = NULL, void* aObj = NULL ); 
    597587 
    598588        /** 
     
    610600        * C++ constructor. 
    611601        */ 
    612         CMenuItem( const TDesC16& aText, TInt aCmdId, void* aObj = NULL );        
     602        CMenuItem( const TDesC16& aText, TInt aCmdId, CMenuItem* aParent = NULL, 
     603            void* aObj = NULL );        
    613604 
    614605    public: 
     
    640631        * @return first child of menu item 
    641632        */ 
    642         CMenuItem*& FirstChild() { return iFirstChild; } 
     633        CMenuItem* FirstChild() { return iFirstChild; } 
    643634 
    644635        /* 
     
    648639        * @return next sibling of menu item 
    649640        */ 
    650         CMenuItem*& NextSibling() { return iNextSibling; } 
     641        CMenuItem* NextSibling() { return iNextSibling; } 
    651642         
    652643        /* 
     
    664655        * @return onselect callback function of menu item 
    665656        */ 
    666         WidgetEventHandler*& Callback() { return iCallback; } 
     657        WidgetEventHandler* Callback() { return iCallback; } 
    667658 
    668659        /* 
     
    672663        * @return menu item javascript object 
    673664        */ 
    674         void*& Obj() { return iObj; } 
     665        void* Obj() { return iObj; } 
     666 
     667        /* 
     668        * Method Parent() 
     669        * @since 3.2 
     670        * @param none 
     671        * @return parent menu item 
     672        */ 
     673        CMenuItem* Parent() { return iParent; } 
    675674 
    676675        /* 
     
    702701        * @return none 
    703702        */ 
    704         void SetFirstChild( CMenuItem*& aFirstChild ) { iFirstChild = aFirstChild; } 
     703        void SetFirstChild( CMenuItem* aFirstChild ) { iFirstChild = aFirstChild; } 
    705704         
    706705        /* 
     
    710709        * @return none 
    711710        */ 
    712         void SetNextSibling( CMenuItem*& aNextSibling ) { iNextSibling = aNextSibling; } 
     711        void SetNextSibling( CMenuItem* aNextSibling ) { iNextSibling = aNextSibling; } 
    713712         
    714713        /* 
     
    726725        * @return none 
    727726        */ 
    728         void SetCallback( WidgetEventHandler*& aCallback ) { iCallback = aCallback; } 
     727        void SetCallback( WidgetEventHandler* aCallback ) { iCallback = aCallback; } 
    729728 
    730729        /* 
     
    734733        * @return none 
    735734        */ 
    736         void SetObj( void*& aObj ) { iObj = aObj; } 
     735        void SetObj( void* aObj ) { iObj = aObj; } 
    737736 
    738737    private: 
    739738        HBufC*                  iText;//data 
    740739        TInt                    iCmdId;//data 
     740        CMenuItem*              iParent;//data 
    741741        CMenuItem*              iFirstChild;//left node 
    742742        CMenuItem*              iNextSibling;//right node 
  • S60/trunk/WebKit/BrowserView/src/WidgetExtension.cpp

    r21101 r21150  
    7171// LOCAL CONSTANTS AND MACROS 
    7272const TInt KOptionsCmdId = 6000; 
    73 const TInt KMaxOptionsMenu = 25; 
     73const TInt KMaxOptionsMenu = 63; 
    7474const TInt KMaxOptionsMenuItemSize = 256; //bytes 
    7575const TInt KMenuItemCommandIdBase = 20000; 
    7676 
    77 const TInt KMediaGalleryUid = 0x101F8599; 
    78 _LIT(KMediaGallery,"mediagallery"); 
    7977const TInt KWebBrowserUid = 0x10008D39; 
    80 _LIT(KWebBrowser,"webbrowser"); 
    81 const TInt KCamAppEngineUid = 0x101F857A; 
    82 _LIT(KCamAppEngine,"camera"); 
    8378 
    8479// MODULE DATA STRUCTURES 
     
    143138    delete iWidgetBasePath; 
    144139    delete iWidgetBundleId; 
    145     iAppUidMap.ResetAndDestroy(); 
    146     iLibrary.Close(); 
    147140    // delete tree 
    148141    DeleteTree( iMenuRoot );    
    149     } 
    150  
    151 // ---------------------------------------------------------------------------- 
    152 // CWidgetExtension::delTree 
     142    iLibrary.Close(); 
     143    } 
     144 
     145// ---------------------------------------------------------------------------- 
     146// CWidgetExtension::DeleteTree 
    153147// 
    154148// 
     
    186180    LoadWidgetEngineDllL(); 
    187181    iWidgetEngineBridge->SetObserver( *this ); 
    188     CreateAppHashTableL(); 
    189182    iResourceId = R_CASCADE_MENU_1; 
    190     } 
    191  
    192 // ---------------------------------------------------------------------------- 
    193 // CWidgetExtension::CreateAppHashTableL 
    194 // 
    195 // 
    196 // 
    197 // ---------------------------------------------------------------------------- 
    198 // 
    199 void CWidgetExtension::CreateAppHashTableL() 
    200     { 
    201     TInt* uidmg = new TInt( KMediaGalleryUid ); 
    202     HBufC* bufmedia = HBufC::NewL( TPtrC( KMediaGallery ).Length() ); 
    203     *bufmedia = KMediaGallery; 
    204  
    205     TInt* uidweb = new TInt( KWebBrowserUid ); 
    206     HBufC* bufweb = HBufC::NewL( TPtrC( KWebBrowser ).Length() ); 
    207     *bufweb = KWebBrowser; 
    208  
    209     TInt* uidcam = new TInt( KCamAppEngineUid ); 
    210     HBufC* bufcam = HBufC::NewL( TPtrC( KCamAppEngine ).Length() ); 
    211     *bufcam = KCamAppEngine; 
    212  
    213     iAppUidMap.InsertL( bufmedia,uidmg ); 
    214     iAppUidMap.InsertL( bufweb, uidweb ); 
    215     iAppUidMap.InsertL( bufcam, uidcam ); 
    216183    } 
    217184 
     
    364331    } 
    365332 
     333// The binary tree representation of a multiway tree is based on  
     334// first child-next sibling representation of the tree. In this representation  
     335// every node is linked with its leftmost child and its next (right nearest) 
     336// sibling.  
     337 
     338/*  
     339Example: Consider the following multiway tree  
     340 
     341                        1                   
     342                      / | \ 
     343                     /  |  \ 
     344                    /   |   \ 
     345                   2    3    4 
     346                  / \        | 
     347                 5   6       7 
     348                            / \ 
     349                           8   9 
     350 
     351 
     352This tree can be represented in first child-next sibling manner as follows : 
     353 
     354                        1 
     355                       / 
     356                      / 
     357                     / 
     358                    2---3---4 
     359                   /       / 
     360                  5---6   7 
     361                         / 
     362                        8---9 
     363 
     364 
     365If we look at the first child-next sibling representation of the tree closely,  
     366we will see that it forms a binary tree. To see this better, rotate every  
     367next-sibling edge 45 degrees clockwise. After that, the following binary tree is got: 
     368 
     369                        1 
     370                       / 
     371                      2 
     372                     / \ 
     373                    5   3 
     374                     \   \ 
     375                      6   4 
     376                         / 
     377                        7 
     378                       / 
     379                      8 
     380                       \ 
     381                        9 
     382 
     383*/ 
     384 
    366385// ---------------------------------------------------------------------------- 
    367386// CWidgetExtension::AddOptionMenuItemsL 
     
    372391// 
    373392void CWidgetExtension::AddOptionMenuItemsL(  
    374     CEikMenuPane& aMenuPane,TInt aResourceId ) 
     393    CEikMenuPane& aMenuPane, TInt aResourceId ) 
    375394    { 
    376395    CMenuItem* node = NULL; 
     
    396415    else if ( aResourceId >= R_CASCADE_MENU_1 ) //one of the cascade menu pane 
    397416        {    
    398         for (TInt i = 0; i < iCascadeArr.Count(); i++ ) 
     417        for ( TInt i = 0; i < iCascadeArr.Count(); i++ ) 
    399418            { 
    400419            if ( iCascadeArr[i].iResourceId == aResourceId ) 
     
    439458    { 
    440459    CEikMenuPaneItem::SData menuData; 
    441     menuData.iCommandId = aNode->CmdId()+KMenuItemCommandIdBase; 
     460    menuData.iCommandId = aNode->CmdId() + KMenuItemCommandIdBase; 
    442461 
    443462    if ( aNode->FirstChild() ) 
    444         menuData.iCascadeId = iResourceId; 
     463        { 
     464        if ( iResourceId > R_CASCADE_MENU_1 + KMaxOptionsMenu ) 
     465            menuData.iCascadeId = 0; 
     466        else 
     467            menuData.iCascadeId = iResourceId; 
     468        } 
    445469    else 
    446470        menuData.iCascadeId = 0; 
     
    634658// 
    635659void CWidgetExtension::AddOptionsMenuItem(  
    636     const TDesC& aText, TInt aCmdId, TInt aParentId, void* iObj ) 
     660    const TDesC& aText, TInt aCmdId, TInt aParentId, void* aObj ) 
    637661    {    
    638     if ( iMenuRoot == NULL )  
     662    if ( !iMenuRoot )  
    639663        {  
    640664        iMenuRoot = CMenuItem::NewL( _L(""), -1 ); 
     
    642666    if ( aText.Length() > 0 ) 
    643667        { 
    644         CMenuItem* item = CMenuItem::NewL( aText, aCmdId, iObj );  
    645         Insert( iMenuRoot, item, aParentId );     
     668        CMenuItem* parent = FindNodeById( iMenuRoot, aParentId ); 
     669        if ( !parent ) 
     670            return; 
     671        CMenuItem* item = CMenuItem::NewL( aText, aCmdId, parent, aObj );  
     672        Append( parent, item );     
    646673        } 
    647674    } 
     
    662689 
    663690// ----------------------------------------------------------------------------- 
    664 // CWidgetExtension::Insert 
    665 // 
    666 // 
    667 // 
    668 // ----------------------------------------------------------------------------- 
    669 // 
    670 TBool CWidgetExtension::Insert(  
    671     CMenuItem* aRoot, CMenuItem* aItem, TInt aParentId ) 
     691// CWidgetExtension::Append 
     692// 
     693// 
     694// 
     695// ----------------------------------------------------------------------------- 
     696// 
     697TBool CWidgetExtension::Append(  
     698    CMenuItem* aParent, CMenuItem* aItem ) 
    672699    {   
    673     if ( aRoot ) 
    674         { 
    675         if ( aRoot->CmdId() == aParentId )  
    676             { 
    677             if ( aRoot->FirstChild() == NULL ) //first child   
    678                 {  
    679                 aRoot->SetFirstChild( aItem );  
    680                 }  
    681             else //insert as sibling of first child 
    682                 {  
    683                 InsertSibling( aRoot->FirstChild(), aItem ); 
    684                 } 
    685             return true; 
    686             } 
    687         if ( Insert( aRoot->FirstChild(), aItem, aParentId ) ) 
    688             return true; 
    689         if ( Insert( aRoot->NextSibling(), aItem, aParentId ) ) 
    690             return true;           
    691         } 
    692     return false;                       
     700    if ( !aParent ) 
     701        return EFalse; 
     702 
     703    if ( aParent->FirstChild() == NULL ) //first child   
     704        {  
     705        aParent->SetFirstChild( aItem );  
     706        }  
     707    else //insert as sibling of first child 
     708        {  
     709        AppendSibling( aParent->FirstChild(), aItem ); 
     710        } 
     711    return ETrue;             
    693712    }  
    694713 
    695714// ----------------------------------------------------------------------------- 
    696 // CWidgetExtension::InsertSibling 
    697 // 
    698 // 
    699 // 
    700 // ----------------------------------------------------------------------------- 
    701 // 
    702 void CWidgetExtension::InsertSibling( CMenuItem* aRoot, CMenuItem* aItem ) 
     715// CWidgetExtension::AppendSibling 
     716// 
     717// 
     718// 
     719// ----------------------------------------------------------------------------- 
     720// 
     721void CWidgetExtension::AppendSibling( CMenuItem* aRoot, CMenuItem* aItem ) 
    703722    { 
    704723    if ( aRoot && ( aRoot->NextSibling() == NULL ) ) //first sibling 
     
    708727    else 
    709728        { 
    710         InsertSibling( aRoot->NextSibling(), aItem ); 
     729        AppendSibling( aRoot->NextSibling(), aItem ); 
    711730        } 
    712731 
     
    721740// ---------------------------------------------------------------------------- 
    722741// 
    723 void CWidgetExtension::DeleteMenuItem( TInt aCmdId, TInt aParentCmdId ) 
    724     { 
    725     CMenuItem* node = NULL; 
    726     node = FindNodeById( iMenuRoot, aParentCmdId );  
    727  
    728     if ( node && node->FirstChild() ) 
     742void CWidgetExtension::DeleteMenuItem( TInt aCmdId ) 
     743    { 
     744    CMenuItem* node = FindNodeById( iMenuRoot, aCmdId );  
     745 
     746    if ( !node ) 
     747        return; 
     748 
     749    CMenuItem* parent = node->Parent(); 
     750 
     751    if ( parent && parent->FirstChild() ) 
    729752        { 
    730753        //it could be first child 
    731         if ( node->FirstChild()->CmdId() == aCmdId  ) 
    732             { 
    733             CMenuItem* tempFirstChild = node->FirstChild(); 
     754        if ( parent->FirstChild()->CmdId() == aCmdId  ) 
     755            { 
     756            CMenuItem* tempFirstChild = parent->FirstChild(); 
    734757            //the sibling of firstchild will be the new firstchild 
    735             node->SetFirstChild( node->FirstChild()->NextSibling() ); 
     758            parent->SetFirstChild( parent->FirstChild()->NextSibling() ); 
    736759            DeleteTree( tempFirstChild ); 
    737760            tempFirstChild = NULL; 
     
    741764        else  
    742765            { 
    743             CMenuItem* prev = node->FirstChild(); 
     766            CMenuItem* prev = parent->FirstChild(); 
    744767            CMenuItem* item = NULL; 
    745768            if ( prev ) 
     
    798821 
    799822// ---------------------------------------------------------------------------- 
    800 // CWidgetExtension::GetMenuItem 
    801 // 
    802 // 
    803 // 
    804 // ---------------------------------------------------------------------------- 
    805 // 
    806 void CWidgetExtension::GetMenuItem(  
     823// CWidgetExtension::MenuItem 
     824// 
     825// 
     826// 
     827// ---------------------------------------------------------------------------- 
     828// 
     829void CWidgetExtension::MenuItem(  
    807830    TDes& textVal, TInt& cmdId, TBool& dimStat ) 
    808831    { 
     
    893916 
    894917// ---------------------------------------------------------------------------- 
    895 // CWidgetExtension::GetMenuItemObserver 
    896 // 
    897 // 
    898 // 
    899 // ---------------------------------------------------------------------------- 
    900 // 
    901 WidgetEventHandler* CWidgetExtension::GetMenuItemObserver( TInt aCmdId ) 
     918// CWidgetExtension::MenuItemObserver 
     919// 
     920// 
     921// 
     922// ---------------------------------------------------------------------------- 
     923// 
     924WidgetEventHandler* CWidgetExtension::MenuItemObserver( TInt aCmdId ) 
    902925    { 
    903926    CMenuItem* node = NULL; 
     
    923946 
    924947// ---------------------------------------------------------------------------- 
    925 // CWidgetExtension::GetMenuObserver 
    926 // 
    927 // 
    928 // 
    929 // ---------------------------------------------------------------------------- 
    930 // 
    931 WidgetEventHandler*& CWidgetExtension::GetMenuObserver() 
     948// CWidgetExtension::MenuObserver 
     949// 
     950// 
     951// 
     952// ---------------------------------------------------------------------------- 
     953// 
     954WidgetEventHandler* CWidgetExtension::MenuObserver() 
    932955    {   
    933956    return iMenuCallback; 
     
    953976// ---------------------------------------------------------------------------- 
    954977// 
    955 WidgetEventHandler*& CWidgetExtension::GetRightKeyObserver() 
     978WidgetEventHandler* CWidgetExtension::RightKeyObserver() 
    956979    {   
    957980    return iRightKeyCallback; 
     
    959982 
    960983// ---------------------------------------------------------------------------- 
    961 // CWidgetExtension::RightKeyCallback 
    962 // 
    963 // 
    964 // 
    965 // ---------------------------------------------------------------------------- 
    966 // 
    967 TBool CWidgetExtension::RightKeyCallback() 
    968     { 
    969     if ( iWidgetEngineBridge ) 
     984// CWidgetExtension::HandleCommandL 
     985// 
     986// 
     987// 
     988// ---------------------------------------------------------------------------- 
     989// 
     990TBool CWidgetExtension::HandleCommandL( TInt aCommandId ) 
     991    { 
     992    if ( iWidgetEngineBridge && aCommandId == EAknSoftkeyExit ) 
    970993        { 
    971994        return iWidgetEngineBridge->RightSoftKeyPressed(); 
     
    10521075// 
    10531076CMenuItem* CMenuItem::NewL( 
    1054     const TDesC16& aText, TInt aCmdId, void* aObj ) 
    1055     { 
    1056     CMenuItem* self = new ( ELeave ) CMenuItem( aText, aCmdId, aObj ); 
     1077    const TDesC16& a