/src/mozilla-central/layout/generic/nsHTMLCanvasFrame.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 <canvas> element */ |
8 | | |
9 | | #ifndef nsHTMLCanvasFrame_h___ |
10 | | #define nsHTMLCanvasFrame_h___ |
11 | | |
12 | | #include "mozilla/Attributes.h" |
13 | | #include "nsContainerFrame.h" |
14 | | #include "nsStringFwd.h" |
15 | | #include "FrameLayerBuilder.h" |
16 | | |
17 | | namespace mozilla { |
18 | | namespace layers { |
19 | | class Layer; |
20 | | class LayerManager; |
21 | | class WebRenderCanvasData; |
22 | | } // namespace layers |
23 | | } // namespace mozilla |
24 | | |
25 | | class nsPresContext; |
26 | | class nsDisplayItem; |
27 | | |
28 | | nsIFrame* NS_NewHTMLCanvasFrame(nsIPresShell* aPresShell, |
29 | | mozilla::ComputedStyle* aStyle); |
30 | | |
31 | | class nsHTMLCanvasFrame final : public nsContainerFrame |
32 | | { |
33 | | public: |
34 | | typedef mozilla::layers::CanvasRenderer CanvasRenderer; |
35 | | typedef mozilla::layers::Layer Layer; |
36 | | typedef mozilla::layers::LayerManager LayerManager; |
37 | | typedef mozilla::layers::WebRenderCanvasData WebRenderCanvasData; |
38 | | typedef mozilla::ContainerLayerParameters ContainerLayerParameters; |
39 | | |
40 | | NS_DECL_QUERYFRAME |
41 | | NS_DECL_FRAMEARENA_HELPERS(nsHTMLCanvasFrame) |
42 | | |
43 | | explicit nsHTMLCanvasFrame(ComputedStyle* aStyle) |
44 | | : nsContainerFrame(aStyle, kClassID) |
45 | | , mBorderPadding(GetWritingMode()) |
46 | 0 | {} |
47 | | |
48 | | virtual void Init(nsIContent* aContent, |
49 | | nsContainerFrame* aParent, |
50 | | nsIFrame* aPrevInFlow) override; |
51 | | |
52 | | virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder, |
53 | | const nsDisplayListSet& aLists) override; |
54 | | |
55 | | already_AddRefed<Layer> BuildLayer(nsDisplayListBuilder* aBuilder, |
56 | | LayerManager* aManager, |
57 | | nsDisplayItem* aItem, |
58 | | const ContainerLayerParameters& aContainerParameters); |
59 | | |
60 | | bool UpdateWebRenderCanvasData(nsDisplayListBuilder* aBuilder, |
61 | | WebRenderCanvasData* aCanvasData); |
62 | | |
63 | | /* get the size of the canvas's image */ |
64 | | nsIntSize GetCanvasSize(); |
65 | | |
66 | | virtual nscoord GetMinISize(gfxContext *aRenderingContext) override; |
67 | | virtual nscoord GetPrefISize(gfxContext *aRenderingContext) override; |
68 | | virtual mozilla::IntrinsicSize GetIntrinsicSize() override; |
69 | | virtual nsSize GetIntrinsicRatio() override; |
70 | | |
71 | | virtual mozilla::LogicalSize |
72 | | ComputeSize(gfxContext *aRenderingContext, |
73 | | mozilla::WritingMode aWritingMode, |
74 | | const mozilla::LogicalSize& aCBSize, |
75 | | nscoord aAvailableISize, |
76 | | const mozilla::LogicalSize& aMargin, |
77 | | const mozilla::LogicalSize& aBorder, |
78 | | const mozilla::LogicalSize& aPadding, |
79 | | ComputeSizeFlags aFlags) override; |
80 | | |
81 | | virtual void Reflow(nsPresContext* aPresContext, |
82 | | ReflowOutput& aDesiredSize, |
83 | | const ReflowInput& aReflowInput, |
84 | | nsReflowStatus& aStatus) override; |
85 | | |
86 | | nsRect GetInnerArea() const; |
87 | | |
88 | | #ifdef ACCESSIBILITY |
89 | | virtual mozilla::a11y::AccType AccessibleType() override; |
90 | | #endif |
91 | | |
92 | | virtual bool IsFrameOfType(uint32_t aFlags) const override |
93 | 0 | { |
94 | 0 | return nsSplittableFrame::IsFrameOfType(aFlags & |
95 | 0 | ~(nsIFrame::eReplaced | nsIFrame::eReplacedSizing)); |
96 | 0 | } |
97 | | |
98 | | #ifdef DEBUG_FRAME_DUMP |
99 | | virtual nsresult GetFrameName(nsAString& aResult) const override; |
100 | | #endif |
101 | | |
102 | | // Inserted child content gets its frames parented by our child block |
103 | 0 | virtual nsContainerFrame* GetContentInsertionFrame() override { |
104 | 0 | return PrincipalChildList().FirstChild()->GetContentInsertionFrame(); |
105 | 0 | } |
106 | | |
107 | | // Return the ::-moz-html-canvas-content anonymous box. |
108 | | void AppendDirectlyOwnedAnonBoxes(nsTArray<OwnedAnonBox>& aResult) override; |
109 | | |
110 | | protected: |
111 | | virtual ~nsHTMLCanvasFrame(); |
112 | | |
113 | | nscoord GetContinuationOffset(nscoord* aWidth = 0) const; |
114 | | |
115 | | mozilla::LogicalMargin mBorderPadding; |
116 | | }; |
117 | | |
118 | | #endif /* nsHTMLCanvasFrame_h___ */ |