nsFirstLetterFrame.h (4363B)
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 nsFirstLetterFrame_h__ 8 #define nsFirstLetterFrame_h__ 9 10 /* rendering object for CSS :first-letter pseudo-element */ 11 12 #include "nsContainerFrame.h" 13 14 class nsFirstLetterFrame : public nsContainerFrame { 15 public: 16 NS_DECL_QUERYFRAME 17 NS_DECL_FRAMEARENA_HELPERS(nsFirstLetterFrame) 18 19 nsFirstLetterFrame(ComputedStyle* aStyle, nsPresContext* aPresContext, 20 ClassID aClassID) 21 : nsContainerFrame(aStyle, aPresContext, aClassID) {} 22 23 nsFirstLetterFrame(ComputedStyle* aStyle, nsPresContext* aPresContext) 24 : nsContainerFrame(aStyle, aPresContext, kClassID) {} 25 26 void BuildDisplayList(nsDisplayListBuilder* aBuilder, 27 const nsDisplayListSet& aLists) final; 28 29 void Init(nsIContent* aContent, nsContainerFrame* aParent, 30 nsIFrame* aPrevInFlow) final; 31 void SetInitialChildList(ChildListID aListID, nsFrameList&& aChildList) final; 32 #ifdef DEBUG_FRAME_DUMP 33 nsresult GetFrameName(nsAString& aResult) const final; 34 #endif 35 36 bool IsFloating() const { return HasAnyStateBits(NS_FRAME_OUT_OF_FLOW); } 37 38 nscoord IntrinsicISize(const mozilla::IntrinsicSizeInput& aInput, 39 mozilla::IntrinsicISizeType aType) final; 40 41 void AddInlineMinISize(const mozilla::IntrinsicSizeInput& aInput, 42 InlineMinISizeData* aData) final; 43 void AddInlinePrefISize(const mozilla::IntrinsicSizeInput& aInput, 44 InlinePrefISizeData* aData) final; 45 46 SizeComputationResult ComputeSize( 47 const SizeComputationInput& aSizingInput, mozilla::WritingMode aWM, 48 const mozilla::LogicalSize& aCBSize, nscoord aAvailableISize, 49 const mozilla::LogicalSize& aMargin, 50 const mozilla::LogicalSize& aBorderPadding, 51 const mozilla::StyleSizeOverrides& aSizeOverrides, 52 mozilla::ComputeSizeFlags aFlags) final; 53 54 void Reflow(nsPresContext* aPresContext, ReflowOutput& aDesiredSize, 55 const ReflowInput& aReflowInput, nsReflowStatus& aStatus) final; 56 57 bool CanContinueTextRun() const final; 58 Maybe<nscoord> GetNaturalBaselineBOffset(mozilla::WritingMode aWM, 59 BaselineSharingGroup aBaselineGroup, 60 BaselineExportContext) const final; 61 LogicalSides GetLogicalSkipSides() const final; 62 63 // final of nsFrame method 64 nsresult GetChildFrameContainingOffset(int32_t inContentOffset, bool inHint, 65 int32_t* outFrameContentOffset, 66 nsIFrame** outChildFrame) final; 67 68 nscoord GetFirstLetterBaseline() const { return mBaseline; } 69 70 // For floating first letter frames, create a continuation for aChild and 71 // place it in the correct place. aContinuation is an outparam for the 72 // continuation that is created. aIsFluid determines if the continuation is 73 // fluid or not. 74 void CreateContinuationForFloatingParent(nsIFrame* aChild, 75 nsIFrame** aContinuation, 76 bool aIsFluid); 77 78 // Create a new continuation for the first-letter frame (to hold text that 79 // is not part of the first-letter range), and move any frames after aFrame 80 // to it; if there are none, create a new text continuation there instead. 81 // Returns the first text frame of the new continuation. 82 nsTextFrame* CreateContinuationForFramesAfter(nsTextFrame* aFrame); 83 84 // Whether to use tight glyph bounds for a floating first-letter frame, 85 // or "loose" bounds based on font metrics rather than individual glyphs. 86 bool UseTightBounds() const; 87 88 protected: 89 nscoord mBaseline; 90 91 void DrainOverflowFrames(nsPresContext* aPresContext); 92 }; 93 94 class nsFloatingFirstLetterFrame : public nsFirstLetterFrame { 95 public: 96 NS_DECL_QUERYFRAME 97 NS_DECL_FRAMEARENA_HELPERS(nsFloatingFirstLetterFrame) 98 99 nsFloatingFirstLetterFrame(ComputedStyle* aStyle, nsPresContext* aPresContext) 100 : nsFirstLetterFrame(aStyle, aPresContext, kClassID) {} 101 }; 102 103 #endif /* nsFirstLetterFrame_h__ */