Reviewed by Sam Weinig.
- clean up AnimationBase
* page/animation/AnimationBase.cpp:
* page/animation/AnimationBase.h:
* page/animation/CompositeAnimation.cpp:
* page/animation/ImplicitAnimation.cpp:
* page/animation/ImplicitAnimation.h:
* page/animation/KeyframeAnimation.cpp:
* page/animation/KeyframeAnimation.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@36320 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 2d9bf57..9827cfd 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,17 @@
+2008-09-10 Dan Bernstein <mitz@apple.com>
+
+ Reviewed by Sam Weinig.
+
+ - clean up AnimationBase
+
+ * page/animation/AnimationBase.cpp:
+ * page/animation/AnimationBase.h:
+ * page/animation/CompositeAnimation.cpp:
+ * page/animation/ImplicitAnimation.cpp:
+ * page/animation/ImplicitAnimation.h:
+ * page/animation/KeyframeAnimation.cpp:
+ * page/animation/KeyframeAnimation.h:
+
2008-09-10 Alexey Proskuryakov <ap@webkit.org>
Reviewed by Darin Adler.
diff --git a/WebCore/WebCore.base.exp b/WebCore/WebCore.base.exp
index ff6c445..db83779 100644
--- a/WebCore/WebCore.base.exp
+++ b/WebCore/WebCore.base.exp
@@ -454,6 +454,7 @@
__ZN7WebCore4PageD1Ev
__ZN7WebCore5Cache11setDisabledEb
__ZN7WebCore5Cache13getStatisticsEv
+__ZN7WebCore5Cache13runSimulationERKNS_6StringE
__ZN7WebCore5Cache13setCapacitiesEjjj
__ZN7WebCore5Frame10findStringERKNS_6StringEbbbb
__ZN7WebCore5Frame11forceLayoutEb
diff --git a/WebCore/loader/Cache.cpp b/WebCore/loader/Cache.cpp
index 771ab5e4..cadad6e 100644
--- a/WebCore/loader/Cache.cpp
+++ b/WebCore/loader/Cache.cpp
@@ -37,10 +37,143 @@
#include "SystemTime.h"
#include <stdio.h>
+#ifndef NDEBUG
+#include "CString.h"
+#include "FileSystem.h"
+#include "PlatformString.h"
+#include "SQLiteDatabase.h"
+#include "SQLiteStatement.h"
+#endif
+
using namespace std;
namespace WebCore {
+#ifndef NDEBUG
+class SimulatedCachedResource : public CachedResource {
+public:
+ SimulatedCachedResource(const String& url, Type type)
+ : CachedResource(url, type)
+ , m_peakEncodedSize(0)
+ , m_peakDecodedSize(0)
+ , m_suppressSizeChanges(false)
+ {
+ }
+
+ virtual void load(DocLoader*) { }
+ virtual void data(PassRefPtr<SharedBuffer>, bool) { }
+ virtual void error() { }
+
+ virtual void destroyDecodedData() { setDecodedSize(0); }
+
+ unsigned peakEncodedSize() const { return m_peakEncodedSize; }
+ void setPeakEncodedSize(unsigned size) { m_peakEncodedSize = size; }
+
+ unsigned peakDecodedSize() const { return m_peakDecodedSize; }
+ void setPeakDecodedSize(unsigned size) { m_peakDecodedSize = size; }
+
+ double finalDecodedDataAccessTime() const { return m_finalDecodedAccessTime; }
+ void setFinalDecodedDataAccessTime(double time) { m_finalDecodedAccessTime = time; }
+
+ bool suppressSizeChanges() const { return m_suppressSizeChanges; }
+ void setSuppressSizeChanges(bool suppress = true) { m_suppressSizeChanges = suppress; }
+
+private:
+ unsigned m_peakEncodedSize;
+ unsigned m_peakDecodedSize;
+ bool m_suppressSizeChanges;
+ double m_finalDecodedAccessTime;
+};
+
+class CacheEventLogger : public Noncopyable {
+public:
+ CacheEventLogger();
+
+ void log(double time, Cache::EventType, CachedResource*, unsigned size);
+
+ unsigned getIdentifierForURL(const String&);
+ void removeIdentifierForURL(const String&);
+
+ void setTypeForResourceIdentifier(unsigned, CachedResource::Type);
+ void updatePeakDecodedSizeForResourceIdentifier(unsigned identifier, unsigned decodedSize);
+
+private:
+ SQLiteDatabase m_database;
+ unsigned m_lastIdentifier;
+};
+
+CacheEventLogger::CacheEventLogger()
+ : m_lastIdentifier(0)
+{
+ String logDirectory = pathByAppendingComponent(homeDirectoryPath(), "WebCore Cache Logs");
+ makeAllDirectories(logDirectory);
+ m_database.open(pathByAppendingComponent(logDirectory, String::number(static_cast<unsigned>(WebCore::currentTime())) + ".db"));
+ m_database.setSynchronous(SQLiteDatabase::SyncOff);
+ m_database.executeCommand("CREATE TABLE IF NOT EXISTS log (time REAL, eventType INTEGER, identifier INTEGER, encodedSize INTEGER)");
+ m_database.executeCommand("CREATE TEMPORARY TABLE resources (url UNIQUE PRIMARY KEY, identifier INTEGER)");
+ m_database.executeCommand("CREATE TABLE IF NOT EXISTS typesAndSizes (identifier UNIQUE PRIMARY KEY, resourceType INTEGER, peakDecodedSize INTEGER DEFAULT 0)");
+}
+
+void CacheEventLogger::log(double time, Cache::EventType type, CachedResource* resource, unsigned size)
+{
+ SQLiteStatement statement(m_database, "INSERT INTO log (time, eventType, identifier, encodedSize) VALUES (?, ?, ?, ?)");
+ statement.prepare();
+ statement.bindDouble(1, time);
+ statement.bindInt64(2, type);
+ ASSERT(resource->m_identifier);
+ statement.bindInt64(3, resource->m_identifier);
+ statement.bindInt64(4, size);
+ statement.step();
+}
+
+unsigned CacheEventLogger::getIdentifierForURL(const String& url)
+{
+ SQLiteStatement selectStatement(m_database, "SELECT identifier FROM resources WHERE url = ?");
+ selectStatement.prepare();
+ selectStatement.bindText(1, url);
+ selectStatement.step();
+ unsigned identifier = selectStatement.getColumnInt(0);
+ if (identifier)
+ return identifier;
+
+ identifier = ++m_lastIdentifier;
+ SQLiteStatement insertStatement(m_database, "INSERT INTO resources (url, identifier) VALUES (?, ?)");
+ insertStatement.prepare();
+ insertStatement.bindText(1, url);
+ insertStatement.bindInt64(2, identifier);
+ insertStatement.step();
+ return identifier;
+}
+
+void CacheEventLogger::removeIdentifierForURL(const String& url)
+{
+ SQLiteStatement statement(m_database, "DELETE FROM resources WHERE url = ?");
+ statement.prepare();
+ statement.bindText(1, url);
+ statement.step();
+}
+
+void CacheEventLogger::setTypeForResourceIdentifier(unsigned identifier, CachedResource::Type resourceType)
+{
+ SQLiteStatement statement(m_database, "INSERT OR REPLACE INTO typesAndSizes (identifier, resourceType) VALUES (?, ?)");
+ statement.prepare();
+ statement.bindInt64(1, identifier);
+ statement.bindInt64(2, resourceType);
+ statement.step();
+}
+
+void CacheEventLogger::updatePeakDecodedSizeForResourceIdentifier(unsigned identifier, unsigned decodedSize)
+{
+ SQLiteStatement statement(m_database, "UPDATE typesAndSizes SET peakDecodedSize = ? WHERE identifier = ? AND peakDecodedSize < ?");
+ statement.prepare();
+ statement.bindInt64(1, decodedSize);
+ statement.bindInt64(2, identifier);
+ statement.bindInt64(3, decodedSize);
+ statement.step();
+}
+
+#endif
+
static const int cDefaultCacheCapacity = 8192 * 1024;
static const double cMinDelayBeforeLiveDecodedPrune = 1; // Seconds.
static const float cTargetPrunePercentage = .95f; // Percentage of capacity toward which we prune, to avoid immediately pruning again.
@@ -60,6 +193,11 @@
, m_liveSize(0)
, m_deadSize(0)
{
+#ifndef NDEBUG
+ m_eventLogger = new CacheEventLogger();
+ m_inSimulation = false;
+ m_simulatedTime = 0;
+#endif
}
static CachedResource* createResource(CachedResource::Type type, const KURL& url, const String& charset)
@@ -98,17 +236,28 @@
// Look up the resource in our map.
CachedResource* resource = m_resources.get(url.string());
+#ifndef NDEBUG
+ bool created = false;
+#endif
if (resource) {
if (isPreload && !resource->isPreloaded())
return 0;
- if (FrameLoader::restrictAccessToLocal() && !FrameLoader::canLoad(url, String(), docLoader->doc())) {
+ if (
+#ifndef NDEBUG
+ !m_inSimulation &&
+#endif
+ FrameLoader::restrictAccessToLocal() && !FrameLoader::canLoad(url, String(), docLoader->doc())) {
Document* doc = docLoader->doc();
if(doc && !isPreload)
FrameLoader::reportLocalLoadFailed(doc->frame(), resource->url());
return 0;
}
} else {
- if (FrameLoader::restrictAccessToLocal() && !FrameLoader::canLoad(url, String(), docLoader->doc())) {
+ if (
+#ifndef NDEBUG
+ !m_inSimulation &&
+#endif
+ FrameLoader::restrictAccessToLocal() && !FrameLoader::canLoad(url, String(), docLoader->doc())) {
Document* doc = docLoader->doc();
if(doc && !isPreload)
FrameLoader::reportLocalLoadFailed(doc->frame(), url.string());
@@ -116,9 +265,22 @@
}
// The resource does not exist. Create it.
- resource = createResource(type, url, charset);
+#ifndef NDEBUG
+ created = true;
+ if (m_inSimulation)
+ resource = new SimulatedCachedResource(url.string(), type);
+ else
+#endif
+ resource = createResource(type, url, charset);
ASSERT(resource);
+#ifndef NDEBUG
+ if (!m_inSimulation) {
+ resource->m_identifier = m_eventLogger->getIdentifierForURL(url);
+ m_eventLogger->setTypeForResourceIdentifier(resource->m_identifier, type);
+ }
+#endif
+
// Pretend the resource is in the cache, to prevent it from being deleted during the load() call.
// FIXME: CachedResource should just use normal refcounting instead.
resource->setInCache(true);
@@ -151,6 +313,9 @@
return 0;
#endif
+#ifndef NDEBUG
+ log(WebCore::currentTime(), created ? RequestResourceCreatedEvent : RequestResourceExistedEvent, resource);
+#endif
if (!disabled()) {
// This will move the resource to the front of its LRU list and increase its access count.
resourceAccessed(resource);
@@ -269,7 +434,11 @@
return;
unsigned targetSize = static_cast<unsigned>(capacity * cTargetPrunePercentage); // Cut by a percentage to avoid immediately pruning again.
- double currentTime = Frame::currentPaintTimeStamp();
+ double currentTime =
+#ifndef NDEBUG
+ m_inSimulation ? m_simulatedTime :
+#endif
+ Frame::currentPaintTimeStamp();
if (!currentTime) // In case prune is called directly, outside of a Frame paint.
currentTime = WebCore::currentTime();
@@ -333,7 +502,7 @@
while (current) {
CachedResource* prev = current->m_prevInAllResourcesList;
if (!current->hasClients() && !current->isPreloaded()) {
- remove(current);
+ evict(current);
if (m_deadSize <= targetSize)
return;
@@ -362,6 +531,16 @@
void Cache::remove(CachedResource* resource)
{
+#ifndef NDEBUG
+ log(WebCore::currentTime(), RemoveEvent, resource);
+ if (m_eventLogger->getIdentifierForURL(resource->url()) == resource->m_identifier)
+ m_eventLogger->removeIdentifierForURL(resource->url());
+#endif
+ evict(resource);
+}
+
+void Cache::evict(CachedResource* resource)
+{
// The resource may have already been removed by someone other than our caller,
// who needed a fresh copy for a reload. See <http://bugs.webkit.org/show_bug.cgi?id=12479#c6>.
if (resource->inCache()) {
@@ -702,6 +881,207 @@
}
}
}
+
+void Cache::log(double time, EventType type, CachedResource* resource, unsigned size)
+{
+ if (m_inSimulation)
+ return;
+ m_eventLogger->log(time, type, resource, size);
+}
+
+void Cache::updatePeakDecodedSizeForResource(CachedResource* resource)
+{
+ if (m_inSimulation)
+ return;
+ m_eventLogger->updatePeakDecodedSizeForResourceIdentifier(resource->m_identifier, resource->decodedSize());
+}
+
#endif
+String Cache::runSimulation(const String& databasePath)
+{
+ String result;
+#ifndef NDEBUG
+ m_inSimulation = true;
+
+ String utf8Charset("UTF-8");
+ String prefix("sim:");
+ HashMap<unsigned, SimulatedCachedResource*> resourceMap;
+ Vector<double> accessIntervals;
+ Vector<double> decodedDataAges;
+ Vector<std::pair<double, unsigned> > uselessDecodedDataSizeLog;
+ CachedResourceClient client;
+
+ SQLiteDatabase database;
+ database.open(databasePath);
+ SQLiteStatement readLogStatement(database, "SELECT * FROM log ORDER BY time ASC");
+ readLogStatement.prepare();
+
+ unsigned totalEncodedSizeReloaded = 0;
+ unsigned totalDecodingDone = 0;
+
+ while (readLogStatement.step() == SQLResultRow) {
+ double time = readLogStatement.getColumnDouble(0);
+ Cache::EventType type = static_cast<Cache::EventType>(readLogStatement.getColumnInt(1));
+ unsigned identifier = readLogStatement.getColumnInt(2);
+ unsigned size = readLogStatement.getColumnInt(3);
+
+ m_simulatedTime = time;
+ SimulatedCachedResource* existingResource = resourceMap.get(identifier);
+
+ if (!existingResource && type != RequestResourceCreatedEvent && type != RequestResourceExistedEvent) {
+ LOG_ERROR("No existing resource for %d event for resource identifier %d at time %f", type, identifier, time);
+ continue;
+ }
+
+ switch (type) {
+ case RequestResourceCreatedEvent:
+ case RequestResourceExistedEvent:
+ {
+ SQLiteStatement getTypeStatement(database, "SELECT resourceType, peakDecodedSize FROM typesAndSizes WHERE identifier = ?");
+ getTypeStatement.prepare();
+ getTypeStatement.bindInt64(1, identifier);
+ getTypeStatement.step();
+ SimulatedCachedResource* resource = static_cast<SimulatedCachedResource*>(cache()->requestResource(0, static_cast<CachedResource::Type>(getTypeStatement.getColumnInt(0)), KURL(prefix + String::number(identifier)), utf8Charset));
+ if (resource == existingResource) {
+ if (type == RequestResourceCreatedEvent)
+ resource->setSuppressSizeChanges();
+ break;
+ }
+
+ if (existingResource) {
+ ASSERT(!existingResource->hasClients());
+ ASSERT(!existingResource->inCache());
+ unsigned existingPeakEncodedSize = existingResource->peakEncodedSize();
+ totalEncodedSizeReloaded += existingPeakEncodedSize;
+ // Should cause the resource to be deleted.
+ existingResource->setRequest(0);
+ if (type == RequestResourceExistedEvent)
+ resource->setPeakEncodedSize(existingPeakEncodedSize);
+ }
+ resource->setPeakDecodedSize(getTypeStatement.getColumnInt(1));
+
+ SQLiteStatement getFinalDecodedDataAccessTimeStatement(database, "SELECT MAX(time) FROM log WHERE identifier = ? AND eventType = ?");
+ getFinalDecodedDataAccessTimeStatement.prepare();
+ getFinalDecodedDataAccessTimeStatement.bindInt64(1, identifier);
+ getFinalDecodedDataAccessTimeStatement.bindInt64(2, DecodedDataAccessEvent);
+ getFinalDecodedDataAccessTimeStatement.step();
+ resource->setFinalDecodedDataAccessTime(getFinalDecodedDataAccessTimeStatement.getColumnDouble(0));
+
+ // Ensures that canDelete() is always false, so we control deletion.
+ resource->m_request = reinterpret_cast<Request*>(-1);
+ resourceMap.set(identifier, resource);
+ }
+ break;
+ case RemoveEvent:
+ cache()->remove(existingResource);
+ break;
+ case FirstRefEvent:
+ existingResource->addClient(&client);
+ if (!existingResource->encodedSize()) {
+ if (unsigned peakEncodedSize = existingResource->peakEncodedSize())
+ existingResource->setEncodedSize(peakEncodedSize); // Simulate instantaneous loading
+ }
+ break;
+ case LastDerefEvent:
+ if (!existingResource->hasClients()) {
+ LOG_ERROR("Extra last deref event for resource identifier %d at time %f", identifier, time);
+ continue;
+ }
+ existingResource->removeClient(&client);
+ break;
+ case EncodedSizeEvent:
+ if (size > existingResource->peakEncodedSize())
+ existingResource->setPeakEncodedSize(size);
+ if (!existingResource->suppressSizeChanges()) {
+ existingResource->destroyDecodedData();
+ existingResource->setEncodedSize(size);
+ }
+ break;
+ case DecodedDataAccessEvent:
+ if (existingResource->m_lastDecodedAccessTime)
+ accessIntervals.append(time - existingResource->m_lastDecodedAccessTime);
+ existingResource->didAccessDecodedData(time);
+ if (!existingResource->decodedSize()) {
+ if (unsigned peakDecodedSize = existingResource->peakDecodedSize()) {
+ existingResource->setDecodedSize(peakDecodedSize);
+ totalDecodingDone += peakDecodedSize;
+ }
+ }
+ break;
+ default:
+ break;
+ }
+
+ CachedResourceMap::iterator e = m_resources.end();
+ unsigned totalUselessDecodedDataSize = 0;
+ for (CachedResourceMap::iterator i = m_resources.begin(); i != e; ++i) {
+ SimulatedCachedResource* o = static_cast<SimulatedCachedResource*>(i->second);
+ if (o->type() != CachedResource::ImageResource)
+ continue;
+ if (m_simulatedTime > o->finalDecodedDataAccessTime())
+ totalUselessDecodedDataSize += o->decodedSize();
+ }
+ if (uselessDecodedDataSizeLog.isEmpty() || totalUselessDecodedDataSize != uselessDecodedDataSizeLog.last().second)
+ uselessDecodedDataSizeLog.append(std::pair<double, unsigned>(m_simulatedTime, totalUselessDecodedDataSize));
+ }
+
+ FILE* logFile = fopen("/Volumes/Data/Users/dan/Desktop/uselessDecodedDataSizeLog.txt", "w");
+ for (size_t i = 0; i < uselessDecodedDataSizeLog.size(); ++i)
+ fprintf(logFile, "%lf\t%d\n", uselessDecodedDataSizeLog[i].first, uselessDecodedDataSizeLog[i].second);
+ fclose(logFile);
+
+ unsigned totalEncodedSize = 0;
+ unsigned totalEncodedSizeInCache = 0;
+ unsigned totalDecodedSize = 0;
+ unsigned totalDecodedSizeInCache = 0;
+ HashMap<unsigned, SimulatedCachedResource*>::iterator end = resourceMap.end();
+ for (HashMap<unsigned, SimulatedCachedResource*>::iterator it = resourceMap.begin(); it != end; ++it) {
+ totalEncodedSize += it->second->peakEncodedSize();
+ totalDecodedSize += it->second->peakDecodedSize();
+ if (it->second->inCache()) {
+ totalEncodedSizeInCache += it->second->peakEncodedSize();
+ totalDecodedSizeInCache += it->second->peakDecodedSize();
+ if (it->second->decodedSize())
+ decodedDataAges.append(m_simulatedTime - it->second->m_lastDecodedAccessTime);
+ }
+ }
+
+ std::sort(accessIntervals.begin(), accessIntervals.end());
+ std::sort(decodedDataAges.begin(), decodedDataAges.end());
+
+ result = String::format("Total encoded data size: %d\nCached encoded data size: %d\nTotal cache miss encoded data size: %d\nTotal decoded data size: %d\nCached decoded data size: %d\nTotal decoded bytes produced: %d\n",
+ totalEncodedSize, totalEncodedSizeInCache, totalEncodedSizeReloaded, totalDecodedSize, totalDecodedSizeInCache, totalDecodingDone);
+
+ result += "Decoded data repeated access interval histogram:\n";
+ int binTop = 0;
+ size_t samplesInBin = 0;
+ for (size_t i = 0; i < accessIntervals.size(); ++i) {
+ if (accessIntervals[i] > binTop) {
+ result += String::number(binTop) + " : " + String::number(samplesInBin) + ", ";
+ samplesInBin = 0;
+ binTop = static_cast<int>(ceil(accessIntervals[i] / 10) * 10);
+ }
+ samplesInBin++;
+ }
+ result += String::number(binTop) + " : " + String::number(samplesInBin) + ".\n";
+
+ result += "Cached decoded data age histogram:\n";
+ binTop = 0;
+ samplesInBin = 0;
+ for (size_t i = 0; i < decodedDataAges.size(); ++i) {
+ if (decodedDataAges[i] > binTop) {
+ result += String::number(binTop) + " : " + String::number(samplesInBin) + ", ";
+ samplesInBin = 0;
+ binTop = static_cast<int>(ceil(decodedDataAges[i] / 10) * 10);
+ }
+ samplesInBin++;
+ }
+ result += String::number(binTop) + " : " + String::number(samplesInBin) + ".\n";
+
+ m_inSimulation = false;
+#endif // NDEBUG
+ return result;
+}
+
} // namespace WebCore
diff --git a/WebCore/loader/Cache.h b/WebCore/loader/Cache.h
index 63b754e..828396c 100644
--- a/WebCore/loader/Cache.h
+++ b/WebCore/loader/Cache.h
@@ -41,6 +41,9 @@
class CachedCSSStyleSheet;
class CachedResource;
+#ifndef NDEBUG
+class CacheEventLogger;
+#endif
class DocLoader;
class KURL;
@@ -149,6 +152,22 @@
// Function to collect cache statistics for the caches window in the Safari Debug menu.
Statistics getStatistics();
+ String runSimulation(const String&);
+
+#ifndef NDEBUG
+ enum EventType {
+ RequestResourceCreatedEvent,
+ RequestResourceExistedEvent,
+ RemoveEvent,
+ FirstRefEvent,
+ LastDerefEvent,
+ EncodedSizeEvent,
+ DecodedDataAccessEvent
+ };
+
+ void log(double time, EventType, CachedResource*, unsigned size = 0);
+ void updatePeakDecodedSizeForResource(CachedResource*);
+#endif
private:
Cache();
@@ -166,6 +185,8 @@
void pruneDeadResources(); // Flush decoded and encoded data from resources not referenced by Web pages.
void pruneLiveResources(); // Flush decoded data from resources still referenced by Web pages.
+ void evict(CachedResource*);
+
// Member variables.
HashSet<DocLoader*> m_docLoaders;
Loader m_loader;
@@ -191,6 +212,11 @@
// A URL-based map of all resources that are in the cache (including the freshest version of objects that are currently being
// referenced by a Web page).
HashMap<String, CachedResource*> m_resources;
+#ifndef NDEBUG
+ CacheEventLogger* m_eventLogger;
+ bool m_inSimulation;
+ double m_simulatedTime;
+#endif
};
// Function to obtain the global cache.
diff --git a/WebCore/loader/CachedResource.cpp b/WebCore/loader/CachedResource.cpp
index 1fe4899..36b2242 100644
--- a/WebCore/loader/CachedResource.cpp
+++ b/WebCore/loader/CachedResource.cpp
@@ -69,6 +69,7 @@
#ifndef NDEBUG
m_deleted = false;
m_lruIndex = 0;
+ m_identifier = 0;
#endif
m_errorOccurred = false;
}
@@ -138,6 +139,10 @@
}
if (!hasClients() && inCache())
cache()->addToLiveResourcesSize(this);
+#ifndef NDEBUG
+ if (m_identifier && !hasClients())
+ cache()->log(WebCore::currentTime(), Cache::FirstRefEvent, this);
+#endif
m_clients.add(c);
}
@@ -145,6 +150,10 @@
{
ASSERT(m_clients.contains(c));
m_clients.remove(c);
+#ifndef NDEBUG
+ if (m_identifier && !hasClients())
+ cache()->log(WebCore::currentTime(), Cache::LastDerefEvent, this);
+#endif
if (canDelete() && !inCache())
delete this;
else if (!hasClients() && inCache()) {
@@ -175,7 +184,11 @@
cache()->removeFromLRUList(this);
m_decodedSize = size;
-
+ #ifndef NDEBUG
+ if (m_identifier)
+ cache()->updatePeakDecodedSizeForResource(this);
+#endif
+
if (inCache()) {
// Now insert into the new LRU list.
cache()->insertInLRUList(this);
@@ -196,6 +209,10 @@
if (size == m_encodedSize)
return;
+#ifndef NDEBUG
+ if (m_identifier)
+ cache()->log(WebCore::currentTime(), Cache::EncodedSizeEvent, this, size);
+#endif
// The size cannot ever shrink (unless it is being nulled out because of an error). If it ever does, assert.
ASSERT(size == 0 || size >= m_encodedSize);
@@ -220,6 +237,10 @@
void CachedResource::didAccessDecodedData(double timeStamp)
{
+#ifndef NDEBUG
+ if (m_identifier)
+ cache()->log(timeStamp, Cache::DecodedDataAccessEvent, this);
+#endif
m_lastDecodedAccessTime = timeStamp;
if (inCache()) {
diff --git a/WebCore/loader/CachedResource.h b/WebCore/loader/CachedResource.h
index 5e469dd..c71cbd8 100644
--- a/WebCore/loader/CachedResource.h
+++ b/WebCore/loader/CachedResource.h
@@ -45,6 +45,9 @@
// This class also does the actual communication with the loader to obtain the resource from the network.
class CachedResource {
friend class Cache;
+#ifndef NDEBUG
+ friend class CacheEventLogger;
+#endif
public:
enum Type {
@@ -209,6 +212,7 @@
#ifndef NDEBUG
bool m_deleted;
unsigned m_lruIndex;
+ unsigned m_identifier;
#endif
private:
diff --git a/WebCore/page/animation/AnimationBase.cpp b/WebCore/page/animation/AnimationBase.cpp
index 5f96357..b4a5ca4 100644
--- a/WebCore/page/animation/AnimationBase.cpp
+++ b/WebCore/page/animation/AnimationBase.cpp
@@ -28,17 +28,17 @@
#include "config.h"
#include "AnimationBase.h"
-#include "AnimationController.h"
-#include "KeyframeAnimation.h"
-#include "ImplicitAnimation.h"
-#include "CompositeAnimation.h"
+#include "AnimationController.h"
#include "CSSPropertyNames.h"
#include "CString.h"
+#include "CompositeAnimation.h"
#include "Document.h"
#include "EventNames.h"
#include "FloatConversion.h"
#include "Frame.h"
+#include "ImplicitAnimation.h"
+#include "KeyframeAnimation.h"
#include "RenderObject.h"
#include "RenderStyle.h"
#include "SystemTime.h"
@@ -66,10 +66,10 @@
}
AnimationEventDispatcher::AnimationEventDispatcher(AnimationBase* anim)
-: AnimationTimerBase(anim)
-, m_property(CSSPropertyInvalid)
-, m_reset(false)
-, m_elapsedTime(-1)
+ : AnimationTimerBase(anim)
+ , m_property(CSSPropertyInvalid)
+ , m_reset(false)
+ , m_elapsedTime(-1)
{
}
@@ -151,14 +151,16 @@
class PropertyWrapperBase {
public:
PropertyWrapperBase(int prop)
- : m_prop(prop)
- { }
+ : m_prop(prop)
+ {
+ }
+
virtual ~PropertyWrapperBase() { }
- virtual bool equals(const RenderStyle* a, const RenderStyle* b) const=0;
- virtual void blend(RenderStyle* dst, const RenderStyle* a, const RenderStyle* b, double prog) const=0;
-
+ virtual bool equals(const RenderStyle* a, const RenderStyle* b) const = 0;
+ virtual void blend(RenderStyle* dst, const RenderStyle* a, const RenderStyle* b, double progress) const = 0;
+
int property() const { return m_prop; }
-
+
private:
int m_prop;
};
@@ -167,15 +169,16 @@
class PropertyWrapperGetter : public PropertyWrapperBase {
public:
PropertyWrapperGetter(int prop, T (RenderStyle::*getter)() const)
- : PropertyWrapperBase(prop)
- , m_getter(getter)
- { }
-
+ : PropertyWrapperBase(prop)
+ , m_getter(getter)
+ {
+ }
+
virtual bool equals(const RenderStyle* a, const RenderStyle* b) const
{
return (a->*m_getter)() == (b->*m_getter)();
}
-
+
protected:
T (RenderStyle::*m_getter)() const;
};
@@ -184,15 +187,16 @@
class PropertyWrapper : public PropertyWrapperGetter<T> {
public:
PropertyWrapper(int prop, T (RenderStyle::*getter)() const, void (RenderStyle::*setter)(T))
- : PropertyWrapperGetter<T>(prop, getter)
- , m_setter(setter)
- { }
-
- virtual void blend(RenderStyle* dst, const RenderStyle* a, const RenderStyle* b, double prog) const
+ : PropertyWrapperGetter<T>(prop, getter)
+ , m_setter(setter)
{
- (dst->*m_setter)(blendFunc((a->*PropertyWrapperGetter<T>::m_getter)(), (b->*PropertyWrapperGetter<T>::m_getter)(), prog));
}
+ virtual void blend(RenderStyle* dst, const RenderStyle* a, const RenderStyle* b, double progress) const
+ {
+ (dst->*m_setter)(blendFunc((a->*PropertyWrapperGetter<T>::m_getter)(), (b->*PropertyWrapperGetter<T>::m_getter)(), progress));
+ }
+
protected:
void (RenderStyle::*m_setter)(T);
};
@@ -200,36 +204,37 @@
class PropertyWrapperShadow : public PropertyWrapperGetter<ShadowData*> {
public:
PropertyWrapperShadow(int prop, ShadowData* (RenderStyle::*getter)() const, void (RenderStyle::*setter)(ShadowData*, bool))
- : PropertyWrapperGetter<ShadowData*>(prop, getter)
- , m_setter(setter)
- { }
-
+ : PropertyWrapperGetter<ShadowData*>(prop, getter)
+ , m_setter(setter)
+ {
+ }
+
virtual bool equals(const RenderStyle* a, const RenderStyle* b) const
{
- ShadowData* shadowa = (a->*m_getter)();
- ShadowData* shadowb = (b->*m_getter)();
-
- if (!shadowa && shadowb || shadowa && !shadowb)
+ ShadowData* shadowA = (a->*m_getter)();
+ ShadowData* shadowB = (b->*m_getter)();
+
+ if (!shadowA && shadowB || shadowA && !shadowB)
return false;
- if (shadowa && shadowb && (*shadowa != *shadowb))
+ if (shadowA && shadowB && (*shadowA != *shadowB))
return false;
return true;
}
-
- virtual void blend(RenderStyle* dst, const RenderStyle* a, const RenderStyle* b, double prog) const
+
+ virtual void blend(RenderStyle* dst, const RenderStyle* a, const RenderStyle* b, double progress) const
{
- ShadowData* shadowa = (a->*m_getter)();
- ShadowData* shadowb = (b->*m_getter)();
+ ShadowData* shadowA = (a->*m_getter)();
+ ShadowData* shadowB = (b->*m_getter)();
ShadowData defaultShadowData(0, 0, 0, Color::transparent);
-
- if (!shadowa)
- shadowa = &defaultShadowData;
- if (!shadowb)
- shadowb = &defaultShadowData;
-
- (dst->*m_setter)(blendFunc(shadowa, shadowb, prog), false);
+
+ if (!shadowA)
+ shadowA = &defaultShadowData;
+ if (!shadowB)
+ shadowB = &defaultShadowData;
+
+ (dst->*m_setter)(blendFunc(shadowA, shadowB, progress), false);
}
-
+
private:
void (RenderStyle::*m_setter)(ShadowData*, bool);
};
@@ -237,11 +242,12 @@
class PropertyWrapperMaybeInvalidColor : public PropertyWrapperBase {
public:
PropertyWrapperMaybeInvalidColor(int prop, const Color& (RenderStyle::*getter)() const, void (RenderStyle::*setter)(const Color&))
- : PropertyWrapperBase(prop)
- , m_getter(getter)
- , m_setter(setter)
- { }
-
+ : PropertyWrapperBase(prop)
+ , m_getter(getter)
+ , m_setter(setter)
+ {
+ }
+
virtual bool equals(const RenderStyle* a, const RenderStyle* b) const
{
Color fromColor = (a->*m_getter)();
@@ -250,11 +256,11 @@
fromColor = a->color();
if (!toColor.isValid())
toColor = b->color();
-
+
return fromColor == toColor;
}
-
- virtual void blend(RenderStyle* dst, const RenderStyle* a, const RenderStyle* b, double prog) const
+
+ virtual void blend(RenderStyle* dst, const RenderStyle* a, const RenderStyle* b, double progress) const
{
Color fromColor = (a->*m_getter)();
Color toColor = (b->*m_getter)();
@@ -262,9 +268,9 @@
fromColor = a->color();
if (!toColor.isValid())
toColor = b->color();
- (dst->*m_setter)(blendFunc(fromColor, toColor, prog));
+ (dst->*m_setter)(blendFunc(fromColor, toColor, progress));
}
-
+
private:
const Color& (RenderStyle::*m_getter)() const;
void (RenderStyle::*m_setter)(const Color&);
@@ -278,7 +284,7 @@
// FIXME: This data is never destroyed. Maybe we should ref count it and toss it when the last AnimationController is destroyed?
if (gPropertyWrappers == 0) {
gPropertyWrappers = new Vector<PropertyWrapperBase*>();
-
+
// build the list of property wrappers to do the comparisons and blends
gPropertyWrappers->append(new PropertyWrapper<Length>(CSSPropertyLeft, &RenderStyle::left, &RenderStyle::setLeft));
gPropertyWrappers->append(new PropertyWrapper<Length>(CSSPropertyRight, &RenderStyle::right, &RenderStyle::setRight));
@@ -323,7 +329,7 @@
gPropertyWrappers->append(new PropertyWrapper<const IntSize&>(CSSPropertyWebkitBorderBottomRightRadius, &RenderStyle::borderBottomRightRadius, &RenderStyle::setBorderBottomRightRadius));
gPropertyWrappers->append(new PropertyWrapper<EVisibility>(CSSPropertyVisibility, &RenderStyle::visibility, &RenderStyle::setVisibility));
gPropertyWrappers->append(new PropertyWrapper<float>(CSSPropertyZoom, &RenderStyle::zoom, &RenderStyle::setZoom));
-
+
// FIXME: these might be invalid colors, need to check for that
gPropertyWrappers->append(new PropertyWrapperMaybeInvalidColor(CSSPropertyWebkitColumnRuleColor, &RenderStyle::columnRuleColor, &RenderStyle::setColumnRuleColor));
gPropertyWrappers->append(new PropertyWrapperMaybeInvalidColor(CSSPropertyWebkitTextStrokeColor, &RenderStyle::textStrokeColor, &RenderStyle::setTextStrokeColor));
@@ -333,15 +339,15 @@
gPropertyWrappers->append(new PropertyWrapperMaybeInvalidColor(CSSPropertyBorderTopColor, &RenderStyle::borderTopColor, &RenderStyle::setBorderTopColor));
gPropertyWrappers->append(new PropertyWrapperMaybeInvalidColor(CSSPropertyBorderBottomColor, &RenderStyle::borderBottomColor, &RenderStyle::setBorderBottomColor));
gPropertyWrappers->append(new PropertyWrapperMaybeInvalidColor(CSSPropertyOutlineColor, &RenderStyle::outlineColor, &RenderStyle::setOutlineColor));
-
+
// These are for shadows
gPropertyWrappers->append(new PropertyWrapperShadow(CSSPropertyWebkitBoxShadow, &RenderStyle::boxShadow, &RenderStyle::setBoxShadow));
gPropertyWrappers->append(new PropertyWrapperShadow(CSSPropertyTextShadow, &RenderStyle::textShadow, &RenderStyle::setTextShadow));
-
+
// Make sure unused slots have a value
for (unsigned int i = 0; i < (unsigned int) numCSSProperties; ++i)
gPropertyWrapperMap[i] = CSSPropertyInvalid;
-
+
size_t n = gPropertyWrappers->size();
for (unsigned int i = 0; i < n; ++i) {
ASSERT((*gPropertyWrappers)[i]->property() - firstCSSProperty < numCSSProperties);
@@ -351,28 +357,27 @@
}
AnimationBase::AnimationBase(const Animation* transition, RenderObject* renderer, CompositeAnimation* compAnim)
-: m_animState(STATE_NEW)
-, m_iteration(0)
-, m_animating(false)
-, m_waitedForResponse(false)
-, m_startTime(0)
-, m_pauseTime(-1)
-, m_object(renderer)
-, m_animationTimerCallback(const_cast<AnimationBase*>(this))
-, m_animationEventDispatcher(const_cast<AnimationBase*>(this))
-, m_animation(const_cast<Animation*>(transition))
-, m_compAnim(compAnim)
-, m_waitingForEndEvent(false)
+ : m_animState(AnimationStateNew)
+ , m_iteration(0)
+ , m_animating(false)
+ , m_waitedForResponse(false)
+ , m_startTime(0)
+ , m_pauseTime(-1)
+ , m_object(renderer)
+ , m_animationTimerCallback(const_cast<AnimationBase*>(this))
+ , m_animationEventDispatcher(const_cast<AnimationBase*>(this))
+ , m_animation(const_cast<Animation*>(transition))
+ , m_compAnim(compAnim)
+ , m_waitingForEndEvent(false)
{
- ensurePropertyMap();
}
AnimationBase::~AnimationBase()
{
- if (m_animState == STATE_START_WAIT_STYLE_AVAILABLE)
+ if (m_animState == AnimationStateStartWaitStyleAvailable)
m_compAnim->setWaitingForStyleAvailable(false);
}
-// static
+
bool AnimationBase::propertiesEqual(int prop, const RenderStyle* a, const RenderStyle* b)
{
ensurePropertyMap();
@@ -384,61 +389,59 @@
}
} else {
int propIndex = prop - firstCSSProperty;
-
+
if (propIndex >= 0 && propIndex < numCSSProperties) {
int i = gPropertyWrapperMap[propIndex];
- return (i >= 0) ? (*gPropertyWrappers)[i]->equals(a, b) : true;
+ return i >= 0 ? (*gPropertyWrappers)[i]->equals(a, b) : true;
}
}
return true;
}
-// static
int AnimationBase::getPropertyAtIndex(int i)
{
ensurePropertyMap();
- if (i < 0 || i >= (int) gPropertyWrappers->size())
+ if (i < 0 || i >= static_cast<int>(gPropertyWrappers->size()))
return CSSPropertyInvalid;
-
+
return (*gPropertyWrappers)[i]->property();
}
-//static
int AnimationBase::getNumProperties()
{
ensurePropertyMap();
return gPropertyWrappers->size();
}
-
-// static - return true if we need to start software animation timers
-bool AnimationBase::blendProperties(int prop, RenderStyle* dst, const RenderStyle* a, const RenderStyle* b, double prog)
+// Returns true if we need to start animation timers
+bool AnimationBase::blendProperties(int prop, RenderStyle* dst, const RenderStyle* a, const RenderStyle* b, double progress)
{
+ ASSERT(prop != cAnimateAll);
+ // FIXME: Why can this happen?
if (prop == cAnimateAll) {
- ASSERT(0);
bool needsTimer = false;
-
+
size_t n = gPropertyWrappers->size();
for (unsigned int i = 0; i < n; ++i) {
PropertyWrapperBase* wrapper = (*gPropertyWrappers)[i];
if (!wrapper->equals(a, b)) {
- wrapper->blend(dst, a, b, prog);
+ wrapper->blend(dst, a, b, progress);
needsTimer = true;
}
}
return needsTimer;
}
-
+
int propIndex = prop - firstCSSProperty;
if (propIndex >= 0 && propIndex < numCSSProperties) {
int i = gPropertyWrapperMap[propIndex];
if (i >= 0) {
PropertyWrapperBase* wrapper = (*gPropertyWrappers)[i];
- wrapper->blend(dst, a, b, prog);
+ wrapper->blend(dst, a, b, progress);
return true;
}
}
-
+
return false;
}
@@ -469,243 +472,240 @@
return static_cast<Element*>(m_object->node());
return 0;
}
-
+
void AnimationBase::updateStateMachine(AnimStateInput input, double param)
{
- // If we get a RESTART then we force a new animation, regardless of state
- if (input == STATE_INPUT_MAKE_NEW) {
- if (m_animState == STATE_START_WAIT_STYLE_AVAILABLE)
+ // If we get AnimationStateInputRestartAnimation then we force a new animation, regardless of state.
+ if (input == AnimationStateInputMakeNew) {
+ if (m_animState == AnimationStateStartWaitStyleAvailable)
m_compAnim->setWaitingForStyleAvailable(false);
- m_animState = STATE_NEW;
+ m_animState = AnimationStateNew;
m_startTime = 0;
m_pauseTime = -1;
m_waitedForResponse = false;
endAnimation(false);
return;
}
- else if (input == STATE_INPUT_RESTART_ANIMATION) {
+
+ if (input == AnimationStateInputRestartAnimation) {
cancelTimers();
- if (m_animState == STATE_START_WAIT_STYLE_AVAILABLE)
+ if (m_animState == AnimationStateStartWaitStyleAvailable)
m_compAnim->setWaitingForStyleAvailable(false);
- m_animState = STATE_NEW;
+ m_animState = AnimationStateNew;
m_startTime = 0;
m_pauseTime = -1;
endAnimation(false);
-
+
if (!paused())
- updateStateMachine(STATE_INPUT_START_ANIMATION, -1);
+ updateStateMachine(AnimationStateInputStartAnimation, -1);
return;
}
- else if (input == STATE_INPUT_END_ANIMATION) {
+
+ if (input == AnimationStateInputEndAnimation) {
cancelTimers();
- if (m_animState == STATE_START_WAIT_STYLE_AVAILABLE)
+ if (m_animState == AnimationStateStartWaitStyleAvailable)
m_compAnim->setWaitingForStyleAvailable(false);
- m_animState = STATE_DONE;
+ m_animState = AnimationStateDone;
endAnimation(true);
return;
}
- else if (input == STATE_INPUT_PAUSE_OVERRIDE) {
- if (m_animState == STATE_START_WAIT_RESPONSE) {
- // If we are in the WAIT_RESPONSE state, the animation will get canceled before
- // we get a response, so move to the next state
+
+ if (input == AnimationStateInputPauseOverride) {
+ if (m_animState == AnimationStateStartWaitResponse) {
+ // If we are in AnimationStateStartWaitResponse, the animation will get canceled before
+ // we get a response, so move to the next state.
endAnimation(false);
- updateStateMachine(STATE_INPUT_START_TIME_SET, currentTime());
+ updateStateMachine(AnimationStateInputStartTimeSet, currentTime());
}
return;
}
- else if (input == STATE_INPUT_RESUME_OVERRIDE) {
- if (m_animState == STATE_LOOPING || m_animState == STATE_ENDING) {
+
+ if (input == AnimationStateInputResumeOverride) {
+ if (m_animState == AnimationStateLooping || m_animState == AnimationStateEnding) {
// Start the animation
startAnimation(m_startTime);
}
return;
}
-
+
// Execute state machine
switch(m_animState) {
- case STATE_NEW:
- ASSERT(input == STATE_INPUT_START_ANIMATION || input == STATE_INPUT_PLAY_STATE_RUNNING || input == STATE_INPUT_PLAY_STATE_PAUSED);
- if (input == STATE_INPUT_START_ANIMATION || input == STATE_INPUT_PLAY_STATE_RUNNING) {
+ case AnimationStateNew:
+ ASSERT(input == AnimationStateInputStartAnimation || input == AnimationStateInputPlayStateRunnning || input == AnimationStateInputPlayStatePaused);
+ if (input == AnimationStateInputStartAnimation || input == AnimationStateInputPlayStateRunnning) {
// Set the start timer to the initial delay (0 if no delay)
m_waitedForResponse = false;
- m_animState = STATE_START_WAIT_TIMER;
+ m_animState = AnimationStateStartWaitTimer;
m_animationTimerCallback.startTimer(m_animation->delay(), EventNames::webkitAnimationStartEvent, m_animation->delay());
}
break;
- case STATE_START_WAIT_TIMER:
- ASSERT(input == STATE_INPUT_START_TIMER_FIRED || input == STATE_INPUT_PLAY_STATE_PAUSED);
-
- if (input == STATE_INPUT_START_TIMER_FIRED) {
+ case AnimationStateStartWaitTimer:
+ ASSERT(input == AnimationStateInputStartTimerFired || input == AnimationStateInputPlayStatePaused);
+
+ if (input == AnimationStateInputStartTimerFired) {
ASSERT(param >= 0);
// Start timer has fired, tell the animation to start and wait for it to respond with start time
- m_animState = STATE_START_WAIT_STYLE_AVAILABLE;
+ m_animState = AnimationStateStartWaitStyleAvailable;
m_compAnim->setWaitingForStyleAvailable(true);
-
+
// Trigger a render so we can start the animation
setChanged(m_object->element());
m_object->animation()->startUpdateRenderingDispatcher();
- }
- else {
+ } else {
ASSERT(running());
// We're waiting for the start timer to fire and we got a pause. Cancel the timer, pause and wait
m_pauseTime = currentTime();
cancelTimers();
- m_animState = STATE_PAUSED_WAIT_TIMER;
+ m_animState = AnimationStatePausedWaitTimer;
}
break;
- case STATE_START_WAIT_STYLE_AVAILABLE:
- ASSERT(input == STATE_INPUT_STYLE_AVAILABLE || input == STATE_INPUT_PLAY_STATE_PAUSED);
-
+ case AnimationStateStartWaitStyleAvailable:
+ ASSERT(input == AnimationStateInputStyleAvailable || input == AnimationStateInputPlayStatePaused);
+
m_compAnim->setWaitingForStyleAvailable(false);
-
- if (input == STATE_INPUT_STYLE_AVAILABLE) {
+
+ if (input == AnimationStateInputStyleAvailable) {
// Start timer has fired, tell the animation to start and wait for it to respond with start time
- m_animState = STATE_START_WAIT_RESPONSE;
-
+ m_animState = AnimationStateStartWaitResponse;
+
overrideAnimations();
-
+
// Send start event, if needed
- onAnimationStart(0.0f); // The elapsedTime is always 0 here
-
+ onAnimationStart(0); // The elapsedTime is always 0 here
+
// Start the animation
if (overridden() || !startAnimation(0)) {
// We're not going to get a startTime callback, so fire the start time here
- m_animState = STATE_START_WAIT_RESPONSE;
- updateStateMachine(STATE_INPUT_START_TIME_SET, currentTime());
- }
- else
+ m_animState = AnimationStateStartWaitResponse;
+ updateStateMachine(AnimationStateInputStartTimeSet, currentTime());
+ } else
m_waitedForResponse = true;
- }
- else {
+ } else {
ASSERT(running());
// We're waiting for the a notification that the style has been setup. If we're asked to wait
// at this point, the style must have been processed, so we can deal with this like we would
// for WAIT_RESPONSE, except that we don't need to do an endAnimation().
m_pauseTime = 0;
- m_animState = STATE_START_WAIT_RESPONSE;
+ m_animState = AnimationStateStartWaitResponse;
}
break;
- case STATE_START_WAIT_RESPONSE:
- ASSERT(input == STATE_INPUT_START_TIME_SET || input == STATE_INPUT_PLAY_STATE_PAUSED);
-
- if (input == STATE_INPUT_START_TIME_SET) {
+ case AnimationStateStartWaitResponse:
+ ASSERT(input == AnimationStateInputStartTimeSet || input == AnimationStateInputPlayStatePaused);
+
+ if (input == AnimationStateInputStartTimeSet) {
ASSERT(param >= 0);
// We have a start time, set it, unless the startTime is already set
if (m_startTime <= 0)
m_startTime = param;
-
+
// Decide when the end or loop event needs to fire
primeEventTimers();
-
+
// Trigger a render so we can start the animation
setChanged(m_object->element());
m_object->animation()->startUpdateRenderingDispatcher();
- }
- else {
+ } else {
// We are pausing while waiting for a start response. Cancel the animation and wait. When
// we unpause, we will act as though the start timer just fired
m_pauseTime = 0;
endAnimation(false);
- m_animState = STATE_PAUSED_WAIT_RESPONSE;
+ m_animState = AnimationStatePausedWaitResponse;
}
break;
- case STATE_LOOPING:
- ASSERT(input == STATE_INPUT_LOOP_TIMER_FIRED || input == STATE_INPUT_PLAY_STATE_PAUSED);
-
- if (input == STATE_INPUT_LOOP_TIMER_FIRED) {
+ case AnimationStateLooping:
+ ASSERT(input == AnimationStateInputLoopTimerFired || input == AnimationStateInputPlayStatePaused);
+
+ if (input == AnimationStateInputLoopTimerFired) {
ASSERT(param >= 0);
// Loop timer fired, loop again or end.
onAnimationIteration(param);
primeEventTimers();
- }
- else {
+ } else {
// We are pausing while running. Cancel the animation and wait
m_pauseTime = currentTime();
cancelTimers();
endAnimation(false);
- m_animState = STATE_PAUSED_RUN;
+ m_animState = AnimationStatePausedRun;
}
break;
- case STATE_ENDING:
- ASSERT(input == STATE_INPUT_END_TIMER_FIRED || input == STATE_INPUT_PLAY_STATE_PAUSED);
-
- if (input == STATE_INPUT_END_TIMER_FIRED) {
+ case AnimationStateEnding:
+ ASSERT(input == AnimationStateInputEndTimerFired || input == AnimationStateInputPlayStatePaused);
+
+ if (input == AnimationStateInputEndTimerFired) {
ASSERT(param >= 0);
// End timer fired, finish up
onAnimationEnd(param);
-
+
resumeOverriddenAnimations();
-
+
// Fire off another style change so we can set the final value
setChanged(m_object->element());
- m_animState = STATE_DONE;
+ m_animState = AnimationStateDone;
m_object->animation()->startUpdateRenderingDispatcher();
// |this| may be deleted here when we've been called from timerFired()
- }
- else {
+ } else {
// We are pausing while running. Cancel the animation and wait
m_pauseTime = currentTime();
cancelTimers();
endAnimation(false);
- m_animState = STATE_PAUSED_RUN;
+ m_animState = AnimationStatePausedRun;
}
// |this| may be deleted here
break;
- case STATE_PAUSED_WAIT_TIMER:
- ASSERT(input == STATE_INPUT_PLAY_STATE_RUNNING);
+ case AnimationStatePausedWaitTimer:
+ ASSERT(input == AnimationStateInputPlayStateRunnning);
ASSERT(!running());
// Update the times
m_startTime += currentTime() - m_pauseTime;
m_pauseTime = -1;
-
+
// we were waiting for the start timer to fire, go back and wait again
- m_animState = STATE_NEW;
- updateStateMachine(STATE_INPUT_START_ANIMATION, 0);
+ m_animState = AnimationStateNew;
+ updateStateMachine(AnimationStateInputStartAnimation, 0);
break;
- case STATE_PAUSED_WAIT_RESPONSE:
- case STATE_PAUSED_RUN:
- // We treat these two cases the same. The only difference is that, when we are in the WAIT_RESPONSE
- // state, we don't yet have a valid startTime, so we send 0 to startAnimation. When the START_TIME
- // event comes in qnd we were in the RUN state, we will notice that we have already set the
- // startTime and will ignore it.
- ASSERT(input == STATE_INPUT_PLAY_STATE_RUNNING);
+ case AnimationStatePausedWaitResponse:
+ case AnimationStatePausedRun:
+ // We treat these two cases the same. The only difference is that, when we are in
+ // AnimationStatePausedWaitResponse, we don't yet have a valid startTime, so we send 0 to startAnimation.
+ // When the AnimationStateInputStartTimeSet comes in and we were in AnimationStatePausedRun, we will notice
+ // that we have already set the startTime and will ignore it.
+ ASSERT(input == AnimationStateInputPlayStateRunnning);
ASSERT(!running());
// Update the times
- if (m_animState == STATE_PAUSED_RUN)
+ if (m_animState == AnimationStatePausedRun)
m_startTime += currentTime() - m_pauseTime;
else
m_startTime = 0;
m_pauseTime = -1;
-
+
// We were waiting for a begin time response from the animation, go back and wait again
- m_animState = STATE_START_WAIT_RESPONSE;
-
+ m_animState = AnimationStateStartWaitResponse;
+
// Start the animation
if (overridden() || !startAnimation(m_startTime)) {
// We're not going to get a startTime callback, so fire the start time here
- updateStateMachine(STATE_INPUT_START_TIME_SET, currentTime());
- }
- else
+ updateStateMachine(AnimationStateInputStartTimeSet, currentTime());
+ } else
m_waitedForResponse = true;
break;
- case STATE_DONE:
+ case AnimationStateDone:
// We're done. Stay in this state until we are deleted
break;
}
- // |this| may be deleted here if we came out of STATE_ENDING when we've been called from timerFired()
+ // |this| may be deleted here if we came out of AnimationStateEnding when we've been called from timerFired()
}
void AnimationBase::animationTimerCallbackFired(const AtomicString& eventType, double elapsedTime)
{
ASSERT(m_object->document() && !m_object->document()->inPageCache());
-
+
// FIXME: use an enum
if (eventType == EventNames::webkitAnimationStartEvent)
- updateStateMachine(STATE_INPUT_START_TIMER_FIRED, elapsedTime);
+ updateStateMachine(AnimationStateInputStartTimerFired, elapsedTime);
else if (eventType == EventNames::webkitAnimationIterationEvent)
- updateStateMachine(STATE_INPUT_LOOP_TIMER_FIRED, elapsedTime);
+ updateStateMachine(AnimationStateInputLoopTimerFired, elapsedTime);
else if (eventType == EventNames::webkitAnimationEndEvent) {
- updateStateMachine(STATE_INPUT_END_TIMER_FIRED, elapsedTime);
+ updateStateMachine(AnimationStateInputEndTimerFired, elapsedTime);
// |this| may be deleted here
}
}
@@ -714,7 +714,7 @@
bool reset, const AtomicString& eventType, double elapsedTime)
{
m_waitingForEndEvent = false;
-
+
// Keep an atomic string on the stack to keep it alive until we exit this method
// (since dispatching the event may cause |this| to be deleted, therefore removing
// the last ref to the atomic string).
@@ -722,7 +722,7 @@
AtomicString animEventType(eventType);
// Make sure the element sticks around too
RefPtr<Element> elementRetainer(element);
-
+
ASSERT(!element || (element->document() && !element->document()->inPageCache()));
if (!element)
return;
@@ -733,49 +733,48 @@
element->dispatchWebKitAnimationEvent(eventType, name, elapsedTime);
// Restore the original (unanimated) style
- if (animEventType == EventNames::webkitAnimationEndEvent)
- if (element->renderer())
- setChanged(element->renderer()->element());
+ if (animEventType == EventNames::webkitAnimationEndEvent && element->renderer())
+ setChanged(element->renderer()->element());
}
void AnimationBase::updatePlayState(bool run)
{
if (paused() == run || isNew())
- updateStateMachine(run ? STATE_INPUT_PLAY_STATE_RUNNING : STATE_INPUT_PLAY_STATE_PAUSED, -1);
+ updateStateMachine(run ? AnimationStateInputPlayStateRunnning : AnimationStateInputPlayStatePaused, -1);
}
double AnimationBase::progress(double scale, double offset) const
{
if (preActive())
return 0;
-
+
double elapsedTime = running() ? (currentTime() - m_startTime) : (m_pauseTime - m_startTime);
if (running() && elapsedTime < 0)
return 0;
-
+
double dur = m_animation->duration();
if (m_animation->iterationCount() > 0)
dur *= m_animation->iterationCount();
-
+
if (postActive() || !m_animation->duration() || (m_animation->iterationCount() > 0 && elapsedTime >= dur))
return 1.0;
-
+
// Compute the fractional time, taking into account direction.
// There is no need to worry about iterations, we assume that we would have
- // short circuited above if we were done
+ // short circuited above if we were done.
double fractionalTime = elapsedTime / m_animation->duration();
- int integralTime = (int) fractionalTime;
+ int integralTime = static_cast<int>(fractionalTime);
fractionalTime -= integralTime;
-
+
if (m_animation->direction() && (integralTime & 1))
fractionalTime = 1 - fractionalTime;
-
- if (scale != 1 || offset != 0)
+
+ if (scale != 1 || offset)
fractionalTime = (fractionalTime - offset) * scale;
-
+
if (m_animation->timingFunction().type() == LinearTimingFunction)
return fractionalTime;
-
+
// Cubic bezier.
double result = solveCubicBezierFunction(m_animation->timingFunction().x1(),
m_animation->timingFunction().y1(),
@@ -791,7 +790,7 @@
double ct = currentTime();
const double elapsedDuration = ct - m_startTime;
ASSERT(elapsedDuration >= 0);
-
+
double totalDuration = -1;
if (m_animation->iterationCount() > 0)
totalDuration = m_animation->duration() * m_animation->iterationCount();
@@ -802,7 +801,7 @@
durationLeft = m_animation->duration() - fmod(elapsedDuration, m_animation->duration());
nextIterationTime = elapsedDuration + durationLeft;
}
-
+
// At this point, we may have 0 durationLeft, if we've gotten the event late and we are already
// past totalDuration. In this case we still fire an end timer before processing the end.
// This defers the call to sendAnimationEvents to avoid re-entrant calls that destroy
@@ -810,14 +809,13 @@
if (totalDuration < 0 || nextIterationTime < totalDuration) {
// We are not at the end yet, send a loop event
ASSERT(nextIterationTime > 0);
- m_animState = STATE_LOOPING;
+ m_animState = AnimationStateLooping;
m_animationTimerCallback.startTimer(durationLeft, EventNames::webkitAnimationIterationEvent, nextIterationTime);
- }
- else {
+ } else {
// We are at the end, send an end event
- m_animState = STATE_ENDING;
+ m_animState = AnimationStateEnding;
m_animationTimerCallback.startTimer(durationLeft, EventNames::webkitAnimationEndEvent, nextIterationTime);
}
}
-}
+} // namespace WebCore
diff --git a/WebCore/page/animation/AnimationBase.h b/WebCore/page/animation/AnimationBase.h
index 5399954..734660d 100644
--- a/WebCore/page/animation/AnimationBase.h
+++ b/WebCore/page/animation/AnimationBase.h
@@ -29,51 +29,49 @@
#ifndef AnimationBase_h
#define AnimationBase_h
-#include "Timer.h"
-#include "wtf/HashMap.h"
#include "AtomicString.h"
+#include "Timer.h"
+#include <wtf/HashMap.h>
namespace WebCore {
-class AnimationController;
+class Animation;
class AnimationBase;
+class AnimationController;
+class CompositeAnimation;
+class Element;
class ImplicitAnimation;
class KeyframeAnimation;
-class CompositeAnimation;
+class Node;
class RenderObject;
class RenderStyle;
-class AtomicStringImpl;
-class Animation;
-class Element;
-class Node;
class AnimationTimerBase {
public:
AnimationTimerBase(AnimationBase* anim)
- : m_timer(this, &AnimationTimerBase::timerFired)
- , m_anim(anim)
+ : m_timer(this, &AnimationTimerBase::timerFired)
+ , m_anim(anim)
{
m_timer.startOneShot(0);
}
- virtual ~AnimationTimerBase()
- {
- }
-
- void startTimer(double timeout=0)
+
+ virtual ~AnimationTimerBase() { }
+
+ void startTimer(double timeout = 0)
{
m_timer.startOneShot(timeout);
}
-
+
void cancelTimer()
{
m_timer.stop();
}
-
+
virtual void timerFired(Timer<AnimationTimerBase>*) = 0;
-
+
private:
Timer<AnimationTimerBase> m_timer;
-
+
protected:
AnimationBase* m_anim;
};
@@ -81,10 +79,8 @@
class AnimationEventDispatcher : public AnimationTimerBase {
public:
AnimationEventDispatcher(AnimationBase* anim);
- virtual ~AnimationEventDispatcher()
- {
- }
-
+ virtual ~AnimationEventDispatcher() { }
+
void startTimer(Element* element, const AtomicString& name, int property, bool reset,
const AtomicString& eventType, double elapsedTime)
{
@@ -96,9 +92,9 @@
m_elapsedTime = elapsedTime;
AnimationTimerBase::startTimer();
}
-
+
virtual void timerFired(Timer<AnimationTimerBase>*);
-
+
private:
RefPtr<Element> m_element;
AtomicString m_name;
@@ -111,20 +107,22 @@
class AnimationTimerCallback : public AnimationTimerBase {
public:
AnimationTimerCallback(AnimationBase* anim)
- : AnimationTimerBase(anim)
- , m_elapsedTime(0)
- { }
+ : AnimationTimerBase(anim)
+ , m_elapsedTime(0)
+ {
+ }
+
virtual ~AnimationTimerCallback() { }
-
+
virtual void timerFired(Timer<AnimationTimerBase>*);
-
+
void startTimer(double timeout, const AtomicString& eventType, double elapsedTime)
{
m_eventType = eventType;
m_elapsedTime = elapsedTime;
AnimationTimerBase::startTimer(timeout);
}
-
+
private:
AtomicString m_eventType;
double m_elapsedTime;
@@ -132,108 +130,107 @@
class AnimationBase : public Noncopyable {
friend class CompositeAnimation;
-
+
public:
AnimationBase(const Animation* transition, RenderObject* renderer, CompositeAnimation* compAnim);
virtual ~AnimationBase();
-
+
RenderObject* renderer() const { return m_object; }
double startTime() const { return m_startTime; }
double duration() const;
-
+
void cancelTimers()
{
m_animationTimerCallback.cancelTimer();
m_animationEventDispatcher.cancelTimer();
}
-
+
// Animations and Transitions go through the states below. When entering the STARTED state
// the animation is started. This may or may not require deferred response from the animator.
// If so, we stay in this state until that response is received (and it returns the start time).
- // Otherwise, we use the current time as the start time and go immediately to the LOOPING or
- // ENDING state.
+ // Otherwise, we use the current time as the start time and go immediately to AnimationStateLooping
+ // or AnimationStateEnding.
enum AnimState {
- STATE_NEW, // animation just created, animation not running yet
- STATE_START_WAIT_TIMER, // start timer running, waiting for fire
- STATE_START_WAIT_STYLE_AVAILABLE, // waiting for style setup so we can start animations
- STATE_START_WAIT_RESPONSE, // animation started, waiting for response
- STATE_LOOPING, // response received, animation running, loop timer running, waiting for fire
- STATE_ENDING, // response received, animation running, end timer running, waiting for fire
- STATE_PAUSED_WAIT_TIMER, // animation in pause mode when animation started
- STATE_PAUSED_WAIT_RESPONSE, // animation paused when in STARTING state
- STATE_PAUSED_RUN, // animation paused when in LOOPING or ENDING state
- STATE_DONE // end timer fired, animation finished and removed
+ AnimationStateNew, // animation just created, animation not running yet
+ AnimationStateStartWaitTimer, // start timer running, waiting for fire
+ AnimationStateStartWaitStyleAvailable, // waiting for style setup so we can start animations
+ AnimationStateStartWaitResponse, // animation started, waiting for response
+ AnimationStateLooping, // response received, animation running, loop timer running, waiting for fire
+ AnimationStateEnding, // received, animation running, end timer running, waiting for fire
+ AnimationStatePausedWaitTimer, // in pause mode when animation started
+ AnimationStatePausedWaitResponse, // animation paused when in STARTING state
+ AnimationStatePausedRun, // animation paused when in LOOPING or ENDING state
+ AnimationStateDone // end timer fired, animation finished and removed
};
-
+
enum AnimStateInput {
- STATE_INPUT_MAKE_NEW, // reset back to new from any state
- STATE_INPUT_START_ANIMATION, // animation requests a start
- STATE_INPUT_RESTART_ANIMATION, // force a restart from any state
- STATE_INPUT_START_TIMER_FIRED, // start timer fired
- STATE_INPUT_STYLE_AVAILABLE, // style is setup, ready to start animating
- STATE_INPUT_START_TIME_SET, // m_startTime was set
- STATE_INPUT_LOOP_TIMER_FIRED, // loop timer fired
- STATE_INPUT_END_TIMER_FIRED, // end timer fired
- STATE_INPUT_PAUSE_OVERRIDE, // pause an animation due to override
- STATE_INPUT_RESUME_OVERRIDE, // resume an overridden animation
- STATE_INPUT_PLAY_STATE_RUNNING, // play state paused -> running
- STATE_INPUT_PLAY_STATE_PAUSED, // play state running -> paused
- STATE_INPUT_END_ANIMATION // force an end from any state
+ AnimationStateInputMakeNew, // reset back to new from any state
+ AnimationStateInputStartAnimation, // animation requests a start
+ AnimationStateInputRestartAnimation, // force a restart from any state
+ AnimationStateInputStartTimerFired, // start timer fired
+ AnimationStateInputStyleAvailable, // style is setup, ready to start animating
+ AnimationStateInputStartTimeSet, // m_startTime was set
+ AnimationStateInputLoopTimerFired, // loop timer fired
+ AnimationStateInputEndTimerFired, // end timer fired
+ AnimationStateInputPauseOverride, // pause an animation due to override
+ AnimationStateInputResumeOverride, // resume an overridden animation
+ AnimationStateInputPlayStateRunnning, // play state paused -> running
+ AnimationStateInputPlayStatePaused, // play state running -> paused
+ AnimationStateInputEndAnimation // force an end from any state
};
-
- // Called when animation is in NEW state to start animation
- void updateStateMachine(AnimStateInput input, double param);
-
+
+ // Called when animation is in AnimationStateNew to start animation
+ void updateStateMachine(AnimStateInput, double param);
+
// Animation has actually started, at passed time
void onAnimationStartResponse(double startTime);
-
+
// Called to change to or from paused state
void updatePlayState(bool running);
bool playStatePlaying() const;
-
- bool waitingToStart() const { return m_animState == STATE_NEW || m_animState == STATE_START_WAIT_TIMER; }
+
+ bool waitingToStart() const { return m_animState == AnimationStateNew || m_animState == AnimationStateStartWaitTimer; }
bool preActive() const
- { return m_animState == STATE_NEW ||
- m_animState == STATE_START_WAIT_TIMER ||
- m_animState == STATE_START_WAIT_STYLE_AVAILABLE ||
- m_animState == STATE_START_WAIT_RESPONSE;
+ {
+ return m_animState == AnimationStateNew || m_animState == AnimationStateStartWaitTimer || m_animState == AnimationStateStartWaitStyleAvailable || m_animState == AnimationStateStartWaitResponse;
}
- bool postActive() const { return m_animState == STATE_DONE; }
+
+ bool postActive() const { return m_animState == AnimationStateDone; }
bool active() const { return !postActive() && !preActive(); }
bool running() const { return !isNew() && !postActive(); }
bool paused() const { return m_pauseTime >= 0; }
- bool isNew() const { return m_animState == STATE_NEW; }
- bool waitingForStartTime() const { return m_animState == STATE_START_WAIT_RESPONSE; }
- bool waitingForStyleAvailable() const { return m_animState == STATE_START_WAIT_STYLE_AVAILABLE; }
+ bool isNew() const { return m_animState == AnimationStateNew; }
+ bool waitingForStartTime() const { return m_animState == AnimationStateStartWaitResponse; }
+ bool waitingForStyleAvailable() const { return m_animState == AnimationStateStartWaitStyleAvailable; }
bool waitingForEndEvent() const { return m_waitingForEndEvent; }
-
+
// "animating" means that something is running that requires a timer to keep firing
// (e.g. a software animation)
void setAnimating(bool inAnimating = true) { m_animating = inAnimating; }
bool animating() const { return m_animating; }
-
+
double progress(double scale, double offset) const;
-
+
virtual void animate(CompositeAnimation*, RenderObject*, const RenderStyle* currentStyle,
const RenderStyle* targetStyle, RenderStyle*& animatedStyle) { }
- virtual void reset(RenderObject* renderer, const RenderStyle* from = 0, const RenderStyle* to = 0) { }
-
+ virtual void reset(RenderObject*, const RenderStyle* from = 0, const RenderStyle* to = 0) { }
+
virtual bool shouldFireEvents() const { return false; }
-
+
void animationTimerCallbackFired(const AtomicString& eventType, double elapsedTime);
- void animationEventDispatcherFired(Element* element, const AtomicString& name, int property, bool reset,
+ void animationEventDispatcherFired(Element*, const AtomicString& name, int property, bool reset,
const AtomicString& eventType, double elapsedTime);
-
- bool animationsMatch(const Animation* anim) const;
-
+
+ bool animationsMatch(const Animation*) const;
+
void setAnimation(const Animation* anim) { m_animation = const_cast<Animation*>(anim); }
-
+
// Return true if this animation is overridden. This will only be the case for
// ImplicitAnimations and is used to determine whether or not we should force
// set the start time. If an animation is overridden, it will probably not get
- // back the START_TIME event.
+ // back the AnimationStateInputStartTimeSet input.
virtual bool overridden() const { return false; }
-
+
// Does this animation/transition involve the given property?
virtual bool affectsProperty(int property) const { return false; }
bool isAnimatingProperty(int property, bool isRunningNow) const
@@ -243,52 +240,50 @@
return !postActive() && affectsProperty(property);
}
-
+
protected:
Element* elementForEventDispatch();
-
+
virtual void overrideAnimations() { }
virtual void resumeOverriddenAnimations() { }
-
+
CompositeAnimation* compositeAnimation() { return m_compAnim; }
-
+
// These are called when the corresponding timer fires so subclasses can do any extra work
virtual void onAnimationStart(double elapsedTime) { }
virtual void onAnimationIteration(double elapsedTime) { }
virtual void onAnimationEnd(double elapsedTime) { }
virtual bool startAnimation(double beginTime) { return false; }
virtual void endAnimation(bool reset) { }
-
+
void primeEventTimers();
-
+
static bool propertiesEqual(int prop, const RenderStyle* a, const RenderStyle* b);
- static int getPropertyAtIndex(int i);
+ static int getPropertyAtIndex(int);
static int getNumProperties();
-
+
// Return true if we need to start software animation timers
- static bool blendProperties(int prop, RenderStyle* dst, const RenderStyle* a, const RenderStyle* b, double prog);
+ static bool blendProperties(int prop, RenderStyle* dst, const RenderStyle* a, const RenderStyle* b, double progress);
- static void setChanged(Node* node);
-
+ static void setChanged(Node*);
+
protected:
AnimState m_animState;
int m_iteration;
-
+
bool m_animating; // transition/animation requires continual timer firing
bool m_waitedForResponse;
double m_startTime;
double m_pauseTime;
RenderObject* m_object;
-
+
AnimationTimerCallback m_animationTimerCallback;
AnimationEventDispatcher m_animationEventDispatcher;
RefPtr<Animation> m_animation;
CompositeAnimation* m_compAnim;
bool m_waitingForEndEvent;
-
-private:
};
-}
+} // namespace WebCore
-#endif
+#endif // AnimationBase_h
diff --git a/WebCore/page/animation/CompositeAnimation.cpp b/WebCore/page/animation/CompositeAnimation.cpp
index 8eff0b5..d840900 100644
--- a/WebCore/page/animation/CompositeAnimation.cpp
+++ b/WebCore/page/animation/CompositeAnimation.cpp
@@ -327,7 +327,7 @@
for (AnimationNameMap::const_iterator it = m_keyframeAnimations.begin(); it != kfend; ++it) {
KeyframeAnimation* anim = it->second;
if (anim && anim->waitingForStartTime())
- anim->updateStateMachine(AnimationBase::STATE_INPUT_START_TIME_SET, t);
+ anim->updateStateMachine(AnimationBase::AnimationStateInputStartTimeSet, t);
}
}
@@ -338,7 +338,7 @@
for (CSSPropertyTransitionsMap::const_iterator it = m_transitions.begin(); it != end; ++it) {
ImplicitAnimation* anim = it->second;
if (anim && anim->waitingForStartTime() && anim->animatingProperty() == property)
- anim->updateStateMachine(AnimationBase::STATE_INPUT_START_TIME_SET, t);
+ anim->updateStateMachine(AnimationBase::AnimationStateInputStartTimeSet, t);
}
}
@@ -434,14 +434,14 @@
for (i = 0; i < animations.size(); ++i) {
KeyframeAnimation* anim = animations[i];
if (anim && anim->waitingForStyleAvailable())
- anim->updateStateMachine(AnimationBase::STATE_INPUT_STYLE_AVAILABLE, -1);
+ anim->updateStateMachine(AnimationBase::AnimationStateInputStyleAvailable, -1);
}
CSSPropertyTransitionsMap::const_iterator end = m_transitions.end();
for (CSSPropertyTransitionsMap::const_iterator it = m_transitions.begin(); it != end; ++it) {
ImplicitAnimation* anim = it->second;
if (anim && anim->waitingForStyleAvailable())
- anim->updateStateMachine(AnimationBase::STATE_INPUT_STYLE_AVAILABLE, -1);
+ anim->updateStateMachine(AnimationBase::AnimationStateInputStyleAvailable, -1);
}
}
diff --git a/WebCore/page/animation/ImplicitAnimation.cpp b/WebCore/page/animation/ImplicitAnimation.cpp
index 4eda313..07be231 100644
--- a/WebCore/page/animation/ImplicitAnimation.cpp
+++ b/WebCore/page/animation/ImplicitAnimation.cpp
@@ -124,14 +124,14 @@
// restart the transition
if (from && to)
- updateStateMachine(STATE_INPUT_RESTART_ANIMATION, -1);
+ updateStateMachine(AnimationStateInputRestartAnimation, -1);
}
void ImplicitAnimation::setOverridden(bool b)
{
if (b != m_overridden) {
m_overridden = b;
- updateStateMachine(m_overridden ? STATE_INPUT_PAUSE_OVERRIDE : STATE_INPUT_RESUME_OVERRIDE, -1);
+ updateStateMachine(m_overridden ? AnimationStateInputPauseOverride : AnimationStateInputResumeOverride, -1);
}
}
diff --git a/WebCore/page/animation/ImplicitAnimation.h b/WebCore/page/animation/ImplicitAnimation.h
index f27ab78..d5ce3bc 100644
--- a/WebCore/page/animation/ImplicitAnimation.h
+++ b/WebCore/page/animation/ImplicitAnimation.h
@@ -50,7 +50,7 @@
// Do the cleanup here instead of in the base class so the specialized methods get called
if (!postActive())
- updateStateMachine(STATE_INPUT_END_ANIMATION, -1);
+ updateStateMachine(AnimationStateInputEndAnimation, -1);
}
int transitionProperty() const { return m_transitionProperty; }
diff --git a/WebCore/page/animation/KeyframeAnimation.cpp b/WebCore/page/animation/KeyframeAnimation.cpp
index c590be8..17585f3 100644
--- a/WebCore/page/animation/KeyframeAnimation.cpp
+++ b/WebCore/page/animation/KeyframeAnimation.cpp
@@ -40,7 +40,7 @@
{
// if we have not yet started, we will not have a valid start time, so just start the animation if needed
if (isNew() && m_animation->playState() == AnimPlayStatePlaying)
- updateStateMachine(STATE_INPUT_START_ANIMATION, -1);
+ updateStateMachine(AnimationStateInputStartAnimation, -1);
// If we get this far and the animation is done, it means we are cleaning up a just finished animation.
// If so, we need to send back the targetStyle
@@ -93,7 +93,7 @@
// if either style is 0 we have an invalid case, just stop the animation
if (!fromStyle || !toStyle) {
- updateStateMachine(STATE_INPUT_END_ANIMATION, -1);
+ updateStateMachine(AnimationStateInputEndAnimation, -1);
return;
}
diff --git a/WebCore/page/animation/KeyframeAnimation.h b/WebCore/page/animation/KeyframeAnimation.h
index 745bdcd..fd73be4 100644
--- a/WebCore/page/animation/KeyframeAnimation.h
+++ b/WebCore/page/animation/KeyframeAnimation.h
@@ -51,7 +51,7 @@
{
// Do the cleanup here instead of in the base class so the specialized methods get called
if (!postActive())
- updateStateMachine(STATE_INPUT_END_ANIMATION, -1);
+ updateStateMachine(AnimationStateInputEndAnimation, -1);
}
virtual void animate(CompositeAnimation*, RenderObject*, const RenderStyle* currentStyle,
diff --git a/WebCore/platform/win/FileSystemWin.cpp b/WebCore/platform/win/FileSystemWin.cpp
index 5671462..e759404 100644
--- a/WebCore/platform/win/FileSystemWin.cpp
+++ b/WebCore/platform/win/FileSystemWin.cpp
@@ -122,8 +122,11 @@
String homeDirectoryPath()
{
- notImplemented();
- return "";
+ TCHAR pathChars[MAX_PATH];
+ if (FAILED(SHGetFolderPath(0, CSIDL_LOCAL_APPDATA | CSIDL_FLAG_CREATE, 0, 0, pathChars)))
+ return "";
+
+ return pathChars;
}
String pathGetFileName(const String& path)
diff --git a/WebCore/rendering/RenderListItem.cpp b/WebCore/rendering/RenderListItem.cpp
index ff4a6fa..425dc21 100644
--- a/WebCore/rendering/RenderListItem.cpp
+++ b/WebCore/rendering/RenderListItem.cpp
@@ -235,47 +235,48 @@
void RenderListItem::positionListMarker()
{
- if (m_marker && !m_marker->isInside() && m_marker->inlineBoxWrapper()) {
- int markerOldX = m_marker->xPos();
- int yOffset = 0;
- int xOffset = 0;
- for (RenderObject* o = m_marker->parent(); o != this; o = o->parent()) {
- yOffset += o->yPos();
- xOffset += o->xPos();
- }
+ if (!m_marker || m_marker->isInside() || !m_marker->inlineBoxWrapper())
+ return;
- bool adjustOverflow = false;
- int markerXPos;
- RootInlineBox* root = m_marker->inlineBoxWrapper()->root();
+ int markerOldX = m_marker->xPos();
+ int yOffset = 0;
+ int xOffset = 0;
+ for (RenderObject* o = m_marker->parent(); o != this; o = o->parent()) {
+ yOffset += o->yPos();
+ xOffset += o->xPos();
+ }
- if (style()->direction() == LTR) {
- int leftLineOffset = leftRelOffset(yOffset, leftOffset(yOffset));
- markerXPos = leftLineOffset - xOffset - paddingLeft() - borderLeft() + m_marker->marginLeft();
- m_marker->inlineBoxWrapper()->adjustPosition(markerXPos - markerOldX, 0);
- if (markerXPos < root->leftOverflow()) {
- root->setHorizontalOverflowPositions(markerXPos, root->rightOverflow());
- adjustOverflow = true;
- }
- } else {
- int rightLineOffset = rightRelOffset(yOffset, rightOffset(yOffset));
- markerXPos = rightLineOffset - xOffset + paddingRight() + borderRight() + m_marker->marginLeft();
- m_marker->inlineBoxWrapper()->adjustPosition(markerXPos - markerOldX, 0);
- if (markerXPos + m_marker->width() > root->rightOverflow()) {
- root->setHorizontalOverflowPositions(root->leftOverflow(), markerXPos + m_marker->width());
- adjustOverflow = true;
- }
- }
+ bool adjustOverflow = false;
+ int markerXPos;
+ RootInlineBox* root = m_marker->inlineBoxWrapper()->root();
- if (adjustOverflow) {
- IntRect markerRect(markerXPos + xOffset, yOffset, m_marker->width(), m_marker->height());
- RenderObject* o = m_marker;
- do {
- o = o->parent();
- if (o->isRenderBlock())
- static_cast<RenderBlock*>(o)->addVisualOverflow(markerRect);
- markerRect.move(-o->xPos(), -o->yPos());
- } while (o != this);
+ if (style()->direction() == LTR) {
+ int leftLineOffset = leftRelOffset(yOffset, leftOffset(yOffset));
+ markerXPos = leftLineOffset - xOffset - paddingLeft() - borderLeft() + m_marker->marginLeft();
+ m_marker->inlineBoxWrapper()->adjustPosition(markerXPos - markerOldX, 0);
+ if (markerXPos < root->leftOverflow()) {
+ root->setHorizontalOverflowPositions(markerXPos, root->rightOverflow());
+ adjustOverflow = true;
}
+ } else {
+ int rightLineOffset = rightRelOffset(yOffset, rightOffset(yOffset));
+ markerXPos = rightLineOffset - xOffset + paddingRight() + borderRight() + m_marker->marginLeft();
+ m_marker->inlineBoxWrapper()->adjustPosition(markerXPos - markerOldX, 0);
+ if (markerXPos + m_marker->width() > root->rightOverflow()) {
+ root->setHorizontalOverflowPositions(root->leftOverflow(), markerXPos + m_marker->width());
+ adjustOverflow = true;
+ }
+ }
+
+ if (adjustOverflow) {
+ IntRect markerRect(markerXPos + xOffset, yOffset, m_marker->width(), m_marker->height());
+ RenderObject* o = m_marker;
+ do {
+ o = o->parent();
+ if (o->isRenderBlock())
+ static_cast<RenderBlock*>(o)->addVisualOverflow(markerRect);
+ markerRect.move(-o->xPos(), -o->yPos());
+ } while (o != this);
}
}