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