2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/* rendering object for the HTML <canvas> element */
|
|
|
|
|
|
|
|
#include "nsHTMLCanvasFrame.h"
|
2013-09-24 18:43:43 -07:00
|
|
|
|
|
|
|
#include "nsGkAtoms.h"
|
2013-01-03 21:16:14 -08:00
|
|
|
#include "mozilla/dom/HTMLCanvasElement.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsDisplayList.h"
|
2009-07-21 17:44:57 -07:00
|
|
|
#include "nsLayoutUtils.h"
|
2012-08-20 21:06:46 -07:00
|
|
|
#include "Layers.h"
|
2013-09-04 04:30:57 -07:00
|
|
|
#include "ActiveLayerTracker.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-01-15 04:22:03 -08:00
|
|
|
#include <algorithm>
|
2009-03-05 05:43:45 -08:00
|
|
|
|
2010-05-17 21:04:22 -07:00
|
|
|
using namespace mozilla;
|
2013-01-03 21:16:14 -08:00
|
|
|
using namespace mozilla::dom;
|
2010-05-17 21:04:22 -07:00
|
|
|
using namespace mozilla::layers;
|
|
|
|
|
2010-07-15 14:07:44 -07:00
|
|
|
class nsDisplayCanvas : public nsDisplayItem {
|
2009-03-05 05:43:45 -08:00
|
|
|
public:
|
2010-08-13 03:01:13 -07:00
|
|
|
nsDisplayCanvas(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame)
|
|
|
|
: nsDisplayItem(aBuilder, aFrame)
|
2009-03-05 05:43:45 -08:00
|
|
|
{
|
2010-07-15 14:07:44 -07:00
|
|
|
MOZ_COUNT_CTOR(nsDisplayCanvas);
|
2009-03-05 05:43:45 -08:00
|
|
|
}
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
2010-07-15 14:07:44 -07:00
|
|
|
virtual ~nsDisplayCanvas() {
|
|
|
|
MOZ_COUNT_DTOR(nsDisplayCanvas);
|
2009-03-05 05:43:45 -08:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-07-15 14:07:49 -07:00
|
|
|
NS_DISPLAY_DECL_NAME("nsDisplayCanvas", TYPE_CANVAS)
|
2009-03-05 05:43:45 -08:00
|
|
|
|
2011-01-02 17:48:09 -08:00
|
|
|
virtual nsRegion GetOpaqueRegion(nsDisplayListBuilder* aBuilder,
|
2014-02-24 06:41:56 -08:00
|
|
|
bool* aSnap) MOZ_OVERRIDE {
|
2012-04-10 04:24:18 -07:00
|
|
|
*aSnap = false;
|
2013-04-19 05:02:13 -07:00
|
|
|
nsIFrame* f = Frame();
|
2013-01-03 21:16:14 -08:00
|
|
|
HTMLCanvasElement *canvas =
|
|
|
|
HTMLCanvasElement::FromContent(f->GetContent());
|
2011-01-02 17:48:09 -08:00
|
|
|
nsRegion result;
|
|
|
|
if (canvas->GetIsOpaque()) {
|
2012-04-10 04:24:18 -07:00
|
|
|
result = GetBounds(aBuilder, aSnap);
|
2011-01-02 17:48:09 -08:00
|
|
|
}
|
|
|
|
return result;
|
2009-03-05 05:43:45 -08:00
|
|
|
}
|
|
|
|
|
2014-02-24 06:41:56 -08:00
|
|
|
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder,
|
|
|
|
bool* aSnap) MOZ_OVERRIDE {
|
2012-11-13 11:56:47 -08:00
|
|
|
*aSnap = true;
|
2013-04-19 05:02:13 -07:00
|
|
|
nsHTMLCanvasFrame* f = static_cast<nsHTMLCanvasFrame*>(Frame());
|
2010-08-13 03:01:58 -07:00
|
|
|
return f->GetInnerArea() + ToReferenceFrame();
|
2009-03-05 05:43:45 -08:00
|
|
|
}
|
2010-05-17 21:04:22 -07: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-05-17 21:04:22 -07:00
|
|
|
{
|
2010-07-15 14:07:46 -07:00
|
|
|
return static_cast<nsHTMLCanvasFrame*>(mFrame)->
|
2012-09-16 15:25:33 -07:00
|
|
|
BuildLayer(aBuilder, aManager, this, aContainerParameters);
|
2010-05-17 21:04:22 -07: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
|
|
|
{
|
2013-01-03 21:16:14 -08:00
|
|
|
if (HTMLCanvasElement::FromContent(mFrame->GetContent())->ShouldForceInactiveLayer(aManager))
|
2011-07-08 03:42:21 -07:00
|
|
|
return LAYER_INACTIVE;
|
|
|
|
|
2011-02-04 10:11:24 -08:00
|
|
|
// If compositing is cheap, just do that
|
2013-09-04 04:30:57 -07:00
|
|
|
if (aManager->IsCompositingCheap() ||
|
|
|
|
ActiveLayerTracker::IsContentActive(mFrame))
|
2011-02-04 10:11:24 -08:00
|
|
|
return mozilla::LAYER_ACTIVE;
|
|
|
|
|
2013-09-04 04:30:57 -07:00
|
|
|
return LAYER_INACTIVE;
|
2010-07-15 14:08:05 -07:00
|
|
|
}
|
2009-03-05 05:43:45 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIFrame*
|
|
|
|
NS_NewHTMLCanvasFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
|
|
|
{
|
|
|
|
return new (aPresShell) nsHTMLCanvasFrame(aContext);
|
|
|
|
}
|
|
|
|
|
2013-04-03 16:35:07 -07:00
|
|
|
NS_QUERYFRAME_HEAD(nsHTMLCanvasFrame)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsHTMLCanvasFrame)
|
|
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsContainerFrame)
|
|
|
|
|
2009-09-12 09:49:24 -07:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsHTMLCanvasFrame)
|
|
|
|
|
2013-03-19 18:47:48 -07:00
|
|
|
void
|
2014-05-24 15:20:40 -07:00
|
|
|
nsHTMLCanvasFrame::Init(nsIContent* aContent,
|
|
|
|
nsContainerFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow)
|
2011-02-04 10:11:24 -08:00
|
|
|
{
|
2013-03-21 12:09:15 -07:00
|
|
|
nsContainerFrame::Init(aContent, aParent, aPrevInFlow);
|
2011-02-04 10:11:24 -08:00
|
|
|
|
|
|
|
// We can fill in the canvas before the canvas frame is created, in
|
2013-09-04 04:30:57 -07:00
|
|
|
// which case we never get around to marking the content as active. Therefore,
|
2011-02-04 10:11:24 -08:00
|
|
|
// we mark it active here when we create the frame.
|
2013-09-04 04:30:57 -07:00
|
|
|
ActiveLayerTracker::NotifyContentChange(this);
|
2011-02-04 10:11:24 -08:00
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsHTMLCanvasFrame::~nsHTMLCanvasFrame()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-01-14 19:27:09 -08:00
|
|
|
nsIntSize
|
2007-03-22 10:30:00 -07:00
|
|
|
nsHTMLCanvasFrame::GetCanvasSize()
|
|
|
|
{
|
2010-05-17 21:04:22 -07:00
|
|
|
nsIntSize size(0,0);
|
2013-01-03 21:16:14 -08:00
|
|
|
HTMLCanvasElement *canvas =
|
|
|
|
HTMLCanvasElement::FromContentOrNull(GetContent());
|
2007-03-22 10:30:00 -07:00
|
|
|
if (canvas) {
|
2010-05-17 21:04:22 -07:00
|
|
|
size = canvas->GetSize();
|
2007-03-22 10:30:00 -07:00
|
|
|
} else {
|
|
|
|
NS_NOTREACHED("couldn't get canvas size");
|
|
|
|
}
|
|
|
|
|
2010-05-17 21:04:22 -07:00
|
|
|
return size;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ nscoord
|
2011-04-07 18:04:40 -07:00
|
|
|
nsHTMLCanvasFrame::GetMinWidth(nsRenderingContext *aRenderingContext)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
// XXX The caller doesn't account for constraints of the height,
|
|
|
|
// min-height, and max-height properties.
|
|
|
|
nscoord result = nsPresContext::CSSPixelsToAppUnits(GetCanvasSize().width);
|
|
|
|
DISPLAY_MIN_WIDTH(this, result);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ nscoord
|
2011-04-07 18:04:40 -07:00
|
|
|
nsHTMLCanvasFrame::GetPrefWidth(nsRenderingContext *aRenderingContext)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
// XXX The caller doesn't account for constraints of the height,
|
|
|
|
// min-height, and max-height properties.
|
|
|
|
nscoord result = nsPresContext::CSSPixelsToAppUnits(GetCanvasSize().width);
|
|
|
|
DISPLAY_PREF_WIDTH(this, result);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2007-06-12 11:27:09 -07:00
|
|
|
/* virtual */ nsSize
|
|
|
|
nsHTMLCanvasFrame::GetIntrinsicRatio()
|
|
|
|
{
|
2009-01-14 19:27:09 -08:00
|
|
|
nsIntSize size(GetCanvasSize());
|
|
|
|
return nsSize(nsPresContext::CSSPixelsToAppUnits(size.width),
|
|
|
|
nsPresContext::CSSPixelsToAppUnits(size.height));
|
2007-06-12 11:27:09 -07:00
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/* virtual */ nsSize
|
2011-04-07 18:04:40 -07:00
|
|
|
nsHTMLCanvasFrame::ComputeSize(nsRenderingContext *aRenderingContext,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsSize aCBSize, nscoord aAvailableWidth,
|
|
|
|
nsSize aMargin, nsSize aBorder, nsSize aPadding,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t aFlags)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2009-01-14 19:27:09 -08:00
|
|
|
nsIntSize size = GetCanvasSize();
|
2007-11-18 04:09:03 -08:00
|
|
|
|
|
|
|
IntrinsicSize intrinsicSize;
|
|
|
|
intrinsicSize.width.SetCoordValue(nsPresContext::CSSPixelsToAppUnits(size.width));
|
|
|
|
intrinsicSize.height.SetCoordValue(nsPresContext::CSSPixelsToAppUnits(size.height));
|
|
|
|
|
2009-01-14 19:27:09 -08:00
|
|
|
nsSize intrinsicRatio = GetIntrinsicRatio(); // won't actually be used
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
return nsLayoutUtils::ComputeSizeWithIntrinsicDimensions(
|
2007-11-18 04:09:03 -08:00
|
|
|
aRenderingContext, this,
|
|
|
|
intrinsicSize, intrinsicRatio, aCBSize,
|
|
|
|
aMargin, aBorder, aPadding);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2014-05-12 17:47:52 -07:00
|
|
|
void
|
2007-03-22 10:30:00 -07:00
|
|
|
nsHTMLCanvasFrame::Reflow(nsPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aMetrics,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsHTMLCanvasFrame");
|
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowState, aMetrics, aStatus);
|
|
|
|
NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
|
|
|
|
("enter nsHTMLCanvasFrame::Reflow: availSize=%d,%d",
|
2013-12-27 09:59:21 -08:00
|
|
|
aReflowState.AvailableWidth(), aReflowState.AvailableHeight()));
|
2007-03-22 10:30:00 -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();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// stash this away so we can compute our inner area later
|
2013-12-27 09:59:21 -08:00
|
|
|
mBorderPadding = aReflowState.ComputedPhysicalBorderPadding();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-12-27 09:59:52 -08:00
|
|
|
aMetrics.Width() += mBorderPadding.left + mBorderPadding.right;
|
|
|
|
aMetrics.Height() += mBorderPadding.top + mBorderPadding.bottom;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
if (GetPrevInFlow()) {
|
2013-12-27 09:59:52 -08:00
|
|
|
nscoord y = GetContinuationOffset(&aMetrics.Width());
|
|
|
|
aMetrics.Height() -= y + mBorderPadding.top;
|
|
|
|
aMetrics.Height() = std::max(0, aMetrics.Height());
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2010-10-06 21:25:46 -07:00
|
|
|
aMetrics.SetOverflowAreasToDesiredBounds();
|
2007-03-22 10:30:00 -07:00
|
|
|
FinishAndStoreOverflow(&aMetrics);
|
|
|
|
|
2012-02-17 20:26:37 -08:00
|
|
|
// Reflow the single anon block child.
|
|
|
|
nsReflowStatus childStatus;
|
|
|
|
nsSize availSize(aReflowState.ComputedWidth(), NS_UNCONSTRAINEDSIZE);
|
|
|
|
nsIFrame* childFrame = mFrames.FirstChild();
|
|
|
|
NS_ASSERTION(!childFrame->GetNextSibling(), "HTML canvas should have 1 kid");
|
2013-12-27 09:59:52 -08:00
|
|
|
nsHTMLReflowMetrics childDesiredSize(aReflowState.GetWritingMode(), aMetrics.mFlags);
|
2012-02-17 20:26:37 -08:00
|
|
|
nsHTMLReflowState childReflowState(aPresContext, aReflowState, childFrame,
|
|
|
|
availSize);
|
|
|
|
ReflowChild(childFrame, aPresContext, childDesiredSize, childReflowState,
|
2012-07-30 07:20:58 -07:00
|
|
|
0, 0, 0, childStatus, nullptr);
|
2014-01-16 17:34:44 -08:00
|
|
|
FinishReflowChild(childFrame, aPresContext, childDesiredSize,
|
|
|
|
&childReflowState, 0, 0, 0);
|
2012-02-17 20:26:37 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
|
|
|
|
("exit nsHTMLCanvasFrame::Reflow: size=%d,%d",
|
2013-12-27 09:59:52 -08:00
|
|
|
aMetrics.Width(), aMetrics.Height()));
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aMetrics);
|
|
|
|
}
|
|
|
|
|
|
|
|
// FIXME taken from nsImageFrame, but then had splittable frame stuff
|
|
|
|
// removed. That needs to be fixed.
|
|
|
|
nsRect
|
|
|
|
nsHTMLCanvasFrame::GetInnerArea() const
|
|
|
|
{
|
|
|
|
nsRect r;
|
|
|
|
r.x = mBorderPadding.left;
|
|
|
|
r.y = mBorderPadding.top;
|
|
|
|
r.width = mRect.width - mBorderPadding.left - mBorderPadding.right;
|
|
|
|
r.height = mRect.height - mBorderPadding.top - mBorderPadding.bottom;
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2010-05-17 21:04:22 -07:00
|
|
|
already_AddRefed<Layer>
|
|
|
|
nsHTMLCanvasFrame::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)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2010-08-13 03:01:58 -07:00
|
|
|
nsRect area = GetContentRect() - GetPosition() + aItem->ToReferenceFrame();
|
2013-01-03 21:16:14 -08:00
|
|
|
HTMLCanvasElement* element = static_cast<HTMLCanvasElement*>(GetContent());
|
2010-05-17 21:04:22 -07:00
|
|
|
nsIntSize canvasSize = GetCanvasSize();
|
2009-05-06 13:02:59 -07:00
|
|
|
|
2012-08-30 17:24:35 -07:00
|
|
|
nsPresContext* presContext = PresContext();
|
|
|
|
element->HandlePrintCallback(presContext->Type());
|
|
|
|
|
2010-05-17 21:04:22 -07:00
|
|
|
if (canvasSize.width <= 0 || canvasSize.height <= 0 || area.IsEmpty())
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-07-15 14:07:46 -07:00
|
|
|
CanvasLayer* oldLayer = static_cast<CanvasLayer*>
|
2012-08-28 22:47:15 -07:00
|
|
|
(aManager->GetLayerBuilder()->GetLeafLayerFor(aBuilder, aItem));
|
2011-03-27 16:59:47 -07:00
|
|
|
nsRefPtr<CanvasLayer> layer = element->GetCanvasLayer(aBuilder, oldLayer, aManager);
|
2010-05-17 21:04:22 -07:00
|
|
|
if (!layer)
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-05-17 21:04:22 -07:00
|
|
|
gfxRect r = gfxRect(presContext->AppUnitsToGfxUnits(area.x),
|
|
|
|
presContext->AppUnitsToGfxUnits(area.y),
|
|
|
|
presContext->AppUnitsToGfxUnits(area.width),
|
|
|
|
presContext->AppUnitsToGfxUnits(area.height));
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-05-17 21:04:22 -07:00
|
|
|
// Transform the canvas into 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-05-17 21:04:22 -07:00
|
|
|
transform.Scale(r.Width()/canvasSize.width, r.Height()/canvasSize.height);
|
2014-01-27 07:28:33 -08:00
|
|
|
layer->SetBaseTransform(gfx::Matrix4x4::From2D(transform));
|
2010-05-17 21:04:22 -07:00
|
|
|
layer->SetFilter(nsLayoutUtils::GetGraphicsFilterForFrame(this));
|
2011-02-22 21:38:09 -08:00
|
|
|
layer->SetVisibleRegion(nsIntRect(0, 0, canvasSize.width, canvasSize.height));
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-08-05 15:11:23 -07:00
|
|
|
return layer.forget();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-02-14 03:12:27 -08:00
|
|
|
void
|
2007-03-22 10:30:00 -07:00
|
|
|
nsHTMLCanvasFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
|
|
|
{
|
|
|
|
if (!IsVisibleForPainting(aBuilder))
|
2013-02-14 03:12:27 -08:00
|
|
|
return;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-02-14 03:08:08 -08:00
|
|
|
DisplayBorderBackgroundOutline(aBuilder, aLists);
|
2007-03-22 10:30:00 -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
|
|
|
|
2013-03-04 01:56:02 -08:00
|
|
|
aLists.Content()->AppendNewToTop(
|
2013-02-14 03:08:08 -08:00
|
|
|
new (aBuilder) nsDisplayCanvas(aBuilder, this));
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-03-04 01:56:02 -08:00
|
|
|
DisplaySelectionOverlay(aBuilder, aLists.Content(),
|
2013-02-14 03:08:08 -08:00
|
|
|
nsISelectionDisplay::DISPLAY_IMAGES);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsIAtom*
|
|
|
|
nsHTMLCanvasFrame::GetType() const
|
|
|
|
{
|
|
|
|
return nsGkAtoms::HTMLCanvasFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
// get the offset into the content area of the image where aImg starts if it is a continuation.
|
|
|
|
// from nsImageFrame
|
|
|
|
nscoord
|
|
|
|
nsHTMLCanvasFrame::GetContinuationOffset(nscoord* aWidth) const
|
|
|
|
{
|
|
|
|
nscoord offset = 0;
|
|
|
|
if (aWidth) {
|
|
|
|
*aWidth = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GetPrevInFlow()) {
|
|
|
|
for (nsIFrame* prevInFlow = GetPrevInFlow() ; prevInFlow; prevInFlow = prevInFlow->GetPrevInFlow()) {
|
|
|
|
nsRect rect = prevInFlow->GetRect();
|
|
|
|
if (aWidth) {
|
|
|
|
*aWidth = rect.width;
|
|
|
|
}
|
|
|
|
offset += rect.height;
|
|
|
|
}
|
|
|
|
offset -= mBorderPadding.top;
|
2013-01-15 04:22:03 -08:00
|
|
|
offset = std::max(0, offset);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
return offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef ACCESSIBILITY
|
2012-09-28 14:53:44 -07:00
|
|
|
a11y::AccType
|
|
|
|
nsHTMLCanvasFrame::AccessibleType()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-12-17 17:25:52 -08:00
|
|
|
return a11y::eHTMLCanvasType;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-01-05 15:31:14 -08:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2014-02-17 23:47:48 -08:00
|
|
|
nsresult
|
2007-03-22 10:30:00 -07:00
|
|
|
nsHTMLCanvasFrame::GetFrameName(nsAString& aResult) const
|
|
|
|
{
|
|
|
|
return MakeFrameName(NS_LITERAL_STRING("HTMLCanvas"), aResult);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|