Changeset 197599 in webkit
- Timestamp:
- Mar 4, 2016, 4:56:07 PM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 11 edited
-
ChangeLog (modified) (1 diff)
-
inspector/InspectorInstrumentation.cpp (modified) (1 diff)
-
inspector/InspectorInstrumentation.h (modified) (3 diffs)
-
inspector/InspectorTimelineAgent.cpp (modified) (1 diff)
-
inspector/InspectorTimelineAgent.h (modified) (1 diff)
-
inspector/TimelineRecordFactory.cpp (modified) (1 diff)
-
inspector/TimelineRecordFactory.h (modified) (1 diff)
-
page/DOMTimer.cpp (modified) (5 diffs)
-
page/DOMTimer.h (modified) (1 diff)
-
page/DOMWindow.cpp (modified) (2 diffs)
-
workers/WorkerGlobalScope.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r197596 r197599 1 2016-03-04 Gavin Barraclough <barraclough@apple.com> 2 3 Convert DOMTimer interval from int to std::chromo::milliseconds 4 https://bugs.webkit.org/show_bug.cgi?id=155051 5 6 Reviewed by Ryosuke Niwa. 7 8 This change is pretty much mechanical, replacing int with std::chrono::milliseconds. 9 10 * inspector/InspectorInstrumentation.cpp: 11 (WebCore::InspectorInstrumentation::willSendXMLHttpRequestImpl): 12 (WebCore::InspectorInstrumentation::didInstallTimerImpl): 13 * inspector/InspectorInstrumentation.h: 14 (WebCore::InspectorInstrumentation::willSendXMLHttpRequest): 15 (WebCore::InspectorInstrumentation::didInstallTimer): 16 * inspector/InspectorTimelineAgent.cpp: 17 (WebCore::InspectorTimelineAgent::didPaint): 18 (WebCore::InspectorTimelineAgent::didInstallTimer): 19 * inspector/InspectorTimelineAgent.h: 20 * inspector/TimelineRecordFactory.cpp: 21 (WebCore::TimelineRecordFactory::createGenericTimerData): 22 (WebCore::TimelineRecordFactory::createTimerInstallData): 23 * inspector/TimelineRecordFactory.h: 24 * page/DOMTimer.cpp: 25 (WebCore::shouldForwardUserGesture): 26 (WebCore::DOMTimer::DOMTimer): 27 (WebCore::DOMTimer::~DOMTimer): 28 (WebCore::DOMTimer::install): 29 (WebCore::DOMTimer::intervalClampedToMinimum): 30 * page/DOMTimer.h: 31 * page/DOMWindow.cpp: 32 (WebCore::DOMWindow::setTimeout): 33 (WebCore::DOMWindow::clearTimeout): 34 (WebCore::DOMWindow::setInterval): 35 (WebCore::DOMWindow::clearInterval): 36 * workers/WorkerGlobalScope.cpp: 37 (WebCore::WorkerGlobalScope::setTimeout): 38 (WebCore::WorkerGlobalScope::clearTimeout): 39 (WebCore::WorkerGlobalScope::setInterval): 40 (WebCore::WorkerGlobalScope::clearInterval): 41 1 42 2016-03-03 Enrica Casucci <enrica@apple.com> 2 43 -
trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp
r194496 r197599 311 311 } 312 312 313 void InspectorInstrumentation::didInstallTimerImpl(InstrumentingAgents& instrumentingAgents, int timerId, inttimeout, bool singleShot, ScriptExecutionContext* context)313 void InspectorInstrumentation::didInstallTimerImpl(InstrumentingAgents& instrumentingAgents, int timerId, std::chrono::milliseconds timeout, bool singleShot, ScriptExecutionContext* context) 314 314 { 315 315 pauseOnNativeEventIfNeeded(instrumentingAgents, false, setTimerEventName, true); -
trunk/Source/WebCore/inspector/InspectorInstrumentation.h
r194496 r197599 141 141 142 142 static void willSendXMLHttpRequest(ScriptExecutionContext*, const String& url); 143 static void didInstallTimer(ScriptExecutionContext*, int timerId, inttimeout, bool singleShot);143 static void didInstallTimer(ScriptExecutionContext*, int timerId, std::chrono::milliseconds timeout, bool singleShot); 144 144 static void didRemoveTimer(ScriptExecutionContext*, int timerId); 145 145 … … 310 310 311 311 static void willSendXMLHttpRequestImpl(InstrumentingAgents&, const String& url); 312 static void didInstallTimerImpl(InstrumentingAgents&, int timerId, inttimeout, bool singleShot, ScriptExecutionContext*);312 static void didInstallTimerImpl(InstrumentingAgents&, int timerId, std::chrono::milliseconds timeout, bool singleShot, ScriptExecutionContext*); 313 313 static void didRemoveTimerImpl(InstrumentingAgents&, int timerId, ScriptExecutionContext*); 314 314 … … 649 649 } 650 650 651 inline void InspectorInstrumentation::didInstallTimer(ScriptExecutionContext* context, int timerId, inttimeout, bool singleShot)651 inline void InspectorInstrumentation::didInstallTimer(ScriptExecutionContext* context, int timerId, std::chrono::milliseconds timeout, bool singleShot) 652 652 { 653 653 FAST_RETURN_IF_NO_FRONTENDS(void()); -
trunk/Source/WebCore/inspector/InspectorTimelineAgent.cpp
r196165 r197599 340 340 } 341 341 342 void InspectorTimelineAgent::didInstallTimer(int timerId, inttimeout, bool singleShot, Frame* frame)342 void InspectorTimelineAgent::didInstallTimer(int timerId, std::chrono::milliseconds timeout, bool singleShot, Frame* frame) 343 343 { 344 344 appendRecord(TimelineRecordFactory::createTimerInstallData(timerId, timeout, singleShot), TimelineRecordType::TimerInstall, true, frame); -
trunk/Source/WebCore/inspector/InspectorTimelineAgent.h
r197563 r197599 111 111 112 112 // InspectorInstrumentation callbacks. 113 void didInstallTimer(int timerId, inttimeout, bool singleShot, Frame*);113 void didInstallTimer(int timerId, std::chrono::milliseconds timeout, bool singleShot, Frame*); 114 114 void didRemoveTimer(int timerId, Frame*); 115 115 void willFireTimer(int timerId, Frame*); -
trunk/Source/WebCore/inspector/TimelineRecordFactory.cpp
r194496 r197599 96 96 } 97 97 98 Ref<InspectorObject> TimelineRecordFactory::createTimerInstallData(int timerId, inttimeout, bool singleShot)98 Ref<InspectorObject> TimelineRecordFactory::createTimerInstallData(int timerId, std::chrono::milliseconds timeout, bool singleShot) 99 99 { 100 100 Ref<InspectorObject> data = InspectorObject::create(); 101 101 data->setInteger(ASCIILiteral("timerId"), timerId); 102 data->setInteger(ASCIILiteral("timeout"), timeout );102 data->setInteger(ASCIILiteral("timeout"), timeout.count()); 103 103 data->setBoolean(ASCIILiteral("singleShot"), singleShot); 104 104 return data; -
trunk/Source/WebCore/inspector/TimelineRecordFactory.h
r191967 r197599 59 59 static Ref<Inspector::InspectorObject> createEventDispatchData(const Event&); 60 60 static Ref<Inspector::InspectorObject> createGenericTimerData(int timerId); 61 static Ref<Inspector::InspectorObject> createTimerInstallData(int timerId, inttimeout, bool singleShot);61 static Ref<Inspector::InspectorObject> createTimerInstallData(int timerId, std::chrono::milliseconds timeout, bool singleShot); 62 62 static Ref<Inspector::InspectorObject> createEvaluateScriptData(const String&, double lineNumber); 63 63 static Ref<Inspector::InspectorObject> createTimeStampData(const String&); -
trunk/Source/WebCore/page/DOMTimer.cpp
r197415 r197599 53 53 namespace WebCore { 54 54 55 static const int maxIntervalForUserGestureForwarding = 1000; // One second matches Gecko.55 static const std::chrono::milliseconds maxIntervalForUserGestureForwarding = std::chrono::milliseconds(1000); // One second matches Gecko. 56 56 static const int minIntervalForNonUserObservableChangeTimers = 1000; // Empirically determined to maximize battery life. 57 57 static const int maxTimerNestingLevel = 5; … … 163 163 bool NestedTimersMap::isTrackingNestedTimers = false; 164 164 165 static inline bool shouldForwardUserGesture( intinterval, int nestingLevel)165 static inline bool shouldForwardUserGesture(std::chrono::milliseconds interval, int nestingLevel) 166 166 { 167 167 return UserGestureIndicator::processingUserGesture() … … 170 170 } 171 171 172 DOMTimer::DOMTimer(ScriptExecutionContext& context, std::unique_ptr<ScheduledAction> action, intinterval, bool singleShot)172 DOMTimer::DOMTimer(ScriptExecutionContext& context, std::unique_ptr<ScheduledAction> action, std::chrono::milliseconds interval, bool singleShot) 173 173 : SuspendableTimer(context) 174 174 , m_nestingLevel(context.timerNestingLevel()) … … 196 196 } 197 197 198 int DOMTimer::install(ScriptExecutionContext& context, std::unique_ptr<ScheduledAction> action, inttimeout, bool singleShot)198 int DOMTimer::install(ScriptExecutionContext& context, std::unique_ptr<ScheduledAction> action, std::chrono::milliseconds timeout, bool singleShot) 199 199 { 200 200 // DOMTimer constructor passes ownership of the initial ref on the object to the constructor. … … 409 409 ASSERT(m_nestingLevel <= maxTimerNestingLevel); 410 410 411 double intervalInSeconds = std::max(oneMillisecond, m_originalInterval * oneMillisecond);411 double intervalInSeconds = std::max(oneMillisecond, m_originalInterval.count() * oneMillisecond); 412 412 413 413 // Only apply throttling to repeating timers. -
trunk/Source/WebCore/page/DOMTimer.h
r197563 r197599 34 34 namespace WebCore { 35 35 36 class DOMTimerFireState;37 class Document;38 class Element;39 class HTMLPlugInElement;40 class IntRect;41 class ScheduledAction;36 class DOMTimerFireState; 37 class Document; 38 class Element; 39 class HTMLPlugInElement; 40 class IntRect; 41 class ScheduledAction; 42 42 43 class DOMTimer final : public RefCounted<DOMTimer>, public SuspendableTimer {44 WTF_MAKE_NONCOPYABLE(DOMTimer);45 WTF_MAKE_FAST_ALLOCATED;46 public:47 virtual ~DOMTimer();43 class DOMTimer final : public RefCounted<DOMTimer>, public SuspendableTimer { 44 WTF_MAKE_NONCOPYABLE(DOMTimer); 45 WTF_MAKE_FAST_ALLOCATED; 46 public: 47 virtual ~DOMTimer(); 48 48 49 static double defaultMinimumInterval() { return 0.004; } // 4 milliseconds.50 static double defaultAlignmentInterval() { return 0; }51 static double hiddenPageAlignmentInterval() { return 1.0; } // 1 second.49 static double defaultMinimumInterval() { return 0.004; } // 4 milliseconds. 50 static double defaultAlignmentInterval() { return 0; } 51 static double hiddenPageAlignmentInterval() { return 1.0; } // 1 second. 52 52 53 // Creates a new timer owned by specified ScriptExecutionContext, starts it54 // and returns its Id.55 static int install(ScriptExecutionContext&, std::unique_ptr<ScheduledAction>, inttimeout, bool singleShot);56 static void removeById(ScriptExecutionContext&, int timeoutId);53 // Creates a new timer owned by specified ScriptExecutionContext, starts it 54 // and returns its Id. 55 static int install(ScriptExecutionContext&, std::unique_ptr<ScheduledAction>, std::chrono::milliseconds timeout, bool singleShot); 56 static void removeById(ScriptExecutionContext&, int timeoutId); 57 57 58 // Notify that the interval may need updating (e.g. because the minimum interval59 // setting for the context has changed).60 void updateTimerIntervalIfNecessary();58 // Notify that the interval may need updating (e.g. because the minimum interval 59 // setting for the context has changed). 60 void updateTimerIntervalIfNecessary(); 61 61 62 static void scriptDidInteractWithPlugin(HTMLPlugInElement&);62 static void scriptDidInteractWithPlugin(HTMLPlugInElement&); 63 63 64 private:65 DOMTimer(ScriptExecutionContext&, std::unique_ptr<ScheduledAction>, intinterval, bool singleShot);66 friend class Internals;64 private: 65 DOMTimer(ScriptExecutionContext&, std::unique_ptr<ScheduledAction>, std::chrono::milliseconds interval, bool singleShot); 66 friend class Internals; 67 67 68 double intervalClampedToMinimum() const;68 double intervalClampedToMinimum() const; 69 69 70 bool isDOMTimersThrottlingEnabled(Document&) const;71 void updateThrottlingStateIfNecessary(const DOMTimerFireState&);70 bool isDOMTimersThrottlingEnabled(Document&) const; 71 void updateThrottlingStateIfNecessary(const DOMTimerFireState&); 72 72 73 // SuspendableTimer74 void fired() override;75 void didStop() override;76 double alignedFireTime(double) const override;73 // SuspendableTimer 74 void fired() override; 75 void didStop() override; 76 double alignedFireTime(double) const override; 77 77 78 // ActiveDOMObject API.79 const char* activeDOMObjectName() const override;78 // ActiveDOMObject API. 79 const char* activeDOMObjectName() const override; 80 80 81 enum TimerThrottleState {82 Undetermined,83 ShouldThrottle,84 ShouldNotThrottle85 };81 enum TimerThrottleState { 82 Undetermined, 83 ShouldThrottle, 84 ShouldNotThrottle 85 }; 86 86 87 int m_timeoutId;88 int m_nestingLevel;89 std::unique_ptr<ScheduledAction> m_action;90 intm_originalInterval;91 TimerThrottleState m_throttleState;92 double m_currentTimerInterval;93 bool m_shouldForwardUserGesture;94 };87 int m_timeoutId; 88 int m_nestingLevel; 89 std::unique_ptr<ScheduledAction> m_action; 90 std::chrono::milliseconds m_originalInterval; 91 TimerThrottleState m_throttleState; 92 double m_currentTimerInterval; 93 bool m_shouldForwardUserGesture; 94 }; 95 95 96 96 } // namespace WebCore -
trunk/Source/WebCore/page/DOMWindow.cpp
r197591 r197599 1604 1604 return -1; 1605 1605 } 1606 return DOMTimer::install(*context, WTFMove(action), timeout, true);1606 return DOMTimer::install(*context, WTFMove(action), std::chrono::milliseconds(timeout), true); 1607 1607 } 1608 1608 … … 1638 1638 return -1; 1639 1639 } 1640 return DOMTimer::install(*context, WTFMove(action), timeout, false);1640 return DOMTimer::install(*context, WTFMove(action), std::chrono::milliseconds(timeout), false); 1641 1641 } 1642 1642 -
trunk/Source/WebCore/workers/WorkerGlobalScope.cpp
r196594 r197599 151 151 int WorkerGlobalScope::setTimeout(std::unique_ptr<ScheduledAction> action, int timeout) 152 152 { 153 return DOMTimer::install(*this, WTFMove(action), timeout, true);153 return DOMTimer::install(*this, WTFMove(action), std::chrono::milliseconds(timeout), true); 154 154 } 155 155 … … 161 161 int WorkerGlobalScope::setInterval(std::unique_ptr<ScheduledAction> action, int timeout) 162 162 { 163 return DOMTimer::install(*this, WTFMove(action), timeout, false);163 return DOMTimer::install(*this, WTFMove(action), std::chrono::milliseconds(timeout), false); 164 164 } 165 165
Note:
See TracChangeset
for help on using the changeset viewer.