Skip to content

Instantly share code, notes, and snippets.

@zenoalbisser
Created July 25, 2012 14:57
Show Gist options
  • Select an option

  • Save zenoalbisser/3176606 to your computer and use it in GitHub Desktop.

Select an option

Save zenoalbisser/3176606 to your computer and use it in GitHub Desktop.
commit 139dc780c527fbfe5b5cf495dcbf6c1e29e2222d
Author: Zeno Albisser <zeno@webkit.org>
Date: Wed Jul 25 16:48:01 2012 +0200
rafN
diff --git a/Source/WTF/ChangeLog b/Source/WTF/ChangeLog
index 1ff1262..f84c98a 100644
--- a/Source/WTF/ChangeLog
+++ b/Source/WTF/ChangeLog
@@ -1,3 +1,16 @@
+2012-07-25 Zeno Albisser <zeno@webkit.org>
+
+ [Qt] requestAnimationFrame should only trigger when a new frame can be displayed.
+ https://bugs.webkit.org/show_bug.cgi?id=88638
+
+ Disable REQUEST_ANIMATION_FRAME_TIMER for the Qt port and tie
+ the servicing of scripted animations to the renderNextFrame call for WK2.
+ For WK1 we rely on the RefreshAnimation that is based on QAbstractAnimation.
+
+ Reviewed by NOBODY (OOPS!).
+
+ * wtf/Platform.h:
+
2012-07-25 Csaba Osztrogonác <ossy@webkit.org>
[Qt] There are parallel GC related crashes regularly
diff --git a/Source/WTF/wtf/Platform.h b/Source/WTF/wtf/Platform.h
index 726a66b..f99c4c8 100644
--- a/Source/WTF/wtf/Platform.h
+++ b/Source/WTF/wtf/Platform.h
@@ -1105,7 +1105,7 @@
#define WTF_USE_COREMEDIA 1
#endif
-#if PLATFORM(MAC) || PLATFORM(GTK) || PLATFORM(EFL) || (PLATFORM(WIN) && !OS(WINCE) && !PLATFORM(WIN_CAIRO)) || PLATFORM(QT) || PLATFORM(BLACKBERRY)
+#if PLATFORM(MAC) || PLATFORM(GTK) || PLATFORM(EFL) || (PLATFORM(WIN) && !OS(WINCE) && !PLATFORM(WIN_CAIRO)) || PLATFORM(BLACKBERRY)
#define WTF_USE_REQUEST_ANIMATION_FRAME_TIMER 1
#endif
diff --git a/Source/WebKit/qt/ChangeLog b/Source/WebKit/qt/ChangeLog
index fbfcf39..bbb06b1 100644
--- a/Source/WebKit/qt/ChangeLog
+++ b/Source/WebKit/qt/ChangeLog
@@ -1,3 +1,30 @@
+2012-07-25 Zeno Albisser <zeno@webkit.org>
+
+ [Qt] requestAnimationFrame should only trigger when a new frame can be displayed.
+ https://bugs.webkit.org/show_bug.cgi?id=88638
+
+ Disable REQUEST_ANIMATION_FRAME_TIMER for the Qt port and tie
+ the servicing of scripted animations to the renderNextFrame call for WK2.
+ For WK1 we rely on the RefreshAnimation that is based on QAbstractAnimation.
+
+ Reviewed by NOBODY (OOPS!).
+
+ * WebCoreSupport/ChromeClientQt.cpp:
+ (RefreshAnimation):
+ Add a RefreshAnimation that is based on QAbstractAnimation
+ and drives the servicing of the scripted animations for WK1.
+ (WebCore::RefreshAnimation::RefreshAnimation):
+ (WebCore::RefreshAnimation::duration):
+ (WebCore::RefreshAnimation::updateCurrentTime):
+ (WebCore):
+ (WebCore::ChromeClientQt::scheduleAnimation):
+ Create and start the RefreshAnimation instance with the
+ first call to scheduleAnimation.
+ (WebCore::ChromeClientQt::refreshAnimationCallback):
+ * WebCoreSupport/ChromeClientQt.h:
+ (WebCore):
+ (ChromeClientQt):
+
2012-07-24 Pierre Rossi <pierre.rossi@gmail.com>
[Qt][WK1] color input type support
diff --git a/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp b/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp
index 43b105e..a5d2177 100644
--- a/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp
+++ b/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp
@@ -70,6 +70,7 @@
#include "qwebsecurityorigin.h"
#include "qwebsecurityorigin_p.h"
#include "qwebview.h"
+#include <qabstractanimation.h>
#include <qdebug.h>
#include <qeventloop.h>
#include <qtooltip.h>
@@ -88,11 +89,31 @@
namespace WebCore {
+class RefreshAnimation : public QAbstractAnimation {
+public:
+ RefreshAnimation(ChromeClientQt* chromeClient)
+ : QAbstractAnimation()
+ , m_chromeClient(chromeClient)
+ { }
+
+ virtual int duration() const { return -1; }
+protected:
+ virtual void updateCurrentTime(int currentTime)
+ {
+ UNUSED_PARAM(currentTime);
+
+ m_chromeClient->serviceScriptedAnimations();
+ }
+private:
+ ChromeClientQt* m_chromeClient;
+};
+
bool ChromeClientQt::dumpVisitedLinksCallbacks = false;
ChromeClientQt::ChromeClientQt(QWebPage* webPage)
: m_webPage(webPage)
, m_eventLoop(0)
+ , m_animationScheduled(false)
#if ENABLE(VIDEO) && ((USE(GSTREAMER) && !defined(GST_API_VERSION_1)) || USE(QT_MULTIMEDIA) || USE(QTKIT))
, m_fullScreenVideo(0)
#endif
@@ -618,6 +639,24 @@ void ChromeClientQt::setCursor(const Cursor& cursor)
#endif
}
+void ChromeClientQt::scheduleAnimation()
+{
+ m_animantionScheduled = true;
+ if (!m_refreshAnimation)
+ m_refreshAnimation = adoptPtr(new RefreshAnimation(this));
+ if (m_refreshAnimation->state() != QAbstractAnimation::Running)
+ m_refreshAnimation->start();
+}
+
+void ChromeClientQt::serviceScriptedAnimations()
+{
+ if (m_animationScheduled) {
+ m_animationScheduled = false;
+ m_webPage->mainFrame()->d->frame->view()->serviceScriptedAnimations(convertSecondsToDOMTimeStamp(currentTime()));
+ } else {
+ m_refreshAnimation->stop();
+ }
+}
#if USE(ACCELERATED_COMPOSITING)
void ChromeClientQt::attachRootGraphicsLayer(Frame* frame, GraphicsLayer* graphicsLayer)
diff --git a/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.h b/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.h
index af1fff6..22fb10f 100644
--- a/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.h
+++ b/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.h
@@ -49,6 +49,7 @@ class FileChooser;
class FileIconLoader;
class FloatRect;
class Page;
+class RefreshAnimation;
struct FrameLoadRequest;
class QtAbstractWebPopup;
struct ViewportArguments;
@@ -176,6 +177,9 @@ public:
virtual void setCursor(const Cursor&);
virtual void setCursorHiddenUntilMouseMoves(bool) { }
+ virtual void scheduleAnimation();
+ virtual void serviceScriptedAnimations();
+
virtual void scrollRectIntoView(const LayoutRect) const { }
virtual bool selectItemWritingDirectionIsNatural();
@@ -200,7 +204,9 @@ public:
bool toolBarsVisible;
bool statusBarVisible;
bool menuBarVisible;
+ bool m_animationScheduled;
QEventLoop* m_eventLoop;
+ OwnPtr<RefreshAnimation> m_refreshAnimation;
#if ENABLE(VIDEO) && (USE(GSTREAMER) || USE(QT_MULTIMEDIA) || USE(QTKIT))
FullScreenVideoQt* m_fullScreenVideo;
diff --git a/Source/WebKit2/ChangeLog b/Source/WebKit2/ChangeLog
index aca1cf9..d3b895b 100644
--- a/Source/WebKit2/ChangeLog
+++ b/Source/WebKit2/ChangeLog
@@ -1,3 +1,32 @@
+2012-07-25 Zeno Albisser <zeno@webkit.org>
+
+ [Qt] requestAnimationFrame should only trigger when a new frame can be displayed.
+ https://bugs.webkit.org/show_bug.cgi?id=88638
+
+ Disable REQUEST_ANIMATION_FRAME_TIMER for the Qt port and tie
+ the servicing of scripted animations to the renderNextFrame call for WK2.
+ For WK1 we rely on the RefreshAnimation that is based on QAbstractAnimation.
+
+ Reviewed by NOBODY (OOPS!).
+
+ * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+ (WebKit):
+ (WebKit::WebChromeClient::scheduleAnimation):
+ * WebProcess/WebCoreSupport/WebChromeClient.h:
+ (WebChromeClient):
+ * WebProcess/WebPage/LayerTreeCoordinator/LayerTreeCoordinator.cpp:
+ (WebKit::LayerTreeCoordinator::LayerTreeCoordinator):
+ (WebKit::LayerTreeCoordinator::scheduleAnimation):
+ Override scheduleAnimation and set the flag m_animationScheduled.
+ (WebKit):
+ (WebKit::LayerTreeCoordinator::renderNextFrame):
+ Call serviceScriptedAnimations in case the flag m_animationScheduled
+ was set before.
+ * WebProcess/WebPage/LayerTreeCoordinator/LayerTreeCoordinator.h:
+ (LayerTreeCoordinator):
+ * WebProcess/WebPage/LayerTreeHost.h:
+ (LayerTreeHost):
+
2012-07-25 Gyuyoung Kim <gyuyoung.kim@samsung.com>
[EFL] Use eina_stringshare_add instead of strdup.
diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp
index 33370bd..5dbc9be 100644
--- a/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp
+++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp
@@ -635,6 +635,13 @@ void WebChromeClient::setCursorHiddenUntilMouseMoves(bool hiddenUntilMouseMoves)
m_page->send(Messages::WebPageProxy::SetCursorHiddenUntilMouseMoves(hiddenUntilMouseMoves));
}
+#if ENABLE(REQUEST_ANIMATION_FRAME) && !USE(REQUEST_ANIMATION_FRAME_TIMER)
+void WebChromeClient::scheduleAnimation()
+{
+ m_page->drawingArea()->layerTreeHost()->scheduleAnimation();
+}
+#endif
+
void WebChromeClient::formStateDidChange(const Node*)
{
notImplemented();
diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h b/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h
index 383eeac..619dd6f 100644
--- a/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h
+++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h
@@ -162,6 +162,9 @@ private:
virtual void setCursor(const WebCore::Cursor&) OVERRIDE;
virtual void setCursorHiddenUntilMouseMoves(bool) OVERRIDE;
+#if ENABLE(REQUEST_ANIMATION_FRAME) && !USE(REQUEST_ANIMATION_FRAME_TIMER)
+ virtual void scheduleAnimation() OVERRIDE;
+#endif
// Notification that the given form element has changed. This function
// will be called frequently, so handling should be very fast.
diff --git a/Source/WebKit2/WebProcess/WebPage/LayerTreeCoordinator/LayerTreeCoordinator.cpp b/Source/WebKit2/WebProcess/WebPage/LayerTreeCoordinator/LayerTreeCoordinator.cpp
index a3b9a13..b02b568 100644
--- a/Source/WebKit2/WebProcess/WebPage/LayerTreeCoordinator/LayerTreeCoordinator.cpp
+++ b/Source/WebKit2/WebProcess/WebPage/LayerTreeCoordinator/LayerTreeCoordinator.cpp
@@ -77,6 +77,9 @@ LayerTreeCoordinator::LayerTreeCoordinator(WebPage* webPage)
, m_shouldSyncRootLayer(true)
, m_layerFlushTimer(this, &LayerTreeCoordinator::layerFlushTimerFired)
, m_layerFlushSchedulingEnabled(true)
+#if ENABLE(REQUEST_ANIMATION_FRAME) && !USE(REQUEST_ANIMATION_FRAME_TIMER)
+ , m_animationScheduled(false)
+#endif
{
// Create a root layer.
m_rootLayer = GraphicsLayer::create(this);
@@ -357,6 +360,11 @@ void LayerTreeCoordinator::performScheduledLayerFlush()
if (m_isSuspended || m_waitingForUIProcess)
return;
+ if (m_animationScheduled) {
+ m_animationScheduled = false;
+ m_webPage->corePage()->mainFrame()->view()->serviceScriptedAnimations(convertSecondsToDOMTimeStamp(currentTime()));
+ }
+
m_webPage->layoutIfNeeded();
if (!m_isValid)
@@ -544,6 +552,11 @@ void LayerTreeCoordinator::setVisibleContentsRect(const IntRect& rect, float sca
m_shouldSendScrollPositionUpdate = true;
}
+void LayerTreeCoordinator::scheduleAnimation()
+{
+ m_animationScheduled = true;
+}
+
void LayerTreeCoordinator::renderNextFrame()
{
m_waitingForUIProcess = false;
diff --git a/Source/WebKit2/WebProcess/WebPage/LayerTreeCoordinator/LayerTreeCoordinator.h b/Source/WebKit2/WebProcess/WebPage/LayerTreeCoordinator/LayerTreeCoordinator.h
index 9b5154c..336d7d3 100644
--- a/Source/WebKit2/WebProcess/WebPage/LayerTreeCoordinator/LayerTreeCoordinator.h
+++ b/Source/WebKit2/WebProcess/WebPage/LayerTreeCoordinator/LayerTreeCoordinator.h
@@ -87,6 +87,10 @@ public:
virtual PassOwnPtr<WebCore::GraphicsContext> beginContentUpdate(const WebCore::IntSize&, ShareableBitmap::Flags, ShareableSurface::Handle&, WebCore::IntPoint&);
+#if ENABLE(REQUEST_ANIMATION_FRAME) && !USE(REQUEST_ANIMATION_FRAME_TIMER)
+ virtual void scheduleAnimation() OVERRIDE;
+#endif
+
protected:
explicit LayerTreeCoordinator(WebPage*);
@@ -133,6 +137,9 @@ private:
void layerFlushTimerFired(WebCore::Timer<LayerTreeCoordinator>*);
WebCore::Timer<LayerTreeCoordinator> m_layerFlushTimer;
bool m_layerFlushSchedulingEnabled;
+#if ENABLE(REQUEST_ANIMATION_FRAME) && !USE(REQUEST_ANIMATION_FRAME_TIMER)
+ bool m_animationScheduled;
+#endif
};
}
diff --git a/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.h b/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.h
index 368230c..3eb5a38 100644
--- a/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.h
+++ b/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.h
@@ -105,6 +105,10 @@ public:
virtual WebCore::GraphicsDeviceAdapter* graphicsDeviceAdapter() const { return 0; }
#endif
+#if ENABLE(REQUEST_ANIMATION_FRAME) && !USE(REQUEST_ANIMATION_FRAME_TIMER)
+ virtual void scheduleAnimation() = 0;
+#endif
+
protected:
explicit LayerTreeHost(WebPage*);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment