E-book viewer: Use the Qt API to set document padding during next page operation, instead of javascript. Fixes #5343 (Preview EPUB "crashes" when PgDwn is used)

This commit is contained in:
Kovid Goyal 2010-04-29 20:40:18 -06:00
parent 8a759d7738
commit a47273f7b8

View File

@ -394,13 +394,14 @@ class Document(QWebPage):
return self.mainFrame().contentsSize().width() # offsetWidth gives inaccurate results return self.mainFrame().contentsSize().width() # offsetWidth gives inaccurate results
def set_bottom_padding(self, amount): def set_bottom_padding(self, amount):
padding = '%dpx'%amount body = self.mainFrame().documentElement().findFirst('body')
try: if body.isNull():
old_padding = unicode(self.javascript('$("body").css("padding-bottom")').toString()) return
except: old_padding = unicode(body.styleProperty('padding-bottom',
old_padding = '' body.ComputedStyle)).strip()
padding = u'%dpx'%amount
if old_padding != padding: if old_padding != padding:
self.javascript('$("body").css("padding-bottom", "%s")' % padding) body.setStyleProperty('padding-bottom', padding + ' !important')
class EntityDeclarationProcessor(object): class EntityDeclarationProcessor(object):