Commit 10c906a4 authored by adachan@apple.com's avatar adachan@apple.com

WebCore:

        Reviewed by Steve Falkenburg.

        Add a base class for DOMTimer called SuspendableTimer which captures just the
        basic functionality of TimerBase and ActiveDOMObject combined.  It does not
        contain functionality specific to scripting timers.
        
        SuspendableTimer is used in fixing https://bugs.webkit.org/show_bug.cgi?id=39651

        * Android.mk:
        * CMakeLists.txt:
        * GNUmakefile.am:
        * WebCore.gypi:
        * WebCore.pro:
        * WebCore.vcproj/WebCore.vcproj:
        * WebCore.xcodeproj/project.pbxproj:
        * page/DOMTimer.cpp:
        (WebCore::DOMTimer::DOMTimer):
        (WebCore::DOMTimer::contextDestroyed):
        (WebCore::DOMTimer::stop):
        * page/DOMTimer.h:
        * page/SuspendableTimer.cpp: Added.
        (WebCore::SuspendableTimer::SuspendableTimer):
        (WebCore::SuspendableTimer::~SuspendableTimer):
        (WebCore::SuspendableTimer::hasPendingActivity):
        (WebCore::SuspendableTimer::stop):
        (WebCore::SuspendableTimer::suspend):
        (WebCore::SuspendableTimer::resume):
        (WebCore::SuspendableTimer::canSuspend):
        * page/SuspendableTimer.h: Added.

WebKit/win:
        Reviewed by Steve Falkenburg.

        https://bugs.webkit.org/show_bug.cgi?id=39651
        
        Make m_closeWindowTimer a SuspendableTimer, so it is properly suspended
        when page loading is deferred.

        * WebView.cpp:
        (WebView::WebView): m_closeWindowTimer is now a pointer to a SuspendableTimer.
        (WindowCloseTimer::create):
        (WindowCloseTimer::WindowCloseTimer):
        (WindowCloseTimer::contextDestroyed): Make sure we delete the WindowCloseTimer in the end.
        (WindowCloseTimer::fired):
        (WebView::closeWindowSoon):
        (WebView::closeWindowTimerFired):
        (WebView::notifyPreferencesChanged): Can just check for the existence m_closeWindowTimer, since
        we only create it when we need to start the timer.
        * WebView.h:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@60150 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent e5dfa5e9
......@@ -360,6 +360,7 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \
page/SecurityOrigin.cpp \
page/Settings.cpp \
page/SpatialNavigation.cpp \
page/SuspendableTimer.cpp \
page/UserContentURLPattern.cpp \
page/WindowFeatures.cpp \
page/WorkerNavigator.cpp \
......
......@@ -1102,6 +1102,7 @@ SET(WebCore_SOURCES
page/SecurityOrigin.cpp
page/Settings.cpp
page/SpatialNavigation.cpp
page/SuspendableTimer.cpp
page/UserContentURLPattern.cpp
page/WindowFeatures.cpp
page/WorkerNavigator.cpp
......
2010-05-25 Ada Chan <adachan@apple.com>
Reviewed by Steve Falkenburg.
Add a base class for DOMTimer called SuspendableTimer which captures just the
basic functionality of TimerBase and ActiveDOMObject combined. It does not
contain functionality specific to scripting timers.
SuspendableTimer is used in fixing https://bugs.webkit.org/show_bug.cgi?id=39651
* Android.mk:
* CMakeLists.txt:
* GNUmakefile.am:
* WebCore.gypi:
* WebCore.pro:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* page/DOMTimer.cpp:
(WebCore::DOMTimer::DOMTimer):
(WebCore::DOMTimer::contextDestroyed):
(WebCore::DOMTimer::stop):
* page/DOMTimer.h:
* page/SuspendableTimer.cpp: Added.
(WebCore::SuspendableTimer::SuspendableTimer):
(WebCore::SuspendableTimer::~SuspendableTimer):
(WebCore::SuspendableTimer::hasPendingActivity):
(WebCore::SuspendableTimer::stop):
(WebCore::SuspendableTimer::suspend):
(WebCore::SuspendableTimer::resume):
(WebCore::SuspendableTimer::canSuspend):
* page/SuspendableTimer.h: Added.
2010-05-25 Justin Schuh <jschuh@chromium.org>
Reviewed by Nate Chapin.
......
......@@ -1514,6 +1514,8 @@ webcore_sources += \
WebCore/page/Settings.h \
WebCore/page/SpatialNavigation.cpp \
WebCore/page/SpatialNavigation.h \
WebCore/page/SuspendableTimer.cpp \
WebCore/page/SuspendableTimer.h \
WebCore/page/UserContentURLPattern.cpp \
WebCore/page/UserContentURLPattern.h \
WebCore/page/UserScript.h \
......
......@@ -1965,6 +1965,8 @@
'page/Settings.h',
'page/SpatialNavigation.h',
'page/SpatialNavigation.cpp',
'page/SuspendableTimer.cpp',
'page/SuspendableTimer.h',
'page/UserContentURLPattern.cpp',
'page/UserContentURLPattern.h',
'page/UserScript.h',
......
......@@ -797,6 +797,7 @@ SOURCES += \
page/Screen.cpp \
page/Settings.cpp \
page/SpatialNavigation.cpp \
page/SuspendableTimer.cpp \
page/UserContentURLPattern.cpp \
page/WindowFeatures.cpp \
page/XSSAuditor.cpp \
......
......@@ -21612,6 +21612,14 @@
RelativePath="..\page\SpatialNavigation.h"
>
</File>
<File
RelativePath="..\page\SuspendableTimer.cpp"
>
</File>
<File
RelativePath="..\page\SuspendableTimer.h"
>
</File>
<File
RelativePath="..\page\UserContentURLPattern.cpp"
>
......@@ -1207,6 +1207,8 @@
5DFE8F570D16477C0076E937 /* ScheduledAction.h in Headers */ = {isa = PBXBuildFile; fileRef = BCA378BB0D15F64200B793D6 /* ScheduledAction.h */; };
626CDE0E1140424C001E5A68 /* SpatialNavigation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 626CDE0C1140424C001E5A68 /* SpatialNavigation.cpp */; };
626CDE0F1140424C001E5A68 /* SpatialNavigation.h in Headers */ = {isa = PBXBuildFile; fileRef = 626CDE0D1140424C001E5A68 /* SpatialNavigation.h */; settings = {ATTRIBUTES = (Private, ); }; };
62C1217C11AB9E77003C462C /* SuspendableTimer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 62C1217A11AB9E76003C462C /* SuspendableTimer.cpp */; };
62C1217D11AB9E77003C462C /* SuspendableTimer.h in Headers */ = {isa = PBXBuildFile; fileRef = 62C1217B11AB9E77003C462C /* SuspendableTimer.h */; };
62CD32591157E57C0063B0A7 /* CustomEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 62CD32561157E57C0063B0A7 /* CustomEvent.cpp */; };
62CD325A1157E57C0063B0A7 /* CustomEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 62CD32571157E57C0063B0A7 /* CustomEvent.h */; };
63189AE30E83A33300012E41 /* NodeRareData.h in Headers */ = {isa = PBXBuildFile; fileRef = 63189AE20E83A33300012E41 /* NodeRareData.h */; settings = {ATTRIBUTES = (); }; };
......@@ -6816,6 +6818,8 @@
5DC87EEF11716DF2001C0E6D /* EmptyProtocolDefinitions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EmptyProtocolDefinitions.h; sourceTree = "<group>"; };
626CDE0C1140424C001E5A68 /* SpatialNavigation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SpatialNavigation.cpp; sourceTree = "<group>"; };
626CDE0D1140424C001E5A68 /* SpatialNavigation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpatialNavigation.h; sourceTree = "<group>"; };
62C1217A11AB9E76003C462C /* SuspendableTimer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SuspendableTimer.cpp; sourceTree = "<group>"; };
62C1217B11AB9E77003C462C /* SuspendableTimer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SuspendableTimer.h; sourceTree = "<group>"; };
62CD32561157E57C0063B0A7 /* CustomEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CustomEvent.cpp; sourceTree = "<group>"; };
62CD32571157E57C0063B0A7 /* CustomEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CustomEvent.h; sourceTree = "<group>"; };
62CD32581157E57C0063B0A7 /* CustomEvent.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CustomEvent.idl; sourceTree = "<group>"; };
......@@ -12037,6 +12041,8 @@
F587863A02DE3A1401EA4122 /* Settings.h */,
626CDE0C1140424C001E5A68 /* SpatialNavigation.cpp */,
626CDE0D1140424C001E5A68 /* SpatialNavigation.h */,
62C1217A11AB9E76003C462C /* SuspendableTimer.cpp */,
62C1217B11AB9E77003C462C /* SuspendableTimer.h */,
BCACF3BA1072921A00C0C8A3 /* UserContentURLPattern.cpp */,
BCACF3BB1072921A00C0C8A3 /* UserContentURLPattern.h */,
BCA2B0601050475F0043BD1C /* UserScript.h */,
......@@ -19324,6 +19330,7 @@
B734B183119B991D006587BD /* FontTranscoder.h in Headers */,
C544274B11A57E7A0063A749 /* DOMStringList.h in Headers */,
C5137CF311A58378004ADB99 /* JSDOMStringList.h in Headers */,
62C1217D11AB9E77003C462C /* SuspendableTimer.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -21613,6 +21620,7 @@
B734B181119B9911006587BD /* FontTranscoder.cpp in Sources */,
C5137CF211A58378004ADB99 /* JSDOMStringList.cpp in Sources */,
C55610F111A704EB00B82D27 /* DOMStringList.cpp in Sources */,
62C1217C11AB9E77003C462C /* SuspendableTimer.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -44,13 +44,8 @@ double DOMTimer::s_minTimerInterval = 0.010; // 10 milliseconds
static int timerNestingLevel = 0;
DOMTimer::DOMTimer(ScriptExecutionContext* context, PassOwnPtr<ScheduledAction> action, int timeout, bool singleShot)
: ActiveDOMObject(context, this)
: SuspendableTimer(context)
, m_action(action)
, m_nextFireInterval(0)
, m_repeatInterval(0)
#if !ASSERT_DISABLED
, m_suspended(false)
#endif
{
static int lastUsedTimeoutId = 0;
++lastUsedTimeoutId;
......@@ -155,50 +150,19 @@ void DOMTimer::fired()
timerNestingLevel = 0;
}
bool DOMTimer::hasPendingActivity() const
{
return isActive();
}
void DOMTimer::contextDestroyed()
{
ActiveDOMObject::contextDestroyed();
SuspendableTimer::contextDestroyed();
delete this;
}
void DOMTimer::stop()
{
TimerBase::stop();
SuspendableTimer::stop();
// Need to release JS objects potentially protected by ScheduledAction
// because they can form circular references back to the ScriptExecutionContext
// which will cause a memory leak.
m_action.clear();
}
void DOMTimer::suspend()
{
#if !ASSERT_DISABLED
ASSERT(!m_suspended);
m_suspended = true;
#endif
m_nextFireInterval = nextFireInterval();
m_repeatInterval = repeatInterval();
TimerBase::stop();
}
void DOMTimer::resume()
{
#if !ASSERT_DISABLED
ASSERT(m_suspended);
m_suspended = false;
#endif
start(m_nextFireInterval, m_repeatInterval);
}
bool DOMTimer::canSuspend() const
{
return true;
}
} // namespace WebCore
......@@ -27,9 +27,8 @@
#ifndef DOMTimer_h
#define DOMTimer_h
#include "ActiveDOMObject.h"
#include "ScheduledAction.h"
#include "Timer.h"
#include "SuspendableTimer.h"
#include <wtf/OwnPtr.h>
#include <wtf/PassOwnPtr.h>
......@@ -37,7 +36,7 @@ namespace WebCore {
class InspectorTimelineAgent;
class DOMTimer : public TimerBase, public ActiveDOMObject {
class DOMTimer : public SuspendableTimer {
public:
virtual ~DOMTimer();
// Creates a new timer owned by specified ScriptExecutionContext, starts it
......@@ -46,12 +45,8 @@ namespace WebCore {
static void removeById(ScriptExecutionContext*, int timeoutId);
// ActiveDOMObject
virtual bool hasPendingActivity() const;
virtual void contextDestroyed();
virtual void stop();
virtual bool canSuspend() const;
virtual void suspend();
virtual void resume();
// The lowest allowable timer setting (in seconds, 0.001 == 1 ms).
// Default is 10ms.
......@@ -66,11 +61,6 @@ namespace WebCore {
int m_timeoutId;
int m_nestingLevel;
OwnPtr<ScheduledAction> m_action;
double m_nextFireInterval;
double m_repeatInterval;
#if !ASSERT_DISABLED
bool m_suspended;
#endif
static double s_minTimerInterval;
};
......
/*
* Copyright (C) 2008 Apple Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "config.h"
#include "SuspendableTimer.h"
#include "ScriptExecutionContext.h"
namespace WebCore {
SuspendableTimer::SuspendableTimer(ScriptExecutionContext* context)
: ActiveDOMObject(context, this)
, m_nextFireInterval(0)
, m_repeatInterval(0)
#if !ASSERT_DISABLED
, m_suspended(false)
#endif
{
}
SuspendableTimer::~SuspendableTimer()
{
}
bool SuspendableTimer::hasPendingActivity() const
{
return isActive();
}
void SuspendableTimer::stop()
{
TimerBase::stop();
}
void SuspendableTimer::suspend()
{
#if !ASSERT_DISABLED
ASSERT(!m_suspended);
m_suspended = true;
#endif
m_nextFireInterval = nextFireInterval();
m_repeatInterval = repeatInterval();
TimerBase::stop();
}
void SuspendableTimer::resume()
{
#if !ASSERT_DISABLED
ASSERT(m_suspended);
m_suspended = false;
#endif
start(m_nextFireInterval, m_repeatInterval);
}
bool SuspendableTimer::canSuspend() const
{
return true;
}
} // namespace WebCore
/*
* Copyright (C) 2008 Apple Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef SuspendableTimer_h
#define SuspendableTimer_h
#include "ActiveDOMObject.h"
#include "Timer.h"
namespace WebCore {
class SuspendableTimer : public TimerBase, public ActiveDOMObject {
public:
SuspendableTimer(ScriptExecutionContext*);
virtual ~SuspendableTimer();
// ActiveDOMObject
virtual bool hasPendingActivity() const;
virtual void stop();
virtual bool canSuspend() const;
virtual void suspend();
virtual void resume();
private:
virtual void fired() = 0;
double m_nextFireInterval;
double m_repeatInterval;
#if !ASSERT_DISABLED
bool m_suspended;
#endif
};
} // namespace WebCore
#endif // SuspendableTimer_h
2010-05-25 Ada Chan <adachan@apple.com>
Reviewed by Steve Falkenburg.
https://bugs.webkit.org/show_bug.cgi?id=39651
Make m_closeWindowTimer a SuspendableTimer, so it is properly suspended
when page loading is deferred.
* WebView.cpp:
(WebView::WebView): m_closeWindowTimer is now a pointer to a SuspendableTimer.
(WindowCloseTimer::create):
(WindowCloseTimer::WindowCloseTimer):
(WindowCloseTimer::contextDestroyed): Make sure we delete the WindowCloseTimer in the end.
(WindowCloseTimer::fired):
(WebView::closeWindowSoon):
(WebView::closeWindowTimerFired):
(WebView::notifyPreferencesChanged): Can just check for the existence m_closeWindowTimer, since
we only create it when we need to start the timer.
* WebView.h:
2010-05-24 Darin Adler <darin@apple.com>
Reviewed by Eric Seidel.
......
......@@ -330,7 +330,7 @@ WebView::WebView()
, m_didClose(false)
, m_inIMEComposition(0)
, m_toolTipHwnd(0)
, m_closeWindowTimer(this, &WebView::closeWindowTimerFired)
, m_closeWindowTimer(0)
, m_topLevelParent(0)
, m_deleteBackingStoreTimerActive(false)
, m_transparent(false)
......@@ -1079,13 +1079,67 @@ void WebView::frameRect(RECT* rect)
::GetWindowRect(m_viewWindow, rect);
}
class WindowCloseTimer : public WebCore::SuspendableTimer {
public:
static WindowCloseTimer* create(WebView*);
private:
WindowCloseTimer(ScriptExecutionContext*, WebView*);
virtual void contextDestroyed();
virtual void fired();
WebView* m_webView;
};
WindowCloseTimer* WindowCloseTimer::create(WebView* webView)
{
ASSERT_ARG(webView, webView);
Frame* frame = core(webView->topLevelFrame());
ASSERT(frame);
if (!frame)
return 0;
Document* document = frame->document();
ASSERT(document);
if (!document)
return 0;
return new WindowCloseTimer(document, webView);
}
WindowCloseTimer::WindowCloseTimer(ScriptExecutionContext* context, WebView* webView)
: SuspendableTimer(context)
, m_webView(webView)
{
ASSERT_ARG(context, context);
ASSERT_ARG(webView, webView);
}
void WindowCloseTimer::contextDestroyed()
{
SuspendableTimer::contextDestroyed();
delete this;
}
void WindowCloseTimer::fired()
{
m_webView->closeWindowTimerFired();
}
void WebView::closeWindowSoon()
{
m_closeWindowTimer.startOneShot(0);
if (m_closeWindowTimer)
return;
m_closeWindowTimer = WindowCloseTimer::create(this);
if (!m_closeWindowTimer)
return;
m_closeWindowTimer->startOneShot(0);
AddRef();
}
void WebView::closeWindowTimerFired(WebCore::Timer<WebView>*)
void WebView::closeWindowTimerFired()
{
closeWindow();
Release();
......@@ -4737,7 +4791,7 @@ HRESULT WebView::notifyPreferencesChanged(IWebNotification* notification)
settings->setWebGLEnabled(true);
#endif // ENABLE(3D_CANVAS)
if (!m_closeWindowTimer.isActive())
if (!m_closeWindowTimer)
m_mainFrame->invalidate(); // FIXME
hr = updateSharedSettingsFromPreferencesIfNeeded(preferences.get());
......
......@@ -33,7 +33,7 @@
#include <WebCore/DragActions.h>
#include <WebCore/IntRect.h>
#include <WebCore/RefCountedGDIHandle.h>
#include <WebCore/Timer.h>
#include <WebCore/SuspendableTimer.h>
#include <WebCore/WindowMessageListener.h>
#include <WebCore/WKCACFLayer.h>
#include <WebCore/WKCACFLayerRenderer.h>
......@@ -832,6 +832,7 @@ public:
void frameRect(RECT* rect);
void closeWindow();
void closeWindowSoon();
void closeWindowTimerFired();
bool didClose() const { return m_didClose; }
bool transparent() const { return m_transparent; }
......@@ -939,7 +940,6 @@ protected:
void preflightSpellChecker();
bool continuousCheckingAllowed();
void initializeToolTipWindow();
void closeWindowTimerFired(WebCore::Timer<WebView>*);
void prepareCandidateWindow(WebCore::Frame*, HIMC);
void updateSelectionForIME();
LRESULT onIMERequestCharPosition(WebCore::Frame*, IMECHARPOSITION*);
......@@ -1011,7 +1011,7 @@ protected:
static bool s_allowSiteSpecificHacks;
WebCore::Timer<WebView> m_closeWindowTimer;
WebCore::SuspendableTimer* m_closeWindowTimer;
OwnPtr<TRACKMOUSEEVENT> m_mouseOutTracker;
HWND m_topLevelParent;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment