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
parent a782bbef63
commit 67d71baa8f
3 changed files with 26 additions and 8 deletions

View File

@ -104,12 +104,13 @@ TextTrackCue::StashDocument(nsISupports* aGlobal)
void
TextTrackCue::CreateCueOverlay()
{
mDocument->CreateElem(NS_LITERAL_STRING("div"), nullptr,
kNameSpaceID_XHTML,
getter_AddRefs(mDisplayState));
nsGenericHTMLElement* cueDiv =
static_cast<nsGenericHTMLElement*>(mDisplayState.get());
cueDiv->SetClassName(NS_LITERAL_STRING("caption-text"));
nsCOMPtr<nsINodeInfo> nodeInfo =
mDocument->NodeInfoManager()->GetNodeInfo(nsGkAtoms::div,
nullptr,
kNameSpaceID_XHTML,
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);
}

View File

@ -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.

View File

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