| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 | 45 |
| 46 | 46 |
| 47 PassRefPtr<DocumentTimeline> DocumentTimeline::create(Document* document, PassOw
nPtr<PlatformTiming> timing) | 47 PassRefPtr<DocumentTimeline> DocumentTimeline::create(Document* document, PassOw
nPtr<PlatformTiming> timing) |
| 48 { | 48 { |
| 49 return adoptRef(new DocumentTimeline(document, timing)); | 49 return adoptRef(new DocumentTimeline(document, timing)); |
| 50 } | 50 } |
| 51 | 51 |
| 52 DocumentTimeline::DocumentTimeline(Document* document, PassOwnPtr<PlatformTiming
> timing) | 52 DocumentTimeline::DocumentTimeline(Document* document, PassOwnPtr<PlatformTiming
> timing) |
| 53 : m_zeroTime(nullValue()) | 53 : m_zeroTime(nullValue()) |
| 54 , m_document(document) | 54 , m_document(document) |
| 55 , m_eventDistpachTimer(this, &DocumentTimeline::eventDispatchTimerFired) | |
| 56 { | 55 { |
| 57 if (!timing) | 56 if (!timing) |
| 58 m_timing = adoptPtr(new DocumentTimelineTiming(this)); | 57 m_timing = adoptPtr(new DocumentTimelineTiming(this)); |
| 59 else | 58 else |
| 60 m_timing = timing; | 59 m_timing = timing; |
| 61 | 60 |
| 62 ASSERT(document); | 61 ASSERT(document); |
| 63 } | 62 } |
| 64 | 63 |
| 65 DocumentTimeline::~DocumentTimeline() | 64 DocumentTimeline::~DocumentTimeline() |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 } | 153 } |
| 155 | 154 |
| 156 void DocumentTimeline::setOutdatedPlayer(Player* player) | 155 void DocumentTimeline::setOutdatedPlayer(Player* player) |
| 157 { | 156 { |
| 158 m_playersNeedingUpdate.add(player); | 157 m_playersNeedingUpdate.add(player); |
| 159 m_hasOutdatedPlayer = true; | 158 m_hasOutdatedPlayer = true; |
| 160 if (m_document && m_document->page() && !m_document->page()->animator().isSe
rvicingAnimations()) | 159 if (m_document && m_document->page() && !m_document->page()->animator().isSe
rvicingAnimations()) |
| 161 m_timing->serviceOnNextFrame(); | 160 m_timing->serviceOnNextFrame(); |
| 162 } | 161 } |
| 163 | 162 |
| 164 void DocumentTimeline::dispatchEvents() | |
| 165 { | |
| 166 Vector<EventToDispatch> events = m_events; | |
| 167 m_events.clear(); | |
| 168 for (size_t i = 0; i < events.size(); i++) | |
| 169 events[i].target->dispatchEvent(events[i].event.release()); | |
| 170 } | |
| 171 | |
| 172 void DocumentTimeline::dispatchEventsAsync() | |
| 173 { | |
| 174 if (m_events.isEmpty() || m_eventDistpachTimer.isActive()) | |
| 175 return; | |
| 176 m_eventDistpachTimer.startOneShot(0); | |
| 177 } | |
| 178 | |
| 179 void DocumentTimeline::eventDispatchTimerFired(Timer<DocumentTimeline>*) | |
| 180 { | |
| 181 dispatchEvents(); | |
| 182 } | |
| 183 | |
| 184 size_t DocumentTimeline::numberOfActiveAnimationsForTesting() const | 163 size_t DocumentTimeline::numberOfActiveAnimationsForTesting() const |
| 185 { | 164 { |
| 186 if (isNull(m_zeroTime)) | 165 if (isNull(m_zeroTime)) |
| 187 return 0; | 166 return 0; |
| 188 // Includes all players whose directly associated timed items | 167 // Includes all players whose directly associated timed items |
| 189 // are current or in effect. | 168 // are current or in effect. |
| 190 if (isNull(m_zeroTime)) | 169 if (isNull(m_zeroTime)) |
| 191 return 0; | 170 return 0; |
| 192 size_t count = 0; | 171 size_t count = 0; |
| 193 for (HashSet<RefPtr<Player> >::iterator it = m_playersNeedingUpdate.begin();
it != m_playersNeedingUpdate.end(); ++it) { | 172 for (HashSet<RefPtr<Player> >::iterator it = m_playersNeedingUpdate.begin();
it != m_playersNeedingUpdate.end(); ++it) { |
| 194 const TimedItem* timedItem = (*it)->source(); | 173 const TimedItem* timedItem = (*it)->source(); |
| 195 if ((*it)->hasStartTime()) | 174 if ((*it)->hasStartTime()) |
| 196 count += (timedItem && (timedItem->isCurrent() || timedItem->isInEff
ect())); | 175 count += (timedItem && (timedItem->isCurrent() || timedItem->isInEff
ect())); |
| 197 } | 176 } |
| 198 return count; | 177 return count; |
| 199 } | 178 } |
| 200 | 179 |
| 201 void DocumentTimeline::detachFromDocument() { | 180 void DocumentTimeline::detachFromDocument() { |
| 202 m_document = 0; | 181 m_document = 0; |
| 203 } | 182 } |
| 204 | 183 |
| 205 } // namespace | 184 } // namespace |
| OLD | NEW |