|
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/. */ |
|
6 |
|
7 /* rendering object for the HTML <video> element */ |
|
8 |
|
9 #ifndef nsVideoFrame_h___ |
|
10 #define nsVideoFrame_h___ |
|
11 |
|
12 #include "mozilla/Attributes.h" |
|
13 #include "nsContainerFrame.h" |
|
14 #include "nsIAnonymousContentCreator.h" |
|
15 #include "nsTArrayForwardDeclare.h" |
|
16 #include "FrameLayerBuilder.h" |
|
17 |
|
18 namespace mozilla { |
|
19 namespace layers { |
|
20 class Layer; |
|
21 class LayerManager; |
|
22 } |
|
23 } |
|
24 |
|
25 class nsAString; |
|
26 class nsPresContext; |
|
27 class nsDisplayItem; |
|
28 |
|
29 nsIFrame* NS_NewVideoFrame (nsIPresShell* aPresShell, nsStyleContext* aContext); |
|
30 |
|
31 class nsVideoFrame : public nsContainerFrame, public nsIAnonymousContentCreator |
|
32 { |
|
33 public: |
|
34 typedef mozilla::layers::Layer Layer; |
|
35 typedef mozilla::layers::LayerManager LayerManager; |
|
36 typedef mozilla::ContainerLayerParameters ContainerLayerParameters; |
|
37 |
|
38 nsVideoFrame(nsStyleContext* aContext); |
|
39 |
|
40 NS_DECL_QUERYFRAME |
|
41 NS_DECL_QUERYFRAME_TARGET(nsVideoFrame) |
|
42 NS_DECL_FRAMEARENA_HELPERS |
|
43 |
|
44 virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder, |
|
45 const nsRect& aDirtyRect, |
|
46 const nsDisplayListSet& aLists) MOZ_OVERRIDE; |
|
47 |
|
48 virtual nsresult AttributeChanged(int32_t aNameSpaceID, |
|
49 nsIAtom* aAttribute, |
|
50 int32_t aModType) MOZ_OVERRIDE; |
|
51 |
|
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; |
|
63 |
|
64 virtual nsresult Reflow(nsPresContext* aPresContext, |
|
65 nsHTMLReflowMetrics& aDesiredSize, |
|
66 const nsHTMLReflowState& aReflowState, |
|
67 nsReflowStatus& aStatus) MOZ_OVERRIDE; |
|
68 |
|
69 #ifdef ACCESSIBILITY |
|
70 virtual mozilla::a11y::AccType AccessibleType() MOZ_OVERRIDE; |
|
71 #endif |
|
72 |
|
73 virtual nsIAtom* GetType() const MOZ_OVERRIDE; |
|
74 |
|
75 virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE |
|
76 { |
|
77 return nsSplittableFrame::IsFrameOfType(aFlags & ~(nsIFrame::eReplaced)); |
|
78 } |
|
79 |
|
80 virtual nsresult CreateAnonymousContent(nsTArray<ContentInfo>& aElements) MOZ_OVERRIDE; |
|
81 virtual void AppendAnonymousContentTo(nsBaseContentList& aElements, |
|
82 uint32_t aFilters) MOZ_OVERRIDE; |
|
83 |
|
84 nsIContent* GetPosterImage() { return mPosterImage; } |
|
85 |
|
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(); |
|
89 |
|
90 nsIContent *GetCaptionOverlay() { return mCaptionDiv; } |
|
91 |
|
92 #ifdef DEBUG_FRAME_DUMP |
|
93 virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE; |
|
94 #endif |
|
95 |
|
96 already_AddRefed<Layer> BuildLayer(nsDisplayListBuilder* aBuilder, |
|
97 LayerManager* aManager, |
|
98 nsDisplayItem* aItem, |
|
99 const ContainerLayerParameters& aContainerParameters); |
|
100 |
|
101 protected: |
|
102 |
|
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(); |
|
106 |
|
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(); |
|
111 |
|
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 void UpdatePosterSource(bool aNotify); |
|
116 |
|
117 virtual ~nsVideoFrame(); |
|
118 |
|
119 nsMargin mBorderPadding; |
|
120 |
|
121 // Anonymous child which is bound via XBL to the video controls. |
|
122 nsCOMPtr<nsIContent> mVideoControls; |
|
123 |
|
124 // Anonymous child which is the image element of the poster frame. |
|
125 nsCOMPtr<nsIContent> mPosterImage; |
|
126 |
|
127 // Anonymous child which is the text track caption display div. |
|
128 nsCOMPtr<nsIContent> mCaptionDiv; |
|
129 |
|
130 }; |
|
131 |
|
132 #endif /* nsVideoFrame_h___ */ |