Update the traversal path logic.

Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>


git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14220 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
ydong10 2013-03-27 03:09:18 +00:00
parent 05b9f4cf70
commit c40bd44249
3 changed files with 66 additions and 27 deletions

View File

@ -244,6 +244,11 @@ SendForm (
// //
gFooterHeight = FOOTER_HEIGHT + (Index / 3); gFooterHeight = FOOTER_HEIGHT + (Index / 3);
//
// Clean the history menu list.
//
InitializeListHead (&gMenuList);
// //
// Save globals used by SendForm() // Save globals used by SendForm()
// //
@ -378,6 +383,7 @@ SendForm (
} }
FreeBrowserStrings (); FreeBrowserStrings ();
UiFreeMenuList(&gMenuList);
gST->ConOut->SetAttribute (gST->ConOut, EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK)); gST->ConOut->SetAttribute (gST->ConOut, EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK));
gST->ConOut->ClearScreen (gST->ConOut); gST->ConOut->ClearScreen (gST->ConOut);

View File

@ -15,7 +15,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "Setup.h" #include "Setup.h"
LIST_ENTRY gMenuOption; LIST_ENTRY gMenuOption;
LIST_ENTRY gMenuList = INITIALIZE_LIST_HEAD_VARIABLE (gMenuList); LIST_ENTRY gMenuList;
MENU_REFRESH_ENTRY *gMenuRefreshHead; // Menu list used for refresh timer opcode. MENU_REFRESH_ENTRY *gMenuRefreshHead; // Menu list used for refresh timer opcode.
MENU_REFRESH_ENTRY *gMenuEventGuidRefreshHead; // Menu list used for refresh event guid opcode. MENU_REFRESH_ENTRY *gMenuEventGuidRefreshHead; // Menu list used for refresh event guid opcode.
@ -219,9 +219,10 @@ UiAddMenuList (
/** /**
Search Menu with given FormId and FormSetGuid in all cached menu list. Search Menu with given FormId, FormSetGuid and Handle in all cached menu list.
@param Parent The parent of menu to search. @param Parent The parent of menu to search.
@param Handle Hii handle related to this formset.
@param FormSetGuid The Formset GUID of the menu to search. @param FormSetGuid The Formset GUID of the menu to search.
@param FormId The Form ID of menu to search. @param FormId The Form ID of menu to search.
@ -231,6 +232,7 @@ UiAddMenuList (
UI_MENU_LIST * UI_MENU_LIST *
UiFindChildMenuList ( UiFindChildMenuList (
IN UI_MENU_LIST *Parent, IN UI_MENU_LIST *Parent,
IN EFI_HII_HANDLE Handle,
IN EFI_GUID *FormSetGuid, IN EFI_GUID *FormSetGuid,
IN UINT16 FormId IN UINT16 FormId
) )
@ -241,7 +243,7 @@ UiFindChildMenuList (
ASSERT (Parent != NULL); ASSERT (Parent != NULL);
if (Parent->FormId == FormId && CompareGuid (FormSetGuid, &Parent->FormSetGuid)) { if (Parent->FormId == FormId && CompareGuid (FormSetGuid, &Parent->FormSetGuid) && Parent->HiiHandle == Handle) {
return Parent; return Parent;
} }
@ -249,7 +251,7 @@ UiFindChildMenuList (
while (!IsNull (&Parent->ChildListHead, Link)) { while (!IsNull (&Parent->ChildListHead, Link)) {
Child = UI_MENU_LIST_FROM_LINK (Link); Child = UI_MENU_LIST_FROM_LINK (Link);
MenuList = UiFindChildMenuList (Child, FormSetGuid, FormId); MenuList = UiFindChildMenuList (Child, Handle, FormSetGuid, FormId);
if (MenuList != NULL) { if (MenuList != NULL) {
return MenuList; return MenuList;
} }
@ -262,9 +264,10 @@ UiFindChildMenuList (
/** /**
Search Menu with given FormSetGuid and FormId in all cached menu list. Search Menu with given Handle, FormSetGuid and FormId in all cached menu list.
@param FormSetGuid The Formset GUID of the menu to search. @param FormSetGuid The Formset GUID of the menu to search.
@param Handle Hii handle related to this formset.
@param FormId The Form ID of menu to search. @param FormId The Form ID of menu to search.
@return A pointer to menu found or NULL if not found. @return A pointer to menu found or NULL if not found.
@ -272,6 +275,7 @@ UiFindChildMenuList (
**/ **/
UI_MENU_LIST * UI_MENU_LIST *
UiFindMenuList ( UiFindMenuList (
IN EFI_HII_HANDLE Handle,
IN EFI_GUID *FormSetGuid, IN EFI_GUID *FormSetGuid,
IN UINT16 FormId IN UINT16 FormId
) )
@ -284,8 +288,14 @@ UiFindMenuList (
while (!IsNull (&gMenuList, Link)) { while (!IsNull (&gMenuList, Link)) {
MenuList = UI_MENU_LIST_FROM_LINK (Link); MenuList = UI_MENU_LIST_FROM_LINK (Link);
Child = UiFindChildMenuList(MenuList, FormSetGuid, FormId); Child = UiFindChildMenuList(MenuList, Handle, FormSetGuid, FormId);
if (Child != NULL) { if (Child != NULL) {
//
// If this form already in the menu history list,
// just free the list between old this form.
//
UiFreeMenuList(&Child->ChildListHead);
return Child; return Child;
} }
@ -295,6 +305,28 @@ UiFindMenuList (
return NULL; return NULL;
} }
/**
Free Menu list linked list.
@param MenuListHead One Menu list point in the menu list.
**/
VOID
UiFreeMenuList (
LIST_ENTRY *MenuListHead
)
{
UI_MENU_LIST *MenuList;
while (!IsListEmpty (MenuListHead)) {
MenuList = UI_MENU_LIST_FROM_LINK (MenuListHead->ForwardLink);
RemoveEntryList (&MenuList->Link);
UiFreeMenuList(&MenuList->ChildListHead);
FreePool (MenuList);
}
}
/** /**
Free Menu option linked list. Free Menu option linked list.
@ -1997,11 +2029,8 @@ ProcessGotoOpCode (
FORM_BROWSER_FORM *RefForm; FORM_BROWSER_FORM *RefForm;
EFI_INPUT_KEY Key; EFI_INPUT_KEY Key;
EFI_STATUS Status; EFI_STATUS Status;
UI_MENU_LIST *MenuList;
BOOLEAN UpdateFormInfo; Status = EFI_SUCCESS;
Status = EFI_SUCCESS;
UpdateFormInfo = TRUE;
StringPtr = NULL; StringPtr = NULL;
// //
@ -2122,22 +2151,10 @@ ProcessGotoOpCode (
*NewLine = TRUE; *NewLine = TRUE;
} }
} }
UpdateFormInfo = FALSE;
} else { } else {
if ((Statement->QuestionFlags & EFI_IFR_FLAG_CALLBACK) != 0) { if ((Statement->QuestionFlags & EFI_IFR_FLAG_CALLBACK) != 0) {
Selection->Action = UI_ACTION_REFRESH_FORM; Selection->Action = UI_ACTION_REFRESH_FORM;
} }
UpdateFormInfo = FALSE;
}
if (UpdateFormInfo) {
//
// Link current form so that we can always go back when someone hits the ESC
//
MenuList = UiFindMenuList (&Selection->FormSetGuid, Selection->FormId);
if (MenuList == NULL && Selection->CurrentMenu != NULL) {
MenuList = UiAddMenuList (Selection->CurrentMenu, Selection->Handle, &Selection->FormSetGuid, Selection->FormId);
}
} }
return Status; return Status;
@ -2279,12 +2296,12 @@ UiDisplayMenu (
// //
// Find current Menu // Find current Menu
// //
CurrentMenu = UiFindMenuList (&Selection->FormSetGuid, Selection->FormId); CurrentMenu = UiFindMenuList (Selection->Handle, &Selection->FormSetGuid, Selection->FormId);
if (CurrentMenu == NULL) { if (CurrentMenu == NULL) {
// //
// Current menu not found, add it to the menu tree // Current menu not found, add it to the menu tree
// //
CurrentMenu = UiAddMenuList (NULL, Selection->Handle, &Selection->FormSetGuid, Selection->FormId); CurrentMenu = UiAddMenuList (Selection->CurrentMenu, Selection->Handle, &Selection->FormSetGuid, Selection->FormId);
} }
ASSERT (CurrentMenu != NULL); ASSERT (CurrentMenu != NULL);
Selection->CurrentMenu = CurrentMenu; Selection->CurrentMenu = CurrentMenu;

View File

@ -195,6 +195,7 @@ typedef struct {
extern LIST_ENTRY gMenuOption; extern LIST_ENTRY gMenuOption;
extern LIST_ENTRY gMenuList;
extern MENU_REFRESH_ENTRY *gMenuRefreshHead; extern MENU_REFRESH_ENTRY *gMenuRefreshHead;
extern UI_MENU_SELECTION *gCurrentSelection; extern UI_MENU_SELECTION *gCurrentSelection;
extern BOOLEAN mHiiPackageListUpdated; extern BOOLEAN mHiiPackageListUpdated;
@ -250,9 +251,10 @@ UiAddMenuList (
); );
/** /**
Search Menu with given FormId in the parent menu and all its child menus. Search Menu with given FormId, FormSetGuid and Handle in all cached menu list.
@param Parent The parent of menu to search. @param Parent The parent of menu to search.
@param Handle Hii handle related to this formset.
@param FormSetGuid The Formset GUID of the menu to search. @param FormSetGuid The Formset GUID of the menu to search.
@param FormId The Form ID of menu to search. @param FormId The Form ID of menu to search.
@ -262,14 +264,16 @@ UiAddMenuList (
UI_MENU_LIST * UI_MENU_LIST *
UiFindChildMenuList ( UiFindChildMenuList (
IN UI_MENU_LIST *Parent, IN UI_MENU_LIST *Parent,
IN EFI_HII_HANDLE Handle,
IN EFI_GUID *FormSetGuid, IN EFI_GUID *FormSetGuid,
IN UINT16 FormId IN UINT16 FormId
); );
/** /**
Search Menu with given FormSetGuid and FormId in all cached menu list. Search Menu with given Handle, FormSetGuid and FormId in all cached menu list.
@param FormSetGuid The Formset GUID of the menu to search. @param FormSetGuid The Formset GUID of the menu to search.
@param Handle Hii handle related to this formset.
@param FormId The Form ID of menu to search. @param FormId The Form ID of menu to search.
@return A pointer to menu found or NULL if not found. @return A pointer to menu found or NULL if not found.
@ -277,10 +281,22 @@ UiFindChildMenuList (
**/ **/
UI_MENU_LIST * UI_MENU_LIST *
UiFindMenuList ( UiFindMenuList (
IN EFI_HII_HANDLE Handle,
IN EFI_GUID *FormSetGuid, IN EFI_GUID *FormSetGuid,
IN UINT16 FormId IN UINT16 FormId
); );
/**
Free Menu list linked list.
@param MenuListHead One Menu list point in the menu list.
**/
VOID
UiFreeMenuList (
LIST_ENTRY *MenuListHead
);
/** /**
Free Menu option linked list. Free Menu option linked list.