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 */
|
|
|
|
|
2013-09-24 18:43:43 -07:00
|
|
|
#include "nsVideoFrame.h"
|
|
|
|
|
2008-07-09 01:22:20 -07:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsGkAtoms.h"
|
|
|
|
|
2013-03-19 05:27:35 -07:00
|
|
|
#include "mozilla/dom/HTMLVideoElement.h"
|
2008-07-09 01:22:20 -07:00
|
|
|
#include "nsIDOMHTMLVideoElement.h"
|
2012-05-11 01:32:29 -07:00
|
|
|
#include "nsIDOMHTMLImageElement.h"
|
2008-07-09 01:22:20 -07:00
|
|
|
#include "nsDisplayList.h"
|
2013-05-28 13:55:00 -07:00
|
|
|
#include "nsGenericHTMLElement.h"
|
2008-07-09 01:22:20 -07:00
|
|
|
#include "nsPresContext.h"
|
|
|
|
#include "nsContentCreatorFunctions.h"
|
|
|
|
#include "nsBoxLayoutState.h"
|
|
|
|
#include "nsBoxFrame.h"
|
2009-06-26 00:25:17 -07:00
|
|
|
#include "nsImageFrame.h"
|
|
|
|
#include "nsIImageLoadingContent.h"
|
2011-08-11 06:29:50 -07:00
|
|
|
#include "nsContentUtils.h"
|
2012-08-19 12:33:25 -07:00
|
|
|
#include "ImageContainer.h"
|
|
|
|
#include "ImageLayers.h"
|
2012-09-05 13:49:53 -07:00
|
|
|
#include "nsContentList.h"
|
2013-01-15 04:22:03 -08:00
|
|
|
#include <algorithm>
|
2008-07-09 01:22:20 -07:00
|
|
|
|
2010-08-01 20:06:58 -07:00
|
|
|
using namespace mozilla;
|
2010-03-01 15:41:49 -08:00
|
|
|
using namespace mozilla::layers;
|
2011-05-31 18:46:57 -07:00
|
|
|
using namespace mozilla::dom;
|
2013-12-31 01:06:12 -08:00
|
|
|
using namespace mozilla::gfx;
|
2010-03-01 15:41:49 -08:00
|
|
|
|
2008-07-09 01:22:20 -07:00
|
|
|
nsIFrame*
|
|
|
|
NS_NewHTMLVideoFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
|
|
|
{
|
|
|
|
return new (aPresShell) nsVideoFrame(aContext);
|
|
|
|
}
|
|
|
|
|
2009-09-12 09:49:24 -07:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsVideoFrame)
|
|
|
|
|
2008-07-09 01:22:20 -07:00
|
|
|
nsVideoFrame::nsVideoFrame(nsStyleContext* aContext) :
|
|
|
|
nsContainerFrame(aContext)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsVideoFrame::~nsVideoFrame()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-01-12 11:20:59 -08:00
|
|
|
NS_QUERYFRAME_HEAD(nsVideoFrame)
|
2013-05-27 13:34:00 -07:00
|
|
|
NS_QUERYFRAME_ENTRY(nsVideoFrame)
|
2009-01-12 11:20:59 -08:00
|
|
|
NS_QUERYFRAME_ENTRY(nsIAnonymousContentCreator)
|
|
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsContainerFrame)
|
2008-07-09 01:22:20 -07:00
|
|
|
|
|
|
|
nsresult
|
2011-05-06 13:04:44 -07:00
|
|
|
nsVideoFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
|
2008-07-09 01:22:20 -07:00
|
|
|
{
|
2009-06-26 00:25:17 -07:00
|
|
|
nsNodeInfoManager *nodeInfoManager = GetContent()->GetCurrentDoc()->NodeInfoManager();
|
|
|
|
nsCOMPtr<nsINodeInfo> nodeInfo;
|
2013-02-26 13:06:51 -08:00
|
|
|
Element *element;
|
|
|
|
|
2009-06-26 00:25:17 -07:00
|
|
|
if (HasVideoElement()) {
|
|
|
|
// Create an anonymous image element as a child to hold the poster
|
|
|
|
// image. We may not have a poster image now, but one could be added
|
|
|
|
// before we load, or on a subsequent load.
|
|
|
|
nodeInfo = nodeInfoManager->GetNodeInfo(nsGkAtoms::img,
|
2012-07-30 07:20:58 -07:00
|
|
|
nullptr,
|
2011-06-14 00:56:49 -07:00
|
|
|
kNameSpaceID_XHTML,
|
|
|
|
nsIDOMNode::ELEMENT_NODE);
|
2009-06-26 00:25:17 -07:00
|
|
|
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
|
2013-02-26 13:06:51 -08:00
|
|
|
element = NS_NewHTMLImageElement(nodeInfo.forget());
|
2011-05-31 18:46:57 -07:00
|
|
|
mPosterImage = element;
|
2009-06-26 00:25:17 -07:00
|
|
|
NS_ENSURE_TRUE(mPosterImage, NS_ERROR_OUT_OF_MEMORY);
|
2009-11-05 05:56:52 -08:00
|
|
|
|
2009-06-26 00:25:17 -07:00
|
|
|
// Set the nsImageLoadingContent::ImageState() to 0. This means that the
|
|
|
|
// image will always report its state as 0, so it will never be reframed
|
|
|
|
// to show frames for loading or the broken image icon. This is important,
|
|
|
|
// as the image is native anonymous, and so can't be reframed (currently).
|
|
|
|
nsCOMPtr<nsIImageLoadingContent> imgContent = do_QueryInterface(mPosterImage);
|
|
|
|
NS_ENSURE_TRUE(imgContent, NS_ERROR_FAILURE);
|
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
imgContent->ForceImageState(true, 0);
|
2011-05-31 18:46:57 -07:00
|
|
|
// And now have it update its internal state
|
|
|
|
element->UpdateState(false);
|
2009-06-26 00:25:17 -07:00
|
|
|
|
2013-12-03 17:06:16 -08:00
|
|
|
UpdatePosterSource(false);
|
2009-11-05 05:56:52 -08:00
|
|
|
|
2009-06-26 00:25:17 -07:00
|
|
|
if (!aElements.AppendElement(mPosterImage))
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
2013-02-26 13:06:51 -08:00
|
|
|
|
|
|
|
// Set up the caption overlay div for showing any TextTrack data
|
|
|
|
nodeInfo = nodeInfoManager->GetNodeInfo(nsGkAtoms::div,
|
|
|
|
nullptr,
|
|
|
|
kNameSpaceID_XHTML,
|
|
|
|
nsIDOMNode::ELEMENT_NODE);
|
|
|
|
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
mCaptionDiv = NS_NewHTMLDivElement(nodeInfo.forget());
|
|
|
|
NS_ENSURE_TRUE(mCaptionDiv, NS_ERROR_OUT_OF_MEMORY);
|
2013-05-28 13:55:00 -07:00
|
|
|
nsGenericHTMLElement* div = static_cast<nsGenericHTMLElement*>(mCaptionDiv.get());
|
|
|
|
div->SetClassName(NS_LITERAL_STRING("caption-box"));
|
2013-02-26 13:06:51 -08:00
|
|
|
|
|
|
|
if (!aElements.AppendElement(mCaptionDiv))
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
2009-11-05 05:56:52 -08:00
|
|
|
}
|
2009-06-26 00:25:17 -07:00
|
|
|
|
2008-07-09 01:22:20 -07:00
|
|
|
// Set up "videocontrols" XUL element which will be XBL-bound to the
|
|
|
|
// actual controls.
|
2009-06-26 00:25:17 -07:00
|
|
|
nodeInfo = nodeInfoManager->GetNodeInfo(nsGkAtoms::videocontrols,
|
2012-07-30 07:20:58 -07:00
|
|
|
nullptr,
|
2011-06-14 00:56:49 -07:00
|
|
|
kNameSpaceID_XUL,
|
|
|
|
nsIDOMNode::ELEMENT_NODE);
|
2008-09-25 15:46:52 -07:00
|
|
|
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
|
2008-07-09 01:22:20 -07:00
|
|
|
|
2010-08-19 16:12:46 -07:00
|
|
|
NS_TrustedNewXULElement(getter_AddRefs(mVideoControls), nodeInfo.forget());
|
2008-07-09 01:22:20 -07:00
|
|
|
if (!aElements.AppendElement(mVideoControls))
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
2009-06-26 00:25:17 -07:00
|
|
|
|
2008-07-09 01:22:20 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-02-11 09:34:01 -08:00
|
|
|
void
|
2010-10-15 08:34:35 -07:00
|
|
|
nsVideoFrame::AppendAnonymousContentTo(nsBaseContentList& aElements,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t aFliter)
|
2010-02-11 09:34:01 -08:00
|
|
|
{
|
|
|
|
aElements.MaybeAppendElement(mPosterImage);
|
|
|
|
aElements.MaybeAppendElement(mVideoControls);
|
2013-02-26 13:06:51 -08:00
|
|
|
aElements.MaybeAppendElement(mCaptionDiv);
|
2010-02-11 09:34:01 -08:00
|
|
|
}
|
|
|
|
|
2008-07-09 01:22:20 -07:00
|
|
|
void
|
2009-12-23 21:21:15 -08:00
|
|
|
nsVideoFrame::DestroyFrom(nsIFrame* aDestructRoot)
|
2008-07-09 01:22:20 -07:00
|
|
|
{
|
2013-02-26 13:06:51 -08:00
|
|
|
nsContentUtils::DestroyAnonymousContent(&mCaptionDiv);
|
2008-07-09 01:22:20 -07:00
|
|
|
nsContentUtils::DestroyAnonymousContent(&mVideoControls);
|
2009-06-26 00:25:17 -07:00
|
|
|
nsContentUtils::DestroyAnonymousContent(&mPosterImage);
|
2009-12-23 21:21:15 -08:00
|
|
|
nsContainerFrame::DestroyFrom(aDestructRoot);
|
2008-07-09 01:22:20 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2008-07-09 01:22:20 -07:00
|
|
|
nsVideoFrame::IsLeaf() const
|
|
|
|
{
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2008-07-09 01:22:20 -07:00
|
|
|
}
|
|
|
|
|
2008-12-29 00:20:27 -08:00
|
|
|
// Return the largest rectangle that fits in aRect and has the
|
|
|
|
// same aspect ratio as aRatio, centered at the center of aRect
|
|
|
|
static gfxRect
|
|
|
|
CorrectForAspectRatio(const gfxRect& aRect, const nsIntSize& aRatio)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aRatio.width > 0 && aRatio.height > 0 && !aRect.IsEmpty(),
|
|
|
|
"Nothing to draw");
|
|
|
|
// Choose scale factor that scales aRatio to just fit into aRect
|
|
|
|
gfxFloat scale =
|
2013-01-15 04:22:03 -08:00
|
|
|
std::min(aRect.Width()/aRatio.width, aRect.Height()/aRatio.height);
|
2008-12-29 00:20:27 -08:00
|
|
|
gfxSize scaledRatio(scale*aRatio.width, scale*aRatio.height);
|
|
|
|
gfxPoint topLeft((aRect.Width() - scaledRatio.width)/2,
|
|
|
|
(aRect.Height() - scaledRatio.height)/2);
|
|
|
|
return gfxRect(aRect.TopLeft() + topLeft, scaledRatio);
|
|
|
|
}
|
|
|
|
|
2010-03-01 15:41:49 -08:00
|
|
|
already_AddRefed<Layer>
|
|
|
|
nsVideoFrame::BuildLayer(nsDisplayListBuilder* aBuilder,
|
2010-07-15 14:07:46 -07:00
|
|
|
LayerManager* aManager,
|
2012-09-16 15:25:33 -07:00
|
|
|
nsDisplayItem* aItem,
|
2013-09-26 23:01:16 -07:00
|
|
|
const ContainerLayerParameters& aContainerParameters)
|
2008-07-09 01:22:20 -07:00
|
|
|
{
|
2010-08-13 03:01:58 -07:00
|
|
|
nsRect area = GetContentRect() - GetPosition() + aItem->ToReferenceFrame();
|
2013-03-19 05:27:35 -07:00
|
|
|
HTMLVideoElement* element = static_cast<HTMLVideoElement*>(GetContent());
|
2012-05-11 01:32:15 -07:00
|
|
|
nsIntSize videoSize;
|
|
|
|
if (NS_FAILED(element->GetVideoSize(&videoSize)) || area.IsEmpty()) {
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2012-05-11 01:32:15 -07:00
|
|
|
}
|
2010-03-01 15:41:49 -08:00
|
|
|
|
|
|
|
nsRefPtr<ImageContainer> container = element->GetImageContainer();
|
2012-04-09 12:17:19 -07:00
|
|
|
if (!container)
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2012-01-31 18:18:30 -08:00
|
|
|
|
2010-04-27 01:53:44 -07:00
|
|
|
// Retrieve the size of the decoded video frame, before being scaled
|
|
|
|
// by pixel aspect ratio.
|
2013-12-13 09:32:02 -08:00
|
|
|
mozilla::gfx::IntSize frameSize = container->GetCurrentSize();
|
2010-04-27 01:53:44 -07:00
|
|
|
if (frameSize.width == 0 || frameSize.height == 0) {
|
|
|
|
// No image, or zero-sized image. No point creating a layer.
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2010-04-27 01:53:44 -07:00
|
|
|
}
|
|
|
|
|
2010-03-01 15:41:49 -08:00
|
|
|
// Compute the rectangle in which to paint the video. We need to use
|
|
|
|
// the largest rectangle that fills our content-box and has the
|
|
|
|
// correct aspect ratio.
|
2008-07-09 01:22:20 -07:00
|
|
|
nsPresContext* presContext = PresContext();
|
2009-11-05 05:56:52 -08:00
|
|
|
gfxRect r = gfxRect(presContext->AppUnitsToGfxUnits(area.x),
|
|
|
|
presContext->AppUnitsToGfxUnits(area.y),
|
|
|
|
presContext->AppUnitsToGfxUnits(area.width),
|
2008-07-09 01:22:20 -07:00
|
|
|
presContext->AppUnitsToGfxUnits(area.height));
|
2008-12-29 00:20:27 -08:00
|
|
|
r = CorrectForAspectRatio(r, videoSize);
|
2010-10-25 20:11:13 -07:00
|
|
|
r.Round();
|
2012-11-29 14:11:04 -08:00
|
|
|
if (r.IsEmpty()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2013-12-31 01:06:12 -08:00
|
|
|
IntSize scaleHint(static_cast<int32_t>(r.Width()),
|
|
|
|
static_cast<int32_t>(r.Height()));
|
2010-10-25 20:11:13 -07:00
|
|
|
container->SetScaleHint(scaleHint);
|
2010-03-01 15:41:49 -08:00
|
|
|
|
2010-07-15 14:07:46 -07:00
|
|
|
nsRefPtr<ImageLayer> layer = static_cast<ImageLayer*>
|
2012-08-28 22:47:15 -07:00
|
|
|
(aManager->GetLayerBuilder()->GetLeafLayerFor(aBuilder, aItem));
|
2010-07-15 14:07:46 -07:00
|
|
|
if (!layer) {
|
|
|
|
layer = aManager->CreateImageLayer();
|
|
|
|
if (!layer)
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2010-07-15 14:07:46 -07:00
|
|
|
}
|
2010-03-01 15:41:49 -08:00
|
|
|
|
|
|
|
layer->SetContainer(container);
|
|
|
|
layer->SetFilter(nsLayoutUtils::GetGraphicsFilterForFrame(this));
|
2011-04-12 12:39:50 -07:00
|
|
|
layer->SetContentFlags(Layer::CONTENT_OPAQUE);
|
2010-03-01 15:41:49 -08:00
|
|
|
// Set a transform on the layer to draw the video in the right place
|
2014-01-27 07:28:33 -08:00
|
|
|
gfx::Matrix transform;
|
|
|
|
gfxPoint p = r.TopLeft() + aContainerParameters.mOffset;
|
|
|
|
transform.Translate(p.x, p.y);
|
2010-04-27 01:53:44 -07:00
|
|
|
transform.Scale(r.Width()/frameSize.width, r.Height()/frameSize.height);
|
2014-01-27 07:28:33 -08:00
|
|
|
layer->SetBaseTransform(gfx::Matrix4x4::From2D(transform));
|
2011-11-01 22:44:49 -07:00
|
|
|
layer->SetVisibleRegion(nsIntRect(0, 0, frameSize.width, frameSize.height));
|
2010-03-01 15:41:49 -08:00
|
|
|
nsRefPtr<Layer> result = layer.forget();
|
|
|
|
return result.forget();
|
2008-07-09 01:22:20 -07:00
|
|
|
}
|
|
|
|
|
2013-05-27 22:00:59 -07:00
|
|
|
class DispatchResizeToControls : public nsRunnable
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DispatchResizeToControls(nsIContent* aContent)
|
|
|
|
: mContent(aContent) {}
|
2014-02-24 06:41:56 -08:00
|
|
|
NS_IMETHOD Run() MOZ_OVERRIDE {
|
2013-05-27 22:00:59 -07:00
|
|
|
nsContentUtils::DispatchTrustedEvent(mContent->OwnerDoc(), mContent,
|
|
|
|
NS_LITERAL_STRING("resizevideocontrols"),
|
|
|
|
false, false);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
nsCOMPtr<nsIContent> mContent;
|
|
|
|
};
|
|
|
|
|
2014-02-17 23:47:48 -08:00
|
|
|
nsresult
|
2008-07-09 01:22:20 -07:00
|
|
|
nsVideoFrame::Reflow(nsPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aMetrics,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsVideoFrame");
|
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowState, aMetrics, aStatus);
|
|
|
|
NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
|
|
|
|
("enter nsVideoFrame::Reflow: availSize=%d,%d",
|
2013-12-27 09:59:21 -08:00
|
|
|
aReflowState.AvailableWidth(), aReflowState.AvailableHeight()));
|
2008-07-09 01:22:20 -07:00
|
|
|
|
|
|
|
NS_PRECONDITION(mState & NS_FRAME_IN_REFLOW, "frame is not in reflow");
|
|
|
|
|
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
|
|
|
|
2013-12-27 09:59:52 -08:00
|
|
|
aMetrics.Width() = aReflowState.ComputedWidth();
|
|
|
|
aMetrics.Height() = aReflowState.ComputedHeight();
|
2008-07-09 01:22:20 -07:00
|
|
|
|
|
|
|
// stash this away so we can compute our inner area later
|
2013-12-27 09:59:21 -08:00
|
|
|
mBorderPadding = aReflowState.ComputedPhysicalBorderPadding();
|
2008-07-09 01:22:20 -07:00
|
|
|
|
2013-12-27 09:59:52 -08:00
|
|
|
aMetrics.Width() += mBorderPadding.left + mBorderPadding.right;
|
|
|
|
aMetrics.Height() += mBorderPadding.top + mBorderPadding.bottom;
|
2008-07-09 01:22:20 -07:00
|
|
|
|
2009-06-26 00:25:17 -07:00
|
|
|
// Reflow the child frames. We may have up to two, an image frame
|
|
|
|
// which is the poster, and a box frame, which is the video controls.
|
|
|
|
for (nsIFrame *child = mFrames.FirstChild();
|
|
|
|
child;
|
|
|
|
child = child->GetNextSibling()) {
|
2013-02-26 13:06:51 -08:00
|
|
|
if (child->GetContent() == mPosterImage) {
|
2009-06-26 00:25:17 -07:00
|
|
|
// Reflow the poster frame.
|
|
|
|
nsImageFrame* imageFrame = static_cast<nsImageFrame*>(child);
|
2013-12-31 05:50:31 -08:00
|
|
|
nsHTMLReflowMetrics kidDesiredSize(aReflowState);
|
2013-12-27 09:59:21 -08:00
|
|
|
nsSize availableSize = nsSize(aReflowState.AvailableWidth(),
|
|
|
|
aReflowState.AvailableHeight());
|
2009-10-06 00:37:46 -07:00
|
|
|
nsHTMLReflowState kidReflowState(aPresContext,
|
|
|
|
aReflowState,
|
|
|
|
imageFrame,
|
|
|
|
availableSize,
|
2013-12-27 09:59:52 -08:00
|
|
|
aMetrics.Width(),
|
|
|
|
aMetrics.Height());
|
2012-05-11 01:32:29 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t posterHeight, posterWidth;
|
2012-05-11 01:32:29 -07:00
|
|
|
nsSize scaledPosterSize(0, 0);
|
|
|
|
nsSize computedArea(aReflowState.ComputedWidth(), aReflowState.ComputedHeight());
|
|
|
|
nsPoint posterTopLeft(0, 0);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMHTMLImageElement> posterImage = do_QueryInterface(mPosterImage);
|
|
|
|
NS_ENSURE_TRUE(posterImage, NS_ERROR_FAILURE);
|
|
|
|
posterImage->GetNaturalHeight(&posterHeight);
|
|
|
|
posterImage->GetNaturalWidth(&posterWidth);
|
|
|
|
|
|
|
|
if (ShouldDisplayPoster() && posterHeight && posterWidth) {
|
|
|
|
gfxFloat scale =
|
2013-01-15 04:22:03 -08:00
|
|
|
std::min(static_cast<float>(computedArea.width)/nsPresContext::CSSPixelsToAppUnits(static_cast<float>(posterWidth)),
|
2012-05-11 01:32:29 -07:00
|
|
|
static_cast<float>(computedArea.height)/nsPresContext::CSSPixelsToAppUnits(static_cast<float>(posterHeight)));
|
|
|
|
gfxSize scaledRatio = gfxSize(scale*posterWidth, scale*posterHeight);
|
|
|
|
scaledPosterSize.width = nsPresContext::CSSPixelsToAppUnits(static_cast<float>(scaledRatio.width));
|
2012-08-22 08:56:38 -07:00
|
|
|
scaledPosterSize.height = nsPresContext::CSSPixelsToAppUnits(static_cast<int32_t>(scaledRatio.height));
|
2009-10-06 00:37:46 -07:00
|
|
|
}
|
2012-05-11 01:32:29 -07:00
|
|
|
kidReflowState.SetComputedWidth(scaledPosterSize.width);
|
|
|
|
kidReflowState.SetComputedHeight(scaledPosterSize.height);
|
|
|
|
posterTopLeft.x = ((computedArea.width - scaledPosterSize.width) / 2) + mBorderPadding.left;
|
|
|
|
posterTopLeft.y = ((computedArea.height - scaledPosterSize.height) / 2) + mBorderPadding.top;
|
|
|
|
|
2009-10-06 00:37:46 -07:00
|
|
|
ReflowChild(imageFrame, aPresContext, kidDesiredSize, kidReflowState,
|
2012-05-11 01:32:29 -07:00
|
|
|
posterTopLeft.x, posterTopLeft.y, 0, aStatus);
|
2014-01-16 17:34:44 -08:00
|
|
|
FinishReflowChild(imageFrame, aPresContext, kidDesiredSize, &kidReflowState,
|
2012-05-11 01:32:29 -07:00
|
|
|
posterTopLeft.x, posterTopLeft.y, 0);
|
2013-02-26 13:06:51 -08:00
|
|
|
} else if (child->GetContent() == mVideoControls) {
|
2009-06-26 00:25:17 -07:00
|
|
|
// Reflow the video controls frame.
|
|
|
|
nsBoxLayoutState boxState(PresContext(), aReflowState.rendContext);
|
2013-05-27 22:00:59 -07:00
|
|
|
nsSize size = child->GetSize();
|
2009-06-26 00:25:17 -07:00
|
|
|
nsBoxFrame::LayoutChildAt(boxState,
|
|
|
|
child,
|
|
|
|
nsRect(mBorderPadding.left,
|
|
|
|
mBorderPadding.top,
|
|
|
|
aReflowState.ComputedWidth(),
|
|
|
|
aReflowState.ComputedHeight()));
|
2013-05-27 22:00:59 -07:00
|
|
|
if (child->GetSize() != size) {
|
|
|
|
nsRefPtr<nsRunnable> event = new DispatchResizeToControls(child->GetContent());
|
|
|
|
nsContentUtils::AddScriptRunner(event);
|
|
|
|
}
|
2013-02-26 13:06:51 -08:00
|
|
|
} else if (child->GetContent() == mCaptionDiv) {
|
|
|
|
// Reflow to caption div
|
2013-12-31 05:50:31 -08:00
|
|
|
nsHTMLReflowMetrics kidDesiredSize(aReflowState);
|
2013-12-27 09:59:21 -08:00
|
|
|
nsSize availableSize = nsSize(aReflowState.AvailableWidth(),
|
|
|
|
aReflowState.AvailableHeight());
|
2013-02-26 13:06:51 -08:00
|
|
|
nsHTMLReflowState kidReflowState(aPresContext,
|
|
|
|
aReflowState,
|
|
|
|
child,
|
|
|
|
availableSize,
|
2013-12-27 09:59:52 -08:00
|
|
|
aMetrics.Width(),
|
|
|
|
aMetrics.Height());
|
2013-02-26 13:06:51 -08:00
|
|
|
nsSize size(aReflowState.ComputedWidth(), aReflowState.ComputedHeight());
|
2013-12-27 09:59:21 -08:00
|
|
|
size.width -= kidReflowState.ComputedPhysicalBorderPadding().LeftRight();
|
|
|
|
size.height -= kidReflowState.ComputedPhysicalBorderPadding().TopBottom();
|
2013-02-26 13:06:51 -08:00
|
|
|
|
|
|
|
kidReflowState.SetComputedWidth(std::max(size.width, 0));
|
|
|
|
kidReflowState.SetComputedHeight(std::max(size.height, 0));
|
|
|
|
|
|
|
|
ReflowChild(child, aPresContext, kidDesiredSize, kidReflowState,
|
|
|
|
mBorderPadding.left, mBorderPadding.top, 0, aStatus);
|
|
|
|
FinishReflowChild(child, aPresContext,
|
2014-01-16 17:34:44 -08:00
|
|
|
kidDesiredSize, &kidReflowState,
|
2013-02-26 13:06:51 -08:00
|
|
|
mBorderPadding.left, mBorderPadding.top, 0);
|
2009-06-26 00:25:17 -07:00
|
|
|
}
|
2008-07-09 01:22:20 -07:00
|
|
|
}
|
2010-10-06 21:25:46 -07:00
|
|
|
aMetrics.SetOverflowAreasToDesiredBounds();
|
2008-07-09 01:22:20 -07:00
|
|
|
|
|
|
|
FinishAndStoreOverflow(&aMetrics);
|
|
|
|
|
|
|
|
NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
|
|
|
|
("exit nsVideoFrame::Reflow: size=%d,%d",
|
2013-12-27 09:59:52 -08:00
|
|
|
aMetrics.Width(), aMetrics.Height()));
|
2008-07-09 01:22:20 -07:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aMetrics);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-03-01 15:41:49 -08:00
|
|
|
class nsDisplayVideo : public nsDisplayItem {
|
|
|
|
public:
|
2010-08-13 03:01:13 -07:00
|
|
|
nsDisplayVideo(nsDisplayListBuilder* aBuilder, nsVideoFrame* aFrame)
|
|
|
|
: nsDisplayItem(aBuilder, aFrame)
|
2010-03-01 15:41:49 -08:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsDisplayVideo);
|
|
|
|
}
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual ~nsDisplayVideo() {
|
|
|
|
MOZ_COUNT_DTOR(nsDisplayVideo);
|
|
|
|
}
|
2008-07-09 01:22:20 -07:00
|
|
|
#endif
|
2010-03-01 15:41:49 -08:00
|
|
|
|
2010-07-15 14:07:49 -07:00
|
|
|
NS_DISPLAY_DECL_NAME("Video", TYPE_VIDEO)
|
2010-03-01 15:41:49 -08:00
|
|
|
|
2011-01-02 17:48:09 -08:00
|
|
|
// It would be great if we could override GetOpaqueRegion to return nonempty here,
|
2010-03-01 15:41:49 -08:00
|
|
|
// but it's probably not safe to do so in general. Video frames are
|
|
|
|
// updated asynchronously from decoder threads, and it's possible that
|
2011-01-02 17:48:09 -08:00
|
|
|
// we might have an opaque video frame when GetOpaqueRegion is called, but
|
2010-03-01 15:41:49 -08:00
|
|
|
// when we come to paint, the video frame is transparent or has gone
|
|
|
|
// away completely (e.g. because of a decoder error). The problem would
|
|
|
|
// be especially acute if we have off-main-thread rendering.
|
|
|
|
|
2014-02-24 06:41:56 -08:00
|
|
|
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder, bool* aSnap) MOZ_OVERRIDE
|
2010-03-01 15:41:49 -08:00
|
|
|
{
|
2012-11-13 11:56:47 -08:00
|
|
|
*aSnap = true;
|
2013-04-19 05:02:13 -07:00
|
|
|
nsIFrame* f = Frame();
|
2010-08-13 03:01:58 -07:00
|
|
|
return f->GetContentRect() - f->GetPosition() + ToReferenceFrame();
|
2010-03-01 15:41:49 -08:00
|
|
|
}
|
2008-07-09 01:22:20 -07:00
|
|
|
|
2010-03-01 15:41:49 -08:00
|
|
|
virtual already_AddRefed<Layer> BuildLayer(nsDisplayListBuilder* aBuilder,
|
2011-06-22 05:11:27 -07:00
|
|
|
LayerManager* aManager,
|
2014-02-24 06:41:56 -08:00
|
|
|
const ContainerLayerParameters& aContainerParameters) MOZ_OVERRIDE
|
2010-03-01 15:41:49 -08:00
|
|
|
{
|
2012-09-16 15:25:33 -07:00
|
|
|
return static_cast<nsVideoFrame*>(mFrame)->BuildLayer(aBuilder, aManager, this, aContainerParameters);
|
2010-03-01 15:41:49 -08:00
|
|
|
}
|
2010-07-15 14:08:05 -07:00
|
|
|
|
|
|
|
virtual LayerState GetLayerState(nsDisplayListBuilder* aBuilder,
|
2012-05-03 07:05:55 -07:00
|
|
|
LayerManager* aManager,
|
2014-02-24 06:41:56 -08:00
|
|
|
const ContainerLayerParameters& aParameters) MOZ_OVERRIDE
|
2010-07-15 14:08:05 -07:00
|
|
|
{
|
2012-07-06 06:23:09 -07:00
|
|
|
if (aManager->IsCompositingCheap()) {
|
|
|
|
// Since ImageLayers don't require additional memory of the
|
|
|
|
// video frames we have to have anyway, we can't save much by
|
|
|
|
// making layers inactive. Also, for many accelerated layer
|
|
|
|
// managers calling imageContainer->GetCurrentAsSurface can be
|
|
|
|
// very expensive. So just always be active when compositing is
|
|
|
|
// cheap (i.e. hardware accelerated).
|
2010-08-01 20:06:58 -07:00
|
|
|
return LAYER_ACTIVE;
|
|
|
|
}
|
2013-03-19 05:23:54 -07:00
|
|
|
HTMLMediaElement* elem =
|
|
|
|
static_cast<HTMLMediaElement*>(mFrame->GetContent());
|
2012-11-29 14:11:06 -08:00
|
|
|
return elem->IsPotentiallyPlaying() ? LAYER_ACTIVE_FORCE : LAYER_INACTIVE;
|
2010-07-15 14:08:05 -07:00
|
|
|
}
|
2010-03-01 15:41:49 -08:00
|
|
|
};
|
2008-07-09 01:22:20 -07:00
|
|
|
|
2013-02-14 03:12:27 -08:00
|
|
|
void
|
2008-07-09 01:22:20 -07:00
|
|
|
nsVideoFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
|
|
|
{
|
|
|
|
if (!IsVisibleForPainting(aBuilder))
|
2013-02-14 03:12:27 -08:00
|
|
|
return;
|
2008-07-09 01:22:20 -07:00
|
|
|
|
|
|
|
DO_GLOBAL_REFLOW_COUNT_DSP("nsVideoFrame");
|
|
|
|
|
2013-02-14 03:08:08 -08:00
|
|
|
DisplayBorderBackgroundOutline(aBuilder, aLists);
|
2008-07-09 01:22:20 -07:00
|
|
|
|
2013-03-04 01:56:02 -08:00
|
|
|
DisplayListClipState::AutoClipContainingBlockDescendantsToContentBox
|
|
|
|
clip(aBuilder, this, DisplayListClipState::ASSUME_DRAWING_RESTRICTED_TO_CONTENT_RECT);
|
2010-09-09 08:21:47 -07:00
|
|
|
|
2010-03-01 15:41:49 -08:00
|
|
|
if (HasVideoElement() && !ShouldDisplayPoster()) {
|
2013-03-04 01:56:02 -08:00
|
|
|
aLists.Content()->AppendNewToTop(
|
2010-08-13 03:01:13 -07:00
|
|
|
new (aBuilder) nsDisplayVideo(aBuilder, this));
|
2008-12-16 16:27:46 -08:00
|
|
|
}
|
2008-07-09 01:22:20 -07:00
|
|
|
|
2013-02-26 13:06:51 -08:00
|
|
|
// Add child frames to display list. We expect various children,
|
|
|
|
// but only want to draw mPosterImage conditionally. Others we
|
|
|
|
// always add to the display list.
|
2009-06-26 00:25:17 -07:00
|
|
|
for (nsIFrame *child = mFrames.FirstChild();
|
|
|
|
child;
|
|
|
|
child = child->GetNextSibling()) {
|
2013-02-26 13:06:51 -08:00
|
|
|
if (child->GetContent() != mPosterImage || ShouldDisplayPoster()) {
|
2013-02-14 03:08:08 -08:00
|
|
|
child->BuildDisplayListForStackingContext(aBuilder,
|
|
|
|
aDirtyRect - child->GetOffsetTo(this),
|
2013-03-04 01:56:02 -08:00
|
|
|
aLists.Content());
|
2009-06-26 00:25:17 -07:00
|
|
|
} else if (child->GetType() == nsGkAtoms::boxFrame) {
|
2013-02-14 03:08:08 -08:00
|
|
|
child->BuildDisplayListForStackingContext(aBuilder,
|
|
|
|
aDirtyRect - child->GetOffsetTo(this),
|
2013-03-04 01:56:02 -08:00
|
|
|
aLists.Content());
|
2009-06-26 00:25:17 -07:00
|
|
|
}
|
2008-07-09 01:22:20 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIAtom*
|
|
|
|
nsVideoFrame::GetType() const
|
|
|
|
{
|
|
|
|
return nsGkAtoms::HTMLVideoFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef ACCESSIBILITY
|
2012-09-28 14:53:44 -07:00
|
|
|
a11y::AccType
|
|
|
|
nsVideoFrame::AccessibleType()
|
2008-07-09 01:22:20 -07:00
|
|
|
{
|
2012-12-17 17:25:52 -08:00
|
|
|
return a11y::eHTMLMediaType;
|
2008-07-09 01:22:20 -07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-01-05 15:31:14 -08:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2014-02-17 23:47:48 -08:00
|
|
|
nsresult
|
2008-07-09 01:22:20 -07:00
|
|
|
nsVideoFrame::GetFrameName(nsAString& aResult) const
|
|
|
|
{
|
|
|
|
return MakeFrameName(NS_LITERAL_STRING("HTMLVideo"), aResult);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-04-07 18:04:40 -07:00
|
|
|
nsSize nsVideoFrame::ComputeSize(nsRenderingContext *aRenderingContext,
|
2009-11-05 05:56:52 -08:00
|
|
|
nsSize aCBSize,
|
2008-07-09 01:22:20 -07:00
|
|
|
nscoord aAvailableWidth,
|
2009-11-05 05:56:52 -08:00
|
|
|
nsSize aMargin,
|
|
|
|
nsSize aBorder,
|
2008-07-09 01:22:20 -07:00
|
|
|
nsSize aPadding,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t aFlags)
|
2008-07-09 01:22:20 -07:00
|
|
|
{
|
2010-01-08 16:37:30 -08:00
|
|
|
nsSize size = GetVideoIntrinsicSize(aRenderingContext);
|
2008-07-09 01:22:20 -07:00
|
|
|
|
|
|
|
IntrinsicSize intrinsicSize;
|
|
|
|
intrinsicSize.width.SetCoordValue(size.width);
|
|
|
|
intrinsicSize.height.SetCoordValue(size.height);
|
|
|
|
|
2013-06-25 15:00:04 -07:00
|
|
|
// Only video elements have an intrinsic ratio.
|
|
|
|
nsSize intrinsicRatio = HasVideoElement() ? size : nsSize(0, 0);
|
2008-07-09 01:22:20 -07:00
|
|
|
|
2009-11-05 05:56:52 -08:00
|
|
|
return nsLayoutUtils::ComputeSizeWithIntrinsicDimensions(aRenderingContext,
|
2008-07-09 01:22:20 -07:00
|
|
|
this,
|
|
|
|
intrinsicSize,
|
|
|
|
intrinsicRatio,
|
2009-11-05 05:56:52 -08:00
|
|
|
aCBSize,
|
|
|
|
aMargin,
|
|
|
|
aBorder,
|
2008-07-09 01:22:20 -07:00
|
|
|
aPadding);
|
|
|
|
}
|
|
|
|
|
2011-04-07 18:04:40 -07:00
|
|
|
nscoord nsVideoFrame::GetMinWidth(nsRenderingContext *aRenderingContext)
|
2008-07-09 01:22:20 -07:00
|
|
|
{
|
2010-01-08 16:37:30 -08:00
|
|
|
nscoord result = GetVideoIntrinsicSize(aRenderingContext).width;
|
2008-07-09 01:22:20 -07:00
|
|
|
DISPLAY_MIN_WIDTH(this, result);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2011-04-07 18:04:40 -07:00
|
|
|
nscoord nsVideoFrame::GetPrefWidth(nsRenderingContext *aRenderingContext)
|
2008-07-09 01:22:20 -07:00
|
|
|
{
|
2010-01-08 16:37:30 -08:00
|
|
|
nscoord result = GetVideoIntrinsicSize(aRenderingContext).width;
|
2008-07-09 01:22:20 -07:00
|
|
|
DISPLAY_PREF_WIDTH(this, result);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsSize nsVideoFrame::GetIntrinsicRatio()
|
|
|
|
{
|
2013-06-25 15:00:04 -07:00
|
|
|
if (!HasVideoElement()) {
|
|
|
|
// Audio elements have no intrinsic ratio.
|
|
|
|
return nsSize(0, 0);
|
|
|
|
}
|
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
return GetVideoIntrinsicSize(nullptr);
|
2008-07-09 01:22:20 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool nsVideoFrame::ShouldDisplayPoster()
|
2009-06-26 00:25:17 -07:00
|
|
|
{
|
|
|
|
if (!HasVideoElement())
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2009-06-26 00:25:17 -07:00
|
|
|
|
2013-03-19 05:27:35 -07:00
|
|
|
HTMLVideoElement* element = static_cast<HTMLVideoElement*>(GetContent());
|
2009-06-26 00:25:17 -07:00
|
|
|
if (element->GetPlayedOrSeeked() && HasVideoData())
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2009-06-26 00:25:17 -07:00
|
|
|
|
|
|
|
nsCOMPtr<nsIImageLoadingContent> imgContent = do_QueryInterface(mPosterImage);
|
2011-10-17 07:59:28 -07:00
|
|
|
NS_ENSURE_TRUE(imgContent, false);
|
2009-11-05 05:56:52 -08:00
|
|
|
|
2009-06-26 00:25:17 -07:00
|
|
|
nsCOMPtr<imgIRequest> request;
|
|
|
|
nsresult res = imgContent->GetRequest(nsIImageLoadingContent::CURRENT_REQUEST,
|
|
|
|
getter_AddRefs(request));
|
|
|
|
if (NS_FAILED(res) || !request) {
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2009-06-26 00:25:17 -07:00
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t status = 0;
|
2009-06-26 00:25:17 -07:00
|
|
|
res = request->GetImageStatus(&status);
|
|
|
|
if (NS_FAILED(res) || (status & imgIRequest::STATUS_ERROR))
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2009-11-05 05:56:52 -08:00
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2009-06-26 00:25:17 -07:00
|
|
|
}
|
|
|
|
|
2010-01-08 16:37:30 -08:00
|
|
|
nsSize
|
2011-04-07 18:04:40 -07:00
|
|
|
nsVideoFrame::GetVideoIntrinsicSize(nsRenderingContext *aRenderingContext)
|
2008-07-09 01:22:20 -07:00
|
|
|
{
|
|
|
|
// Defaulting size to 300x150 if no size given.
|
2010-06-15 14:53:44 -07:00
|
|
|
nsIntSize size(300, 150);
|
2013-06-25 15:00:04 -07:00
|
|
|
|
2010-06-15 14:53:44 -07:00
|
|
|
if (!HasVideoElement()) {
|
2013-06-25 15:00:04 -07:00
|
|
|
if (!mFrames.FirstChild()) {
|
2008-12-16 16:27:46 -08:00
|
|
|
return nsSize(0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Ask the controls frame what its preferred height is
|
|
|
|
nsBoxLayoutState boxState(PresContext(), aRenderingContext, 0);
|
2009-06-26 00:25:17 -07:00
|
|
|
nscoord prefHeight = mFrames.LastChild()->GetPrefSize(boxState).height;
|
2008-12-16 16:27:46 -08:00
|
|
|
return nsSize(nsPresContext::CSSPixelsToAppUnits(size.width), prefHeight);
|
|
|
|
}
|
|
|
|
|
2013-03-19 05:27:35 -07:00
|
|
|
HTMLVideoElement* element = static_cast<HTMLVideoElement*>(GetContent());
|
2012-05-11 01:32:15 -07:00
|
|
|
if (NS_FAILED(element->GetVideoSize(&size)) && ShouldDisplayPoster()) {
|
|
|
|
// Use the poster image frame's size.
|
|
|
|
nsIFrame *child = mPosterImage->GetPrimaryFrame();
|
|
|
|
nsImageFrame* imageFrame = do_QueryFrame(child);
|
|
|
|
nsSize imgsize;
|
|
|
|
if (NS_SUCCEEDED(imageFrame->GetIntrinsicImageSize(imgsize))) {
|
|
|
|
return imgsize;
|
|
|
|
}
|
|
|
|
}
|
2008-07-09 01:22:20 -07:00
|
|
|
|
2009-11-05 05:56:52 -08:00
|
|
|
return nsSize(nsPresContext::CSSPixelsToAppUnits(size.width),
|
2008-07-09 01:22:20 -07:00
|
|
|
nsPresContext::CSSPixelsToAppUnits(size.height));
|
|
|
|
}
|
2008-12-16 16:27:46 -08:00
|
|
|
|
2013-12-03 17:06:16 -08:00
|
|
|
void
|
2011-09-28 23:19:26 -07:00
|
|
|
nsVideoFrame::UpdatePosterSource(bool aNotify)
|
2009-06-26 00:25:17 -07:00
|
|
|
{
|
|
|
|
NS_ASSERTION(HasVideoElement(), "Only call this on <video> elements.");
|
2013-03-19 05:27:35 -07:00
|
|
|
HTMLVideoElement* element = static_cast<HTMLVideoElement*>(GetContent());
|
2009-06-26 00:25:17 -07:00
|
|
|
|
2013-12-03 17:06:16 -08:00
|
|
|
if (element->HasAttr(kNameSpaceID_None, nsGkAtoms::poster)) {
|
|
|
|
nsAutoString posterStr;
|
|
|
|
element->GetPoster(posterStr);
|
|
|
|
mPosterImage->SetAttr(kNameSpaceID_None,
|
|
|
|
nsGkAtoms::src,
|
|
|
|
posterStr,
|
|
|
|
aNotify);
|
|
|
|
} else {
|
|
|
|
mPosterImage->UnsetAttr(kNameSpaceID_None, nsGkAtoms::poster, aNotify);
|
|
|
|
}
|
2009-06-26 00:25:17 -07:00
|
|
|
}
|
|
|
|
|
2014-02-17 23:47:48 -08:00
|
|
|
nsresult
|
2012-08-22 08:56:38 -07:00
|
|
|
nsVideoFrame::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
|
|
|
{
|
2009-07-06 19:02:06 -07:00
|
|
|
if (aAttribute == nsGkAtoms::poster && HasVideoElement()) {
|
2013-12-03 17:06:16 -08:00
|
|
|
UpdatePosterSource(true);
|
2009-06-26 00:25:17 -07:00
|
|
|
}
|
|
|
|
return nsContainerFrame::AttributeChanged(aNameSpaceID,
|
|
|
|
aAttribute,
|
|
|
|
aModType);
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool nsVideoFrame::HasVideoElement() {
|
2009-06-26 00:25:17 -07:00
|
|
|
nsCOMPtr<nsIDOMHTMLVideoElement> videoDomElement = do_QueryInterface(mContent);
|
2012-07-30 07:20:58 -07:00
|
|
|
return videoDomElement != nullptr;
|
2009-06-26 00:25:17 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool nsVideoFrame::HasVideoData()
|
2008-12-16 16:27:46 -08:00
|
|
|
{
|
2009-06-26 00:25:17 -07:00
|
|
|
if (!HasVideoElement())
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2013-03-19 05:27:35 -07:00
|
|
|
HTMLVideoElement* element = static_cast<HTMLVideoElement*>(GetContent());
|
2012-05-11 01:32:15 -07:00
|
|
|
nsIntSize size(0, 0);
|
|
|
|
element->GetVideoSize(&size);
|
2009-06-26 00:25:17 -07:00
|
|
|
return size != nsIntSize(0,0);
|
2008-12-16 16:27:46 -08:00
|
|
|
}
|