mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-31 22:25:30 +00:00
Back/forward button popups actually do the right thing now.
This commit is contained in:
parent
4f33963031
commit
2a94df8c39
@ -706,20 +706,30 @@ Boolean CBrowserWindow::ObeyCommand(
|
||||
GetHTMLView()->ObeyCommand(inCommand, ioParam);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
#if 0
|
||||
// The forward and back buttons are LBevelButtons, which means they will
|
||||
// broadcast when the user clicks in them. |ioParam| will be the value of
|
||||
// the popup menu, or 0 if the user clicked the button.
|
||||
case cmd_GoForward:
|
||||
if (CApplicationEventAttachment::CurrentEventHasModifiers(optionKey))
|
||||
{
|
||||
if (mContext)
|
||||
if ( ioParam > 0 ) {
|
||||
|
||||
|
||||
}
|
||||
else {
|
||||
if (CApplicationEventAttachment::CurrentEventHasModifiers(optionKey))
|
||||
{
|
||||
mContext->GoForwardOneHost();
|
||||
if (mContext)
|
||||
{
|
||||
mContext->GoForwardOneHost();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SendAEGo(kAENext);
|
||||
}
|
||||
cmdHandled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
SendAEGo(kAENext);
|
||||
}
|
||||
cmdHandled = true;
|
||||
break;
|
||||
|
||||
case cmd_GoBack:
|
||||
@ -736,6 +746,7 @@ Boolean CBrowserWindow::ObeyCommand(
|
||||
}
|
||||
cmdHandled = true;
|
||||
break;
|
||||
#endif
|
||||
|
||||
case cmd_Home:
|
||||
SendAEGo(AE_www_go_home);
|
||||
@ -874,18 +885,11 @@ void CBrowserWindow::ListenToMessage(MessageT inMessage, void* ioParam)
|
||||
CStr255* urlString = (CStr255*)ioParam;
|
||||
if (urlString && mContext)
|
||||
{
|
||||
/* old way
|
||||
URL_Struct* theURL =
|
||||
NET_CreateURLStruct(*urlString, NET_DONT_RELOAD);
|
||||
mContext->SwitchLoadURL(theURL, FO_CACHE_AND_PRESENT);
|
||||
*/
|
||||
if (!urlString->IsEmpty())
|
||||
SendAEGetURL(*urlString);
|
||||
}
|
||||
break;
|
||||
|
||||
case cmd_GoForward:
|
||||
case cmd_GoBack:
|
||||
case cmd_Home:
|
||||
case cmd_Reload:
|
||||
case cmd_Stop:
|
||||
|
@ -45,6 +45,7 @@ CNavigationButtonPopup::CNavigationButtonPopup(
|
||||
LStream* inStream)
|
||||
|
||||
: mBrowserContext(nil),
|
||||
mBrowserWindow(nil),
|
||||
mHistory(nil),
|
||||
mCurrentEntry(nil),
|
||||
mCurrentEntryIndex(0),
|
||||
@ -61,7 +62,23 @@ CNavigationButtonPopup::CNavigationButtonPopup(
|
||||
CNavigationButtonPopup::~CNavigationButtonPopup()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// FinishCreateSelf
|
||||
//
|
||||
void
|
||||
CNavigationButtonPopup :: FinishCreateSelf ( )
|
||||
{
|
||||
CToolbarBevelButton::FinishCreateSelf();
|
||||
|
||||
// LBevelButton will broadcast when an item in the popup menu is picked or when
|
||||
// the button is pressed. We want to handle that here instead of elsewhere
|
||||
AddListener(this);
|
||||
|
||||
} // FinishCreateSelf
|
||||
|
||||
|
||||
#pragma mark -
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@ -138,28 +155,36 @@ CNavigationButtonPopup::InsertHistoryItemIntoMenu(
|
||||
|
||||
#pragma mark -
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ¥ HandleNewValue
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Boolean
|
||||
CNavigationButtonPopup::HandleNewValue(
|
||||
Int32 inNewValue)
|
||||
//
|
||||
// ListenToMessage
|
||||
//
|
||||
// The message sent will have
|
||||
//
|
||||
void
|
||||
CNavigationButtonPopup :: ListenToMessage ( MessageT inMessage, void* ioParam )
|
||||
{
|
||||
if (AssertPreconditions() && inNewValue)
|
||||
{
|
||||
Int32 historyIndex = 0;
|
||||
|
||||
if (GetCommandNumber() == cmd_GoBack)
|
||||
historyIndex = SHIST_GetIndex(mHistory, mCurrentEntry) - inNewValue;
|
||||
else if (GetCommandNumber() == cmd_GoForward)
|
||||
historyIndex = SHIST_GetIndex(mHistory, mCurrentEntry) + inNewValue;
|
||||
|
||||
if (historyIndex)
|
||||
mBrowserContext->LoadHistoryEntry(historyIndex);
|
||||
}
|
||||
Uint32 menuValue = *reinterpret_cast<Uint32*>(ioParam);
|
||||
|
||||
return true;
|
||||
if ( AssertPreconditions() ) {
|
||||
if ( menuValue ) {
|
||||
Int32 historyIndex = 0;
|
||||
|
||||
if (inMessage == cmd_GoBack)
|
||||
historyIndex = SHIST_GetIndex(mHistory, mCurrentEntry) - menuValue;
|
||||
else if (inMessage == cmd_GoForward)
|
||||
historyIndex = SHIST_GetIndex(mHistory, mCurrentEntry) + menuValue;
|
||||
|
||||
if (historyIndex)
|
||||
mBrowserContext->LoadHistoryEntry(historyIndex);
|
||||
}
|
||||
else {
|
||||
if (inMessage == cmd_GoBack)
|
||||
mBrowserWindow->SendAEGo(kAEPrevious);
|
||||
else if (inMessage == cmd_GoForward)
|
||||
mBrowserWindow->SendAEGo(kAENext);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@ -170,17 +195,15 @@ CNavigationButtonPopup::HandleNewValue(
|
||||
Boolean
|
||||
CNavigationButtonPopup::AssertPreconditions()
|
||||
{
|
||||
CMediatedWindow* topWindow = CWindowMediator::GetWindowMediator()->FetchTopWindow(WindowType_Any, regularLayerType);
|
||||
|
||||
CMediatedWindow* topWindow = CWindowMediator::GetWindowMediator()->FetchTopWindow(WindowType_Any, regularLayerType);
|
||||
if (!topWindow || topWindow->GetWindowType() != WindowType_Browser)
|
||||
return false;
|
||||
|
||||
CBrowserWindow* browserWindow = dynamic_cast<CBrowserWindow*>(topWindow);
|
||||
|
||||
if (!browserWindow)
|
||||
mBrowserWindow = dynamic_cast<CBrowserWindow*>(topWindow);
|
||||
if (!mBrowserWindow)
|
||||
return false;
|
||||
|
||||
if (!(mBrowserContext = (CBrowserContext*)browserWindow->GetWindowContext()))
|
||||
if (!(mBrowserContext = (CBrowserContext*)mBrowserWindow->GetWindowContext()))
|
||||
return false;
|
||||
|
||||
if (!(mHistory = &((MWContext*)(*mBrowserContext))->hist))
|
||||
|
@ -33,10 +33,11 @@
|
||||
// Forward declarations
|
||||
|
||||
class CBrowserContext;
|
||||
class CBrowserWindow;
|
||||
|
||||
// Class declaration
|
||||
|
||||
class CNavigationButtonPopup : public CToolbarBevelButton
|
||||
class CNavigationButtonPopup : public CToolbarBevelButton, public LListener
|
||||
{
|
||||
public:
|
||||
enum { class_ID = 'TbNv' };
|
||||
@ -48,17 +49,19 @@ public:
|
||||
|
||||
protected:
|
||||
virtual void ClickSelf ( const SMouseDownEvent & inEvent );
|
||||
|
||||
virtual void FinishCreateSelf ( ) ;
|
||||
|
||||
virtual void AdjustMenuContents();
|
||||
|
||||
virtual void InsertHistoryItemIntoMenu(
|
||||
Int32 inHistoryItemIndex,
|
||||
Int16 inAfterItem);
|
||||
|
||||
virtual Boolean HandleNewValue(Int32 inNewValue);
|
||||
virtual void ListenToMessage ( MessageT inMessage, void* ioParam ) ;
|
||||
|
||||
Boolean AssertPreconditions();
|
||||
|
||||
CBrowserWindow* mBrowserWindow;
|
||||
CBrowserContext* mBrowserContext;
|
||||
History* mHistory;
|
||||
History_entry* mCurrentEntry;
|
||||
|
Loading…
Reference in New Issue
Block a user