2017-10-27 20:33:53 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2008-07-09 12:22:20 +04:00
|
|
|
|
|
|
|
/* rendering object for the HTML <video> element */
|
|
|
|
|
|
|
|
#ifndef nsVideoFrame_h___
|
|
|
|
#define nsVideoFrame_h___
|
|
|
|
|
2012-09-14 20:10:08 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2008-07-09 12:22:20 +04:00
|
|
|
#include "nsContainerFrame.h"
|
|
|
|
#include "nsIAnonymousContentCreator.h"
|
2017-08-17 02:48:52 +03:00
|
|
|
#include "nsStringFwd.h"
|
2014-03-15 23:00:17 +04:00
|
|
|
#include "nsTArrayForwardDeclare.h"
|
2012-09-17 02:25:33 +04:00
|
|
|
#include "FrameLayerBuilder.h"
|
2012-07-31 04:42:26 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
class Layer;
|
|
|
|
class LayerManager;
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace layers
|
|
|
|
} // namespace mozilla
|
2008-07-09 12:22:20 +04:00
|
|
|
|
2010-04-11 00:10:12 +04:00
|
|
|
class nsPresContext;
|
2010-07-16 01:07:46 +04:00
|
|
|
class nsDisplayItem;
|
2010-04-11 00:10:12 +04:00
|
|
|
|
2016-04-18 09:26:44 +03:00
|
|
|
class nsVideoFrame : public nsContainerFrame
|
|
|
|
, public nsIAnonymousContentCreator
|
2008-07-09 12:22:20 +04:00
|
|
|
{
|
|
|
|
public:
|
2016-03-26 00:49:43 +03:00
|
|
|
template <typename T> using Maybe = mozilla::Maybe<T>;
|
|
|
|
using Nothing = mozilla::Nothing;
|
|
|
|
using Visibility = mozilla::Visibility;
|
|
|
|
|
2010-03-02 02:41:49 +03:00
|
|
|
typedef mozilla::layers::Layer Layer;
|
|
|
|
typedef mozilla::layers::LayerManager LayerManager;
|
2013-09-27 10:01:16 +04:00
|
|
|
typedef mozilla::ContainerLayerParameters ContainerLayerParameters;
|
2010-03-02 02:41:49 +03:00
|
|
|
|
2018-03-22 21:20:41 +03:00
|
|
|
explicit nsVideoFrame(ComputedStyle* aStyle);
|
2008-07-09 12:22:20 +04:00
|
|
|
|
2009-01-12 22:20:59 +03:00
|
|
|
NS_DECL_QUERYFRAME
|
2017-05-26 13:11:11 +03:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS(nsVideoFrame)
|
2009-09-12 20:49:24 +04:00
|
|
|
|
2017-01-18 03:27:03 +03:00
|
|
|
void BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayListSet& aLists) override;
|
2008-07-09 12:22:20 +04:00
|
|
|
|
2017-01-18 03:27:03 +03:00
|
|
|
nsresult AttributeChanged(int32_t aNameSpaceID,
|
2017-10-03 01:05:19 +03:00
|
|
|
nsAtom* aAttribute,
|
2017-01-18 03:27:03 +03:00
|
|
|
int32_t aModType) override;
|
2009-06-26 11:25:17 +04:00
|
|
|
|
2016-09-12 08:19:07 +03:00
|
|
|
void OnVisibilityChange(Visibility aNewVisibility,
|
2017-02-13 20:07:40 +03:00
|
|
|
const Maybe<OnNonvisible>& aNonvisibleAction = Nothing()) override;
|
2016-03-26 00:49:43 +03:00
|
|
|
|
2008-07-09 12:22:20 +04:00
|
|
|
/* get the size of the video's display */
|
2017-06-09 22:14:53 +03:00
|
|
|
nsSize GetVideoIntrinsicSize(gfxContext *aRenderingContext);
|
2017-01-18 03:27:03 +03:00
|
|
|
nsSize GetIntrinsicRatio() override;
|
|
|
|
mozilla::LogicalSize
|
2017-06-09 22:14:53 +03:00
|
|
|
ComputeSize(gfxContext *aRenderingContext,
|
2014-08-24 18:34:44 +04:00
|
|
|
mozilla::WritingMode aWritingMode,
|
|
|
|
const mozilla::LogicalSize& aCBSize,
|
|
|
|
nscoord aAvailableISize,
|
|
|
|
const mozilla::LogicalSize& aMargin,
|
|
|
|
const mozilla::LogicalSize& aBorder,
|
|
|
|
const mozilla::LogicalSize& aPadding,
|
2015-03-21 19:28:04 +03:00
|
|
|
ComputeSizeFlags aFlags) override;
|
2017-06-09 22:14:53 +03:00
|
|
|
nscoord GetMinISize(gfxContext *aRenderingContext) override;
|
|
|
|
nscoord GetPrefISize(gfxContext *aRenderingContext) override;
|
2017-11-07 03:20:33 +03:00
|
|
|
void DestroyFrom(nsIFrame* aDestructRoot, PostDestroyData& aPostDestroyData) override;
|
2008-07-09 12:22:20 +04:00
|
|
|
|
2017-01-18 03:27:03 +03:00
|
|
|
void Reflow(nsPresContext* aPresContext,
|
|
|
|
ReflowOutput& aDesiredSize,
|
|
|
|
const ReflowInput& aReflowInput,
|
|
|
|
nsReflowStatus& aStatus) override;
|
2008-07-09 12:22:20 +04:00
|
|
|
|
2018-06-27 21:12:38 +03:00
|
|
|
bool IsLeafDynamic() const override;
|
|
|
|
|
2008-07-09 12:22:20 +04:00
|
|
|
#ifdef ACCESSIBILITY
|
2017-01-18 03:27:03 +03:00
|
|
|
mozilla::a11y::AccType AccessibleType() override;
|
2008-07-09 12:22:20 +04:00
|
|
|
#endif
|
|
|
|
|
2017-01-18 03:27:03 +03:00
|
|
|
bool IsFrameOfType(uint32_t aFlags) const override
|
2008-07-09 12:22:20 +04:00
|
|
|
{
|
2016-02-04 01:43:02 +03:00
|
|
|
return nsSplittableFrame::IsFrameOfType(aFlags &
|
|
|
|
~(nsIFrame::eReplaced | nsIFrame::eReplacedSizing));
|
2008-07-09 12:22:20 +04:00
|
|
|
}
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2017-01-18 03:27:03 +03:00
|
|
|
nsresult CreateAnonymousContent(nsTArray<ContentInfo>& aElements) override;
|
|
|
|
void AppendAnonymousContentTo(nsTArray<nsIContent*>& aElements,
|
|
|
|
uint32_t aFilters) override;
|
2008-07-09 12:22:20 +04:00
|
|
|
|
2017-12-05 20:05:51 +03:00
|
|
|
mozilla::dom::Element* GetPosterImage() { return mPosterImage; }
|
2009-12-11 07:02:13 +03:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
// Returns true if we should display the poster. Note that once we show
|
2009-12-11 07:02:13 +03:00
|
|
|
// a video frame, the poster will never be displayed again.
|
2011-09-29 10:19:26 +04:00
|
|
|
bool ShouldDisplayPoster();
|
2009-12-11 07:02:13 +03:00
|
|
|
|
2013-02-27 01:06:51 +04:00
|
|
|
nsIContent *GetCaptionOverlay() { return mCaptionDiv; }
|
2018-06-27 21:12:38 +03:00
|
|
|
nsIContent *GetVideoControls();
|
2016-06-27 06:22:15 +03:00
|
|
|
|
2014-01-06 03:31:14 +04:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2017-01-18 03:27:03 +03:00
|
|
|
nsresult GetFrameName(nsAString& aResult) const override;
|
2008-07-09 12:22:20 +04:00
|
|
|
#endif
|
|
|
|
|
2010-03-02 02:41:49 +03:00
|
|
|
already_AddRefed<Layer> BuildLayer(nsDisplayListBuilder* aBuilder,
|
2010-07-16 01:07:46 +04:00
|
|
|
LayerManager* aManager,
|
2012-09-17 02:25:33 +04:00
|
|
|
nsDisplayItem* aItem,
|
2013-09-27 10:01:16 +04:00
|
|
|
const ContainerLayerParameters& aContainerParameters);
|
2010-03-02 02:41:49 +03:00
|
|
|
|
2008-07-09 12:22:20 +04:00
|
|
|
protected:
|
2009-06-26 11:25:17 +04:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
// Returns true if we're rendering for a video element. We still create
|
2009-06-26 11:25:17 +04:00
|
|
|
// nsVideoFrame to render controls for an audio element.
|
2011-09-29 10:19:26 +04:00
|
|
|
bool HasVideoElement();
|
2009-06-26 11:25:17 +04:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
// Returns true if there is video data to render. Can return false
|
2009-06-26 11:25:17 +04:00
|
|
|
// when we're the frame for an audio element, or we've created a video
|
|
|
|
// element for a media which is audio-only.
|
2011-09-29 10:19:26 +04:00
|
|
|
bool HasVideoData();
|
2009-06-26 11:25:17 +04:00
|
|
|
|
|
|
|
// Sets the mPosterImage's src attribute to be the video's poster attribute,
|
2009-07-07 06:02:06 +04:00
|
|
|
// if we're the frame for a video element. Only call on frames for video
|
|
|
|
// elements, not for frames for audio elements.
|
2013-12-04 05:06:16 +04:00
|
|
|
void UpdatePosterSource(bool aNotify);
|
2008-12-17 03:27:46 +03:00
|
|
|
|
2017-03-28 11:48:40 +03:00
|
|
|
// Notify the mediaElement that the mCaptionDiv was created.
|
|
|
|
void UpdateTextTrack();
|
|
|
|
|
2008-07-09 12:22:20 +04:00
|
|
|
virtual ~nsVideoFrame();
|
|
|
|
|
2009-06-26 11:25:17 +04:00
|
|
|
// Anonymous child which is bound via XBL to the video controls.
|
2017-12-05 20:05:51 +03:00
|
|
|
RefPtr<mozilla::dom::Element> mVideoControls;
|
2012-07-31 04:42:26 +04:00
|
|
|
|
2009-06-26 11:25:17 +04:00
|
|
|
// Anonymous child which is the image element of the poster frame.
|
2017-12-05 20:05:51 +03:00
|
|
|
RefPtr<mozilla::dom::Element> mPosterImage;
|
2013-02-27 01:06:51 +04:00
|
|
|
|
|
|
|
// Anonymous child which is the text track caption display div.
|
|
|
|
nsCOMPtr<nsIContent> mCaptionDiv;
|
|
|
|
|
2008-07-09 12:22:20 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* nsVideoFrame_h___ */
|