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 : /* ***** BEGIN LICENSE BLOCK *****
4 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 : *
6 : * The contents of this file are subject to the Mozilla Public License Version
7 : * 1.1 (the "License"); you may not use this file except in compliance with
8 : * the License. You may obtain a copy of the License at
9 : * http://www.mozilla.org/MPL/
10 : *
11 : * Software distributed under the License is distributed on an "AS IS" basis,
12 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 : * for the specific language governing rights and limitations under the
14 : * License.
15 : *
16 : * The Original Code is Mozilla code.
17 : *
18 : * The Initial Developer of the Original Code is the Mozilla Corporation.
19 : * Portions created by the Initial Developer are Copyright (C) 2007
20 : * the Initial Developer. All Rights Reserved.
21 : *
22 : * Contributor(s):
23 : * Chris Double <chris.double@double.co.nz>
24 : *
25 : * Alternatively, the contents of this file may be used under the terms of
26 : * either the GNU General Public License Version 2 or later (the "GPL"), or
27 : * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 : * in which case the provisions of the GPL or the LGPL are applicable instead
29 : * of those above. If you wish to allow use of your version of this file only
30 : * under the terms of either the GPL or the LGPL, and not to allow others to
31 : * use your version of this file under the terms of the MPL, indicate your
32 : * decision by deleting the provisions above and replace them with the notice
33 : * and other provisions required by the GPL or the LGPL. If you do not delete
34 : * the provisions above, a recipient may use your version of this file under
35 : * the terms of any one of the MPL, the GPL or the LGPL.
36 : *
37 : * ***** END LICENSE BLOCK ***** */
38 :
39 : /* rendering object for the HTML <video> element */
40 :
41 : #ifndef nsVideoFrame_h___
42 : #define nsVideoFrame_h___
43 :
44 : #include "nsContainerFrame.h"
45 : #include "nsString.h"
46 : #include "nsAString.h"
47 : #include "nsIIOService.h"
48 : #include "nsITimer.h"
49 : #include "nsTArray.h"
50 : #include "nsIAnonymousContentCreator.h"
51 : #include "Layers.h"
52 : #include "ImageLayers.h"
53 :
54 : class nsPresContext;
55 : class nsDisplayItem;
56 :
57 : nsIFrame* NS_NewVideoFrame (nsIPresShell* aPresShell, nsStyleContext* aContext);
58 :
59 : class nsVideoFrame : public nsContainerFrame, public nsIAnonymousContentCreator
60 : {
61 : public:
62 : typedef mozilla::layers::Layer Layer;
63 : typedef mozilla::layers::LayerManager LayerManager;
64 :
65 : nsVideoFrame(nsStyleContext* aContext);
66 :
67 : NS_DECL_QUERYFRAME
68 : NS_DECL_FRAMEARENA_HELPERS
69 :
70 : NS_IMETHOD BuildDisplayList(nsDisplayListBuilder* aBuilder,
71 : const nsRect& aDirtyRect,
72 : const nsDisplayListSet& aLists);
73 :
74 : NS_IMETHOD AttributeChanged(PRInt32 aNameSpaceID,
75 : nsIAtom* aAttribute,
76 : PRInt32 aModType);
77 :
78 : /* get the size of the video's display */
79 : nsSize GetVideoIntrinsicSize(nsRenderingContext *aRenderingContext);
80 : virtual nsSize GetIntrinsicRatio();
81 : virtual nsSize ComputeSize(nsRenderingContext *aRenderingContext,
82 : nsSize aCBSize, nscoord aAvailableWidth,
83 : nsSize aMargin, nsSize aBorder, nsSize aPadding,
84 : bool aShrinkWrap);
85 : virtual nscoord GetMinWidth(nsRenderingContext *aRenderingContext);
86 : virtual nscoord GetPrefWidth(nsRenderingContext *aRenderingContext);
87 : virtual void DestroyFrom(nsIFrame* aDestructRoot);
88 : virtual bool IsLeaf() const;
89 :
90 : NS_IMETHOD Reflow(nsPresContext* aPresContext,
91 : nsHTMLReflowMetrics& aDesiredSize,
92 : const nsHTMLReflowState& aReflowState,
93 : nsReflowStatus& aStatus);
94 :
95 : #ifdef ACCESSIBILITY
96 : virtual already_AddRefed<nsAccessible> CreateAccessible();
97 : #endif
98 :
99 : virtual nsIAtom* GetType() const;
100 :
101 0 : virtual bool IsFrameOfType(PRUint32 aFlags) const
102 : {
103 0 : return nsSplittableFrame::IsFrameOfType(aFlags & ~(nsIFrame::eReplaced));
104 : }
105 :
106 : virtual nsresult CreateAnonymousContent(nsTArray<ContentInfo>& aElements);
107 : virtual void AppendAnonymousContentTo(nsBaseContentList& aElements,
108 : PRUint32 aFilters);
109 :
110 0 : nsIContent* GetPosterImage() { return mPosterImage; }
111 :
112 : // Returns true if we should display the poster. Note that once we show
113 : // a video frame, the poster will never be displayed again.
114 : bool ShouldDisplayPoster();
115 :
116 : #ifdef DEBUG
117 : NS_IMETHOD GetFrameName(nsAString& aResult) const;
118 : #endif
119 :
120 : already_AddRefed<Layer> BuildLayer(nsDisplayListBuilder* aBuilder,
121 : LayerManager* aManager,
122 : nsDisplayItem* aItem);
123 :
124 : protected:
125 :
126 : // Returns true if we're rendering for a video element. We still create
127 : // nsVideoFrame to render controls for an audio element.
128 : bool HasVideoElement();
129 :
130 : // Returns true if there is video data to render. Can return false
131 : // when we're the frame for an audio element, or we've created a video
132 : // element for a media which is audio-only.
133 : bool HasVideoData();
134 :
135 : // Sets the mPosterImage's src attribute to be the video's poster attribute,
136 : // if we're the frame for a video element. Only call on frames for video
137 : // elements, not for frames for audio elements.
138 : nsresult UpdatePosterSource(bool aNotify);
139 :
140 : virtual ~nsVideoFrame();
141 :
142 : nsMargin mBorderPadding;
143 :
144 : // Anonymous child which is bound via XBL to the video controls.
145 : nsCOMPtr<nsIContent> mVideoControls;
146 :
147 : // Anonymous child which is the image element of the poster frame.
148 : nsCOMPtr<nsIContent> mPosterImage;
149 : };
150 :
151 : #endif /* nsVideoFrame_h___ */
|