Browser viewer: Fix back/forward buttons not working correctly when clicking on links that lead to different internal files in the book. Fixes #1700004 [Content server: No way to return after footnote](https://bugs.launchpad.net/calibre/+bug/1700004)

This commit is contained in:
Kovid Goyal 2017-07-03 20:30:38 +05:30
parent 8f640edc1e
commit dc4f4a581f
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 10 additions and 3 deletions

View File

@ -250,7 +250,7 @@ class IframeBoss:
csi = current_spine_item() csi = current_spine_item()
if csi.initial_position: if csi.initial_position:
ipos = csi.initial_position ipos = csi.initial_position
self.replace_history_on_next_cfi_update = ipos.replace_history self.replace_history_on_next_cfi_update = ipos.replace_history or False
if ipos.type is 'frac': if ipos.type is 'frac':
self.to_scroll_fraction(ipos.frac) self.to_scroll_fraction(ipos.frac)
elif ipos.type is 'anchor': elif ipos.type is 'anchor':

View File

@ -101,6 +101,7 @@ class View:
self.search_overlay = SearchOverlay(self) self.search_overlay = SearchOverlay(self)
self.overlay = Overlay(self) self.overlay = Overlay(self)
self.src_doc = None self.src_doc = None
self.processing_spine_item_display = False
self.iframe_ready = False self.iframe_ready = False
self.pending_load = None self.pending_load = None
self.encrypted_communications = False self.encrypted_communications = False
@ -363,6 +364,7 @@ class View:
def show_name(self, name, initial_position=None): def show_name(self, name, initial_position=None):
if self.currently_showing.loading: if self.currently_showing.loading:
return return
self.processing_spine_item_display = False
sd = get_session_data() sd = get_session_data()
settings={ settings={
'margin_left': 0 if name is self.book.manifest.title_page_name else sd.get('margin_left'), 'margin_left': 0 if name is self.book.manifest.title_page_name else sd.get('margin_left'),
@ -393,7 +395,9 @@ class View:
def goto_bookpos(self, bookpos): def goto_bookpos(self, bookpos):
cfiname, internal_cfi = self.parse_cfi(bookpos, self.book) cfiname, internal_cfi = self.parse_cfi(bookpos, self.book)
if cfiname and internal_cfi: if cfiname and internal_cfi:
pos = {} # replace_history has to be true here otherwise forward does not
# work after back, as back uses goto_bookpos
pos = {'replace_history': True}
name = cfiname name = cfiname
pos.type, pos.cfi = 'cfi', internal_cfi pos.type, pos.cfi = 'cfi', internal_cfi
self.show_name(name, initial_position=pos) self.show_name(name, initial_position=pos)
@ -430,7 +434,8 @@ class View:
self.goto_named_destination(toc_node.dest, toc_node.frag) self.goto_named_destination(toc_node.dest, toc_node.frag)
def on_update_cfi(self, data): def on_update_cfi(self, data):
if self.overlay.is_visible or self.search_overlay.is_visible: overlay_shown = not self.processing_spine_item_display and self.overlay.is_visible
if overlay_shown or self.search_overlay.is_visible:
# Chrome on Android stupidly resizes the viewport when the on # Chrome on Android stupidly resizes the viewport when the on
# screen keyboard is displayed. This means that the push_state() # screen keyboard is displayed. This means that the push_state()
# below causes the overlay to be closed, making it impossible to # below causes the overlay to be closed, making it impossible to
@ -483,6 +488,7 @@ class View:
# We cannot encrypt this message because the resource data contains # We cannot encrypt this message because the resource data contains
# Blob objects which do not survive encryption # Blob objects which do not survive encryption
self.encrypted_communications = False self.encrypted_communications = False
self.processing_spine_item_display = True
self.send_message('display', self.send_message('display',
resource_data=resource_data, book=self.book, name=self.currently_showing.name, resource_data=resource_data, book=self.book, name=self.currently_showing.name,
initial_position=self.currently_showing.initial_position, initial_position=self.currently_showing.initial_position,
@ -491,6 +497,7 @@ class View:
self.encrypted_communications = True self.encrypted_communications = True
def on_content_loaded(self, data): def on_content_loaded(self, data):
self.processing_spine_item_display = False
self.hide_loading() self.hide_loading()
frac = data.progress_frac or 0 frac = data.progress_frac or 0
self.update_read_percent(frac) self.update_read_percent(frac)