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/. */
7 /* rendering object for the HTML <canvas> element */
9 #ifndef nsHTMLCanvasFrame_h___
10 #define nsHTMLCanvasFrame_h___
12 #include "mozilla/Attributes.h"
13 #include "nsContainerFrame.h"
14 #include "nsStringFwd.h"
22 class WebRenderCanvasData
;
24 } // namespace mozilla
28 nsIFrame
* NS_NewHTMLCanvasFrame(mozilla::PresShell
* aPresShell
,
29 mozilla::ComputedStyle
* aStyle
);
31 class nsHTMLCanvasFrame final
: public nsContainerFrame
{
33 typedef mozilla::layers::CanvasRenderer CanvasRenderer
;
34 typedef mozilla::layers::LayerManager LayerManager
;
35 typedef mozilla::layers::WebRenderCanvasData WebRenderCanvasData
;
38 NS_DECL_FRAMEARENA_HELPERS(nsHTMLCanvasFrame
)
40 nsHTMLCanvasFrame(ComputedStyle
* aStyle
, nsPresContext
* aPresContext
)
41 : nsContainerFrame(aStyle
, aPresContext
, kClassID
) {}
43 virtual void BuildDisplayList(nsDisplayListBuilder
* aBuilder
,
44 const nsDisplayListSet
& aLists
) override
;
46 void Destroy(DestroyContext
&) override
;
48 bool UpdateWebRenderCanvasData(nsDisplayListBuilder
* aBuilder
,
49 WebRenderCanvasData
* aCanvasData
);
51 /* get the size of the canvas's image */
52 nsIntSize
GetCanvasSize() const;
54 virtual nscoord
GetMinISize(gfxContext
* aRenderingContext
) override
;
55 virtual nscoord
GetPrefISize(gfxContext
* aRenderingContext
) override
;
56 virtual mozilla::IntrinsicSize
GetIntrinsicSize() override
;
57 mozilla::AspectRatio
GetIntrinsicRatio() const override
;
59 void UnionChildOverflow(mozilla::OverflowAreas
& aOverflowAreas
) override
;
61 SizeComputationResult
ComputeSize(
62 gfxContext
* aRenderingContext
, mozilla::WritingMode aWM
,
63 const mozilla::LogicalSize
& aCBSize
, nscoord aAvailableISize
,
64 const mozilla::LogicalSize
& aMargin
,
65 const mozilla::LogicalSize
& aBorderPadding
,
66 const mozilla::StyleSizeOverrides
& aSizeOverrides
,
67 mozilla::ComputeSizeFlags aFlags
) override
;
69 virtual void Reflow(nsPresContext
* aPresContext
, ReflowOutput
& aDesiredSize
,
70 const ReflowInput
& aReflowInput
,
71 nsReflowStatus
& aStatus
) override
;
74 virtual mozilla::a11y::AccType
AccessibleType() override
;
77 #ifdef DEBUG_FRAME_DUMP
78 virtual nsresult
GetFrameName(nsAString
& aResult
) const override
;
81 // Inserted child content gets its frames parented by our child block
82 virtual nsContainerFrame
* GetContentInsertionFrame() override
{
83 return PrincipalChildList().FirstChild()->GetContentInsertionFrame();
86 // Return the ::-moz-html-canvas-content anonymous box.
87 void AppendDirectlyOwnedAnonBoxes(nsTArray
<OwnedAnonBox
>& aResult
) override
;
90 virtual ~nsHTMLCanvasFrame();
93 #endif /* nsHTMLCanvasFrame_h___ */