Merge m-c to fx-team.
[gecko.git] / layout / generic / nsVideoFrame.h
blob03f9caf478b590487744ddd51629735842d0cb84
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:set ts=2 sw=2 sts=2 et cindent: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 /* rendering object for the HTML <video> element */
9 #ifndef nsVideoFrame_h___
10 #define nsVideoFrame_h___
12 #include "mozilla/Attributes.h"
13 #include "nsContainerFrame.h"
14 #include "nsIAnonymousContentCreator.h"
15 #include "FrameLayerBuilder.h"
17 namespace mozilla {
18 namespace layers {
19 class Layer;
20 class LayerManager;
24 class nsAString;
25 class nsPresContext;
26 class nsDisplayItem;
27 template <class T> class nsTArray;
29 nsIFrame* NS_NewVideoFrame (nsIPresShell* aPresShell, nsStyleContext* aContext);
31 class nsVideoFrame : public nsContainerFrame, public nsIAnonymousContentCreator
33 public:
34 typedef mozilla::layers::Layer Layer;
35 typedef mozilla::layers::LayerManager LayerManager;
36 typedef mozilla::ContainerLayerParameters ContainerLayerParameters;
38 nsVideoFrame(nsStyleContext* aContext);
40 NS_DECL_QUERYFRAME
41 NS_DECL_QUERYFRAME_TARGET(nsVideoFrame)
42 NS_DECL_FRAMEARENA_HELPERS
44 virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
45 const nsRect& aDirtyRect,
46 const nsDisplayListSet& aLists) MOZ_OVERRIDE;
48 NS_IMETHOD AttributeChanged(int32_t aNameSpaceID,
49 nsIAtom* aAttribute,
50 int32_t aModType) MOZ_OVERRIDE;
52 /* get the size of the video's display */
53 nsSize GetVideoIntrinsicSize(nsRenderingContext *aRenderingContext);
54 virtual nsSize GetIntrinsicRatio() MOZ_OVERRIDE;
55 virtual nsSize ComputeSize(nsRenderingContext *aRenderingContext,
56 nsSize aCBSize, nscoord aAvailableWidth,
57 nsSize aMargin, nsSize aBorder, nsSize aPadding,
58 uint32_t aFlags) MOZ_OVERRIDE;
59 virtual nscoord GetMinWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE;
60 virtual nscoord GetPrefWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE;
61 virtual void DestroyFrom(nsIFrame* aDestructRoot) MOZ_OVERRIDE;
62 virtual bool IsLeaf() const MOZ_OVERRIDE;
64 NS_IMETHOD Reflow(nsPresContext* aPresContext,
65 nsHTMLReflowMetrics& aDesiredSize,
66 const nsHTMLReflowState& aReflowState,
67 nsReflowStatus& aStatus) MOZ_OVERRIDE;
69 #ifdef ACCESSIBILITY
70 virtual mozilla::a11y::AccType AccessibleType() MOZ_OVERRIDE;
71 #endif
73 virtual nsIAtom* GetType() const MOZ_OVERRIDE;
75 virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE
77 return nsSplittableFrame::IsFrameOfType(aFlags & ~(nsIFrame::eReplaced));
80 virtual nsresult CreateAnonymousContent(nsTArray<ContentInfo>& aElements) MOZ_OVERRIDE;
81 virtual void AppendAnonymousContentTo(nsBaseContentList& aElements,
82 uint32_t aFilters) MOZ_OVERRIDE;
84 nsIContent* GetPosterImage() { return mPosterImage; }
86 // Returns true if we should display the poster. Note that once we show
87 // a video frame, the poster will never be displayed again.
88 bool ShouldDisplayPoster();
90 nsIContent *GetCaptionOverlay() { return mCaptionDiv; }
92 #ifdef DEBUG
93 NS_IMETHOD GetFrameName(nsAString& aResult) const MOZ_OVERRIDE;
94 #endif
96 already_AddRefed<Layer> BuildLayer(nsDisplayListBuilder* aBuilder,
97 LayerManager* aManager,
98 nsDisplayItem* aItem,
99 const ContainerLayerParameters& aContainerParameters);
101 protected:
103 // Returns true if we're rendering for a video element. We still create
104 // nsVideoFrame to render controls for an audio element.
105 bool HasVideoElement();
107 // Returns true if there is video data to render. Can return false
108 // when we're the frame for an audio element, or we've created a video
109 // element for a media which is audio-only.
110 bool HasVideoData();
112 // Sets the mPosterImage's src attribute to be the video's poster attribute,
113 // if we're the frame for a video element. Only call on frames for video
114 // elements, not for frames for audio elements.
115 nsresult UpdatePosterSource(bool aNotify);
117 virtual ~nsVideoFrame();
119 nsMargin mBorderPadding;
121 // Anonymous child which is bound via XBL to the video controls.
122 nsCOMPtr<nsIContent> mVideoControls;
124 // Anonymous child which is the image element of the poster frame.
125 nsCOMPtr<nsIContent> mPosterImage;
127 // Anonymous child which is the text track caption display div.
128 nsCOMPtr<nsIContent> mCaptionDiv;
132 #endif /* nsVideoFrame_h___ */