Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | /* rendering object for the HTML <canvas> element */ |
michael@0 | 7 | |
michael@0 | 8 | #ifndef nsHTMLCanvasFrame_h___ |
michael@0 | 9 | #define nsHTMLCanvasFrame_h___ |
michael@0 | 10 | |
michael@0 | 11 | #include "mozilla/Attributes.h" |
michael@0 | 12 | #include "nsContainerFrame.h" |
michael@0 | 13 | #include "FrameLayerBuilder.h" |
michael@0 | 14 | |
michael@0 | 15 | namespace mozilla { |
michael@0 | 16 | namespace layers { |
michael@0 | 17 | class Layer; |
michael@0 | 18 | class LayerManager; |
michael@0 | 19 | } |
michael@0 | 20 | } |
michael@0 | 21 | |
michael@0 | 22 | class nsPresContext; |
michael@0 | 23 | class nsDisplayItem; |
michael@0 | 24 | class nsAString; |
michael@0 | 25 | |
michael@0 | 26 | nsIFrame* NS_NewHTMLCanvasFrame (nsIPresShell* aPresShell, nsStyleContext* aContext); |
michael@0 | 27 | |
michael@0 | 28 | class nsHTMLCanvasFrame : public nsContainerFrame |
michael@0 | 29 | { |
michael@0 | 30 | public: |
michael@0 | 31 | typedef mozilla::layers::Layer Layer; |
michael@0 | 32 | typedef mozilla::layers::LayerManager LayerManager; |
michael@0 | 33 | typedef mozilla::ContainerLayerParameters ContainerLayerParameters; |
michael@0 | 34 | |
michael@0 | 35 | NS_DECL_QUERYFRAME_TARGET(nsHTMLCanvasFrame) |
michael@0 | 36 | NS_DECL_QUERYFRAME |
michael@0 | 37 | NS_DECL_FRAMEARENA_HELPERS |
michael@0 | 38 | |
michael@0 | 39 | nsHTMLCanvasFrame(nsStyleContext* aContext) : nsContainerFrame(aContext) {} |
michael@0 | 40 | |
michael@0 | 41 | virtual void Init(nsIContent* aContent, |
michael@0 | 42 | nsIFrame* aParent, |
michael@0 | 43 | nsIFrame* aPrevInFlow) MOZ_OVERRIDE; |
michael@0 | 44 | |
michael@0 | 45 | virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder, |
michael@0 | 46 | const nsRect& aDirtyRect, |
michael@0 | 47 | const nsDisplayListSet& aLists) MOZ_OVERRIDE; |
michael@0 | 48 | |
michael@0 | 49 | already_AddRefed<Layer> BuildLayer(nsDisplayListBuilder* aBuilder, |
michael@0 | 50 | LayerManager* aManager, |
michael@0 | 51 | nsDisplayItem* aItem, |
michael@0 | 52 | const ContainerLayerParameters& aContainerParameters); |
michael@0 | 53 | |
michael@0 | 54 | /* get the size of the canvas's image */ |
michael@0 | 55 | nsIntSize GetCanvasSize(); |
michael@0 | 56 | |
michael@0 | 57 | virtual nscoord GetMinWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE; |
michael@0 | 58 | virtual nscoord GetPrefWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE; |
michael@0 | 59 | virtual nsSize GetIntrinsicRatio() MOZ_OVERRIDE; |
michael@0 | 60 | |
michael@0 | 61 | virtual nsSize ComputeSize(nsRenderingContext *aRenderingContext, |
michael@0 | 62 | nsSize aCBSize, nscoord aAvailableWidth, |
michael@0 | 63 | nsSize aMargin, nsSize aBorder, nsSize aPadding, |
michael@0 | 64 | uint32_t aFlags) MOZ_OVERRIDE; |
michael@0 | 65 | |
michael@0 | 66 | virtual nsresult Reflow(nsPresContext* aPresContext, |
michael@0 | 67 | nsHTMLReflowMetrics& aDesiredSize, |
michael@0 | 68 | const nsHTMLReflowState& aReflowState, |
michael@0 | 69 | nsReflowStatus& aStatus) MOZ_OVERRIDE; |
michael@0 | 70 | |
michael@0 | 71 | nsRect GetInnerArea() const; |
michael@0 | 72 | |
michael@0 | 73 | #ifdef ACCESSIBILITY |
michael@0 | 74 | virtual mozilla::a11y::AccType AccessibleType() MOZ_OVERRIDE; |
michael@0 | 75 | #endif |
michael@0 | 76 | |
michael@0 | 77 | virtual nsIAtom* GetType() const MOZ_OVERRIDE; |
michael@0 | 78 | |
michael@0 | 79 | virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE |
michael@0 | 80 | { |
michael@0 | 81 | return nsSplittableFrame::IsFrameOfType(aFlags & ~(nsIFrame::eReplaced)); |
michael@0 | 82 | } |
michael@0 | 83 | |
michael@0 | 84 | #ifdef DEBUG_FRAME_DUMP |
michael@0 | 85 | virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE; |
michael@0 | 86 | #endif |
michael@0 | 87 | |
michael@0 | 88 | // Inserted child content gets its frames parented by our child block |
michael@0 | 89 | virtual nsIFrame* GetContentInsertionFrame() MOZ_OVERRIDE { |
michael@0 | 90 | return GetFirstPrincipalChild()->GetContentInsertionFrame(); |
michael@0 | 91 | } |
michael@0 | 92 | |
michael@0 | 93 | protected: |
michael@0 | 94 | virtual ~nsHTMLCanvasFrame(); |
michael@0 | 95 | |
michael@0 | 96 | nscoord GetContinuationOffset(nscoord* aWidth = 0) const; |
michael@0 | 97 | |
michael@0 | 98 | nsMargin mBorderPadding; |
michael@0 | 99 | }; |
michael@0 | 100 | |
michael@0 | 101 | #endif /* nsHTMLCanvasFrame_h___ */ |