Bug 865407 - Part 4: Expose TextTrackCue::DisplayState to chrome JS. r=rillian, r=bz

This commit is contained in:
Rick Eyre 2013-12-12 11:27:30 -05:00
Родитель 4ca6ff109d
Коммит af5883b3b6
3 изменённых файлов: 26 добавлений и 8 удалений

Просмотреть файл

@ -104,12 +104,13 @@ TextTrackCue::StashDocument(nsISupports* aGlobal)
void
TextTrackCue::CreateCueOverlay()
{
mDocument->CreateElem(NS_LITERAL_STRING("div"), nullptr,
nsCOMPtr<nsINodeInfo> nodeInfo =
mDocument->NodeInfoManager()->GetNodeInfo(nsGkAtoms::div,
nullptr,
kNameSpaceID_XHTML,
getter_AddRefs(mDisplayState));
nsGenericHTMLElement* cueDiv =
static_cast<nsGenericHTMLElement*>(mDisplayState.get());
cueDiv->SetClassName(NS_LITERAL_STRING("caption-text"));
nsIDOMNode::ELEMENT_NODE);
mDisplayState = NS_NewHTMLDivElement(nodeInfo.forget());
mDisplayState->SetClassName(NS_LITERAL_STRING("caption-text"));
}
void
@ -148,7 +149,7 @@ TextTrackCue::RenderCue()
nsContentUtils::SetNodeTextContent(overlay, EmptyString(), true);
nsContentUtils::SetNodeTextContent(mDisplayState, EmptyString(), true);
mDisplayState->AppendChild(*frag, rv);
mDisplayState->nsINode::AppendChild(*frag, rv);
overlay->AppendChild(*mDisplayState, rv);
}

Просмотреть файл

@ -14,6 +14,7 @@
#include "nsIWebVTTParserWrapper.h"
#include "mozilla/StaticPtr.h"
#include "nsIDocument.h"
#include "mozilla/dom/HTMLDivElement.h"
namespace mozilla {
namespace dom {
@ -296,6 +297,16 @@ public:
IMPL_EVENT_HANDLER(enter)
IMPL_EVENT_HANDLER(exit)
HTMLDivElement* GetDisplayState()
{
return static_cast<HTMLDivElement*>(mDisplayState.get());
}
void SetDisplayState(HTMLDivElement* aDisplayState)
{
mDisplayState = aDisplayState;
}
// Helper functions for implementation.
bool
operator==(const TextTrackCue& rhs) const
@ -376,7 +387,7 @@ private:
// Holds the computed DOM elements that represent the parsed cue text.
// http://www.whatwg.org/specs/web-apps/current-work/#text-track-cue-display-state
nsCOMPtr<nsIContent> mDisplayState;
nsRefPtr<nsGenericHTMLElement> mDisplayState;
// Tells whether or not we need to recompute mDisplayState. This is set
// anytime a property that relates to the display of the TextTrackCue is
// changed.

Просмотреть файл

@ -53,3 +53,9 @@ interface VTTCue : EventTarget {
attribute EventHandler onexit;
};
// Mozilla extensions.
partial interface VTTCue {
[ChromeOnly]
attribute HTMLDivElement? displayState;
};