Created
February 16, 2013 13:16
-
-
Save nowrep/4966923 to your computer and use it in GitHub Desktop.
Page Visibility API for QtWebKit 2.3 modified patch from https://bugs.webkit.org/show_bug.cgi?id=109422
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4926e111898c9e2e2da040b1c2776e0c5503afb1 | |
diff --git a/Source/WebKit/qt/Api/qwebpage.cpp b/Source/WebKit/qt/Api/qwebpage.cpp | |
index 053c4d8..aacad16 100644 | |
--- a/Source/WebKit/qt/Api/qwebpage.cpp | |
+++ b/Source/WebKit/qt/Api/qwebpage.cpp | |
@@ -674,6 +674,18 @@ void QWebPagePrivate::updateEditorActions() | |
updateAction(QWebPage::AlignRight); | |
} | |
+void QWebPagePrivate::setVisibilityState(int visibilityState, bool isInitialState) | |
+{ | |
+#if ENABLE(PAGE_VISIBILITY_API) | |
+ if (!page) | |
+ return; | |
+ page->setVisibilityState(static_cast<WebCore::PageVisibilityState>(visibilityState), isInitialState); | |
+#else | |
+ Q_UNUSED(visibilityState); | |
+ Q_UNUSED(isInitialState); | |
+#endif | |
+} | |
+ | |
void QWebPagePrivate::timerEvent(QTimerEvent *ev) | |
{ | |
int timerId = ev->timerId(); | |
@@ -1029,6 +1041,11 @@ void QWebPagePrivate::leaveEvent(QEvent*) | |
mouseMoveEvent(&fakeEvent); | |
} | |
+void QWebPage::setVisibilityState(int visibilityState, bool isInitialState) | |
+{ | |
+ d->setVisibilityState(visibilityState, isInitialState); | |
+} | |
+ | |
/*! | |
\property QWebPage::palette | |
\brief the page's palette | |
@@ -1946,6 +1963,10 @@ QWebPage::QWebPage(QObject *parent) | |
{ | |
setView(qobject_cast<QWidget*>(parent)); | |
+#if ENABLE(PAGE_VISIBILITY_API) | |
+ setVisibilityState(PageVisibilityStateHidden, true); | |
+#endif | |
+ | |
connect(this, SIGNAL(loadProgress(int)), this, SLOT(_q_onLoadProgressChanged(int))); | |
#ifndef NDEBUG | |
connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), this, SLOT(_q_cleanupLeakMessages())); | |
diff --git a/Source/WebKit/qt/Api/qwebpage.h b/Source/WebKit/qt/Api/qwebpage.h | |
index 3eedfeb..926f8a8 100644 | |
--- a/Source/WebKit/qt/Api/qwebpage.h | |
+++ b/Source/WebKit/qt/Api/qwebpage.h | |
@@ -314,6 +314,8 @@ public: | |
void setContentEditable(bool editable); | |
bool isContentEditable() const; | |
+ void setVisibilityState(int visibilityState, bool isInitialState); | |
+ | |
#ifndef QT_NO_CONTEXTMENU | |
bool swallowContextMenuEvent(QContextMenuEvent *event); | |
#endif | |
diff --git a/Source/WebKit/qt/Api/qwebpage_p.h b/Source/WebKit/qt/Api/qwebpage_p.h | |
index 7943229..3ad53b1 100644 | |
--- a/Source/WebKit/qt/Api/qwebpage_p.h | |
+++ b/Source/WebKit/qt/Api/qwebpage_p.h | |
@@ -95,6 +95,8 @@ public: | |
void updateNavigationActions(); | |
void updateEditorActions(); | |
+ void setVisibilityState(int, bool); | |
+ | |
QColor colorSelectionRequested(const QColor& selectedColor); | |
void timerEvent(QTimerEvent*); | |
diff --git a/Source/WebKit/qt/Api/qwebview.cpp b/Source/WebKit/qt/Api/qwebview.cpp | |
index 8f9dc15..2e83f36 100644 | |
--- a/Source/WebKit/qt/Api/qwebview.cpp | |
+++ b/Source/WebKit/qt/Api/qwebview.cpp | |
@@ -739,8 +739,13 @@ bool QWebView::event(QEvent *e) | |
// Always return true so that we'll receive also TouchUpdate and TouchEnd events | |
return true; | |
- } else if (e->type() == QEvent::Leave) | |
+ } else if (e->type() == QEvent::Leave) { | |
d->page->event(e); | |
+ } else if (e->type() == QEvent::Show || e->type() == QEvent::WindowActivate) { | |
+ d->page->setVisibilityState(WebCore::PageVisibilityStateVisible, false); | |
+ } else if (e->type() == QEvent::Hide || e->type() == QEvent::WindowDeactivate) { | |
+ d->page->setVisibilityState(WebCore::PageVisibilityStateHidden, false); | |
+ } | |
} | |
return QWidget::event(e); | |
@@ -1051,6 +1056,16 @@ void QWebView::changeEvent(QEvent *e) | |
d->page->setPalette(palette()); | |
QWidget::changeEvent(e); | |
} | |
+/*!\reimp | |
+*/ | |
+void QWebView::setVisible(bool visible) | |
+{ | |
+ QWidget::setVisible(visible); | |
+#if ENABLE(PAGE_VISIBILITY_API) | |
+ if (d->page) | |
+ d->page->setVisibilityState(visible ? WebCore::PageVisibilityStateVisible : WebCore::PageVisibilityStateHidden, false); | |
+#endif | |
+} | |
/*! | |
\fn void QWebView::titleChanged(const QString &title) | |
diff --git a/Source/WebKit/qt/Api/qwebview.h b/Source/WebKit/qt/Api/qwebview.h | |
index 90d0a8e..bfd9747 100644 | |
--- a/Source/WebKit/qt/Api/qwebview.h | |
+++ b/Source/WebKit/qt/Api/qwebview.h | |
@@ -138,6 +138,7 @@ protected: | |
virtual QWebView *createWindow(QWebPage::WebWindowType type); | |
virtual void changeEvent(QEvent*); | |
+ virtual void setVisible(bool); | |
virtual void mouseMoveEvent(QMouseEvent*); | |
virtual void mousePressEvent(QMouseEvent*); | |
virtual void mouseDoubleClickEvent(QMouseEvent*); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment