git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53879
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
bool rt_val;
bool needs_refresh = false;
bool rt_val;
bool needs_refresh = false;
(*m_History)[m_HistoryPos].SetPos(y);
}
(*m_History)[m_HistoryPos].SetPos(y);
}
- if (location[0] == wxT('#'))
+ // first check if we're moving to an anchor in the same page
+ size_t posLocalAnchor = location.Find('#');
+ if ( posLocalAnchor != wxString::npos && posLocalAnchor != 0 )
- // local anchor:
- wxString anch = location.Mid(1) /*1 to end*/;
- m_tmpCanDrawLocks--;
- rt_val = ScrollToAnchor(anch);
- m_tmpCanDrawLocks++;
- }
- else if (location.Find(wxT('#')) != wxNOT_FOUND && location.BeforeFirst(wxT('#')) == m_OpenedPage)
- {
- wxString anch = location.AfterFirst(wxT('#'));
- m_tmpCanDrawLocks--;
- rt_val = ScrollToAnchor(anch);
- m_tmpCanDrawLocks++;
+ // check if the part before the anchor is the same as the (either
+ // relative or absolute) URI of the current page
+ const wxString beforeAnchor = location.substr(0, posLocalAnchor);
+ if ( beforeAnchor != m_OpenedPage &&
+ m_FS->GetPath() + beforeAnchor != m_OpenedPage )
+ {
+ // indicate that we're not moving to a local anchor
+ posLocalAnchor = wxString::npos;
+ }
- else if (location.Find(wxT('#')) != wxNOT_FOUND &&
- (m_FS->GetPath() + location.BeforeFirst(wxT('#'))) == m_OpenedPage)
+
+ if ( posLocalAnchor != wxString::npos )
- wxString anch = location.AfterFirst(wxT('#'));
- rt_val = ScrollToAnchor(anch);
+ rt_val = ScrollToAnchor(location.substr(posLocalAnchor + 1));
+ else // moving to another page
{
needs_refresh = true;
#if wxUSE_STATUSBAR
{
needs_refresh = true;
#if wxUSE_STATUSBAR
}
#endif // wxUSE_STATUSBAR
}
#endif // wxUSE_STATUSBAR
- f = m_Parser->OpenURL(wxHTML_URL_PAGE, location);
+ wxFSFile *f = m_Parser->OpenURL(wxHTML_URL_PAGE, location);
// try to interpret 'location' as filename instead of URL:
if (f == NULL)
// try to interpret 'location' as filename instead of URL:
if (f == NULL)