зеркало из https://github.com/mozilla/gecko-dev.git
Bug 976580 - Set cue state to dirty when video resize happens. r=rillian, r=bz
This way when the video is resized the rendering algorithm for the cues will run again and hence, the caption size will be increased/decreased for the new size of the video.
This commit is contained in:
Родитель
ce617b860a
Коммит
ca1c5aecfa
|
@ -3927,6 +3927,7 @@ HTMLMediaElement::GetOrCreateTextTrackManager()
|
|||
{
|
||||
if (!mTextTrackManager) {
|
||||
mTextTrackManager = new TextTrackManager(this);
|
||||
mTextTrackManager->AddListeners();
|
||||
}
|
||||
return mTextTrackManager;
|
||||
}
|
||||
|
|
|
@ -8,8 +8,10 @@
|
|||
#include "mozilla/dom/TextTrackManager.h"
|
||||
#include "mozilla/dom/HTMLMediaElement.h"
|
||||
#include "mozilla/dom/HTMLTrackElement.h"
|
||||
#include "mozilla/dom/HTMLVideoElement.h"
|
||||
#include "mozilla/dom/TextTrack.h"
|
||||
#include "mozilla/dom/TextTrackCue.h"
|
||||
#include "mozilla/dom/Event.h"
|
||||
#include "mozilla/ClearOnShutdown.h"
|
||||
#include "nsComponentManagerUtils.h"
|
||||
#include "nsVideoFrame.h"
|
||||
|
@ -75,8 +77,13 @@ CompareTextTracks::LessThan(TextTrack* aOne, TextTrack* aTwo) const
|
|||
|
||||
NS_IMPL_CYCLE_COLLECTION_4(TextTrackManager, mMediaElement, mTextTracks,
|
||||
mPendingTextTracks, mNewCues)
|
||||
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(TextTrackManager, AddRef)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(TextTrackManager, Release)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TextTrackManager)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMEventListener)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(TextTrackManager)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(TextTrackManager)
|
||||
|
||||
StaticRefPtr<nsIWebVTTParserWrapper> TextTrackManager::sParserWrapper;
|
||||
|
||||
|
@ -84,8 +91,6 @@ TextTrackManager::TextTrackManager(HTMLMediaElement *aMediaElement)
|
|||
: mMediaElement(aMediaElement)
|
||||
, performedTrackSelection(false)
|
||||
{
|
||||
MOZ_COUNT_CTOR(TextTrackManager);
|
||||
|
||||
bool hasHadScriptObject = true;
|
||||
nsIScriptGlobalObject* scriptObject =
|
||||
mMediaElement->OwnerDoc()->GetScriptHandlingObject(hasHadScriptObject);
|
||||
|
@ -105,11 +110,6 @@ TextTrackManager::TextTrackManager(HTMLMediaElement *aMediaElement)
|
|||
}
|
||||
}
|
||||
|
||||
TextTrackManager::~TextTrackManager()
|
||||
{
|
||||
MOZ_COUNT_DTOR(TextTrackManager);
|
||||
}
|
||||
|
||||
TextTrackList*
|
||||
TextTrackManager::TextTracks() const
|
||||
{
|
||||
|
@ -255,6 +255,15 @@ TextTrackManager::PopulatePendingList()
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
TextTrackManager::AddListeners()
|
||||
{
|
||||
if (mMediaElement) {
|
||||
mMediaElement->AddEventListener(NS_LITERAL_STRING("resizevideocontrols"),
|
||||
this, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
TextTrackManager::HonorUserPreferencesForTrackSelection()
|
||||
{
|
||||
|
@ -352,5 +361,22 @@ TextTrackManager::GetTextTracksOfKind(TextTrackKind aTextTrackKind,
|
|||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TextTrackManager::HandleEvent(nsIDOMEvent* aEvent)
|
||||
{
|
||||
if (!mTextTracks) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsAutoString type;
|
||||
aEvent->GetType(type);
|
||||
if (type.EqualsLiteral("resizevideocontrols")) {
|
||||
for (uint32_t i = 0; i< mTextTracks->Length(); i++) {
|
||||
((*mTextTracks)[i])->SetCuesDirty();
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -33,14 +33,15 @@ public:
|
|||
class TextTrack;
|
||||
class TextTrackCue;
|
||||
|
||||
class TextTrackManager
|
||||
class TextTrackManager MOZ_FINAL : public nsIDOMEventListener
|
||||
{
|
||||
public:
|
||||
NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(TextTrackManager)
|
||||
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(TextTrackManager);
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS(TextTrackManager)
|
||||
|
||||
NS_DECL_NSIDOMEVENTLISTENER
|
||||
|
||||
TextTrackManager(HTMLMediaElement *aMediaElement);
|
||||
~TextTrackManager();
|
||||
|
||||
TextTrackList* TextTracks() const;
|
||||
already_AddRefed<TextTrack> AddTextTrack(TextTrackKind aKind,
|
||||
|
@ -88,6 +89,8 @@ public:
|
|||
|
||||
void PopulatePendingList();
|
||||
|
||||
void AddListeners();
|
||||
|
||||
// The HTMLMediaElement that this TextTrackManager manages the TextTracks of.
|
||||
nsRefPtr<HTMLMediaElement> mMediaElement;
|
||||
private:
|
||||
|
|
|
@ -124,6 +124,14 @@ TextTrack::RemoveCue(TextTrackCue& aCue, ErrorResult& aRv)
|
|||
SetDirty();
|
||||
}
|
||||
|
||||
void
|
||||
TextTrack::SetCuesDirty()
|
||||
{
|
||||
for (uint32_t i = 0; i < mCueList->Length(); i++) {
|
||||
((*mCueList)[i])->Reset();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
TextTrack::UpdateActiveCueList()
|
||||
{
|
||||
|
|
|
@ -105,6 +105,7 @@ public:
|
|||
void AddCue(TextTrackCue& aCue);
|
||||
void RemoveCue(TextTrackCue& aCue, ErrorResult& aRv);
|
||||
void SetDirty() { mDirty = true; }
|
||||
void SetCuesDirty();
|
||||
|
||||
TextTrackList* GetTextTrackList();
|
||||
void SetTextTrackList(TextTrackList* aTextTrackList);
|
||||
|
|
|
@ -295,6 +295,11 @@ public:
|
|||
mReset = false;
|
||||
}
|
||||
|
||||
void Reset()
|
||||
{
|
||||
mReset = true;
|
||||
}
|
||||
|
||||
bool HasBeenReset()
|
||||
{
|
||||
return mReset;
|
||||
|
|
Загрузка…
Ссылка в новой задаче