2008-07-09 01:22:20 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2008-07-09 01:22:20 -07:00
|
|
|
|
|
|
|
/* rendering object for the HTML <video> element */
|
|
|
|
|
|
|
|
#ifndef nsVideoFrame_h___
|
|
|
|
#define nsVideoFrame_h___
|
|
|
|
|
2012-09-14 09:10:08 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2008-07-09 01:22:20 -07:00
|
|
|
#include "nsContainerFrame.h"
|
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsAString.h"
|
|
|
|
#include "nsIIOService.h"
|
|
|
|
#include "nsITimer.h"
|
|
|
|
#include "nsTArray.h"
|
|
|
|
#include "nsIAnonymousContentCreator.h"
|
2012-07-30 17:42:26 -07:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
class Layer;
|
|
|
|
class LayerManager;
|
|
|
|
}
|
|
|
|
}
|
2008-07-09 01:22:20 -07:00
|
|
|
|
2010-04-10 13:10:12 -07:00
|
|
|
class nsPresContext;
|
2010-07-15 14:07:46 -07:00
|
|
|
class nsDisplayItem;
|
2010-04-10 13:10:12 -07:00
|
|
|
|
2008-07-09 01:22:20 -07:00
|
|
|
nsIFrame* NS_NewVideoFrame (nsIPresShell* aPresShell, nsStyleContext* aContext);
|
|
|
|
|
|
|
|
class nsVideoFrame : public nsContainerFrame, public nsIAnonymousContentCreator
|
|
|
|
{
|
|
|
|
public:
|
2010-03-01 15:41:49 -08:00
|
|
|
typedef mozilla::layers::Layer Layer;
|
|
|
|
typedef mozilla::layers::LayerManager LayerManager;
|
|
|
|
|
2008-07-09 01:22:20 -07:00
|
|
|
nsVideoFrame(nsStyleContext* aContext);
|
|
|
|
|
2009-01-12 11:20:59 -08:00
|
|
|
NS_DECL_QUERYFRAME
|
2009-09-12 09:49:24 -07:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
|
|
|
|
2008-07-09 01:22:20 -07:00
|
|
|
NS_IMETHOD BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
2012-09-14 09:10:08 -07:00
|
|
|
const nsDisplayListSet& aLists) MOZ_OVERRIDE;
|
2008-07-09 01:22:20 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
NS_IMETHOD AttributeChanged(int32_t aNameSpaceID,
|
2009-06-26 00:25:17 -07:00
|
|
|
nsIAtom* aAttribute,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t aModType);
|
2009-06-26 00:25:17 -07:00
|
|
|
|
2008-07-09 01:22:20 -07:00
|
|
|
/* get the size of the video's display */
|
2011-04-07 18:04:40 -07:00
|
|
|
nsSize GetVideoIntrinsicSize(nsRenderingContext *aRenderingContext);
|
2008-07-09 01:22:20 -07:00
|
|
|
virtual nsSize GetIntrinsicRatio();
|
2011-04-07 18:04:40 -07:00
|
|
|
virtual nsSize ComputeSize(nsRenderingContext *aRenderingContext,
|
2008-07-09 01:22:20 -07:00
|
|
|
nsSize aCBSize, nscoord aAvailableWidth,
|
|
|
|
nsSize aMargin, nsSize aBorder, nsSize aPadding,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t aFlags) MOZ_OVERRIDE;
|
2011-04-07 18:04:40 -07:00
|
|
|
virtual nscoord GetMinWidth(nsRenderingContext *aRenderingContext);
|
|
|
|
virtual nscoord GetPrefWidth(nsRenderingContext *aRenderingContext);
|
2012-09-14 09:10:08 -07:00
|
|
|
virtual void DestroyFrom(nsIFrame* aDestructRoot) MOZ_OVERRIDE;
|
|
|
|
virtual bool IsLeaf() const MOZ_OVERRIDE;
|
2008-07-09 01:22:20 -07:00
|
|
|
|
|
|
|
NS_IMETHOD Reflow(nsPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus);
|
|
|
|
|
|
|
|
#ifdef ACCESSIBILITY
|
2012-05-28 18:18:45 -07:00
|
|
|
virtual already_AddRefed<Accessible> CreateAccessible();
|
2008-07-09 01:22:20 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
virtual nsIAtom* GetType() const;
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual bool IsFrameOfType(uint32_t aFlags) const
|
2008-07-09 01:22:20 -07:00
|
|
|
{
|
|
|
|
return nsSplittableFrame::IsFrameOfType(aFlags & ~(nsIFrame::eReplaced));
|
|
|
|
}
|
|
|
|
|
2012-09-14 09:10:08 -07:00
|
|
|
virtual nsresult CreateAnonymousContent(nsTArray<ContentInfo>& aElements) MOZ_OVERRIDE;
|
2010-10-15 08:34:35 -07:00
|
|
|
virtual void AppendAnonymousContentTo(nsBaseContentList& aElements,
|
2012-09-14 09:10:08 -07:00
|
|
|
uint32_t aFilters) MOZ_OVERRIDE;
|
2008-07-09 01:22:20 -07:00
|
|
|
|
2009-12-10 20:02:13 -08:00
|
|
|
nsIContent* GetPosterImage() { return mPosterImage; }
|
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
// Returns true if we should display the poster. Note that once we show
|
2009-12-10 20:02:13 -08:00
|
|
|
// a video frame, the poster will never be displayed again.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool ShouldDisplayPoster();
|
2009-12-10 20:02:13 -08:00
|
|
|
|
2008-07-09 01:22:20 -07:00
|
|
|
#ifdef DEBUG
|
|
|
|
NS_IMETHOD GetFrameName(nsAString& aResult) const;
|
|
|
|
#endif
|
|
|
|
|
2010-03-01 15:41:49 -08:00
|
|
|
already_AddRefed<Layer> BuildLayer(nsDisplayListBuilder* aBuilder,
|
2010-07-15 14:07:46 -07:00
|
|
|
LayerManager* aManager,
|
|
|
|
nsDisplayItem* aItem);
|
2010-03-01 15:41:49 -08:00
|
|
|
|
2008-07-09 01:22:20 -07:00
|
|
|
protected:
|
2009-06-26 00:25:17 -07:00
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
// Returns true if we're rendering for a video element. We still create
|
2009-06-26 00:25:17 -07:00
|
|
|
// nsVideoFrame to render controls for an audio element.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool HasVideoElement();
|
2009-06-26 00:25:17 -07:00
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
// Returns true if there is video data to render. Can return false
|
2009-06-26 00:25:17 -07:00
|
|
|
// when we're the frame for an audio element, or we've created a video
|
|
|
|
// element for a media which is audio-only.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool HasVideoData();
|
2009-06-26 00:25:17 -07:00
|
|
|
|
|
|
|
// Sets the mPosterImage's src attribute to be the video's poster attribute,
|
2009-07-06 19:02:06 -07:00
|
|
|
// if we're the frame for a video element. Only call on frames for video
|
|
|
|
// elements, not for frames for audio elements.
|
2011-09-28 23:19:26 -07:00
|
|
|
nsresult UpdatePosterSource(bool aNotify);
|
2008-12-16 16:27:46 -08:00
|
|
|
|
2008-07-09 01:22:20 -07:00
|
|
|
virtual ~nsVideoFrame();
|
|
|
|
|
|
|
|
nsMargin mBorderPadding;
|
2012-07-30 17:42:26 -07:00
|
|
|
|
2009-06-26 00:25:17 -07:00
|
|
|
// Anonymous child which is bound via XBL to the video controls.
|
2008-07-09 01:22:20 -07:00
|
|
|
nsCOMPtr<nsIContent> mVideoControls;
|
2012-07-30 17:42:26 -07:00
|
|
|
|
2009-06-26 00:25:17 -07:00
|
|
|
// Anonymous child which is the image element of the poster frame.
|
|
|
|
nsCOMPtr<nsIContent> mPosterImage;
|
2008-07-09 01:22:20 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* nsVideoFrame_h___ */
|