layout/generic/nsHTMLCanvasFrame.h

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:53e336ab0d9c
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 }
20 }
21
22 class nsPresContext;
23 class nsDisplayItem;
24 class nsAString;
25
26 nsIFrame* NS_NewHTMLCanvasFrame (nsIPresShell* aPresShell, nsStyleContext* aContext);
27
28 class nsHTMLCanvasFrame : 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_TARGET(nsHTMLCanvasFrame)
36 NS_DECL_QUERYFRAME
37 NS_DECL_FRAMEARENA_HELPERS
38
39 nsHTMLCanvasFrame(nsStyleContext* aContext) : nsContainerFrame(aContext) {}
40
41 virtual void Init(nsIContent* aContent,
42 nsIFrame* aParent,
43 nsIFrame* aPrevInFlow) MOZ_OVERRIDE;
44
45 virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
46 const nsRect& aDirtyRect,
47 const nsDisplayListSet& aLists) MOZ_OVERRIDE;
48
49 already_AddRefed<Layer> BuildLayer(nsDisplayListBuilder* aBuilder,
50 LayerManager* aManager,
51 nsDisplayItem* aItem,
52 const ContainerLayerParameters& aContainerParameters);
53
54 /* get the size of the canvas's image */
55 nsIntSize GetCanvasSize();
56
57 virtual nscoord GetMinWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE;
58 virtual nscoord GetPrefWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE;
59 virtual nsSize GetIntrinsicRatio() MOZ_OVERRIDE;
60
61 virtual nsSize ComputeSize(nsRenderingContext *aRenderingContext,
62 nsSize aCBSize, nscoord aAvailableWidth,
63 nsSize aMargin, nsSize aBorder, nsSize aPadding,
64 uint32_t aFlags) MOZ_OVERRIDE;
65
66 virtual nsresult Reflow(nsPresContext* aPresContext,
67 nsHTMLReflowMetrics& aDesiredSize,
68 const nsHTMLReflowState& aReflowState,
69 nsReflowStatus& aStatus) MOZ_OVERRIDE;
70
71 nsRect GetInnerArea() const;
72
73 #ifdef ACCESSIBILITY
74 virtual mozilla::a11y::AccType AccessibleType() MOZ_OVERRIDE;
75 #endif
76
77 virtual nsIAtom* GetType() const MOZ_OVERRIDE;
78
79 virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE
80 {
81 return nsSplittableFrame::IsFrameOfType(aFlags & ~(nsIFrame::eReplaced));
82 }
83
84 #ifdef DEBUG_FRAME_DUMP
85 virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE;
86 #endif
87
88 // Inserted child content gets its frames parented by our child block
89 virtual nsIFrame* GetContentInsertionFrame() MOZ_OVERRIDE {
90 return GetFirstPrincipalChild()->GetContentInsertionFrame();
91 }
92
93 protected:
94 virtual ~nsHTMLCanvasFrame();
95
96 nscoord GetContinuationOffset(nscoord* aWidth = 0) const;
97
98 nsMargin mBorderPadding;
99 };
100
101 #endif /* nsHTMLCanvasFrame_h___ */

mercurial