Skip to content

Add NavigationService.RemoveForwardEntry #7229

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,12 @@ bool CanGoBack
/// </summary>
/// <returns>The JournalEntry removed</returns>
JournalEntry RemoveBackEntry();

/// <summary>
/// Remove the first JournalEntry from NavigationWindow's forward history
/// </summary>
/// <returns>The JournalEntry removed</returns>
JournalEntry RemoveForwardEntry();

/// <summary>
/// The back stack of the navigator, when it owns a journal (JournalNavigationScope).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,12 @@ public JournalEntry RemoveBackEntry()
_host.VerifyContextAndObjectState();
return _journal == null ? null : _journal.RemoveBackEntry();
}

public JournalEntry RemoveForwardEntry()
{
_host.VerifyContextAndObjectState();
return _journal == null ? null : _journal.RemoveForwardEntry();
}

public System.Collections.IEnumerable BackStack
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ public enum JournalOwnership
Automatic = 0,

/// <summary>
/// The Frame has its own Journal which operates independent of the hosting containers
/// The Frame has its own Journal which operates independent of the hosting containers
/// journal (if it has one).
/// </summary>
OwnsJournal,

/// <summary>
/// The Frames journal entries are merged into the hosting containers journal, if available.
/// The Frames journal entries are merged into the hosting containers journal, if available.
/// Otherwise navigations in this frame are not journaled.
/// </summary>
UsesParentJournal
Expand Down Expand Up @@ -863,6 +863,17 @@ public JournalEntry RemoveBackEntry()
throw new InvalidOperationException(SR.Get(SRID.InvalidOperation_NoJournal));
return _ownJournalScope.RemoveBackEntry();
}

/// <summary>
/// Removes the first JournalEntry from the frame's forward stack.
/// </summary>
/// <exception cref="InvalidOperationException"> The frame doesn't own a journal. </exception>
public JournalEntry RemoveForwardEntry()
{
if (_ownJournalScope == null)
throw new InvalidOperationException(SR.Get(SRID.InvalidOperation_NoJournal));
return _ownJournalScope.RemoveForwardEntry();
}

/// <summary>
/// Navigates to the Uri and downloads the content. Whether the navigation is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,27 @@ internal JournalEntry RemoveBackEntry()
UpdateView();
return removedEntry;
}

/// <summary>
/// Remove the top JournalEntry from forward entry
/// </summary>
// Not a true "remove"
internal JournalEntry RemoveForwardEntry()
{
Debug.Assert(ValidateIndexes());
int index = _currentEntryIndex; // start from current but do not change it
do
{
if (++index >= TotalCount)
{
return null;
}
} while (IsNavigable(_journalEntryList[index]) == false);
JournalEntry removedEntry = RemoveEntryInternal(index);
Debug.Assert(ValidateIndexes());
UpdateView();
return removedEntry;
}

/// <summary>
/// Ensures current data about the current page is stored in the journal.
Expand Down Expand Up @@ -433,7 +454,7 @@ internal void NavigateTo(JournalEntry target)
int index = _journalEntryList.IndexOf(target);

// When navigating back to a page which contains a previously navigated frame a
// saved journal entry is replayed to restore the frames location, in many cases
// saved journal entry is replayed to restore the frame's location, in many cases
// this entry is not in the journal.
if (index > -1)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1477,6 +1477,20 @@ public JournalEntry RemoveBackEntry()
return null; //(Normally, no exception is thrown if there is no back entry.)
return JournalScope.RemoveBackEntry();
}

/// <summary>
/// Remove the first JournalEntry from NavigationWindow's forward history
/// </summary>
public JournalEntry RemoveForwardEntry()
{
if (IsDisposed)
{
return null;
}
if (JournalScope == null)
return null; //(Normally, no exception is thrown if there is no forward entry.)
return JournalScope.RemoveForwardEntry();
}

//
// bool INavigator.Navigate(Uri source)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,14 @@ public JournalEntry RemoveBackEntry()
{
return _JNS.RemoveBackEntry();
}

/// <summary>
/// Remove the first JournalEntry from NavigationWindow's forward history
/// </summary>
public JournalEntry RemoveForwardEntry()
{
return _JNS.RemoveForwardEntry();
}
#endregion INavigator Methods

#region IUriContext Members
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5016,6 +5016,7 @@ protected virtual void OnContentRendered(System.EventArgs args) { }
protected override System.Windows.Automation.Peers.AutomationPeer OnCreateAutomationPeer() { throw null; }
public void Refresh() { }
public System.Windows.Navigation.JournalEntry RemoveBackEntry() { throw null; }
public System.Windows.Navigation.JournalEntry RemoveForwardEntry() { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public override bool ShouldSerializeContent() { throw null; }
public void StopLoading() { }
Expand Down Expand Up @@ -12085,6 +12086,7 @@ public void GoForward() { }
public bool Navigate(System.Uri source, object navigationState, bool sandboxExternalContent) { throw null; }
public void Refresh() { }
public System.Windows.Navigation.JournalEntry RemoveBackEntry() { throw null; }
public System.Windows.Navigation.JournalEntry RemoveForwardEntry() { throw null; }
public void StopLoading() { }
}
public delegate void NavigationStoppedEventHandler(object sender, System.Windows.Navigation.NavigationEventArgs e);
Expand Down Expand Up @@ -12138,6 +12140,7 @@ protected override void OnClosed(System.EventArgs args) { }
protected override System.Windows.Automation.Peers.AutomationPeer OnCreateAutomationPeer() { throw null; }
public void Refresh() { }
public System.Windows.Navigation.JournalEntry RemoveBackEntry() { throw null; }
public System.Windows.Navigation.JournalEntry RemoveForwardEntry() { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public override bool ShouldSerializeContent() { throw null; }
public void StopLoading() { }
Expand Down