nsCanvasFrame.h (3769B)
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 that goes directly inside the document's scrollbars */ 8 9 #ifndef nsCanvasFrame_h___ 10 #define nsCanvasFrame_h___ 11 12 #include "mozilla/EventForwards.h" 13 #include "nsContainerFrame.h" 14 #include "nsDisplayList.h" 15 #include "nsIAnonymousContentCreator.h" 16 #include "nsIPopupContainer.h" 17 18 class nsPresContext; 19 class gfxContext; 20 21 /** 22 * Root frame class. 23 * 24 * The root frame is the parent frame for the document element's frame. 25 * It only supports having a single child frame which must be an area 26 * frame. 27 * @note nsCanvasFrame keeps overflow container continuations of its child 28 * frame in the main child list. 29 */ 30 class nsCanvasFrame final : public nsContainerFrame, 31 public nsIAnonymousContentCreator, 32 public nsIPopupContainer { 33 using Element = mozilla::dom::Element; 34 35 public: 36 explicit nsCanvasFrame(ComputedStyle* aStyle, nsPresContext* aPresContext) 37 : nsContainerFrame(aStyle, aPresContext, kClassID) {} 38 39 NS_DECL_QUERYFRAME 40 NS_DECL_FRAMEARENA_HELPERS(nsCanvasFrame) 41 42 Element* GetDefaultTooltip() override; 43 44 void Destroy(DestroyContext&) override; 45 46 void SetInitialChildList(ChildListID aListID, 47 nsFrameList&& aChildList) override; 48 void AppendFrames(ChildListID aListID, nsFrameList&& aFrameList) override; 49 void InsertFrames(ChildListID aListID, nsIFrame* aPrevFrame, 50 const nsLineList::iterator* aPrevFrameLine, 51 nsFrameList&& aFrameList) override; 52 #ifdef DEBUG 53 void RemoveFrame(DestroyContext&, ChildListID, nsIFrame*) override; 54 #endif 55 56 nscoord IntrinsicISize(const mozilla::IntrinsicSizeInput& aInput, 57 mozilla::IntrinsicISizeType aType) override; 58 59 void Reflow(nsPresContext* aPresContext, ReflowOutput& aDesiredSize, 60 const ReflowInput& aReflowInput, 61 nsReflowStatus& aStatus) override; 62 63 // nsIAnonymousContentCreator 64 nsresult CreateAnonymousContent(nsTArray<ContentInfo>& aElements) override; 65 void AppendAnonymousContentTo(nsTArray<nsIContent*>& aElements, 66 uint32_t aFilter) override; 67 68 void BuildDisplayList(nsDisplayListBuilder* aBuilder, 69 const nsDisplayListSet& aLists) override; 70 #ifdef DEBUG_FRAME_DUMP 71 nsresult GetFrameName(nsAString& aResult) const override; 72 #endif 73 nsIContent* GetContentForEvent(const mozilla::WidgetEvent*) const override; 74 nsRect CanvasArea() const; 75 76 protected: 77 nsCOMPtr<Element> mTooltipContent; 78 }; 79 80 namespace mozilla { 81 82 class nsDisplayCanvasBackgroundImage final : public nsDisplayBackgroundImage { 83 public: 84 explicit nsDisplayCanvasBackgroundImage(nsDisplayListBuilder* aBuilder, 85 nsIFrame* aFrame, 86 const InitData& aInitData) 87 : nsDisplayBackgroundImage(aBuilder, aFrame, aInitData) {} 88 89 void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) override; 90 91 // We still need to paint a background color as well as an image for this 92 // item, so we can't support this yet. 93 bool SupportsOptimizingToImage() const override { return false; } 94 95 bool IsSingleFixedPositionImage(nsDisplayListBuilder* aBuilder, 96 const nsRect& aClipRect, gfxRect* aDestRect); 97 98 NS_DISPLAY_DECL_NAME("CanvasBackgroundImage", TYPE_CANVAS_BACKGROUND_IMAGE) 99 }; 100 101 } // namespace mozilla 102 103 #endif /* nsCanvasFrame_h___ */