diff options
author | Manuel QuiƱones <manuel.por.aca@gmail.com> | 2011-05-31 04:57:06 (GMT) |
---|---|---|
committer | Gonzalo Odiard <godiard@sugarlabs.org> | 2011-05-31 13:13:05 (GMT) |
commit | d542a53a21f62a1a4c19c9391534eb8f55b72a3b (patch) | |
tree | 4491dfc7e52d21fbfcc704bfd66906a4a3e621ce | |
parent | 78399f5c9a827510094eef25fa24c28a36dffd61 (diff) |
Check for page load in get_page_height function
-rw-r--r-- | epubview/widgets.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/epubview/widgets.py b/epubview/widgets.py index 7af4f31..a603c34 100644 --- a/epubview/widgets.py +++ b/epubview/widgets.py @@ -11,19 +11,21 @@ class _WebView(webkit.WebView): Gets height (in pixels) of loaded (X)HTML page. This is done via javascript at the moment ''' - #TODO: Need to check status of page load js = 'oldtitle=document.title;' + \ + 'if (document.body == null) {' + \ + 'document.title = 0} else {' + \ 'document.title=Math.max(document.body.scrollHeight, ' + \ 'document.body.offsetHeight,document.documentElement.clientHeight,' + \ 'document.documentElement.scrollHeight, ' + \ - 'document.documentElement.offsetHeight);' + 'document.documentElement.offsetHeight)};' self.execute_script(js) ret = self.get_main_frame().get_title() js = 'document.title=oldtitle;' self.execute_script(js) - if ret is None: + try: + return int(ret) + except ValueError: return 0 - return int(ret) def add_bottom_padding(self, incr): ''' |