mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-29 21:25:35 +00:00
Bug 895091 - Remove references to C WebVTT parser and unused code r=rillian
- Remove left over references to WebVTT C parser in TextTrackCue and WebVTTListener classes. - Remove miscellaneous unused code as well and included libraries as well.
This commit is contained in:
parent
cd77eb0805
commit
3352fbe8c5
@ -48,7 +48,6 @@ TextTrackCue::TextTrackCue(nsISupports* aGlobal,
|
||||
: mText(aText)
|
||||
, mStartTime(aStartTime)
|
||||
, mEndTime(aEndTime)
|
||||
, mHead(nullptr)
|
||||
, mReset(false)
|
||||
{
|
||||
SetDefaultCueSettings();
|
||||
@ -64,16 +63,13 @@ TextTrackCue::TextTrackCue(nsISupports* aGlobal,
|
||||
double aEndTime,
|
||||
const nsAString& aText,
|
||||
HTMLTrackElement* aTrackElement,
|
||||
webvtt_node* head,
|
||||
ErrorResult& aRv)
|
||||
: mText(aText)
|
||||
, mStartTime(aStartTime)
|
||||
, mEndTime(aEndTime)
|
||||
, mTrackElement(aTrackElement)
|
||||
, mHead(head)
|
||||
, mReset(false)
|
||||
{
|
||||
// Ref mHead here.
|
||||
SetDefaultCueSettings();
|
||||
MOZ_ASSERT(aGlobal);
|
||||
SetIsDOMBinding();
|
||||
@ -82,13 +78,6 @@ TextTrackCue::TextTrackCue(nsISupports* aGlobal,
|
||||
}
|
||||
}
|
||||
|
||||
TextTrackCue::~TextTrackCue()
|
||||
{
|
||||
if (mHead) {
|
||||
// Release mHead here.
|
||||
}
|
||||
}
|
||||
|
||||
/** Save a reference to our creating document so it's available
|
||||
* even when unlinked during discard/teardown.
|
||||
*/
|
||||
@ -162,52 +151,10 @@ TextTrackCue::GetCueAsHTML()
|
||||
{
|
||||
MOZ_ASSERT(mDocument);
|
||||
nsRefPtr<DocumentFragment> frag = mDocument->CreateDocumentFragment();
|
||||
ConvertNodeTreeToDOMTree(frag);
|
||||
|
||||
return frag.forget();
|
||||
}
|
||||
|
||||
struct WebVTTNodeParentPair
|
||||
{
|
||||
webvtt_node* mNode;
|
||||
nsIContent* mParent;
|
||||
|
||||
WebVTTNodeParentPair(webvtt_node* aNode, nsIContent* aParent)
|
||||
: mNode(aNode)
|
||||
, mParent(aParent)
|
||||
{}
|
||||
};
|
||||
|
||||
void
|
||||
TextTrackCue::ConvertNodeTreeToDOMTree(nsIContent* aParentContent)
|
||||
{
|
||||
nsTArray<WebVTTNodeParentPair> nodeParentPairStack;
|
||||
|
||||
// mHead should actually be the head of a node tree.
|
||||
// Seed the stack for traversal.
|
||||
}
|
||||
|
||||
already_AddRefed<nsIContent>
|
||||
TextTrackCue::ConvertInternalNodeToContent(const webvtt_node* aWebVTTNode)
|
||||
{
|
||||
nsIAtom* atom = nsGkAtoms::span;
|
||||
|
||||
nsCOMPtr<nsIContent> cueTextContent;
|
||||
mDocument->CreateElem(nsDependentAtomString(atom), nullptr,
|
||||
kNameSpaceID_XHTML,
|
||||
getter_AddRefs(cueTextContent));
|
||||
return cueTextContent.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<nsIContent>
|
||||
TextTrackCue::ConvertLeafNodeToContent(const webvtt_node* aWebVTTNode)
|
||||
{
|
||||
nsCOMPtr<nsIContent> cueTextContent;
|
||||
// Use mDocument to create nodes on cueTextContent.
|
||||
|
||||
return cueTextContent.forget();
|
||||
}
|
||||
|
||||
JSObject*
|
||||
TextTrackCue::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
|
||||
{
|
||||
|
@ -8,14 +8,11 @@
|
||||
#define mozilla_dom_TextTrackCue_h
|
||||
|
||||
#include "mozilla/dom/DocumentFragment.h"
|
||||
#include "mozilla/dom/TextTrack.h"
|
||||
#include "mozilla/dom/VTTCueBinding.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsDOMEventTargetHelper.h"
|
||||
#include "nsIDocument.h"
|
||||
|
||||
struct webvtt_node;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
@ -46,9 +43,7 @@ public:
|
||||
|
||||
TextTrackCue(nsISupports* aGlobal, double aStartTime, double aEndTime,
|
||||
const nsAString& aText, HTMLTrackElement* aTrackElement,
|
||||
webvtt_node* head, ErrorResult& aRv);
|
||||
|
||||
~TextTrackCue();
|
||||
ErrorResult& aRv);
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
|
||||
@ -234,12 +229,6 @@ public:
|
||||
CueChanged();
|
||||
}
|
||||
|
||||
already_AddRefed<DocumentFragment> GetCueAsHTML() const
|
||||
{
|
||||
// XXXhumph: todo. Bug 868509.
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
IMPL_EVENT_HANDLER(enter)
|
||||
IMPL_EVENT_HANDLER(exit)
|
||||
|
||||
@ -256,17 +245,17 @@ public:
|
||||
}
|
||||
|
||||
/**
|
||||
* Overview of WEBVTT cuetext and anonymous content setup.
|
||||
* Overview of WebVTT cuetext and anonymous content setup.
|
||||
*
|
||||
* webvtt_nodes are the parsed version of WEBVTT cuetext. WEBVTT cuetext is
|
||||
* the portion of a WEBVTT cue that specifies what the caption will actually
|
||||
* WebVTT nodes are the parsed version of WebVTT cuetext. WebVTT cuetext is
|
||||
* the portion of a WebVTT cue that specifies what the caption will actually
|
||||
* show up as on screen.
|
||||
*
|
||||
* WEBVTT cuetext can contain markup that loosely relates to HTML markup. It
|
||||
* WebVTT cuetext can contain markup that loosely relates to HTML markup. It
|
||||
* can contain tags like <b>, <u>, <i>, <c>, <v>, <ruby>, <rt>, <lang>,
|
||||
* including timestamp tags.
|
||||
*
|
||||
* When the caption is ready to be displayed the webvtt_nodes are converted
|
||||
* When the caption is ready to be displayed the WebVTT nodes are converted
|
||||
* over to anonymous DOM content. <i>, <u>, <b>, <ruby>, and <rt> all become
|
||||
* HTMLElements of their corresponding HTML markup tags. <c> and <v> are
|
||||
* converted to <span> tags. Timestamp tags are converted to XML processing
|
||||
@ -274,7 +263,7 @@ public:
|
||||
* This takes the form of <foo.class.subclass>. These classes are then parsed
|
||||
* and set as the anonymous content's class attribute.
|
||||
*
|
||||
* Rules on constructing DOM objects from webvtt_nodes can be found here
|
||||
* Rules on constructing DOM objects from WebVTT nodes can be found here
|
||||
* http://dev.w3.org/html5/webvtt/#webvtt-cue-text-dom-construction-rules.
|
||||
* Current rules are taken from revision on April 15, 2013.
|
||||
*/
|
||||
@ -287,39 +276,13 @@ public:
|
||||
|
||||
/**
|
||||
* Produces a tree of anonymous content based on the tree of the processed
|
||||
* cue text. This lives in a tree of C nodes whose head is mHead.
|
||||
* cue text.
|
||||
*
|
||||
* Returns a DocumentFragment that is the head of the tree of anonymous
|
||||
* content.
|
||||
*/
|
||||
already_AddRefed<DocumentFragment> GetCueAsHTML();
|
||||
|
||||
/**
|
||||
* Converts mHead to a list of DOM elements and attaches it to aParentContent.
|
||||
*
|
||||
* Processes the C node tree in a depth-first pre-order traversal and creates
|
||||
* a mirrored DOM tree. The conversion rules come from the webvtt DOM
|
||||
* construction rules:
|
||||
* http://dev.w3.org/html5/webvtt/#webvtt-cue-text-dom-construction-rules
|
||||
* Current rules taken from revision on May 13, 2013.
|
||||
*/
|
||||
void
|
||||
ConvertNodeTreeToDOMTree(nsIContent* aParentContent);
|
||||
|
||||
/**
|
||||
* Converts an internal webvtt node, i.e. one that has children, to an
|
||||
* anonymous HTMLElement.
|
||||
*/
|
||||
already_AddRefed<nsIContent>
|
||||
ConvertInternalNodeToContent(const webvtt_node* aWebVTTNode);
|
||||
|
||||
/**
|
||||
* Converts a leaf webvtt node, i.e. one that does not have children, to
|
||||
* either a text node or processing instruction.
|
||||
*/
|
||||
already_AddRefed<nsIContent>
|
||||
ConvertLeafNodeToContent(const webvtt_node* aWebVTTNode);
|
||||
|
||||
private:
|
||||
void CueChanged();
|
||||
void SetDefaultCueSettings();
|
||||
@ -333,7 +296,6 @@ private:
|
||||
|
||||
nsRefPtr<TextTrack> mTrack;
|
||||
nsRefPtr<HTMLTrackElement> mTrackElement;
|
||||
webvtt_node *mHead;
|
||||
nsString mId;
|
||||
int32_t mPosition;
|
||||
int32_t mSize;
|
||||
|
@ -57,10 +57,6 @@ WebVTTLoadListener::LoadResource()
|
||||
}
|
||||
|
||||
LOG("Loading text track resource.");
|
||||
webvtt_parser_t* parser = nullptr;
|
||||
// Create parser here.
|
||||
mParser.own(parser);
|
||||
NS_ENSURE_TRUE(mParser != nullptr, NS_ERROR_FAILURE);
|
||||
|
||||
mElement->mReadyState = HTMLTrackElement::LOADING;
|
||||
return NS_OK;
|
||||
@ -130,7 +126,6 @@ WebVTTLoadListener::ParseChunk(nsIInputStream* aInStream, void* aClosure,
|
||||
const char* aFromSegment, uint32_t aToOffset,
|
||||
uint32_t aCount, uint32_t* aWriteCount)
|
||||
{
|
||||
//WebVTTLoadListener* loadListener = static_cast<WebVTTLoadListener*>(aClosure);
|
||||
// Call parser incrementally on new data.
|
||||
if (1) {
|
||||
LOG("WebVTT parser disabled.");
|
||||
@ -142,32 +137,5 @@ WebVTTLoadListener::ParseChunk(nsIInputStream* aInStream, void* aClosure,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
WebVTTLoadListener::OnParsedCue(webvtt_cue* aCue)
|
||||
{
|
||||
nsRefPtr<TextTrackCue> textTrackCue;
|
||||
// Create a new textTrackCue here.
|
||||
// Copy settings from the parsed cue here.
|
||||
mElement->mTrack->AddCue(*textTrackCue);
|
||||
}
|
||||
|
||||
int
|
||||
WebVTTLoadListener::OnReportError(uint32_t aLine, uint32_t aCol,
|
||||
webvtt_error aError)
|
||||
{
|
||||
#ifdef PR_LOGGING
|
||||
// Get source webvtt file to display in the log
|
||||
DOMString wideFile;
|
||||
mElement->GetSrc(wideFile);
|
||||
|
||||
NS_ConvertUTF16toUTF8 file(wideFile);
|
||||
|
||||
const char* error = "parser error";
|
||||
|
||||
LOG("error: %s(%d:%d) - %s\n", file.get(), aLine, aCol, error);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
@ -13,27 +13,14 @@
|
||||
#include "nsAutoRef.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
|
||||
struct webvtt_parser_t;
|
||||
struct webvtt_cue;
|
||||
typedef int webvtt_error;
|
||||
|
||||
template <>
|
||||
class nsAutoRefTraits<webvtt_parser_t> : public nsPointerRefTraits<webvtt_parser_t>
|
||||
{
|
||||
public:
|
||||
static void Release(webvtt_parser_t* aParser) {
|
||||
// Call parser dtor here.
|
||||
}
|
||||
};
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class HTMLTrackElement;
|
||||
|
||||
/**
|
||||
* Class that manages the libwebvtt parsing library and functions as an
|
||||
* interface between Gecko and libwebvtt.
|
||||
* Class that manages the WebVTT parsing library and functions as an
|
||||
* interface between Gecko and WebVTT.
|
||||
*
|
||||
* Currently it's only designed to work with an HTMLTrackElement. The
|
||||
* HTMLTrackElement controls the lifetime of the WebVTTLoadListener.
|
||||
@ -41,11 +28,10 @@ class HTMLTrackElement;
|
||||
* The workflow of this class is as follows:
|
||||
* - Gets Loaded via an HTMLTrackElement class.
|
||||
* - As the HTMLTrackElement class gets new data WebVTTLoadListener's
|
||||
* OnDataAvailable() function is called and data is passed to the libwebvtt
|
||||
* OnDataAvailable() function is called and data is passed to the WebVTT
|
||||
* parser.
|
||||
* - When the libwebvtt parser has finished a cue it will call the callbacks
|
||||
* that are exposed by the WebVTTLoadListener -- OnParsedCueWebVTTCallBack or
|
||||
* OnReportErrorWebVTTCallBack if it has encountered an error.
|
||||
* - When the WebVTT parser has finished a cue it will call the callbacks
|
||||
* that are exposed by the WebVTTLoadListener.
|
||||
* - When it has returned a cue successfully the WebVTTLoadListener will create
|
||||
* a new TextTrackCue and add it to the HTMLTrackElement's TextTrack.
|
||||
*/
|
||||
@ -66,7 +52,7 @@ public:
|
||||
WebVTTLoadListener(HTMLTrackElement* aElement);
|
||||
~WebVTTLoadListener();
|
||||
|
||||
// Loads the libwebvtt parser. Must call this function in order to the
|
||||
// Loads the WebVTT parser. Must call this function in order to the
|
||||
// WebVTTLoadListener to be ready to accept data.
|
||||
nsresult LoadResource();
|
||||
|
||||
@ -76,10 +62,6 @@ private:
|
||||
uint32_t aCount, uint32_t* aWriteCount);
|
||||
|
||||
nsRefPtr<HTMLTrackElement> mElement;
|
||||
nsAutoRef<webvtt_parser_t> mParser;
|
||||
|
||||
void OnParsedCue(webvtt_cue* aCue);
|
||||
int OnReportError(uint32_t aLine, uint32_t aCol, webvtt_error aError);
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user