Index: Source/wtf/LinkedStack.h |
diff --git a/public/web/WebInbandTextTrack.h b/Source/wtf/LinkedStack.h |
similarity index 59% |
copy from public/web/WebInbandTextTrack.h |
copy to Source/wtf/LinkedStack.h |
index cebdf20b8552aee6e4cc4977ebcf6cb7ebbc1e02..f87309eb36d7fd85e672b16984d16d3c00fc935c 100644 |
--- a/public/web/WebInbandTextTrack.h |
+++ b/Source/wtf/LinkedStack.h |
@@ -28,49 +28,80 @@ |
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
-#ifndef WebInbandTextTrack_h |
-#define WebInbandTextTrack_h |
+#ifndef LinkedStack_h |
+#define LinkedStack_h |
-namespace WebKit { |
+#include "wtf/OwnPtr.h" |
-class WebString; |
-class WebInbandTextTrackClient; |
+namespace WTF { |
-class WebInbandTextTrack { |
+template <typename T> |
+class LinkedStack { |
public: |
- enum Kind { |
- KindSubtitles, |
- KindCaptions, |
- KindDescriptions, |
- KindChapters, |
- KindMetadata, |
- KindNone |
- }; |
+ LinkedStack() : m_size(0) { } |
+ |
+ bool isEmpty(); |
+ |
+ void push(const T&); |
+ const T& peek(); |
+ void pop(); |
+ |
+ size_t size(); |
+ |
+private: |
+ struct Node { |
+ Node(const T&, PassOwnPtr<Node> next); |
- enum Mode { |
- ModeDisabled, |
- ModeHidden, |
- ModeShowing |
+ T m_data; |
+ OwnPtr<Node> m_next; |
}; |
- virtual ~WebInbandTextTrack() {} |
+ OwnPtr<Node> m_head; |
+ size_t m_size; |
+}; |
- virtual void setClient(WebInbandTextTrackClient*) = 0; |
- virtual WebInbandTextTrackClient* client() = 0; |
+template <typename T> |
+LinkedStack<T>::Node::Node(const T& data, PassOwnPtr<Node> next) |
+ : m_data(data) |
+ , m_next(next) |
+{ |
+} |
- virtual void setMode(Mode) = 0; |
- virtual Mode mode() const = 0; |
+template <typename T> |
+inline bool LinkedStack<T>::isEmpty() |
+{ |
+ return !m_head; |
+} |
- virtual Kind kind() const = 0; |
- virtual bool isClosedCaptions() const = 0; |
+template <typename T> |
+inline void LinkedStack<T>::push(const T& data) |
+{ |
+ m_head = adoptPtr(new Node(data, m_head.release())); |
+ ++m_size; |
+} |
- virtual WebString label() const = 0; |
- virtual WebString language() const = 0; |
- virtual bool isDefault() const = 0; |
+template <typename T> |
+inline const T& LinkedStack<T>::peek() |
+{ |
+ return m_head->m_data; |
+} |
- virtual int textTrackIndex() const = 0; |
-}; |
+template <typename T> |
+inline void LinkedStack<T>::pop() |
+{ |
+ ASSERT(m_head && m_size); |
+ m_head = m_head->m_next.release(); |
+ --m_size; |
+} |
+ |
+template <typename T> |
+inline size_t LinkedStack<T>::size() |
+{ |
+ return m_size; |
+} |
+ |
+} |
-} // namespace WebKit |
+using WTF::LinkedStack; |
#endif |