nsHTMLCanvasFrame.h (3071B)
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 "nsContainerFrame.h" 13 #include "nsStringFwd.h" 14 15 namespace mozilla { 16 class PresShell; 17 namespace layers { 18 class WebRenderCanvasData; 19 } // namespace layers 20 } // namespace mozilla 21 22 class nsPresContext; 23 24 nsIFrame* NS_NewHTMLCanvasFrame(mozilla::PresShell* aPresShell, 25 mozilla::ComputedStyle* aStyle); 26 27 class nsHTMLCanvasFrame final : public nsContainerFrame { 28 public: 29 using WebRenderCanvasData = mozilla::layers::WebRenderCanvasData; 30 31 NS_DECL_QUERYFRAME 32 NS_DECL_FRAMEARENA_HELPERS(nsHTMLCanvasFrame) 33 34 nsHTMLCanvasFrame(ComputedStyle* aStyle, nsPresContext* aPresContext) 35 : nsContainerFrame(aStyle, aPresContext, kClassID) {} 36 37 void BuildDisplayList(nsDisplayListBuilder* aBuilder, 38 const nsDisplayListSet& aLists) override; 39 40 void Destroy(DestroyContext&) override; 41 42 bool UpdateWebRenderCanvasData(nsDisplayListBuilder* aBuilder, 43 WebRenderCanvasData* aCanvasData); 44 45 // Get the size of the canvas's image in CSS pixels. 46 mozilla::CSSIntSize GetCanvasSize() const; 47 48 nscoord IntrinsicISize(const mozilla::IntrinsicSizeInput& aInput, 49 mozilla::IntrinsicISizeType aType) override; 50 51 mozilla::IntrinsicSize GetIntrinsicSize() override; 52 mozilla::AspectRatio GetIntrinsicRatio() const override; 53 54 void UnionChildOverflow(mozilla::OverflowAreas&, bool aAsIfScrolled) override; 55 56 SizeComputationResult ComputeSize( 57 const SizeComputationInput& aSizingInput, mozilla::WritingMode aWM, 58 const mozilla::LogicalSize& aCBSize, nscoord aAvailableISize, 59 const mozilla::LogicalSize& aMargin, 60 const mozilla::LogicalSize& aBorderPadding, 61 const mozilla::StyleSizeOverrides& aSizeOverrides, 62 mozilla::ComputeSizeFlags aFlags) override; 63 64 void Reflow(nsPresContext* aPresContext, ReflowOutput& aDesiredSize, 65 const ReflowInput& aReflowInput, 66 nsReflowStatus& aStatus) override; 67 68 nsRect GetDestRect(const nsRect& aFrameContentBox) const; 69 70 #ifdef ACCESSIBILITY 71 mozilla::a11y::AccType AccessibleType() override; 72 #endif 73 74 #ifdef DEBUG_FRAME_DUMP 75 nsresult GetFrameName(nsAString& aResult) const override; 76 #endif 77 78 // Inserted child content gets its frames parented by our child block 79 nsContainerFrame* GetContentInsertionFrame() override { 80 return PrincipalChildList().FirstChild()->GetContentInsertionFrame(); 81 } 82 83 // Return the ::-moz-html-canvas-content anonymous box. 84 void AppendDirectlyOwnedAnonBoxes(nsTArray<OwnedAnonBox>& aResult) override; 85 86 protected: 87 virtual ~nsHTMLCanvasFrame(); 88 }; 89 90 #endif /* nsHTMLCanvasFrame_h___ */