+
+void BookView::addJavaScriptObjects()
+{
+ page()->mainFrame()->addToJavaScriptWindowObject("bv", this);
+}
+
+void BookView::onContentsSizeChanged(const QSize &size)
+{
+ Trace t("BookView::onContentsSizeChanged");
+ t.trace(QString("To %1").arg(size.height()));
+ contentsHeight = size.height();
+ if (decorated) {
+ decorated = false;
+ if (restore) {
+ restore = false;
+ if (mBook) {
+ QWebPage *webPage = page();
+ QWebFrame *mainFrame = webPage->mainFrame();
+ int height = contentsHeight;
+ int scrollPos = (qreal)height * positionAfterLoad;
+ mainFrame->setScrollPosition(QPoint(0, scrollPos));
+ t.trace(QString("Restoring positon to %1 (%2%, height %3)").
+ arg(scrollPos).arg(positionAfterLoad * 100).arg(height));
+ foreach (QString key, mainFrame->metaData().keys()) {
+ QString value = mainFrame->metaData().value(key);
+ t.trace(key + ": " + value);
+ }
+ }
+ }
+ }
+}