layout/generic/nsVideoFrame.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/layout/generic/nsVideoFrame.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,132 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* vim:set ts=2 sw=2 sts=2 et cindent: */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +/* rendering object for the HTML <video> element */
    1.11 +
    1.12 +#ifndef nsVideoFrame_h___
    1.13 +#define nsVideoFrame_h___
    1.14 +
    1.15 +#include "mozilla/Attributes.h"
    1.16 +#include "nsContainerFrame.h"
    1.17 +#include "nsIAnonymousContentCreator.h"
    1.18 +#include "nsTArrayForwardDeclare.h"
    1.19 +#include "FrameLayerBuilder.h"
    1.20 +
    1.21 +namespace mozilla {
    1.22 +namespace layers {
    1.23 +class Layer;
    1.24 +class LayerManager;
    1.25 +}
    1.26 +}
    1.27 +
    1.28 +class nsAString;
    1.29 +class nsPresContext;
    1.30 +class nsDisplayItem;
    1.31 +
    1.32 +nsIFrame* NS_NewVideoFrame (nsIPresShell* aPresShell, nsStyleContext* aContext);
    1.33 +
    1.34 +class nsVideoFrame : public nsContainerFrame, public nsIAnonymousContentCreator
    1.35 +{
    1.36 +public:
    1.37 +  typedef mozilla::layers::Layer Layer;
    1.38 +  typedef mozilla::layers::LayerManager LayerManager;
    1.39 +  typedef mozilla::ContainerLayerParameters ContainerLayerParameters;
    1.40 +
    1.41 +  nsVideoFrame(nsStyleContext* aContext);
    1.42 +
    1.43 +  NS_DECL_QUERYFRAME
    1.44 +  NS_DECL_QUERYFRAME_TARGET(nsVideoFrame)
    1.45 +  NS_DECL_FRAMEARENA_HELPERS
    1.46 +
    1.47 +  virtual void BuildDisplayList(nsDisplayListBuilder*   aBuilder,
    1.48 +                                const nsRect&           aDirtyRect,
    1.49 +                                const nsDisplayListSet& aLists) MOZ_OVERRIDE;
    1.50 +
    1.51 +  virtual nsresult AttributeChanged(int32_t aNameSpaceID,
    1.52 +                                    nsIAtom* aAttribute,
    1.53 +                                    int32_t aModType) MOZ_OVERRIDE;
    1.54 +
    1.55 +  /* get the size of the video's display */
    1.56 +  nsSize GetVideoIntrinsicSize(nsRenderingContext *aRenderingContext);
    1.57 +  virtual nsSize GetIntrinsicRatio() MOZ_OVERRIDE;
    1.58 +  virtual nsSize ComputeSize(nsRenderingContext *aRenderingContext,
    1.59 +                             nsSize aCBSize, nscoord aAvailableWidth,
    1.60 +                             nsSize aMargin, nsSize aBorder, nsSize aPadding,
    1.61 +                             uint32_t aFlags) MOZ_OVERRIDE;
    1.62 +  virtual nscoord GetMinWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE;
    1.63 +  virtual nscoord GetPrefWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE;
    1.64 +  virtual void DestroyFrom(nsIFrame* aDestructRoot) MOZ_OVERRIDE;
    1.65 +  virtual bool IsLeaf() const MOZ_OVERRIDE;
    1.66 +
    1.67 +  virtual nsresult Reflow(nsPresContext*          aPresContext,
    1.68 +                          nsHTMLReflowMetrics&     aDesiredSize,
    1.69 +                          const nsHTMLReflowState& aReflowState,
    1.70 +                          nsReflowStatus&          aStatus) MOZ_OVERRIDE;
    1.71 +
    1.72 +#ifdef ACCESSIBILITY
    1.73 +  virtual mozilla::a11y::AccType AccessibleType() MOZ_OVERRIDE;
    1.74 +#endif
    1.75 +
    1.76 +  virtual nsIAtom* GetType() const MOZ_OVERRIDE;
    1.77 +
    1.78 +  virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE
    1.79 +  {
    1.80 +    return nsSplittableFrame::IsFrameOfType(aFlags & ~(nsIFrame::eReplaced));
    1.81 +  }
    1.82 +  
    1.83 +  virtual nsresult CreateAnonymousContent(nsTArray<ContentInfo>& aElements) MOZ_OVERRIDE;
    1.84 +  virtual void AppendAnonymousContentTo(nsBaseContentList& aElements,
    1.85 +                                        uint32_t aFilters) MOZ_OVERRIDE;
    1.86 +
    1.87 +  nsIContent* GetPosterImage() { return mPosterImage; }
    1.88 +
    1.89 +  // Returns true if we should display the poster. Note that once we show
    1.90 +  // a video frame, the poster will never be displayed again.
    1.91 +  bool ShouldDisplayPoster();
    1.92 +
    1.93 +  nsIContent *GetCaptionOverlay() { return mCaptionDiv; }
    1.94 +
    1.95 +#ifdef DEBUG_FRAME_DUMP
    1.96 +  virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE;
    1.97 +#endif
    1.98 +
    1.99 +  already_AddRefed<Layer> BuildLayer(nsDisplayListBuilder* aBuilder,
   1.100 +                                     LayerManager* aManager,
   1.101 +                                     nsDisplayItem* aItem,
   1.102 +                                     const ContainerLayerParameters& aContainerParameters);
   1.103 +
   1.104 +protected:
   1.105 +
   1.106 +  // Returns true if we're rendering for a video element. We still create
   1.107 +  // nsVideoFrame to render controls for an audio element.
   1.108 +  bool HasVideoElement();
   1.109 +
   1.110 +  // Returns true if there is video data to render. Can return false
   1.111 +  // when we're the frame for an audio element, or we've created a video
   1.112 +  // element for a media which is audio-only.
   1.113 +  bool HasVideoData();
   1.114 +
   1.115 +  // Sets the mPosterImage's src attribute to be the video's poster attribute,
   1.116 +  // if we're the frame for a video element. Only call on frames for video
   1.117 +  // elements, not for frames for audio elements.
   1.118 +  void UpdatePosterSource(bool aNotify);
   1.119 +
   1.120 +  virtual ~nsVideoFrame();
   1.121 +
   1.122 +  nsMargin mBorderPadding;
   1.123 +
   1.124 +  // Anonymous child which is bound via XBL to the video controls.
   1.125 +  nsCOMPtr<nsIContent> mVideoControls;
   1.126 +
   1.127 +  // Anonymous child which is the image element of the poster frame.
   1.128 +  nsCOMPtr<nsIContent> mPosterImage;
   1.129 +
   1.130 +  // Anonymous child which is the text track caption display div.
   1.131 +  nsCOMPtr<nsIContent> mCaptionDiv;
   1.132 +
   1.133 +};
   1.134 +
   1.135 +#endif /* nsVideoFrame_h___ */

mercurial