Diff
Modified: trunk/Source/WebCore/ChangeLog (202197 => 202198)
--- trunk/Source/WebCore/ChangeLog 2016-06-18 05:53:28 UTC (rev 202197)
+++ trunk/Source/WebCore/ChangeLog 2016-06-18 11:46:16 UTC (rev 202198)
@@ -1,3 +1,44 @@
+2016-06-18 Antti Koivisto <[email protected]>
+
+ Use time literals in WebCore
+ https://bugs.webkit.org/show_bug.cgi?id=158905
+
+ Reviewed by Andreas Kling.
+
+ std::chrono::milliseconds(1) -> 1ms etc.
+
+ * dom/Document.cpp:
+ (WebCore::Document::minimumLayoutDelay):
+ (WebCore::Document::elapsedTime):
+ * fileapi/FileReader.cpp:
+ (WebCore::FileReader::create):
+ * inspector/InspectorOverlay.cpp:
+ (WebCore::InspectorOverlay::showPaintRect):
+ * loader/CrossOriginPreflightResultCache.cpp:
+ (WebCore::CrossOriginPreflightResultCache::CrossOriginPreflightResultCache):
+ * loader/ProgressTracker.cpp:
+ (WebCore::ProgressTracker::progressStarted):
+ * loader/cache/CachedResource.cpp:
+ (WebCore::CachedResource::freshnessLifetime):
+ * page/ChromeClient.h:
+ * page/DOMTimer.cpp:
+ (WebCore::DOMTimer::intervalClampedToMinimum):
+ (WebCore::DOMTimer::alignedFireTime):
+ * page/DOMTimer.h:
+ * page/FrameView.cpp:
+ (WebCore::FrameView::scrollPositionChanged):
+ * page/ResourceUsageThread.cpp:
+ (WebCore::ResourceUsageThread::threadBody):
+ * page/Settings.cpp:
+ (WebCore::Settings::Settings):
+ * page/mac/ServicesOverlayController.mm:
+ (WebCore::ServicesOverlayController::remainingTimeUntilHighlightShouldBeShown):
+ * platform/graphics/FontCache.cpp:
+ (WebCore::FontCache::fontForFamily):
+ * platform/network/CacheValidation.cpp:
+ (WebCore::computeCurrentAge):
+ (WebCore::computeFreshnessLifetimeForHTTPFamily):
+
2016-06-17 Benjamin Poulain <[email protected]>
:indeterminate pseudo-class should match radios whose group has no checked radio
Modified: trunk/Source/WebCore/dom/Document.cpp (202197 => 202198)
--- trunk/Source/WebCore/dom/Document.cpp 2016-06-18 05:53:28 UTC (rev 202197)
+++ trunk/Source/WebCore/dom/Document.cpp 2016-06-18 11:46:16 UTC (rev 202198)
@@ -2849,13 +2849,13 @@
std::chrono::milliseconds Document::minimumLayoutDelay()
{
if (m_overMinimumLayoutThreshold)
- return std::chrono::milliseconds(0);
+ return 0ms;
- std::chrono::milliseconds elapsed = elapsedTime();
+ auto elapsed = elapsedTime();
m_overMinimumLayoutThreshold = elapsed > settings()->layoutInterval();
// We'll want to schedule the timer to fire at the minimum layout threshold.
- return std::max(std::chrono::milliseconds(0), settings()->layoutInterval() - elapsed);
+ return std::max(0ms, settings()->layoutInterval() - elapsed);
}
std::chrono::milliseconds Document::elapsedTime() const
Modified: trunk/Source/WebCore/fileapi/FileReader.cpp (202197 => 202198)
--- trunk/Source/WebCore/fileapi/FileReader.cpp 2016-06-18 05:53:28 UTC (rev 202197)
+++ trunk/Source/WebCore/fileapi/FileReader.cpp 2016-06-18 11:46:16 UTC (rev 202198)
@@ -43,7 +43,7 @@
namespace WebCore {
-static const auto progressNotificationInterval = std::chrono::milliseconds(50);
+static const auto progressNotificationInterval = 50ms;
Ref<FileReader> FileReader::create(ScriptExecutionContext& context)
{
Modified: trunk/Source/WebCore/inspector/InspectorOverlay.cpp (202197 => 202198)
--- trunk/Source/WebCore/inspector/InspectorOverlay.cpp 2016-06-18 05:53:28 UTC (rev 202197)
+++ trunk/Source/WebCore/inspector/InspectorOverlay.cpp 2016-06-18 11:46:16 UTC (rev 202198)
@@ -505,7 +505,7 @@
IntRect rootRect = m_page.mainFrame().view()->contentsToRootView(enclosingIntRect(rect));
- const std::chrono::milliseconds removeDelay = std::chrono::milliseconds(250);
+ const auto removeDelay = 250ms;
std::chrono::steady_clock::time_point removeTime = std::chrono::steady_clock::now() + removeDelay;
m_paintRects.append(TimeRectPair(removeTime, rootRect));
Modified: trunk/Source/WebCore/loader/CrossOriginPreflightResultCache.cpp (202197 => 202198)
--- trunk/Source/WebCore/loader/CrossOriginPreflightResultCache.cpp 2016-06-18 05:53:28 UTC (rev 202197)
+++ trunk/Source/WebCore/loader/CrossOriginPreflightResultCache.cpp 2016-06-18 11:46:16 UTC (rev 202198)
@@ -37,8 +37,8 @@
namespace WebCore {
// These values are at the discretion of the user agent.
-static const auto defaultPreflightCacheTimeout = std::chrono::seconds(5);
-static const auto maxPreflightCacheTimeout = std::chrono::seconds(600); // Should be short enough to minimize the risk of using a poisoned cache after switching to a secure network.
+static const auto defaultPreflightCacheTimeout = 5s;
+static const auto maxPreflightCacheTimeout = 600s; // Should be short enough to minimize the risk of using a poisoned cache after switching to a secure network.
CrossOriginPreflightResultCache::CrossOriginPreflightResultCache()
{
Modified: trunk/Source/WebCore/loader/ProgressTracker.cpp (202197 => 202198)
--- trunk/Source/WebCore/loader/ProgressTracker.cpp 2016-06-18 05:53:28 UTC (rev 202197)
+++ trunk/Source/WebCore/loader/ProgressTracker.cpp 2016-06-18 11:46:16 UTC (rev 202198)
@@ -60,7 +60,7 @@
// How many bytes are required between heartbeats to consider it progress.
static const unsigned minumumBytesPerHeartbeatForProgress = 1024;
-static const std::chrono::milliseconds progressNotificationTimeInterval = std::chrono::milliseconds(200);
+static const auto progressNotificationTimeInterval = 200ms;
struct ProgressItem {
WTF_MAKE_NONCOPYABLE(ProgressItem); WTF_MAKE_FAST_ALLOCATED;
@@ -137,7 +137,7 @@
bool isMainFrame = !m_originatingProgressFrame->tree().parent();
auto elapsedTimeSinceMainLoadComplete = std::chrono::steady_clock::now() - m_mainLoadCompletionTime;
- static const auto subframePartOfMainLoadThreshold = std::chrono::seconds(1);
+ static const auto subframePartOfMainLoadThreshold = 1s;
m_isMainLoad = isMainFrame || elapsedTimeSinceMainLoadComplete < subframePartOfMainLoadThreshold;
m_client.progressStarted(*m_originatingProgressFrame);
Modified: trunk/Source/WebCore/loader/cache/CachedResource.cpp (202197 => 202198)
--- trunk/Source/WebCore/loader/cache/CachedResource.cpp 2016-06-18 05:53:28 UTC (rev 202197)
+++ trunk/Source/WebCore/loader/cache/CachedResource.cpp 2016-06-18 11:46:16 UTC (rev 202198)
@@ -392,7 +392,7 @@
// FIXME: We should not cache subresources either, but when we tried this
// it caused performance and flakiness issues in our test infrastructure.
if (m_type == MainResource || SchemeRegistry::shouldAlwaysRevalidateURLScheme(protocol))
- return std::chrono::microseconds::zero();
+ return 0us;
}
return std::chrono::microseconds::max();
Modified: trunk/Source/WebCore/page/ChromeClient.h (202197 => 202198)
--- trunk/Source/WebCore/page/ChromeClient.h 2016-06-18 05:53:28 UTC (rev 202197)
+++ trunk/Source/WebCore/page/ChromeClient.h 2016-06-18 11:46:16 UTC (rev 202198)
@@ -239,7 +239,7 @@
virtual void didPreventDefaultForEvent() = 0;
#endif
- virtual std::chrono::milliseconds eventThrottlingDelay() { return std::chrono::milliseconds::zero(); };
+ virtual std::chrono::milliseconds eventThrottlingDelay() { return 0ms; };
#if PLATFORM(IOS)
virtual void didReceiveMobileDocType(bool) = 0;
Modified: trunk/Source/WebCore/page/DOMTimer.cpp (202197 => 202198)
--- trunk/Source/WebCore/page/DOMTimer.cpp 2016-06-18 05:53:28 UTC (rev 202197)
+++ trunk/Source/WebCore/page/DOMTimer.cpp 2016-06-18 11:46:16 UTC (rev 202198)
@@ -52,8 +52,8 @@
namespace WebCore {
-static const std::chrono::milliseconds maxIntervalForUserGestureForwarding = std::chrono::milliseconds(1000); // One second matches Gecko.
-static const std::chrono::milliseconds minIntervalForNonUserObservableChangeTimers = std::chrono::milliseconds(1000); // Empirically determined to maximize battery life.
+static const auto maxIntervalForUserGestureForwarding = 1000ms; // One second matches Gecko.
+static const auto minIntervalForNonUserObservableChangeTimers = 1000ms; // Empirically determined to maximize battery life.
static const int maxTimerNestingLevel = 5;
class DOMTimerFireState {
@@ -406,7 +406,7 @@
ASSERT(scriptExecutionContext());
ASSERT(m_nestingLevel <= maxTimerNestingLevel);
- auto interval = std::max(std::chrono::milliseconds(1), m_originalInterval);
+ auto interval = std::max(1ms, m_originalInterval);
// Only apply throttling to repeating timers.
if (m_nestingLevel < maxTimerNestingLevel)
@@ -422,7 +422,7 @@
Optional<std::chrono::milliseconds> DOMTimer::alignedFireTime(std::chrono::milliseconds fireTime) const
{
auto alignmentInterval = scriptExecutionContext()->timerAlignmentInterval(m_nestingLevel >= maxTimerNestingLevel);
- if (alignmentInterval == std::chrono::milliseconds::zero())
+ if (alignmentInterval == 0ms)
return Nullopt;
static const double randomizedProportion = randomNumber();
Modified: trunk/Source/WebCore/page/DOMTimer.h (202197 => 202198)
--- trunk/Source/WebCore/page/DOMTimer.h 2016-06-18 05:53:28 UTC (rev 202197)
+++ trunk/Source/WebCore/page/DOMTimer.h 2016-06-18 11:46:16 UTC (rev 202198)
@@ -46,9 +46,9 @@
public:
virtual ~DOMTimer();
- static std::chrono::milliseconds defaultMinimumInterval() { return std::chrono::milliseconds(4); }
- static std::chrono::milliseconds defaultAlignmentInterval() { return std::chrono::milliseconds::zero(); }
- static std::chrono::milliseconds hiddenPageAlignmentInterval() { return std::chrono::milliseconds(1000); }
+ static std::chrono::milliseconds defaultMinimumInterval() { return 4ms; }
+ static std::chrono::milliseconds defaultAlignmentInterval() { return 0ms; }
+ static std::chrono::milliseconds hiddenPageAlignmentInterval() { return 1000ms; }
// Creates a new timer owned by specified ScriptExecutionContext, starts it
// and returns its Id.
Modified: trunk/Source/WebCore/page/FrameView.cpp (202197 => 202198)
--- trunk/Source/WebCore/page/FrameView.cpp 2016-06-18 05:53:28 UTC (rev 202197)
+++ trunk/Source/WebCore/page/FrameView.cpp 2016-06-18 11:46:16 UTC (rev 202198)
@@ -2222,9 +2222,9 @@
void FrameView::scrollPositionChanged(const ScrollPosition& oldPosition, const ScrollPosition& newPosition)
{
Page* page = frame().page();
- auto throttlingDelay = page ? page->chrome().client().eventThrottlingDelay() : std::chrono::milliseconds::zero();
+ auto throttlingDelay = page ? page->chrome().client().eventThrottlingDelay() : 0ms;
- if (throttlingDelay == std::chrono::milliseconds::zero()) {
+ if (throttlingDelay == 0ms) {
m_delayedScrollEventTimer.stop();
sendScrollEvent();
} else if (!m_delayedScrollEventTimer.isActive())
Modified: trunk/Source/WebCore/page/ResourceUsageThread.cpp (202197 => 202198)
--- trunk/Source/WebCore/page/ResourceUsageThread.cpp 2016-06-18 05:53:28 UTC (rev 202197)
+++ trunk/Source/WebCore/page/ResourceUsageThread.cpp 2016-06-18 11:46:16 UTC (rev 202198)
@@ -119,8 +119,8 @@
platformThreadBody(m_vm, data);
notifyObservers(WTFMove(data));
- auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - start);
- auto difference = std::chrono::milliseconds(500) - duration;
+ auto duration = std::chrono::system_clock::now() - start;
+ auto difference = 500ms - duration;
std::this_thread::sleep_for(difference);
}
}
Modified: trunk/Source/WebCore/page/Settings.cpp (202197 => 202198)
--- trunk/Source/WebCore/page/Settings.cpp 2016-06-18 05:53:28 UTC (rev 202197)
+++ trunk/Source/WebCore/page/Settings.cpp 2016-06-18 11:46:16 UTC (rev 202198)
@@ -175,7 +175,7 @@
// This amount of time must have elapsed before we will even consider scheduling a layout without a delay.
// FIXME: For faster machines this value can really be lowered to 200. 250 is adequate, but a little high
// for dual G5s. :)
-static const auto layoutScheduleThreshold = std::chrono::milliseconds(250);
+static const auto layoutScheduleThreshold = 250ms;
Settings::Settings(Page* page)
: m_page(nullptr)
Modified: trunk/Source/WebCore/page/mac/ServicesOverlayController.mm (202197 => 202198)
--- trunk/Source/WebCore/page/mac/ServicesOverlayController.mm 2016-06-18 05:53:28 UTC (rev 202197)
+++ trunk/Source/WebCore/page/mac/ServicesOverlayController.mm 2016-06-18 11:46:16 UTC (rev 202198)
@@ -436,7 +436,7 @@
std::chrono::milliseconds ServicesOverlayController::remainingTimeUntilHighlightShouldBeShown(Highlight* highlight) const
{
if (!highlight)
- return std::chrono::milliseconds::zero();
+ return 0ms;
auto minimumTimeUntilHighlightShouldBeShown = 200ms;
Page* page = m_mainFrame.page();
Modified: trunk/Source/WebCore/platform/graphics/FontCache.cpp (202197 => 202198)
--- trunk/Source/WebCore/platform/graphics/FontCache.cpp 2016-06-18 05:53:28 UTC (rev 202197)
+++ trunk/Source/WebCore/platform/graphics/FontCache.cpp 2016-06-18 11:46:16 UTC (rev 202198)
@@ -327,7 +327,7 @@
RefPtr<Font> FontCache::fontForFamily(const FontDescription& fontDescription, const AtomicString& family, const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings, bool checkingAlternateName)
{
if (!m_purgeTimer.isActive())
- m_purgeTimer.startOneShot(std::chrono::milliseconds::zero());
+ m_purgeTimer.startOneShot(0ms);
FontPlatformData* platformData = getCachedFontPlatformData(fontDescription, family, fontFaceFeatures, fontFaceVariantSettings, checkingAlternateName);
if (!platformData)
Modified: trunk/Source/WebCore/platform/network/CacheValidation.cpp (202197 => 202198)
--- trunk/Source/WebCore/platform/network/CacheValidation.cpp 2016-06-18 05:53:28 UTC (rev 202197)
+++ trunk/Source/WebCore/platform/network/CacheValidation.cpp 2016-06-18 11:46:16 UTC (rev 202198)
@@ -103,8 +103,8 @@
// http://tools.ietf.org/html/rfc7234#section-4.2.3
// No compensation for latency as that is not terribly important in practice.
auto dateValue = response.date();
- auto apparentAge = dateValue ? std::max(microseconds::zero(), duration_cast<microseconds>(responseTime - dateValue.value())) : microseconds::zero();
- auto ageValue = response.age().valueOr(microseconds::zero());
+ auto apparentAge = dateValue ? std::max(0us, duration_cast<microseconds>(responseTime - *dateValue)) : 0us;
+ auto ageValue = response.age().valueOr(0us);
auto correctedInitialAge = std::max(apparentAge, ageValue);
auto residentTime = duration_cast<microseconds>(system_clock::now() - responseTime);
return correctedInitialAge + residentTime;
@@ -119,26 +119,25 @@
// http://tools.ietf.org/html/rfc7234#section-4.2.1
auto maxAge = response.cacheControlMaxAge();
if (maxAge)
- return maxAge.value();
- auto expires = response.expires();
+ return *maxAge;
+
auto date = response.date();
- auto dateValue = date ? date.value() : responseTime;
- if (expires)
- return duration_cast<microseconds>(expires.value() - dateValue);
+ auto effectiveDate = date.valueOr(responseTime);
+ if (auto expires = response.expires())
+ return duration_cast<microseconds>(*expires - effectiveDate);
// Implicit lifetime.
switch (response.httpStatusCode()) {
case 301: // Moved Permanently
case 410: // Gone
// These are semantically permanent and so get long implicit lifetime.
- return hours(365 * 24);
+ return 365 * 24h;
default:
// Heuristic Freshness:
// http://tools.ietf.org/html/rfc7234#section-4.2.2
- auto lastModified = response.lastModified();
- if (lastModified)
- return duration_cast<microseconds>((dateValue - lastModified.value()) * 0.1);
- return microseconds::zero();
+ if (auto lastModified = response.lastModified())
+ return duration_cast<microseconds>((effectiveDate - *lastModified) * 0.1);
+ return 0us;
}
}