2008-07-09 12:22:20 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
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"
|
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;
|
|
|
|
}
|
|
|
|
}
|
2008-07-09 12:22:20 +04:00
|
|
|
|
2013-08-22 22:32:52 +04:00
|
|
|
class nsAString;
|
2010-04-11 00:10:12 +04:00
|
|
|
class nsPresContext;
|
2010-07-16 01:07:46 +04:00
|
|
|
class nsDisplayItem;
|
2013-08-22 22:32:52 +04:00
|
|
|
template <class T> class nsTArray;
|
2010-04-11 00:10:12 +04:00
|
|
|
|
2008-07-09 12:22:20 +04:00
|
|
|
nsIFrame* NS_NewVideoFrame (nsIPresShell* aPresShell, nsStyleContext* aContext);
|
|
|
|
|
|
|
|
class nsVideoFrame : public nsContainerFrame, public nsIAnonymousContentCreator
|
|
|
|
{
|
|
|
|
public:
|
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
|
|
|
|
2008-07-09 12:22:20 +04:00
|
|
|
nsVideoFrame(nsStyleContext* aContext);
|
|
|
|
|
2009-01-12 22:20:59 +03:00
|
|
|
NS_DECL_QUERYFRAME
|
2013-05-28 00:34:00 +04:00
|
|
|
NS_DECL_QUERYFRAME_TARGET(nsVideoFrame)
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
|
|
|
|
2013-02-14 15:12:27 +04:00
|
|
|
virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists) MOZ_OVERRIDE;
|
2008-07-09 12:22:20 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHOD AttributeChanged(int32_t aNameSpaceID,
|
2009-06-26 11:25:17 +04:00
|
|
|
nsIAtom* aAttribute,
|
2013-05-14 20:33:23 +04:00
|
|
|
int32_t aModType) MOZ_OVERRIDE;
|
2009-06-26 11:25:17 +04:00
|
|
|
|
2008-07-09 12:22:20 +04:00
|
|
|
/* get the size of the video's display */
|
2011-04-08 05:04:40 +04:00
|
|
|
nsSize GetVideoIntrinsicSize(nsRenderingContext *aRenderingContext);
|
2013-05-14 20:33:23 +04:00
|
|
|
virtual nsSize GetIntrinsicRatio() MOZ_OVERRIDE;
|
2011-04-08 05:04:40 +04:00
|
|
|
virtual nsSize ComputeSize(nsRenderingContext *aRenderingContext,
|
2008-07-09 12:22:20 +04:00
|
|
|
nsSize aCBSize, nscoord aAvailableWidth,
|
|
|
|
nsSize aMargin, nsSize aBorder, nsSize aPadding,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t aFlags) MOZ_OVERRIDE;
|
2013-05-14 20:33:23 +04:00
|
|
|
virtual nscoord GetMinWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE;
|
|
|
|
virtual nscoord GetPrefWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE;
|
2012-09-14 20:10:08 +04:00
|
|
|
virtual void DestroyFrom(nsIFrame* aDestructRoot) MOZ_OVERRIDE;
|
|
|
|
virtual bool IsLeaf() const MOZ_OVERRIDE;
|
2008-07-09 12:22:20 +04:00
|
|
|
|
|
|
|
NS_IMETHOD Reflow(nsPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
2013-05-14 20:33:23 +04:00
|
|
|
nsReflowStatus& aStatus) MOZ_OVERRIDE;
|
2008-07-09 12:22:20 +04:00
|
|
|
|
|
|
|
#ifdef ACCESSIBILITY
|
2012-09-29 01:53:44 +04:00
|
|
|
virtual mozilla::a11y::AccType AccessibleType() MOZ_OVERRIDE;
|
2008-07-09 12:22:20 +04:00
|
|
|
#endif
|
|
|
|
|
2013-05-14 20:33:23 +04:00
|
|
|
virtual nsIAtom* GetType() const MOZ_OVERRIDE;
|
2008-07-09 12:22:20 +04:00
|
|
|
|
2013-05-14 20:33:23 +04:00
|
|
|
virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE
|
2008-07-09 12:22:20 +04:00
|
|
|
{
|
|
|
|
return nsSplittableFrame::IsFrameOfType(aFlags & ~(nsIFrame::eReplaced));
|
|
|
|
}
|
|
|
|
|
2012-09-14 20:10:08 +04:00
|
|
|
virtual nsresult CreateAnonymousContent(nsTArray<ContentInfo>& aElements) MOZ_OVERRIDE;
|
2010-10-15 19:34:35 +04:00
|
|
|
virtual void AppendAnonymousContentTo(nsBaseContentList& aElements,
|
2012-09-14 20:10:08 +04:00
|
|
|
uint32_t aFilters) MOZ_OVERRIDE;
|
2008-07-09 12:22:20 +04:00
|
|
|
|
2009-12-11 07:02:13 +03:00
|
|
|
nsIContent* GetPosterImage() { return mPosterImage; }
|
|
|
|
|
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; }
|
|
|
|
|
2008-07-09 12:22:20 +04:00
|
|
|
#ifdef DEBUG
|
2013-05-14 20:33:23 +04:00
|
|
|
NS_IMETHOD GetFrameName(nsAString& aResult) const MOZ_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-06 18:58:22 +04:00
|
|
|
nsresult UpdatePosterSource(bool aNotify);
|
2008-12-17 03:27:46 +03:00
|
|
|
|
2008-07-09 12:22:20 +04:00
|
|
|
virtual ~nsVideoFrame();
|
|
|
|
|
|
|
|
nsMargin mBorderPadding;
|
2012-07-31 04:42:26 +04:00
|
|
|
|
2009-06-26 11:25:17 +04:00
|
|
|
// Anonymous child which is bound via XBL to the video controls.
|
2008-07-09 12:22:20 +04:00
|
|
|
nsCOMPtr<nsIContent> 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.
|
|
|
|
nsCOMPtr<nsIContent> 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___ */
|