WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
3.2 patch for menu api enhancement
widget_menu_enh_3.2.patch (text/plain), 24.81 KB, created by
Sornalatha Rathnasamy
on 2007-06-26 07:33:14 PDT
(
hide
)
Description:
3.2 patch for menu api enhancement
Filename:
MIME Type:
Creator:
Sornalatha Rathnasamy
Created:
2007-06-26 07:33:14 PDT
Size:
24.81 KB
patch
obsolete
>Index: WebKit/BrowserView/inc/WidgetExtension.h >=================================================================== >--- WebKit/BrowserView/inc/WidgetExtension.h (revision 23763) >+++ WebKit/BrowserView/inc/WidgetExtension.h (working copy) >@@ -189,9 +189,9 @@ > * @param text buffer displayed in the main area of the menu item > * @param ID of the command to issue when the menu item is selected > * @param command ID of the parent menu item >- * @return none >+ * @return Error code > */ >- void AddOptionsMenuItem( const TDesC& aText, TInt aCmdId, TInt aParentCmdId, void* obj ); >+ TInt AddOptionsMenuItem( const TDesC& aText, TInt aCmdId, TInt aParentCmdId, void* obj ); > > /** > * Method SetRightSoftKeyLabel >@@ -224,9 +224,9 @@ > * @param text/label for the new menu item > * @param command ID of the new menu item > * @param dimmed status >- * @return none >+ * @return Error code > */ >- void ReplaceMenuItem( TInt oldCmdId, const TDesC& newText, >+ TInt ReplaceMenuItem( TInt oldCmdId, const TDesC& newText, > TInt newCmdId, TInt newDimmed ); > > /** >@@ -542,9 +542,9 @@ > * @since 3.2 > * @param parent menu item > * @param menu item to be inserted >- * @return TBool >+ * @return error code > */ >- TBool Append( CMenuItem* root, CMenuItem* item ); >+ TInt Append( CMenuItem* root, CMenuItem* item ); > > /* > * Method AppendSibling >Index: WebKit/BrowserView/inc/WidgetPreferences.h >=================================================================== >--- WebKit/BrowserView/inc/WidgetPreferences.h (revision 23763) >+++ WebKit/BrowserView/inc/WidgetPreferences.h (working copy) >@@ -57,7 +57,77 @@ > class CWidgetExtension; > > // CLASS DECLARATION >+ > /** >+* CPrefElement >+* >+* @lib widgetengine.dll >+* @since 3.2 >+*/ >+class CPrefElement : public CBase >+ { >+public : >+ /** >+ * Constructor. >+ */ >+ CPrefElement(); >+ >+ /** >+ * Destructor. >+ */ >+ ~CPrefElement(); >+ >+ /** >+ * SetValueL >+ * Set value for a preference >+ * @param const TDesC& aValue - The value to be set >+ * @return none >+ */ >+ void SetValueL( const TDesC& aValue ); >+ >+ /** >+ * SetValueSize >+ * Set length of value >+ * @param const TInt aSize - The length to be set >+ * @return none >+ */ >+ void SetValueSize( const TInt aSize ) >+ { >+ iValueSize = aSize; >+ } >+ >+ /** >+ * GetValue >+ * Get value for a preference >+ * @param none >+ * @return const TDesC& - value for the preference >+ */ >+ const TDesC& Value() const >+ { >+ if ( iValue ) >+ return *iValue; >+ else >+ return KNullDesC(); >+ } >+ >+ /** >+ * GetValueSize >+ * Get length of value >+ * @param none >+ * @return TInt - length of value for the preference >+ */ >+ TInt ValueSize() const >+ { >+ return iValueSize; >+ } >+ >+private : >+ HBufC* iValue; // value of the preference >+ TInt iValueSize; // length of the value >+ }; >+ >+ >+/** > * CWidgetPreferences > * > * @lib widgetengine.dll >@@ -67,32 +137,55 @@ > { > > public: >- static CWidgetPreferences* NewL(CWidgetExtension& aWidgetExtension); >- static CWidgetPreferences* NewLC(CWidgetExtension& aWidgetExtension); >+ /** >+ * Two-phased constructor. >+ */ >+ static CWidgetPreferences* NewL( CWidgetExtension& aWidgetExtension ); >+ static CWidgetPreferences* NewLC( CWidgetExtension& aWidgetExtension ); >+ >+ /** >+ * Destructor. >+ */ > ~CWidgetPreferences(); > > public: >+ /** >+ * Load preferences from persistent storage >+ */ > void LoadL(); >+ >+ /** >+ * Save preferences to persistent storage >+ */ > void SaveL(); >- TInt PreferenceL(const TDesC& aName, TPtrC& aValue); >- void SetPreferenceL(const TDesC& aName, const TDesC& aValue); >+ >+ /** >+ * Get preference for a particular key >+ */ >+ TInt PreferenceL( const TDesC& aName, TPtrC& aValue ); >+ >+ /** >+ * Set preference for a particular key >+ */ >+ void SetPreferenceL( const TDesC& aName, const TDesC& aValue ); > > protected: >- void Empty(); >- void CreateFilePathL(); >- HBufC* MakeKeyLC(const TDesC& aName); >- >- protected: >- CWidgetPreferences(CWidgetExtension& aWidgetExtension); >+ /** >+ * C++ Constructor >+ */ >+ CWidgetPreferences( CWidgetExtension& aWidgetExtension ); >+ >+ /** >+ * Symbian 2nd phase constructor >+ */ > void ConstructL(); > > private: >- RPtrHashMap<TDesC,TDesC> iMap; >- RPtrHashMap<TDesC,TInt> iSizeMap; >+ RPtrHashMap<TDesC,CPrefElement> iPreferences; > HBufC* iFilePath; > CWidgetExtension* iWidgetExtension; //not owned > HBufC* iBasePath; >- > }; >- >+ >+ > #endif >Index: WebKit/BrowserView/src/WidgetExtension.cpp >=================================================================== >--- WebKit/BrowserView/src/WidgetExtension.cpp (revision 23763) >+++ WebKit/BrowserView/src/WidgetExtension.cpp (working copy) >@@ -412,7 +412,9 @@ > parentNode = FindNodeById( iMenuRoot, parentCmdId ); > } > if ( parentNode ) >+ { > node = parentNode->FirstChild(); >+ } > } > else > { >@@ -428,7 +430,9 @@ > 0, aMenuPane.NumberOfItemsInPane() - 2 ); > } > if ( iMenuRoot ) >- node = iMenuRoot->FirstChild(); >+ { >+ node = iMenuRoot->FirstChild(); >+ } > } > > if ( node ) >@@ -462,12 +466,18 @@ > if ( aNode->FirstChild() ) > { > if ( iResourceId > R_CASCADE_MENU_1 + KMaxOptionsMenu ) >+ { > menuData.iCascadeId = 0; >+ } > else >+ { > menuData.iCascadeId = iResourceId; >+ } > } > else >+ { > menuData.iCascadeId = 0; >+ } > > menuData.iFlags = 0; > menuData.iText = aNode->Text(); >@@ -477,7 +487,7 @@ > entry.parentCmdId = aNode->CmdId(); > iCascadeArr.Append( entry ); > >- aMenuPane.InsertMenuItemL( menuData, 0 ); >+ aMenuPane.InsertMenuItemL( menuData, aMenuPane.NumberOfItemsInPane()-1 ); > aMenuPane.SetItemDimmed( aNode->CmdId()+KMenuItemCommandIdBase, aNode->Dimmed() ); > } > >@@ -656,21 +666,40 @@ > // > // ----------------------------------------------------------------------------- > // >-void CWidgetExtension::AddOptionsMenuItem( >+TInt CWidgetExtension::AddOptionsMenuItem( > const TDesC& aText, TInt aCmdId, TInt aParentId, void* aObj ) >- { >- if ( !iMenuRoot ) >- { >+ { >+ if ( !iMenuRoot ) >+ { > iMenuRoot = CMenuItem::NewL( _L(""), -1 ); >- } >+ } >+ > if ( aText.Length() > 0 ) > { > CMenuItem* parent = FindNodeById( iMenuRoot, aParentId ); > if ( !parent ) >- return; >- CMenuItem* item = CMenuItem::NewL( aText, aCmdId, parent, aObj ); >- Append( parent, item ); >+ { >+ return KErrGeneral; >+ } >+ >+ CMenuItem* item = NULL; >+ item = FindNodeById( iMenuRoot, aCmdId ); >+ if ( item ) >+ { >+ return KErrAlreadyExists; >+ } >+ >+ item = FindNodeByText( iMenuRoot, aText ); >+ if ( item ) >+ { >+ return KErrAlreadyExists; >+ } >+ >+ item = CMenuItem::NewL( aText, aCmdId, parent, aObj ); >+ return Append( parent, item ); > } >+ >+ return KErrGeneral; > } > > // ----------------------------------------------------------------------------- >@@ -694,11 +723,13 @@ > // > // ----------------------------------------------------------------------------- > // >-TBool CWidgetExtension::Append( >+TInt CWidgetExtension::Append( > CMenuItem* aParent, CMenuItem* aItem ) >- { >+ { > if ( !aParent ) >- return EFalse; >+ { >+ return KErrGeneral; >+ } > > if ( aParent->FirstChild() == NULL ) //first child > { >@@ -708,8 +739,8 @@ > { > AppendSibling( aParent->FirstChild(), aItem ); > } >- return ETrue; >- } >+ return KErrNone; >+ } > > // ----------------------------------------------------------------------------- > // CWidgetExtension::AppendSibling >@@ -766,7 +797,10 @@ > CMenuItem* prev = parent->FirstChild(); > CMenuItem* item = NULL; > if ( prev ) >+ { > item = prev->NextSibling(); >+ } >+ > while( item ) > { > if ( item->CmdId() == aCmdId ) >@@ -802,21 +836,41 @@ > // > // ---------------------------------------------------------------------------- > // >-void CWidgetExtension::ReplaceMenuItem( >- TInt oldItemCmdId, >- const TDesC& newItemText, >- TInt newItemCmdId, >+TInt CWidgetExtension::ReplaceMenuItem( >+ TInt oldItemCmdId, >+ const TDesC& newItemText, >+ TInt newItemCmdId, > TInt newItemDimmed ) > { >- CMenuItem* node = NULL; >- >- node = FindNodeById( iMenuRoot, oldItemCmdId ); >- if ( node ) >+ CMenuItem* newItem = NULL; >+ CMenuItem* oldItem = NULL; >+ >+ // check if there is another node in the tree with the same Id as that of >+ // newItem but allow a replace of oldItem with the same Id as the newItem >+ newItem = FindNodeById( iMenuRoot, newItemCmdId ); >+ if ( newItem && newItem->CmdId() != oldItemCmdId ) > { >- node->SetText( newItemText ); >- node->SetCmdId( newItemCmdId ); >- node->SetDimmed( newItemDimmed ); >+ return KErrAlreadyExists; > } >+ >+ // check if there is another node in the tree with the same text as that of >+ // newItem but allow a replace of oldItem with the same text as the newItem >+ newItem = FindNodeByText( iMenuRoot, newItemText ); >+ oldItem = FindNodeById( iMenuRoot, oldItemCmdId ); >+ if ( newItem && oldItem && newItem->Text().Compare(oldItem->Text()) != 0 ) >+ { >+ return KErrAlreadyExists; >+ } >+ >+ if ( oldItem ) >+ { >+ oldItem->SetText( newItemText ); >+ oldItem->SetCmdId( newItemCmdId ); >+ oldItem->SetDimmed( newItemDimmed ); >+ return KErrNone; >+ } >+ >+ return KErrGeneral; > } > > // ---------------------------------------------------------------------------- >@@ -860,9 +914,13 @@ > > node = FindNodeByText( iMenuRoot, textVal ); > if ( node ) >+ { > return node->Obj(); >+ } > else >+ { > return NULL; >+ } > } > > // ---------------------------------------------------------------------------- >@@ -877,10 +935,15 @@ > CMenuItem* node = NULL; > > node = FindNodeById( iMenuRoot, cmdId ); >+ > if ( node ) >+ { > return node->Obj(); >+ } > else >+ { > return NULL; >+ } > } > > // ---------------------------------------------------------------------------- >@@ -894,8 +957,11 @@ > { > CMenuItem* node = NULL; > node = FindNodeById( iMenuRoot, aCmdId ); >+ > if ( node ) >+ { > node->SetDimmed( aValue ); >+ } > } > > // ---------------------------------------------------------------------------- >@@ -910,8 +976,11 @@ > { > CMenuItem* node = NULL; > node = FindNodeById( iMenuRoot, aCmdId ); >+ > if ( node ) >+ { > node->SetCallback( aOnSelectCallback ); >+ } > } > > // ---------------------------------------------------------------------------- >@@ -925,10 +994,15 @@ > { > CMenuItem* node = NULL; > node = FindNodeById( iMenuRoot, aCmdId ); >+ > if ( node ) >+ { > return node->Callback(); >+ } > else >+ { > return NULL; >+ } > } > > >@@ -1008,7 +1082,9 @@ > CMenuItem* item = NULL; > > if ( !node ) >+ { > return item; >+ } > > if ( node->CmdId() == aCmdId ) > { >@@ -1042,7 +1118,9 @@ > CMenuItem* item = NULL; > > if ( !node ) >+ { > return item; >+ } > > if ( node->Text().Compare( aText ) == 0 ) > { >Index: WebKit/BrowserView/src/WidgetPreferences.cpp >=================================================================== >--- WebKit/BrowserView/src/WidgetPreferences.cpp (revision 23763) >+++ WebKit/BrowserView/src/WidgetPreferences.cpp (working copy) >@@ -60,9 +60,9 @@ > > // ---------------------------------------------------------------------------- > // CWidgetPreferences::NewL >+// Two-phased constructor > // > // >-// > // ---------------------------------------------------------------------------- > CWidgetPreferences* CWidgetPreferences::NewL( > CWidgetExtension& aWidgetExtension ) >@@ -75,9 +75,9 @@ > > // ---------------------------------------------------------------------------- > // CWidgetPreferences::NewLC >+// Two-phased constructor > // > // >-// > // ---------------------------------------------------------------------------- > CWidgetPreferences* CWidgetPreferences::NewLC( > CWidgetExtension& aWidgetExtension ) >@@ -91,35 +91,33 @@ > > // ---------------------------------------------------------------------------- > // CWidgetPreferences::CWidgetPreferences >+// C++ Constructor > // > // >-// > // ---------------------------------------------------------------------------- > CWidgetPreferences::CWidgetPreferences( CWidgetExtension& aWidgetExtension ) > : iWidgetExtension( &aWidgetExtension ) >- { >+ { > } > > // ---------------------------------------------------------------------------- > // CWidgetPreferences::~CWidgetPreferences >+// Destructor > // > // >-// > // ---------------------------------------------------------------------------- > CWidgetPreferences::~CWidgetPreferences() > { >- iMap.ResetAndDestroy(); >- iMap.Close(); >- iSizeMap.ResetAndDestroy(); >- iSizeMap.Close(); >+ iPreferences.ResetAndDestroy(); >+ iPreferences.Close(); > delete iBasePath; > } > > // ---------------------------------------------------------------------------- > // CWidgetPreferences::ConstructL >+// Symbian 2nd phase constructor > // > // >-// > // ---------------------------------------------------------------------------- > void CWidgetPreferences::ConstructL() > { >@@ -127,43 +125,48 @@ > > // ---------------------------------------------------------------------------- > // CWidgetPreferences::PreferenceL >+// Get preference for a key > // > // >-// > // ---------------------------------------------------------------------------- > TInt CWidgetPreferences::PreferenceL( const TDesC& aKey, TPtrC& aValue ) > { >+ TInt rSuccess = KErrNotFound; >+ TInt i = 0; >+ TInt size = 0; >+ > if ( !iBasePath && ( iWidgetExtension->WidgetBasePath().Length() > 0 ) ) > iBasePath = iWidgetExtension->WidgetBasePath().AllocL(); > >- TInt rSuccess = KErrNotFound; >- >+ > if ( aKey.Length() <= KMaxKeyValueSize ) > { > HBufC* key = HBufC::NewLC( aKey.Length() + KMaxIntLength + 1 ); > key->Des().Format( KKeyFormat, iWidgetExtension->GetWidgetId(), &aKey ); >- TInt* size = iSizeMap.Find( *key ); >- TDesC* res = iMap.Find( *key ); >- >- if ( !res || !size ) >+ >+ CPrefElement* pref = iPreferences.Find( *key ); >+ >+ if ( !pref ) > { > CleanupStack::PopAndDestroy( key ); > return rSuccess; > } >+ >+ size = pref->ValueSize(); >+ > >- if ( *size > KMaxKeyValueSize ) >+ if ( size > KMaxKeyValueSize ) > { > // return contents from temp file whose name is stored >- // in the value field of iMap >+ // in the iValue member of iPreferences > RFs fs; > > if ( fs.Connect() == KErrNone ) > { > CleanupClosePushL( fs ); >- HBufC* filePath = HBufC::NewLC( res->Length() ); >- >+ HBufC* filePath = HBufC::NewLC( pref->Value().Length() ); > TPtr fName( filePath->Des() ); >- fName.Append( *res ); >+ fName.Append( pref->Value() ); > > RFileReadStream readStream; > >@@ -184,16 +187,16 @@ > CleanupStack::PopAndDestroy();//readStream > } > >- CleanupStack::PopAndDestroy(2); //filePath,fs >+ CleanupStack::PopAndDestroy( 2 ); //filePath,fs > } > } >- else if ( *size >= 0 ) >+ else if ( size >= 0 ) > { >- aValue.Set( *res ); >+ aValue.Set( pref->Value() ); > rSuccess = KErrNone; > } > >- CleanupStack::PopAndDestroy(key); >+ CleanupStack::PopAndDestroy( key ); > } > > return rSuccess; >@@ -201,9 +204,9 @@ > > // ---------------------------------------------------------------------------- > // CWidgetPreferences::SetPreferenceL >+// Set Preference for a key > // > // >-// > // ---------------------------------------------------------------------------- > void CWidgetPreferences::SetPreferenceL( > const TDesC& aKey, const TDesC& aValue ) >@@ -218,19 +221,18 @@ > > if ( aValue.Length() <= KMaxKeyValueSize ) > { >- HBufC* value = aValue.AllocLC(); >- iMap.InsertL( key, value ); >- TInt* size = new TInt(aValue.Length()); >- // make a copy of key and insert that >- HBufC* newKey = key->AllocLC(); >- iSizeMap.InsertL( newKey, size ); >- CleanupStack::Pop( 3 );//newKey,value,key >+ CPrefElement* pref = new (ELeave) CPrefElement; >+ CleanupStack::PushL( pref ); >+ pref->SetValueL( aValue ); >+ pref->SetValueSize( aValue.Length() ); >+ iPreferences.InsertL( key, pref ); >+ CleanupStack::Pop( 2 ); //pref, key > return; > } > else > { > // create a temp file and save the value in temp file. >- // iMap value field contains the temp file name. >+ // iValue member of CPrefElement contains the temp file name. > RFs fs; > RFile file; > >@@ -246,20 +248,19 @@ > > TPtr fName( filePath->Des() ); > fName.Append( tempFileName ); >- iMap.InsertL( key, filePath ); >- TInt* size = new TInt( aValue.Length() ); >- // make a copy of key and insert that >- HBufC* newKey = key->AllocLC(); >- iSizeMap.InsertL( newKey, size ); >- >+ CPrefElement* pref = new ( ELeave ) CPrefElement; >+ CleanupStack::PushL( pref ); >+ pref->SetValueL( *filePath ); >+ pref->SetValueSize( aValue.Length() ); >+ iPreferences.InsertL( key, pref ); > RFileWriteStream writeStream( file ); > CleanupClosePushL( writeStream ); > writeStream.WriteInt32L( aValue.Length() ); > writeStream.WriteL( aValue ); > writeStream.CommitL(); >- CleanupStack::PopAndDestroy(); //writeStream >- CleanupStack::Pop( 2 );//newKey,filePath >- CleanupStack::PopAndDestroy( 2 ); //file,fs >+ CleanupStack::PopAndDestroy( ); //writeStream >+ CleanupStack::Pop( pref ); >+ CleanupStack::PopAndDestroy( 3 ); //filePath,file,fs > CleanupStack::Pop( key ); > return; > } >@@ -271,9 +272,9 @@ > > // ---------------------------------------------------------------------------- > // CWidgetPreferences::SaveL >+// SAve preferences to persistent storage > // > // >-// > // ---------------------------------------------------------------------------- > void CWidgetPreferences::SaveL() > { >@@ -305,24 +306,20 @@ > if ( fileerror == KErrNone ) > { > CleanupClosePushL( writeStream ); >- writeStream.WriteInt32L( iMap.Count() ); >- >- TPtrHashMapIter<TDesC,TDesC> it( iMap ); >+ writeStream.WriteInt32L( iPreferences.Count() ); >+ >+ TPtrHashMapIter<TDesC,CPrefElement> it( iPreferences ); > const TDesC* key; >- const TDesC* value; >+ const CPrefElement* pref; > > while ( ( key = it.NextKey() ) != 0 ) > { >- value = it.CurrentValue(); >+ pref = it.CurrentValue(); > writeStream.WriteInt32L( key->Length() ); > writeStream.WriteL( *key ); >- writeStream.WriteInt32L( value->Length() ); >- writeStream.WriteL( *value ); >- TInt* size = iSizeMap.Find( *key ); >- if ( size ) >- writeStream.WriteInt32L( *size ); >- else >- writeStream.WriteInt32L( 0 ); >+ writeStream.WriteInt32L( pref->Value().Length() ); >+ writeStream.WriteL( pref->Value() ); >+ writeStream.WriteInt32L( pref->ValueSize() ); > } > > writeStream.CommitL(); >@@ -335,9 +332,9 @@ > > // ---------------------------------------------------------------------------- > // CWidgetPreferences::LoadL >+// Load preferences from persistent storage > // > // >-// > // ---------------------------------------------------------------------------- > void CWidgetPreferences::LoadL() > { >@@ -378,12 +375,15 @@ > HBufC* value = HBufC::NewLC( len ); > TPtr ptrvalue = value->Des(); > readStream.ReadL( ptrvalue, len ); >- iMap.InsertL( key, value ); >- TInt *size = new TInt ( readStream.ReadInt32L() ); >- // make a copy of key and insert that >- HBufC* newKey = key->AllocLC(); >- iSizeMap.InsertL( newKey, size ); >- CleanupStack::Pop( 3 ); //newKey,value,key >+ CPrefElement* pref = new ( ELeave ) CPrefElement; >+ CleanupStack::PushL( pref ); >+ pref->SetValueL( ptrvalue ); >+ TInt size = readStream.ReadInt32L(); >+ pref->SetValueSize( size ); >+ iPreferences.InsertL( key, pref ); >+ CleanupStack::Pop(); //pref >+ CleanupStack::PopAndDestroy(); //value >+ CleanupStack::Pop(); //key > } > else > { >@@ -402,4 +402,54 @@ > CleanupStack::PopAndDestroy( 2 ); //fs,filePath > } > } >+ >+// ---------------------------------------------------------------------------- >+// CPrefElement::CPrefElement >+// C++ constructor >+// >+// >+// ---------------------------------------------------------------------------- >+CPrefElement::CPrefElement() >+ { >+ } > >+ >+// ---------------------------------------------------------------------------- >+// CPrefElement::~CPrefElement >+// Destructor >+// >+// >+// ---------------------------------------------------------------------------- >+CPrefElement::~CPrefElement() >+ { >+ delete iValue; >+ } >+ >+ >+// ---------------------------------------------------------------------------- >+// CPrefElement::SetValueL >+// Set value for a preference >+// >+// >+// ---------------------------------------------------------------------------- >+void CPrefElement::SetValueL( const TDesC& aValue ) >+ { >+ if ( !iValue ) >+ { >+ iValue = aValue.AllocL(); >+ return; >+ } >+ >+ if ( aValue.Length() > iValue->Length() ) >+ { >+ delete iValue; >+ iValue = NULL; >+ iValue = aValue.AllocL(); >+ } >+ else >+ { >+ *iValue = aValue; >+ if ( aValue.Length() < iValue->Length() ) >+ iValue = iValue->ReAllocL( aValue.Length() ); // reclaim space >+ } >+ }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
zalan
:
review+
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 14389
:
15231
|
15232
| 15245 |
15376
|
15491
|
15494