Changeset 23814 in webkit
- Timestamp:
- Jun 27, 2007 8:00:02 AM (17 years ago)
- Location:
- S60/trunk/WebKit
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
S60/trunk/WebKit/BrowserView/inc/WidgetExtension.h
r23794 r23814 190 190 * @param ID of the command to issue when the menu item is selected 191 191 * @param command ID of the parent menu item 192 * @return none193 */ 194 voidAddOptionsMenuItem( const TDesC& aText, TInt aCmdId, TInt aParentCmdId, void* obj );192 * @return Error code 193 */ 194 TInt AddOptionsMenuItem( const TDesC& aText, TInt aCmdId, TInt aParentCmdId, void* obj ); 195 195 196 196 /** … … 225 225 * @param command ID of the new menu item 226 226 * @param dimmed status 227 * @return none228 */ 229 voidReplaceMenuItem( TInt oldCmdId, const TDesC& newText,227 * @return Error code 228 */ 229 TInt ReplaceMenuItem( TInt oldCmdId, const TDesC& newText, 230 230 TInt newCmdId, TInt newDimmed ); 231 231 … … 571 571 * @param parent menu item 572 572 * @param menu item to be inserted 573 * @return TBool574 */ 575 T BoolAppend( CMenuItem* root, CMenuItem* item );573 * @return error code 574 */ 575 TInt Append( CMenuItem* root, CMenuItem* item ); 576 576 577 577 /* -
S60/trunk/WebKit/BrowserView/inc/WidgetPreferences.h
r21101 r23814 58 58 59 59 // CLASS DECLARATION 60 61 /** 62 * CPrefElement 63 * 64 * @lib widgetengine.dll 65 * @since 3.2 66 */ 67 class CPrefElement : public CBase 68 { 69 public : 70 /** 71 * Constructor. 72 */ 73 CPrefElement(); 74 75 /** 76 * Destructor. 77 */ 78 ~CPrefElement(); 79 80 /** 81 * SetValueL 82 * Set value for a preference 83 * @param const TDesC& aValue - The value to be set 84 * @return none 85 */ 86 void SetValueL( const TDesC& aValue ); 87 88 /** 89 * SetValueSize 90 * Set length of value 91 * @param const TInt aSize - The length to be set 92 * @return none 93 */ 94 void SetValueSize( const TInt aSize ) 95 { 96 iValueSize = aSize; 97 } 98 99 /** 100 * GetValue 101 * Get value for a preference 102 * @param none 103 * @return const TDesC& - value for the preference 104 */ 105 const TDesC& Value() const 106 { 107 if ( iValue ) 108 return *iValue; 109 else 110 return KNullDesC(); 111 } 112 113 /** 114 * GetValueSize 115 * Get length of value 116 * @param none 117 * @return TInt - length of value for the preference 118 */ 119 TInt ValueSize() const 120 { 121 return iValueSize; 122 } 123 124 private : 125 HBufC* iValue; // value of the preference 126 TInt iValueSize; // length of the value 127 }; 128 129 60 130 /** 61 131 * CWidgetPreferences … … 68 138 69 139 public: 70 static CWidgetPreferences* NewL(CWidgetExtension& aWidgetExtension); 71 static CWidgetPreferences* NewLC(CWidgetExtension& aWidgetExtension); 140 /** 141 * Two-phased constructor. 142 */ 143 static CWidgetPreferences* NewL( CWidgetExtension& aWidgetExtension ); 144 static CWidgetPreferences* NewLC( CWidgetExtension& aWidgetExtension ); 145 146 /** 147 * Destructor. 148 */ 72 149 ~CWidgetPreferences(); 73 150 74 151 public: 152 /** 153 * Load preferences from persistent storage 154 */ 75 155 void LoadL(); 156 157 /** 158 * Save preferences to persistent storage 159 */ 76 160 void SaveL(); 77 TInt PreferenceL(const TDesC& aName, TPtrC& aValue); 78 void SetPreferenceL(const TDesC& aName, const TDesC& aValue); 161 162 /** 163 * Get preference for a particular key 164 */ 165 TInt PreferenceL( const TDesC& aName, TPtrC& aValue ); 166 167 /** 168 * Set preference for a particular key 169 */ 170 void SetPreferenceL( const TDesC& aName, const TDesC& aValue ); 79 171 80 172 protected: 81 void Empty(); 82 void CreateFilePathL(); 83 HBufC* MakeKeyLC(const TDesC& aName); 84 85 protected: 86 CWidgetPreferences(CWidgetExtension& aWidgetExtension); 173 /** 174 * C++ Constructor 175 */ 176 CWidgetPreferences( CWidgetExtension& aWidgetExtension ); 177 178 /** 179 * Symbian 2nd phase constructor 180 */ 87 181 void ConstructL(); 88 182 89 183 private: 90 RPtrHashMap<TDesC,TDesC> iMap; 91 RPtrHashMap<TDesC,TInt> iSizeMap; 184 RPtrHashMap<TDesC,CPrefElement> iPreferences; 92 185 HBufC* iFilePath; 93 186 CWidgetExtension* iWidgetExtension; //not owned 94 187 HBufC* iBasePath; 95 96 188 }; 97 189 190 98 191 #endif -
S60/trunk/WebKit/BrowserView/src/WidgetExtension.cpp
r23794 r23814 412 412 } 413 413 if ( parentNode ) 414 { 414 415 node = parentNode->FirstChild(); 416 } 415 417 } 416 418 else … … 428 430 } 429 431 if ( iMenuRoot ) 430 node = iMenuRoot->FirstChild(); 432 { 433 node = iMenuRoot->FirstChild(); 434 } 431 435 } 432 436 … … 462 466 { 463 467 if ( iResourceId > R_CASCADE_MENU_1 + KMaxOptionsMenu ) 468 { 464 469 menuData.iCascadeId = 0; 470 } 465 471 else 472 { 466 473 menuData.iCascadeId = iResourceId; 474 } 467 475 } 468 476 else 477 { 469 478 menuData.iCascadeId = 0; 479 } 470 480 471 481 menuData.iFlags = 0; … … 477 487 iCascadeArr.Append( entry ); 478 488 479 aMenuPane.InsertMenuItemL( menuData, 0);489 aMenuPane.InsertMenuItemL( menuData, aMenuPane.NumberOfItemsInPane()-1 ); 480 490 aMenuPane.SetItemDimmed( aNode->CmdId()+KMenuItemCommandIdBase, aNode->Dimmed() ); 481 491 } … … 656 666 // ----------------------------------------------------------------------------- 657 667 // 658 void CWidgetExtension::AddOptionsMenuItem( 668 TInt CWidgetExtension::AddOptionsMenuItem( 659 669 const TDesC& aText, TInt aCmdId, TInt aParentId, void* aObj ) 660 { 661 if ( !iMenuRoot ) 662 { 670 { 671 if ( !iMenuRoot ) 672 { 663 673 iMenuRoot = CMenuItem::NewL( _L(""), -1 ); 664 } 674 } 675 665 676 if ( aText.Length() > 0 ) 666 677 { 667 678 CMenuItem* parent = FindNodeById( iMenuRoot, aParentId ); 668 679 if ( !parent ) 669 return; 670 CMenuItem* item = CMenuItem::NewL( aText, aCmdId, parent, aObj ); 671 Append( parent, item ); 672 } 680 { 681 return KErrGeneral; 682 } 683 684 CMenuItem* item = NULL; 685 item = FindNodeById( iMenuRoot, aCmdId ); 686 if ( item ) 687 { 688 return KErrAlreadyExists; 689 } 690 691 item = FindNodeByText( iMenuRoot, aText ); 692 if ( item ) 693 { 694 return KErrAlreadyExists; 695 } 696 697 item = CMenuItem::NewL( aText, aCmdId, parent, aObj ); 698 return Append( parent, item ); 699 } 700 701 return KErrGeneral; 673 702 } 674 703 … … 696 725 // ----------------------------------------------------------------------------- 697 726 // 698 T Bool CWidgetExtension::Append(727 TInt CWidgetExtension::Append( 699 728 CMenuItem* aParent, CMenuItem* aItem ) 700 { 729 { 701 730 if ( !aParent ) 702 return EFalse; 731 { 732 return KErrGeneral; 733 } 703 734 704 735 if ( aParent->FirstChild() == NULL ) //first child … … 710 741 AppendSibling( aParent->FirstChild(), aItem ); 711 742 } 712 return ETrue;713 } 743 return KErrNone; 744 } 714 745 715 746 // ----------------------------------------------------------------------------- … … 768 799 CMenuItem* item = NULL; 769 800 if ( prev ) 801 { 770 802 item = prev->NextSibling(); 803 } 804 771 805 while( item ) 772 806 { … … 804 838 // ---------------------------------------------------------------------------- 805 839 // 806 void CWidgetExtension::ReplaceMenuItem( 807 TInt oldItemCmdId, 808 const TDesC& newItemText, 809 TInt newItemCmdId, 840 TInt CWidgetExtension::ReplaceMenuItem( 841 TInt oldItemCmdId, 842 const TDesC& newItemText, 843 TInt newItemCmdId, 810 844 TInt newItemDimmed ) 811 845 { 812 CMenuItem* node = NULL; 813 814 node = FindNodeById( iMenuRoot, oldItemCmdId ); 815 if ( node ) 816 { 817 node->SetText( newItemText ); 818 node->SetCmdId( newItemCmdId ); 819 node->SetDimmed( newItemDimmed ); 820 } 846 CMenuItem* newItem = NULL; 847 CMenuItem* oldItem = NULL; 848 849 // check if there is another node in the tree with the same Id as that of 850 // newItem but allow a replace of oldItem with the same Id as the newItem 851 newItem = FindNodeById( iMenuRoot, newItemCmdId ); 852 if ( newItem && newItem->CmdId() != oldItemCmdId ) 853 { 854 return KErrAlreadyExists; 855 } 856 857 // check if there is another node in the tree with the same text as that of 858 // newItem but allow a replace of oldItem with the same text as the newItem 859 newItem = FindNodeByText( iMenuRoot, newItemText ); 860 oldItem = FindNodeById( iMenuRoot, oldItemCmdId ); 861 if ( newItem && oldItem && newItem->Text().Compare(oldItem->Text()) != 0 ) 862 { 863 return KErrAlreadyExists; 864 } 865 866 if ( oldItem ) 867 { 868 oldItem->SetText( newItemText ); 869 oldItem->SetCmdId( newItemCmdId ); 870 oldItem->SetDimmed( newItemDimmed ); 871 return KErrNone; 872 } 873 874 return KErrGeneral; 821 875 } 822 876 … … 862 916 node = FindNodeByText( iMenuRoot, textVal ); 863 917 if ( node ) 918 { 864 919 return node->Obj(); 920 } 865 921 else 922 { 866 923 return NULL; 924 } 867 925 } 868 926 … … 879 937 880 938 node = FindNodeById( iMenuRoot, cmdId ); 939 881 940 if ( node ) 941 { 882 942 return node->Obj(); 943 } 883 944 else 945 { 884 946 return NULL; 947 } 885 948 } 886 949 … … 896 959 CMenuItem* node = NULL; 897 960 node = FindNodeById( iMenuRoot, aCmdId ); 961 898 962 if ( node ) 963 { 899 964 node->SetDimmed( aValue ); 965 } 900 966 } 901 967 … … 912 978 CMenuItem* node = NULL; 913 979 node = FindNodeById( iMenuRoot, aCmdId ); 980 914 981 if ( node ) 982 { 915 983 node->SetCallback( aOnSelectCallback ); 984 } 916 985 } 917 986 … … 927 996 CMenuItem* node = NULL; 928 997 node = FindNodeById( iMenuRoot, aCmdId ); 998 929 999 if ( node ) 1000 { 930 1001 return node->Callback(); 1002 } 931 1003 else 1004 { 932 1005 return NULL; 1006 } 933 1007 } 934 1008 … … 1010 1084 1011 1085 if ( !node ) 1086 { 1012 1087 return item; 1088 } 1013 1089 1014 1090 if ( node->CmdId() == aCmdId ) … … 1044 1120 1045 1121 if ( !node ) 1122 { 1046 1123 return item; 1124 } 1047 1125 1048 1126 if ( node->Text().Compare( aText ) == 0 ) -
S60/trunk/WebKit/BrowserView/src/WidgetPreferences.cpp
r21150 r23814 61 61 // ---------------------------------------------------------------------------- 62 62 // CWidgetPreferences::NewL 63 // 63 // Two-phased constructor 64 64 // 65 65 // … … 76 76 // ---------------------------------------------------------------------------- 77 77 // CWidgetPreferences::NewLC 78 // 78 // Two-phased constructor 79 79 // 80 80 // … … 92 92 // ---------------------------------------------------------------------------- 93 93 // CWidgetPreferences::CWidgetPreferences 94 // 94 // C++ Constructor 95 95 // 96 96 // … … 98 98 CWidgetPreferences::CWidgetPreferences( CWidgetExtension& aWidgetExtension ) 99 99 : iWidgetExtension( &aWidgetExtension ) 100 { 100 { 101 101 } 102 102 103 103 // ---------------------------------------------------------------------------- 104 104 // CWidgetPreferences::~CWidgetPreferences 105 // 105 // Destructor 106 106 // 107 107 // … … 109 109 CWidgetPreferences::~CWidgetPreferences() 110 110 { 111 iMap.ResetAndDestroy(); 112 iMap.Close(); 113 iSizeMap.ResetAndDestroy(); 114 iSizeMap.Close(); 111 iPreferences.ResetAndDestroy(); 112 iPreferences.Close(); 115 113 delete iBasePath; 116 114 } … … 118 116 // ---------------------------------------------------------------------------- 119 117 // CWidgetPreferences::ConstructL 120 // 118 // Symbian 2nd phase constructor 121 119 // 122 120 // … … 128 126 // ---------------------------------------------------------------------------- 129 127 // CWidgetPreferences::PreferenceL 130 // 128 // Get preference for a key 131 129 // 132 130 // … … 134 132 TInt CWidgetPreferences::PreferenceL( const TDesC& aKey, TPtrC& aValue ) 135 133 { 134 TInt rSuccess = KErrNotFound; 135 TInt i = 0; 136 TInt size = 0; 137 136 138 if ( !iBasePath && ( iWidgetExtension->WidgetBasePath().Length() > 0 ) ) 137 139 iBasePath = iWidgetExtension->WidgetBasePath().AllocL(); 138 140 139 TInt rSuccess = KErrNotFound; 140 141 141 142 if ( aKey.Length() <= KMaxKeyValueSize ) 142 143 { 143 144 HBufC* key = HBufC::NewLC( aKey.Length() + KMaxIntLength + 1 ); 144 145 key->Des().Format( KKeyFormat, iWidgetExtension->GetWidgetId(), &aKey ); 145 TInt* size = iSizeMap.Find( *key );146 TDesC* res = iMap.Find( *key );147 148 if ( ! res || !size)146 147 CPrefElement* pref = iPreferences.Find( *key ); 148 149 if ( !pref ) 149 150 { 150 151 CleanupStack::PopAndDestroy( key ); 151 152 return rSuccess; 152 153 } 153 154 if ( *size > KMaxKeyValueSize ) 154 155 size = pref->ValueSize(); 156 157 158 if ( size > KMaxKeyValueSize ) 155 159 { 156 160 // return contents from temp file whose name is stored 157 // in the value field of iMap161 // in the iValue member of iPreferences 158 162 RFs fs; 159 163 … … 161 165 { 162 166 CleanupClosePushL( fs ); 163 HBufC* filePath = HBufC::NewLC( res->Length() ); 164 167 HBufC* filePath = HBufC::NewLC( pref->Value().Length() ); 165 168 TPtr fName( filePath->Des() ); 166 fName.Append( *res);169 fName.Append( pref->Value() ); 167 170 168 171 RFileReadStream readStream; … … 185 188 } 186 189 187 CleanupStack::PopAndDestroy( 2); //filePath,fs190 CleanupStack::PopAndDestroy( 2 ); //filePath,fs 188 191 } 189 192 } 190 else if ( *size >= 0 )191 { 192 aValue.Set( *res);193 else if ( size >= 0 ) 194 { 195 aValue.Set( pref->Value() ); 193 196 rSuccess = KErrNone; 194 197 } 195 198 196 CleanupStack::PopAndDestroy( key);199 CleanupStack::PopAndDestroy( key ); 197 200 } 198 201 … … 202 205 // ---------------------------------------------------------------------------- 203 206 // CWidgetPreferences::SetPreferenceL 204 // 207 // Set Preference for a key 205 208 // 206 209 // … … 219 222 if ( aValue.Length() <= KMaxKeyValueSize ) 220 223 { 221 HBufC* value = aValue.AllocLC(); 222 iMap.InsertL( key, value ); 223 TInt* size = new TInt(aValue.Length()); 224 // make a copy of key and insert that 225 HBufC* newKey = key->AllocLC(); 226 iSizeMap.InsertL( newKey, size ); 227 CleanupStack::Pop( 3 );//newKey,value,key 224 CPrefElement* pref = new (ELeave) CPrefElement; 225 CleanupStack::PushL( pref ); 226 pref->SetValueL( aValue ); 227 pref->SetValueSize( aValue.Length() ); 228 iPreferences.InsertL( key, pref ); 229 CleanupStack::Pop( 2 ); //pref, key 228 230 return; 229 231 } … … 231 233 { 232 234 // create a temp file and save the value in temp file. 233 // i Map value fieldcontains the temp file name.235 // iValue member of CPrefElement contains the temp file name. 234 236 RFs fs; 235 237 RFile file; … … 247 249 TPtr fName( filePath->Des() ); 248 250 fName.Append( tempFileName ); 249 iMap.InsertL( key, filePath ); 250 TInt* size = new TInt( aValue.Length() ); 251 // make a copy of key and insert that 252 HBufC* newKey = key->AllocLC(); 253 iSizeMap.InsertL( newKey, size ); 254 251 CPrefElement* pref = new ( ELeave ) CPrefElement; 252 CleanupStack::PushL( pref ); 253 pref->SetValueL( *filePath ); 254 pref->SetValueSize( aValue.Length() ); 255 iPreferences.InsertL( key, pref ); 255 256 RFileWriteStream writeStream( file ); 256 257 CleanupClosePushL( writeStream ); … … 258 259 writeStream.WriteL( aValue ); 259 260 writeStream.CommitL(); 260 CleanupStack::PopAndDestroy( ); //writeStream261 CleanupStack::Pop( 2 );//newKey,filePath262 CleanupStack::PopAndDestroy( 2 ); //file,fs261 CleanupStack::PopAndDestroy( ); //writeStream 262 CleanupStack::Pop( pref ); 263 CleanupStack::PopAndDestroy( 3 ); //filePath,file,fs 263 264 CleanupStack::Pop( key ); 264 265 return; … … 272 273 // ---------------------------------------------------------------------------- 273 274 // CWidgetPreferences::SaveL 274 // 275 // SAve preferences to persistent storage 275 276 // 276 277 // … … 306 307 { 307 308 CleanupClosePushL( writeStream ); 308 writeStream.WriteInt32L( i Map.Count() );309 310 TPtrHashMapIter<TDesC, TDesC> it( iMap);309 writeStream.WriteInt32L( iPreferences.Count() ); 310 311 TPtrHashMapIter<TDesC,CPrefElement> it( iPreferences ); 311 312 const TDesC* key; 312 const TDesC* value;313 const CPrefElement* pref; 313 314 314 315 while ( ( key = it.NextKey() ) != 0 ) 315 316 { 316 value= it.CurrentValue();317 pref = it.CurrentValue(); 317 318 writeStream.WriteInt32L( key->Length() ); 318 319 writeStream.WriteL( *key ); 319 writeStream.WriteInt32L( value->Length() ); 320 writeStream.WriteL( *value ); 321 TInt* size = iSizeMap.Find( *key ); 322 if ( size ) 323 writeStream.WriteInt32L( *size ); 324 else 325 writeStream.WriteInt32L( 0 ); 320 writeStream.WriteInt32L( pref->Value().Length() ); 321 writeStream.WriteL( pref->Value() ); 322 writeStream.WriteInt32L( pref->ValueSize() ); 326 323 } 327 324 … … 336 333 // ---------------------------------------------------------------------------- 337 334 // CWidgetPreferences::LoadL 338 // 335 // Load preferences from persistent storage 339 336 // 340 337 // … … 379 376 TPtr ptrvalue = value->Des(); 380 377 readStream.ReadL( ptrvalue, len ); 381 iMap.InsertL( key, value ); 382 TInt *size = new TInt ( readStream.ReadInt32L() ); 383 // make a copy of key and insert that 384 HBufC* newKey = key->AllocLC(); 385 iSizeMap.InsertL( newKey, size ); 386 CleanupStack::Pop( 3 ); //newKey,value,key 378 CPrefElement* pref = new ( ELeave ) CPrefElement; 379 CleanupStack::PushL( pref ); 380 pref->SetValueL( ptrvalue ); 381 TInt size = readStream.ReadInt32L(); 382 pref->SetValueSize( size ); 383 iPreferences.InsertL( key, pref ); 384 CleanupStack::Pop(); //pref 385 CleanupStack::PopAndDestroy(); //value 386 CleanupStack::Pop(); //key 387 387 } 388 388 else … … 403 403 } 404 404 } 405 405 406 // ---------------------------------------------------------------------------- 407 // CPrefElement::CPrefElement 408 // C++ constructor 409 // 410 // 411 // ---------------------------------------------------------------------------- 412 CPrefElement::CPrefElement() 413 { 414 } 415 416 417 // ---------------------------------------------------------------------------- 418 // CPrefElement::~CPrefElement 419 // Destructor 420 // 421 // 422 // ---------------------------------------------------------------------------- 423 CPrefElement::~CPrefElement() 424 { 425 delete iValue; 426 } 427 428 429 // ---------------------------------------------------------------------------- 430 // CPrefElement::SetValueL 431 // Set value for a preference 432 // 433 // 434 // ---------------------------------------------------------------------------- 435 void CPrefElement::SetValueL( const TDesC& aValue ) 436 { 437 if ( !iValue ) 438 { 439 iValue = aValue.AllocL(); 440 return; 441 } 442 443 if ( aValue.Length() > iValue->Length() ) 444 { 445 delete iValue; 446 iValue = NULL; 447 iValue = aValue.AllocL(); 448 } 449 else 450 { 451 *iValue = aValue; 452 if ( aValue.Length() < iValue->Length() ) 453 iValue = iValue->ReAllocL( aValue.Length() ); // reclaim space 454 } 455 } -
S60/trunk/WebKit/ChangeLog
r23794 r23814 1 rathnasa, reviewed by <zbujtas@gmail.com> 2 DESC: Widget Menu API needs refinement 3 http://bugs.webkit.org/show_bug.cgi?id=14389 4 5 * BrowserView/inc/WidgetExtension.h: 6 * BrowserView/inc/WidgetPreferences.h: 7 (CPrefElement::SetValueSize): 8 (CPrefElement::Value): 9 (CPrefElement::ValueSize): 10 * BrowserView/src/WidgetExtension.cpp: 11 (CWidgetExtension::AddOptionMenuItemsL): 12 (CWidgetExtension::AddMenuItem): 13 (CWidgetExtension::AddOptionsMenuItem): 14 (CWidgetExtension::Append): 15 (CWidgetExtension::DeleteMenuItem): 16 (CWidgetExtension::ReplaceMenuItem): 17 (CWidgetExtension::GetFromMenuItemCollection): 18 (CWidgetExtension::SetDimmed): 19 (CWidgetExtension::SetMenuItemObserver): 20 (CWidgetExtension::MenuItemObserver): 21 (CWidgetExtension::FindNodeById): 22 (CWidgetExtension::FindNodeByText): 23 * BrowserView/src/WidgetPreferences.cpp: 24 (CWidgetPreferences::CWidgetPreferences): 25 (CWidgetPreferences::~CWidgetPreferences): 26 (CWidgetPreferences::PreferenceL): 27 (CWidgetPreferences::SetPreferenceL): 28 (CWidgetPreferences::SaveL): 29 (CWidgetPreferences::LoadL): 30 (CPrefElement::CPrefElement): 31 (CPrefElement::~CPrefElement): 32 (CPrefElement::SetValueL): 33 1 34 winship, reviewed by <reviewer> 2 35 DESC: SYAI-73ARXK - Widget UI must not have scrollbars, always ON status pane & fullscreen mode
Note: See TracChangeset
for help on using the changeset viewer.