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
def set_bottom_padding(self, amount):
padding = '%dpx'%amount
try:
old_padding = unicode(self.javascript('$("body").css("padding-bottom")').toString())
except:
old_padding = ''
body = self.mainFrame().documentElement().findFirst('body')
if body.isNull():
return
old_padding = unicode(body.styleProperty('padding-bottom',
body.ComputedStyle)).strip()
padding = u'%dpx'%amount
if old_padding != padding:
self.javascript('$("body").css("padding-bottom", "%s")' % padding)
body.setStyleProperty('padding-bottom', padding + ' !important')
class EntityDeclarationProcessor(object):