HTMLTrackElement.readyState should return TextTrack "readiness state".
authoreric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 1 Dec 2011 16:42:49 +0000 (16:42 +0000)
committereric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 1 Dec 2011 16:42:49 +0000 (16:42 +0000)
https://bugs.webkit.org/show_bug.cgi?id=73466

Reviewed by Darin Adler.

* html/HTMLTrackElement.cpp:
(WebCore::HTMLTrackElement::HTMLTrackElement): Don't initialize m_readyState.
(WebCore::HTMLTrackElement::setReadyState): Return the TextTrack state.
(WebCore::HTMLTrackElement::readyState): Set the TextTrack state.
* html/HTMLTrackElement.h: Remove m_readyState.

* html/TextTrack.cpp:
(WebCore::TextTrack::TextTrack): Initialize m_readinessState.
* html/TextTrack.h:
(WebCore::TextTrack::readinessState): New.
(WebCore::TextTrack::setReadinessState): New.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@101673 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/html/HTMLTrackElement.cpp
Source/WebCore/html/HTMLTrackElement.h
Source/WebCore/html/TextTrack.cpp
Source/WebCore/html/TextTrack.h

index 49a7e7f..f5a050c 100644 (file)
@@ -1,3 +1,22 @@
+2011-12-01  Eric Carlson  <eric.carlson@apple.com>
+
+        HTMLTrackElement.readyState should return TextTrack "readiness state".
+        https://bugs.webkit.org/show_bug.cgi?id=73466
+
+        Reviewed by Darin Adler.
+
+        * html/HTMLTrackElement.cpp:
+        (WebCore::HTMLTrackElement::HTMLTrackElement): Don't initialize m_readyState.
+        (WebCore::HTMLTrackElement::setReadyState): Return the TextTrack state.
+        (WebCore::HTMLTrackElement::readyState): Set the TextTrack state.
+        * html/HTMLTrackElement.h: Remove m_readyState.
+
+        * html/TextTrack.cpp:
+        (WebCore::TextTrack::TextTrack): Initialize m_readinessState.
+        * html/TextTrack.h:
+        (WebCore::TextTrack::readinessState): New.
+        (WebCore::TextTrack::setReadinessState): New.
+
 2011-12-01  Kentaro Hara  <haraken@chromium.org>
 
         Unreviewed, rolling out r101669.
index 3d082f1..aa29cd2 100644 (file)
@@ -43,7 +43,6 @@ using namespace HTMLNames;
 
 inline HTMLTrackElement::HTMLTrackElement(const QualifiedName& tagName, Document* document)
     : HTMLElement(tagName, document)
-    , m_readyState(HTMLTrackElement::NONE)
 {
     LOG(Media, "HTMLTrackElement::HTMLTrackElement - %p", this);
     ASSERT(hasTagName(trackTag));
@@ -219,12 +218,23 @@ void HTMLTrackElement::didCompleteLoad(LoadableTextTrack*, bool loadingFailed)
     dispatchEvent(Event::create(loadingFailed ? eventNames().errorEvent : eventNames().loadEvent, false, false), ec);
 }
 
+// NOTE: The values in the TextTrack::ReadinessState enum must stay in sync with those in HTMLTrackElement::ReadyState.
+COMPILE_ASSERT(HTMLTrackElement::NONE == static_cast<HTMLTrackElement::ReadyState>(TextTrack::NotLoaded), TextTrackEnumNotLoaded_Is_Wrong_Should_Be_HTMLTrackElementEnumNONE);
+COMPILE_ASSERT(HTMLTrackElement::LOADING == static_cast<HTMLTrackElement::ReadyState>(TextTrack::Loading), TextTrackEnumLoadingIsWrong_ShouldBe_HTMLTrackElementEnumLOADING);
+COMPILE_ASSERT(HTMLTrackElement::LOADED == static_cast<HTMLTrackElement::ReadyState>(TextTrack::Loaded), TextTrackEnumLoaded_Is_Wrong_Should_Be_HTMLTrackElementEnumLOADED);
+COMPILE_ASSERT(HTMLTrackElement::TRACK_ERROR == static_cast<HTMLTrackElement::ReadyState>(TextTrack::FailedToLoad), TextTrackEnumFailedToLoad_Is_Wrong_Should_Be_HTMLTrackElementEnumTRACK_ERROR);
+
 void HTMLTrackElement::setReadyState(ReadyState state)
 {
-    m_readyState = state;
+    ensureTrack()->setReadinessState(static_cast<TextTrack::ReadinessState>(state));
     if (HTMLMediaElement* parent = mediaElement())
         return parent->textTrackReadyStateChanged(m_track.get());
 }
+
+HTMLTrackElement::ReadyState HTMLTrackElement::readyState() 
+{
+    return static_cast<ReadyState>(ensureTrack()->readinessState());
+}
     
 void HTMLTrackElement::textTrackKindChanged(TextTrack* track)
 {
index c9ee853..2afa482 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "HTMLElement.h"
 #include "LoadableTextTrack.h"
+#include "TextTrack.h"
 
 namespace WebCore {
 
@@ -53,9 +54,10 @@ public:
 
     bool isDefault() const;
     void setIsDefault(bool);
-    
+
     enum ReadyState { NONE = 0, LOADING = 1, LOADED = 2, TRACK_ERROR = 3 };
-    ReadyState readyState() const { return m_readyState; }
+    ReadyState readyState();
+    void setReadyState(ReadyState);
 
     TextTrack* track();
     
@@ -63,8 +65,6 @@ public:
     virtual bool canLoadUrl(LoadableTextTrack*, const KURL&);
     virtual void didCompleteLoad(LoadableTextTrack*, bool /* loadingFailed */);
     
-    void setReadyState(ReadyState);
-
 private:
     HTMLTrackElement(const QualifiedName&, Document*);
     virtual ~HTMLTrackElement();
@@ -93,7 +93,6 @@ private:
 
     LoadableTextTrack* ensureTrack();
 
-    HTMLTrackElement::ReadyState m_readyState;
     RefPtr<LoadableTextTrack> m_track;
 };
 
index be25903..786bdab 100644 (file)
@@ -78,6 +78,7 @@ TextTrack::TextTrack(ScriptExecutionContext* context, TextTrackClient* client, c
     , m_mode(TextTrack::HIDDEN)
     , m_client(client)
     , m_trackType(type)
+    , m_readinessState(NotLoaded)
 {
     setKind(kind);
 }
index 75a0d22..65914bc 100644 (file)
@@ -79,12 +79,13 @@ public:
     Mode mode() const { return m_mode; }
     void setMode(unsigned short, ExceptionCode&);
 
+    enum ReadinessState { NotLoaded = 0, Loading = 1, Loaded = 2, FailedToLoad = 3 };
+    ReadinessState readinessState() const { return m_readinessState; }
+    void setReadinessState(ReadinessState state) { m_readinessState = state; }
+
     TextTrackCueList* cues();
     TextTrackCueList* activeCues() const;
 
-    void readyStateChanged();
-    void modeChanged();
-
     virtual void clearClient() { m_client = 0; }
     TextTrackClient* client() { return m_client; }
 
@@ -106,9 +107,10 @@ private:
     String m_kind;
     String m_label;
     String m_language;
-    TextTrack::Mode m_mode;
+    Mode m_mode;
     TextTrackClient* m_client;
     TextTrackType m_trackType;
+    ReadinessState m_readinessState;
 };
 
 } // namespace WebCore