[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kwebkitpart/1.3] src: - Yet another fix for the history navigation synchornization problem. Now for
From: Dawit Alemayehu <adawit () kde ! org>
Date: 2012-07-31 21:34:23
Message-ID: 20120731213423.A7F88A6094 () git ! kde ! org
[Download RAW message or body]
Git commit 413000f299daba48059718415c7a1aa6d78473ae by Dawit Alemayehu.
Committed on 31/07/2012 at 23:25.
Pushed by adawit into branch '1.3'.
- Yet another fix for the history navigation synchornization problem. Now forward
navigation should no longer cause a KPart's (e.g. Konqueror) history list to be
out of sync.
- Removed few unnecessary debug statements and changed two uses of QWeakPointer to
QPointer.
M +15 -14 src/kwebkitpart.cpp
M +28 -24 src/kwebkitpart_ext.cpp
M +2 -3 src/kwebkitpart_ext.h
M +2 -2 src/webpluginfactory.cpp
http://commits.kde.org/kwebkitpart/413000f299daba48059718415c7a1aa6d78473ae
diff --git a/src/kwebkitpart.cpp b/src/kwebkitpart.cpp
index fb90aec..0f142db 100644
--- a/src/kwebkitpart.cpp
+++ b/src/kwebkitpart.cpp
@@ -476,7 +476,6 @@ void KWebKitPart::slotMainFrameLoadFinished (bool ok)
return;
if (!m_emitOpenUrlNotify) {
- m_browserExtension->slotSaveHistory(); // Cache contents of QWebHistory
m_emitOpenUrlNotify = true; // Save history once page loading is done.
}
@@ -606,22 +605,24 @@ void KWebKitPart::slotSaveFrameState(QWebFrame *frame, \
QWebHistoryItem *item) return;
}
- if (!frame->parentFrame()) {
+ // Handle actions that apply only to the mainframe...
+ if (frame == view()->page()->mainFrame()) {
slotWalletClosed();
- }
- // If "NoEmitOpenUrlNotification" property is set to true, do not
- // emit the open url notification. Property is set by this part's
- // extension to prevent openUrl notification being sent when
- // handling history navigation requests.
- const bool doNotEmitOpenUrl = property("NoEmitOpenUrlNotification").toBool();
- if (doNotEmitOpenUrl) {
- setProperty("NoEmitOpenUrlNotification", QVariant());
- }
+ // If "NoEmitOpenUrlNotification" property is set to true, do not
+ // emit the open url notification. Property is set by this part's
+ // extension to prevent openUrl notification being sent when
+ // handling history navigation requests.
+ const bool doNotEmitOpenUrl = \
property("NoEmitOpenUrlNotification").toBool(); + if (doNotEmitOpenUrl) {
+ setProperty("NoEmitOpenUrlNotification", QVariant());
+ }
- if (m_emitOpenUrlNotify && !doNotEmitOpenUrl && !frame->parentFrame()) {
- // kDebug() << "***** EMITTING openUrlNotify" << item->url();
- emit m_browserExtension->openUrlNotify();
+ // Only emit open url notify for the main frame. Do not
+ if (m_emitOpenUrlNotify && !doNotEmitOpenUrl) {
+ // kDebug() << "***** EMITTING openUrlNotify" << item->url();
+ emit m_browserExtension->openUrlNotify();
+ }
}
// For some reason, QtWebKit does not restore scroll position when
diff --git a/src/kwebkitpart_ext.cpp b/src/kwebkitpart_ext.cpp
index 776513a..eea486c 100644
--- a/src/kwebkitpart_ext.cpp
+++ b/src/kwebkitpart_ext.cpp
@@ -63,8 +63,7 @@
WebKitBrowserExtension::WebKitBrowserExtension(KWebKitPart *parent)
:KParts::BrowserExtension(parent),
- m_part(QWeakPointer<KWebKitPart>(parent)),
- m_currentHistoryItemIndex(-1)
+ m_part(parent)
{
enableAction("cut", false);
enableAction("copy", false);
@@ -79,10 +78,10 @@ WebKitBrowserExtension::~WebKitBrowserExtension()
WebView* WebKitBrowserExtension::view()
{
if (!m_view && m_part) {
- m_view = QWeakPointer<WebView>(qobject_cast<WebView*>(m_part.data()->view()));
+ m_view = qobject_cast<WebView*>(m_part->view());
}
- return m_view.data();
+ return m_view;
}
int WebKitBrowserExtension::xOffset()
@@ -104,10 +103,16 @@ int WebKitBrowserExtension::yOffset()
void WebKitBrowserExtension::saveState(QDataStream &stream)
{
// TODO: Save information such as form data from the current page.
- stream << m_part.data()->url()
+ QWebHistory* history = (view() ? view()->history() : 0);
+ const int historyIndex = history ? history->currentItemIndex() : -1;
+ const KUrl historyUrl = history ? history->currentItem().url() : KUrl();
+
+ Q_ASSERT(historyUrl.isValid()); // should never happen ??
+
+ stream << historyUrl
<< static_cast<qint32>(xOffset())
<< static_cast<qint32>(yOffset())
- << m_currentHistoryItemIndex
+ << historyIndex
<< m_historyData;
}
@@ -144,7 +149,8 @@ void WebKitBrowserExtension::restoreState(QDataStream &stream)
if (QCoreApplication::applicationName() == \
QLatin1String("konqueror")) { history->clear();
}
- m_part.data()->setProperty("NoEmitOpenUrlNotification", \
true); + kDebug() << "Restoring URL:" << currentItem.url();
+ m_part->setProperty("NoEmitOpenUrlNotification", true);
history->goToItem(currentItem);
}
}
@@ -160,7 +166,7 @@ void WebKitBrowserExtension::restoreState(QDataStream &stream)
const QPoint scrollPos (xOfs, yOfs);
item.setUserData(scrollPos);
}
- m_part.data()->setProperty("NoEmitOpenUrlNotification", true);
+ m_part->setProperty("NoEmitOpenUrlNotification", true);
history->goToItem(item);
success = true;
}
@@ -175,7 +181,7 @@ void WebKitBrowserExtension::restoreState(QDataStream &stream)
// As a last resort, in case the history restoration logic above fails,
// attempt to open the requested URL directly.
kDebug() << "Normal history navgation logic failed! Falling back to a \
workaround!";
- m_part.data()->openUrl(u);
+ m_part->openUrl(u);
}
void WebKitBrowserExtension::restoreHistoryFromData (const QByteArray& data)
@@ -248,7 +254,7 @@ void WebKitBrowserExtension::updateEditActions()
void WebKitBrowserExtension::updateActions()
{
- const QString protocol (m_part.data()->url().protocol());
+ const QString protocol (m_part->url().protocol());
const bool isValidDocument = (protocol != QL1S("about") && protocol != \
QL1S("error")); enableAction("print", isValidDocument);
}
@@ -779,28 +785,26 @@ void WebKitBrowserExtension::slotSpellCheckDone(const QString&)
void WebKitBrowserExtension::slotSaveHistory()
{
- QByteArray histData;
- QBuffer buff (&histData);
- if (!buff.open(QIODevice::WriteOnly)) {
- kWarning() << "Failed to save history data!";
- return;
- }
+ QWebHistory* history = (view() ? view()->history() : 0);
- QWebHistory* history = view() ? view()->history() : 0;
if (history && history->count() > 0) {
- QDataStream stream (&buff);
- stream << *history;
- m_historyData = qCompress(histData, 9);
- m_currentHistoryItemIndex = history->currentItemIndex();
- QWidget* mainWidget = m_part.data() ? m_part.data()->widget() : 0;
+ kDebug() << "Current history: index=" << history->currentItemIndex() << \
"url=" << history->currentItem().url(); + QByteArray histData;
+ QBuffer buff (&histData);
+ m_historyData.clear();
+ if (buff.open(QIODevice::WriteOnly)) {
+ QDataStream stream (&buff);
+ stream << *history;
+ m_historyData = qCompress(histData, 9);
+ }
+ QWidget* mainWidget = m_part ? m_part->widget() : 0;
QWidget* frameWidget = mainWidget ? mainWidget->parentWidget() : 0;
if (frameWidget) {
emit saveHistory(frameWidget, m_historyData);
// kDebug() << "# of items:" << history->count() << "current item:" << \
history->currentItemIndex() << "url:" << history->currentItem().url(); }
} else {
- m_historyData.clear();
- m_currentHistoryItemIndex = -1;
+ Q_ASSERT(false); // should never happen!!!
}
}
diff --git a/src/kwebkitpart_ext.h b/src/kwebkitpart_ext.h
index f875c7b..ae79fa3 100644
--- a/src/kwebkitpart_ext.h
+++ b/src/kwebkitpart_ext.h
@@ -113,11 +113,10 @@ public Q_SLOTS:
private:
WebView* view();
- QWeakPointer<KWebKitPart> m_part;
- QWeakPointer<WebView> m_view;
+ QPointer<KWebKitPart> m_part;
+ QPointer<WebView> m_view;
quint32 m_spellTextSelectionStart;
quint32 m_spellTextSelectionEnd;
- quint32 m_currentHistoryItemIndex;
QByteArray m_historyData;
};
diff --git a/src/webpluginfactory.cpp b/src/webpluginfactory.cpp
index 91bbb38..a07baed 100644
--- a/src/webpluginfactory.cpp
+++ b/src/webpluginfactory.cpp
@@ -91,7 +91,7 @@ void FakePluginWidget::load (bool loadAll)
}
const QString selector = \
QLatin1String("object[type=\"%1\"],embed[type=\"%1\"]");
- kDebug() << selector.arg(m_mimeType);
+ //kDebug() << selector.arg(m_mimeType);
hide();
m_swapping = true;
@@ -147,7 +147,7 @@ static uint pluginId(const QUrl& url, const QStringList& \
argNames, const QString
QObject* WebPluginFactory::create (const QString& _mimeType, const QUrl& url, const \
QStringList& argumentNames, const QStringList& argumentValues) const {
- kDebug() << _mimeType << url << argumentNames;
+ //kDebug() << _mimeType << url << argumentNames;
QString mimeType (_mimeType.trimmed());
if (mimeType.isEmpty()) {
extractGuessedMimeType (url, &mimeType);
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic