nsFieldSetFrame.h (4356B)
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 #ifndef nsFieldSetFrame_h___ 8 #define nsFieldSetFrame_h___ 9 10 #include "ImgDrawResult.h" 11 #include "nsContainerFrame.h" 12 13 namespace mozilla { 14 class ScrollContainerFrame; 15 } // namespace mozilla 16 17 class nsFieldSetFrame final : public nsContainerFrame { 18 typedef mozilla::image::ImgDrawResult ImgDrawResult; 19 20 public: 21 NS_DECL_FRAMEARENA_HELPERS(nsFieldSetFrame) 22 NS_DECL_QUERYFRAME 23 24 explicit nsFieldSetFrame(ComputedStyle* aStyle, nsPresContext* aPresContext); 25 26 nscoord IntrinsicISize(const mozilla::IntrinsicSizeInput& aInput, 27 mozilla::IntrinsicISizeType aType) override; 28 29 /** 30 * The area to paint box-shadows around. It's the border rect except 31 * when there's a <legend> we offset the y-position to the center of it. 32 */ 33 nsRect VisualBorderRectRelativeToSelf() const override; 34 35 void Reflow(nsPresContext* aPresContext, ReflowOutput& aDesiredSize, 36 const ReflowInput& aReflowInput, 37 nsReflowStatus& aStatus) override; 38 39 nscoord SynthesizeFallbackBaseline( 40 mozilla::WritingMode aWM, 41 BaselineSharingGroup aBaselineGroup) const override; 42 BaselineSharingGroup GetDefaultBaselineSharingGroup() const override; 43 Maybe<nscoord> GetNaturalBaselineBOffset( 44 mozilla::WritingMode aWM, BaselineSharingGroup aBaselineGroup, 45 BaselineExportContext aExportContext) const override; 46 47 void BuildDisplayList(nsDisplayListBuilder* aBuilder, 48 const nsDisplayListSet& aLists) override; 49 50 ImgDrawResult PaintBorder(nsDisplayListBuilder* aBuilder, 51 gfxContext& aRenderingContext, nsPoint aPt, 52 const nsRect& aDirtyRect); 53 54 void SetInitialChildList(ChildListID aListID, 55 nsFrameList&& aChildList) override; 56 void AppendFrames(ChildListID aListID, nsFrameList&& aFrameList) override; 57 void InsertFrames(ChildListID aListID, nsIFrame* aPrevFrame, 58 const nsLineList::iterator* aPrevFrameLine, 59 nsFrameList&& aFrameList) override; 60 #ifdef DEBUG 61 void RemoveFrame(DestroyContext&, ChildListID aListID, 62 nsIFrame* aOldFrame) override; 63 #endif 64 65 mozilla::ScrollContainerFrame* GetScrollTargetFrame() const override; 66 67 // Return the block wrapper around our kids. 68 void AppendDirectlyOwnedAnonBoxes(nsTArray<OwnedAnonBox>& aResult) override; 69 70 #ifdef ACCESSIBILITY 71 virtual mozilla::a11y::AccType AccessibleType() override; 72 #endif 73 74 #ifdef DEBUG_FRAME_DUMP 75 virtual nsresult GetFrameName(nsAString& aResult) const override { 76 return MakeFrameName(u"FieldSet"_ns, aResult); 77 } 78 #endif 79 80 /** 81 * Return the anonymous frame that contains all descendants except the legend 82 * frame. This can be a block/grid/flex/scroll frame. It always has 83 * the pseudo type nsCSSAnonBoxes::fieldsetContent. If it's a scroll frame, 84 * the scrolled frame can be a block/grid/flex frame. 85 * This may return null, for example for a fieldset that is a true overflow 86 * container. 87 */ 88 nsContainerFrame* GetInner() const; 89 90 nsContainerFrame* GetContentInsertionFrame() override { 91 if (auto* inner = GetInner()) { 92 return inner->GetContentInsertionFrame(); 93 } 94 return this; 95 } 96 97 /** 98 * Return the frame that represents the rendered legend if any. 99 * https://html.spec.whatwg.org/multipage/rendering.html#rendered-legend 100 */ 101 nsIFrame* GetLegend() const; 102 103 /** @see mLegendSpace below */ 104 nscoord LegendSpace() const { return mLegendSpace; } 105 106 protected: 107 /** 108 * Convenience method to create a continuation for aChild after we've 109 * reflowed it and got the reflow status aStatus. 110 */ 111 void EnsureChildContinuation(nsIFrame* aChild, const nsReflowStatus& aStatus); 112 113 mozilla::LogicalRect mLegendRect; 114 115 // This is how much to subtract from our inner frame's content-box block-size 116 // to account for a protruding legend. It's zero if there's no legend or 117 // the legend fits entirely inside our start border. 118 nscoord mLegendSpace; 119 }; 120 121 #endif // nsFieldSetFrame_h___