| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011, 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2011, 2012 Apple 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 #include "bindings/v8/ScriptWrappable.h" | 29 #include "bindings/v8/ScriptWrappable.h" |
| 30 #include "core/events/EventListener.h" | 30 #include "core/events/EventListener.h" |
| 31 #include "core/events/EventTarget.h" | 31 #include "core/events/EventTarget.h" |
| 32 #include "platform/Timer.h" | 32 #include "platform/Timer.h" |
| 33 #include "wtf/PassRefPtr.h" | 33 #include "wtf/PassRefPtr.h" |
| 34 #include "wtf/RefCounted.h" | 34 #include "wtf/RefCounted.h" |
| 35 #include "wtf/Vector.h" | 35 #include "wtf/Vector.h" |
| 36 | 36 |
| 37 namespace WebCore { | 37 namespace WebCore { |
| 38 | 38 |
| 39 class GenericEventQueue; |
| 39 class HTMLMediaElement; | 40 class HTMLMediaElement; |
| 40 class TextTrack; | 41 class TextTrack; |
| 41 class TextTrackList; | 42 class TextTrackList; |
| 42 | 43 |
| 43 class TextTrackList : public RefCounted<TextTrackList>, public ScriptWrappable,
public EventTargetWithInlineData { | 44 class TextTrackList : public RefCounted<TextTrackList>, public ScriptWrappable,
public EventTargetWithInlineData { |
| 44 REFCOUNTED_EVENT_TARGET(TextTrackList); | 45 REFCOUNTED_EVENT_TARGET(TextTrackList); |
| 45 public: | 46 public: |
| 46 static PassRefPtr<TextTrackList> create(HTMLMediaElement* owner) | 47 static PassRefPtr<TextTrackList> create(HTMLMediaElement* owner) |
| 47 { | 48 { |
| 48 return adoptRef(new TextTrackList(owner)); | 49 return adoptRef(new TextTrackList(owner)); |
| 49 } | 50 } |
| 50 ~TextTrackList(); | 51 ~TextTrackList(); |
| 51 | 52 |
| 52 unsigned length() const; | 53 unsigned length() const; |
| 53 int getTrackIndex(TextTrack*); | 54 int getTrackIndex(TextTrack*); |
| 54 int getTrackIndexRelativeToRenderedTracks(TextTrack*); | 55 int getTrackIndexRelativeToRenderedTracks(TextTrack*); |
| 55 bool contains(TextTrack*) const; | 56 bool contains(TextTrack*) const; |
| 56 | 57 |
| 57 TextTrack* item(unsigned index); | 58 TextTrack* item(unsigned index); |
| 58 TextTrack* getTrackById(const AtomicString& id); | 59 TextTrack* getTrackById(const AtomicString& id); |
| 59 void append(PassRefPtr<TextTrack>); | 60 void append(PassRefPtr<TextTrack>); |
| 60 void remove(TextTrack*); | 61 void remove(TextTrack*); |
| 61 | 62 |
| 62 // EventTarget | 63 // EventTarget |
| 63 virtual const AtomicString& interfaceName() const OVERRIDE; | 64 virtual const AtomicString& interfaceName() const OVERRIDE; |
| 64 virtual ExecutionContext* executionContext() const OVERRIDE; | 65 virtual ExecutionContext* executionContext() const OVERRIDE; |
| 65 | 66 |
| 66 DEFINE_ATTRIBUTE_EVENT_LISTENER(addtrack); | 67 DEFINE_ATTRIBUTE_EVENT_LISTENER(addtrack); |
| 68 DEFINE_ATTRIBUTE_EVENT_LISTENER(change); |
| 69 DEFINE_ATTRIBUTE_EVENT_LISTENER(removetrack); |
| 67 | 70 |
| 68 void clearOwner() { m_owner = 0; } | 71 void clearOwner() { m_owner = 0; } |
| 69 Node* owner() const; | 72 Node* owner() const; |
| 70 | 73 |
| 71 bool isFiringEventListeners() { return m_dispatchingEvents; } | 74 void scheduleChangeEvent(); |
| 72 | 75 |
| 73 private: | 76 private: |
| 74 explicit TextTrackList(HTMLMediaElement*); | 77 explicit TextTrackList(HTMLMediaElement*); |
| 75 | 78 |
| 79 void scheduleTrackEvent(const AtomicString& eventName, PassRefPtr<TextTrack>
); |
| 80 |
| 76 void scheduleAddTrackEvent(PassRefPtr<TextTrack>); | 81 void scheduleAddTrackEvent(PassRefPtr<TextTrack>); |
| 77 void asyncEventTimerFired(Timer<TextTrackList>*); | 82 void scheduleRemoveTrackEvent(PassRefPtr<TextTrack>); |
| 78 | 83 |
| 79 void invalidateTrackIndexesAfterTrack(TextTrack*); | 84 void invalidateTrackIndexesAfterTrack(TextTrack*); |
| 80 | 85 |
| 81 HTMLMediaElement* m_owner; | 86 HTMLMediaElement* m_owner; |
| 82 | 87 |
| 83 Vector<RefPtr<Event> > m_pendingEvents; | 88 OwnPtr<GenericEventQueue> m_asyncEventQueue; |
| 84 Timer<TextTrackList> m_pendingEventTimer; | |
| 85 | 89 |
| 86 Vector<RefPtr<TextTrack> > m_addTrackTracks; | 90 Vector<RefPtr<TextTrack> > m_addTrackTracks; |
| 87 Vector<RefPtr<TextTrack> > m_elementTracks; | 91 Vector<RefPtr<TextTrack> > m_elementTracks; |
| 88 Vector<RefPtr<TextTrack> > m_inbandTracks; | 92 Vector<RefPtr<TextTrack> > m_inbandTracks; |
| 89 | |
| 90 int m_dispatchingEvents; | |
| 91 }; | 93 }; |
| 92 | 94 |
| 93 } // namespace WebCore | 95 } // namespace WebCore |
| 94 | 96 |
| 95 #endif | 97 #endif |
| OLD | NEW |