| 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 10 matching lines...) Expand all Loading... |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef WebInbandTextTrack_h | 31 #ifndef LinkedStack_h |
| 32 #define WebInbandTextTrack_h | 32 #define LinkedStack_h |
| 33 | 33 |
| 34 namespace WebKit { | 34 #include "wtf/OwnPtr.h" |
| 35 | 35 |
| 36 class WebString; | 36 namespace WTF { |
| 37 class WebInbandTextTrackClient; | |
| 38 | 37 |
| 39 class WebInbandTextTrack { | 38 template <typename T> |
| 39 class LinkedStack { |
| 40 public: | 40 public: |
| 41 enum Kind { | 41 LinkedStack() : m_size(0) { } |
| 42 KindSubtitles, | 42 |
| 43 KindCaptions, | 43 bool isEmpty(); |
| 44 KindDescriptions, | 44 |
| 45 KindChapters, | 45 void push(const T&); |
| 46 KindMetadata, | 46 const T& peek(); |
| 47 KindNone | 47 void pop(); |
| 48 |
| 49 size_t size(); |
| 50 |
| 51 private: |
| 52 struct Node { |
| 53 Node(const T&, PassOwnPtr<Node> next); |
| 54 |
| 55 T m_data; |
| 56 OwnPtr<Node> m_next; |
| 48 }; | 57 }; |
| 49 | 58 |
| 50 enum Mode { | 59 OwnPtr<Node> m_head; |
| 51 ModeDisabled, | 60 size_t m_size; |
| 52 ModeHidden, | |
| 53 ModeShowing | |
| 54 }; | |
| 55 | |
| 56 virtual ~WebInbandTextTrack() {} | |
| 57 | |
| 58 virtual void setClient(WebInbandTextTrackClient*) = 0; | |
| 59 virtual WebInbandTextTrackClient* client() = 0; | |
| 60 | |
| 61 virtual void setMode(Mode) = 0; | |
| 62 virtual Mode mode() const = 0; | |
| 63 | |
| 64 virtual Kind kind() const = 0; | |
| 65 virtual bool isClosedCaptions() const = 0; | |
| 66 | |
| 67 virtual WebString label() const = 0; | |
| 68 virtual WebString language() const = 0; | |
| 69 virtual bool isDefault() const = 0; | |
| 70 | |
| 71 virtual int textTrackIndex() const = 0; | |
| 72 }; | 61 }; |
| 73 | 62 |
| 74 } // namespace WebKit | 63 template <typename T> |
| 64 LinkedStack<T>::Node::Node(const T& data, PassOwnPtr<Node> next) |
| 65 : m_data(data) |
| 66 , m_next(next) |
| 67 { |
| 68 } |
| 69 |
| 70 template <typename T> |
| 71 inline bool LinkedStack<T>::isEmpty() |
| 72 { |
| 73 return !m_head; |
| 74 } |
| 75 |
| 76 template <typename T> |
| 77 inline void LinkedStack<T>::push(const T& data) |
| 78 { |
| 79 m_head = adoptPtr(new Node(data, m_head.release())); |
| 80 ++m_size; |
| 81 } |
| 82 |
| 83 template <typename T> |
| 84 inline const T& LinkedStack<T>::peek() |
| 85 { |
| 86 return m_head->m_data; |
| 87 } |
| 88 |
| 89 template <typename T> |
| 90 inline void LinkedStack<T>::pop() |
| 91 { |
| 92 ASSERT(m_head && m_size); |
| 93 m_head = m_head->m_next.release(); |
| 94 --m_size; |
| 95 } |
| 96 |
| 97 template <typename T> |
| 98 inline size_t LinkedStack<T>::size() |
| 99 { |
| 100 return m_size; |
| 101 } |
| 102 |
| 103 } |
| 104 |
| 105 using WTF::LinkedStack; |
| 75 | 106 |
| 76 #endif | 107 #endif |
| OLD | NEW |