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"
|
2022-04-08 00:46:03 +03:00
|
|
|
#include "nsIReflowCallback.h"
|
2017-08-17 02:48:52 +03:00
|
|
|
#include "nsStringFwd.h"
|
2014-03-15 23:00:17 +04:00
|
|
|
#include "nsTArrayForwardDeclare.h"
|
2012-07-31 04:42:26 +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
|
|
|
|
2018-09-06 04:23:14 +03:00
|
|
|
class nsVideoFrame final : public nsContainerFrame,
|
2022-04-08 00:46:03 +03:00
|
|
|
public nsIReflowCallback,
|
2018-09-06 04:23:14 +03:00
|
|
|
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;
|
|
|
|
|
2019-02-05 19:45:54 +03:00
|
|
|
explicit nsVideoFrame(ComputedStyle*, nsPresContext*);
|
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
|
|
|
|
2022-04-08 00:46:03 +03:00
|
|
|
void ReflowCallbackCanceled() final { mReflowCallbackPosted = false; }
|
|
|
|
bool ReflowFinished() final;
|
|
|
|
|
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, nsAtom* aAttribute,
|
|
|
|
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 */
|
2020-11-03 22:54:51 +03:00
|
|
|
nsSize GetVideoIntrinsicSize() const;
|
|
|
|
mozilla::IntrinsicSize GetIntrinsicSize() override;
|
2020-09-30 01:32:40 +03:00
|
|
|
mozilla::AspectRatio GetIntrinsicRatio() const override;
|
2021-01-26 05:47:40 +03:00
|
|
|
SizeComputationResult ComputeSize(
|
|
|
|
gfxContext* aRenderingContext, mozilla::WritingMode aWM,
|
|
|
|
const mozilla::LogicalSize& aCBSize, nscoord aAvailableISize,
|
|
|
|
const mozilla::LogicalSize& aMargin,
|
|
|
|
const mozilla::LogicalSize& aBorderPadding,
|
|
|
|
const mozilla::StyleSizeOverrides& aSizeOverrides,
|
|
|
|
mozilla::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;
|
2018-11-30 13:46:48 +03: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
|
|
|
|
|
|
|
#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 {
|
2022-04-14 05:10:34 +03:00
|
|
|
// audio element with visible controls is an inline element, so we don't
|
|
|
|
// apply aspect-ratio.
|
|
|
|
if ((aFlags & nsIFrame::eSupportsAspectRatio) && !HasVideoElement()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2020-09-30 01:32:31 +03:00
|
|
|
mozilla::dom::Element* GetPosterImage() const { 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.
|
2020-09-30 01:32:31 +03:00
|
|
|
bool ShouldDisplayPoster() const;
|
2009-12-11 07:02:13 +03:00
|
|
|
|
2020-09-30 01:32:31 +03:00
|
|
|
nsIContent* GetCaptionOverlay() const { return mCaptionDiv; }
|
|
|
|
nsIContent* GetVideoControls() const;
|
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
|
|
|
|
|
|
|
|
protected:
|
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.
|
2020-09-30 01:32:31 +03:00
|
|
|
bool HasVideoElement() const;
|
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.
|
2020-09-30 01:32:31 +03:00
|
|
|
bool HasVideoData() const;
|
|
|
|
|
|
|
|
// Get the poster image's size if there is any.
|
|
|
|
mozilla::Maybe<nsSize> PosterImageSize() const;
|
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 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;
|
2022-04-08 00:46:03 +03:00
|
|
|
|
|
|
|
// Some sizes tracked for notification purposes.
|
|
|
|
// TODO: Maybe the calling code could be rewritten to use ResizeObserver for
|
|
|
|
// this nowadays.
|
|
|
|
nsSize mControlsTrackedSize{-1, -1};
|
|
|
|
nsSize mCaptionTrackedSize{-1, -1};
|
|
|
|
bool mReflowCallbackPosted = false;
|
2008-07-09 12:22:20 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* nsVideoFrame_h___ */
|