layout/generic/nsVideoFrame.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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 "nsTArrayForwardDeclare.h"
    16 #include "FrameLayerBuilder.h"
    18 namespace mozilla {
    19 namespace layers {
    20 class Layer;
    21 class LayerManager;
    22 }
    23 }
    25 class nsAString;
    26 class nsPresContext;
    27 class nsDisplayItem;
    29 nsIFrame* NS_NewVideoFrame (nsIPresShell* aPresShell, nsStyleContext* aContext);
    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;
    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   virtual nsresult 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   virtual nsresult 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
    76   {
    77     return nsSplittableFrame::IsFrameOfType(aFlags & ~(nsIFrame::eReplaced));
    78   }
    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_FRAME_DUMP
    93   virtual nsresult 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   void 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;
   130 };
   132 #endif /* nsVideoFrame_h___ */

mercurial