Line data Source code
1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* This Source Code Form is subject to the terms of the Mozilla Public
3 : * License, v. 2.0. If a copy of the MPL was not distributed with this
4 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 :
6 : /* rendering object for the HTML <canvas> element */
7 :
8 : #ifndef nsHTMLCanvasFrame_h___
9 : #define nsHTMLCanvasFrame_h___
10 :
11 : #include "mozilla/Attributes.h"
12 : #include "nsContainerFrame.h"
13 : #include "FrameLayerBuilder.h"
14 :
15 : namespace mozilla {
16 : namespace layers {
17 : class Layer;
18 : class LayerManager;
19 : } // namespace layers
20 : } // namespace mozilla
21 :
22 : class nsPresContext;
23 : class nsDisplayItem;
24 : class nsAString;
25 :
26 : nsIFrame* NS_NewHTMLCanvasFrame (nsIPresShell* aPresShell, nsStyleContext* aContext);
27 :
28 : class nsHTMLCanvasFrame final : public nsContainerFrame
29 : {
30 : public:
31 : typedef mozilla::layers::Layer Layer;
32 : typedef mozilla::layers::LayerManager LayerManager;
33 : typedef mozilla::ContainerLayerParameters ContainerLayerParameters;
34 :
35 : NS_DECL_QUERYFRAME
36 0 : NS_DECL_FRAMEARENA_HELPERS(nsHTMLCanvasFrame)
37 :
38 0 : explicit nsHTMLCanvasFrame(nsStyleContext* aContext)
39 0 : : nsContainerFrame(aContext, kClassID)
40 0 : , mBorderPadding(GetWritingMode())
41 0 : {}
42 :
43 : virtual void Init(nsIContent* aContent,
44 : nsContainerFrame* aParent,
45 : nsIFrame* aPrevInFlow) override;
46 :
47 : virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
48 : const nsRect& aDirtyRect,
49 : const nsDisplayListSet& aLists) override;
50 :
51 : already_AddRefed<Layer> BuildLayer(nsDisplayListBuilder* aBuilder,
52 : LayerManager* aManager,
53 : nsDisplayItem* aItem,
54 : const ContainerLayerParameters& aContainerParameters);
55 :
56 : /* get the size of the canvas's image */
57 : nsIntSize GetCanvasSize();
58 :
59 : virtual nscoord GetMinISize(gfxContext *aRenderingContext) override;
60 : virtual nscoord GetPrefISize(gfxContext *aRenderingContext) override;
61 : virtual mozilla::IntrinsicSize GetIntrinsicSize() override;
62 : virtual nsSize GetIntrinsicRatio() override;
63 :
64 : virtual mozilla::LogicalSize
65 : ComputeSize(gfxContext *aRenderingContext,
66 : mozilla::WritingMode aWritingMode,
67 : const mozilla::LogicalSize& aCBSize,
68 : nscoord aAvailableISize,
69 : const mozilla::LogicalSize& aMargin,
70 : const mozilla::LogicalSize& aBorder,
71 : const mozilla::LogicalSize& aPadding,
72 : ComputeSizeFlags aFlags) override;
73 :
74 : virtual void Reflow(nsPresContext* aPresContext,
75 : ReflowOutput& aDesiredSize,
76 : const ReflowInput& aReflowInput,
77 : nsReflowStatus& aStatus) override;
78 :
79 : nsRect GetInnerArea() const;
80 :
81 : #ifdef ACCESSIBILITY
82 : virtual mozilla::a11y::AccType AccessibleType() override;
83 : #endif
84 :
85 0 : virtual bool IsFrameOfType(uint32_t aFlags) const override
86 : {
87 0 : return nsSplittableFrame::IsFrameOfType(aFlags &
88 0 : ~(nsIFrame::eReplaced | nsIFrame::eReplacedSizing));
89 : }
90 :
91 : #ifdef DEBUG_FRAME_DUMP
92 : virtual nsresult GetFrameName(nsAString& aResult) const override;
93 : #endif
94 :
95 : // Inserted child content gets its frames parented by our child block
96 0 : virtual nsContainerFrame* GetContentInsertionFrame() override {
97 0 : return PrincipalChildList().FirstChild()->GetContentInsertionFrame();
98 : }
99 :
100 : // Return the ::-moz-html-canvas-content anonymous box.
101 : void AppendDirectlyOwnedAnonBoxes(nsTArray<OwnedAnonBox>& aResult) override;
102 :
103 : protected:
104 : virtual ~nsHTMLCanvasFrame();
105 :
106 : nscoord GetContinuationOffset(nscoord* aWidth = 0) const;
107 :
108 : mozilla::LogicalMargin mBorderPadding;
109 : };
110 :
111 : #endif /* nsHTMLCanvasFrame_h___ */
|