Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/layout/generic/nsVideoFrame.h
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
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 "nsStringFwd.h"
16
#include "nsTArrayForwardDeclare.h"
17
#include "FrameLayerBuilder.h"
18
19
namespace mozilla {
20
namespace layers {
21
class Layer;
22
class LayerManager;
23
} // namespace layers
24
} // namespace mozilla
25
26
class nsPresContext;
27
class nsDisplayItem;
28
29
class nsVideoFrame final : public nsContainerFrame
30
                         , public nsIAnonymousContentCreator
31
{
32
public:
33
  template <typename T> using Maybe = mozilla::Maybe<T>;
34
  using Nothing = mozilla::Nothing;
35
  using Visibility = mozilla::Visibility;
36
37
  typedef mozilla::layers::Layer Layer;
38
  typedef mozilla::layers::LayerManager LayerManager;
39
  typedef mozilla::ContainerLayerParameters ContainerLayerParameters;
40
41
  explicit nsVideoFrame(ComputedStyle* aStyle);
42
43
  NS_DECL_QUERYFRAME
44
  NS_DECL_FRAMEARENA_HELPERS(nsVideoFrame)
45
46
  void BuildDisplayList(nsDisplayListBuilder*   aBuilder,
47
                        const nsDisplayListSet& aLists) override;
48
49
  nsresult AttributeChanged(int32_t aNameSpaceID,
50
                            nsAtom* aAttribute,
51
                            int32_t aModType) override;
52
53
  void OnVisibilityChange(Visibility aNewVisibility,
54
                          const Maybe<OnNonvisible>& aNonvisibleAction = Nothing()) override;
55
56
  /* get the size of the video's display */
57
  nsSize GetVideoIntrinsicSize(gfxContext *aRenderingContext);
58
  nsSize GetIntrinsicRatio() override;
59
  mozilla::LogicalSize
60
  ComputeSize(gfxContext *aRenderingContext,
61
              mozilla::WritingMode aWritingMode,
62
              const mozilla::LogicalSize& aCBSize,
63
              nscoord aAvailableISize,
64
              const mozilla::LogicalSize& aMargin,
65
              const mozilla::LogicalSize& aBorder,
66
              const mozilla::LogicalSize& aPadding,
67
              ComputeSizeFlags aFlags) override;
68
  nscoord GetMinISize(gfxContext *aRenderingContext) override;
69
  nscoord GetPrefISize(gfxContext *aRenderingContext) override;
70
  void DestroyFrom(nsIFrame* aDestructRoot, PostDestroyData& aPostDestroyData) override;
71
72
  void Reflow(nsPresContext*     aPresContext,
73
              ReflowOutput&      aDesiredSize,
74
              const ReflowInput& aReflowInput,
75
              nsReflowStatus&    aStatus) override;
76
77
  bool IsLeafDynamic() const override;
78
79
#ifdef ACCESSIBILITY
80
  mozilla::a11y::AccType AccessibleType() override;
81
#endif
82
83
  bool IsFrameOfType(uint32_t aFlags) const override
84
0
  {
85
0
    return nsSplittableFrame::IsFrameOfType(aFlags &
86
0
      ~(nsIFrame::eReplaced | nsIFrame::eReplacedSizing));
87
0
  }
88
89
  nsresult CreateAnonymousContent(nsTArray<ContentInfo>& aElements) override;
90
  void AppendAnonymousContentTo(nsTArray<nsIContent*>& aElements,
91
                                uint32_t aFilters) override;
92
93
0
  mozilla::dom::Element* GetPosterImage() { return mPosterImage; }
94
95
  // Returns true if we should display the poster. Note that once we show
96
  // a video frame, the poster will never be displayed again.
97
  bool ShouldDisplayPoster();
98
99
0
  nsIContent *GetCaptionOverlay() { return mCaptionDiv; }
100
  nsIContent *GetVideoControls();
101
102
#ifdef DEBUG_FRAME_DUMP
103
  nsresult GetFrameName(nsAString& aResult) const override;
104
#endif
105
106
  already_AddRefed<Layer> BuildLayer(nsDisplayListBuilder* aBuilder,
107
                                     LayerManager* aManager,
108
                                     nsDisplayItem* aItem,
109
                                     const ContainerLayerParameters& aContainerParameters);
110
111
protected:
112
113
  // Returns true if we're rendering for a video element. We still create
114
  // nsVideoFrame to render controls for an audio element.
115
  bool HasVideoElement();
116
117
  // Returns true if there is video data to render. Can return false
118
  // when we're the frame for an audio element, or we've created a video
119
  // element for a media which is audio-only.
120
  bool HasVideoData();
121
122
  // Sets the mPosterImage's src attribute to be the video's poster attribute,
123
  // if we're the frame for a video element. Only call on frames for video
124
  // elements, not for frames for audio elements.
125
  void UpdatePosterSource(bool aNotify);
126
127
  // Notify the mediaElement that the mCaptionDiv was created.
128
  void UpdateTextTrack();
129
130
  virtual ~nsVideoFrame();
131
132
  // Anonymous child which is bound via XBL to the video controls.
133
  RefPtr<mozilla::dom::Element> mVideoControls;
134
135
  // Anonymous child which is the image element of the poster frame.
136
  RefPtr<mozilla::dom::Element> mPosterImage;
137
138
  // Anonymous child which is the text track caption display div.
139
  nsCOMPtr<nsIContent> mCaptionDiv;
140
141
};
142
143
#endif /* nsVideoFrame_h___ */