author Ting-Yu Lin <>
Tue, 26 Jan 2021 02:47:40 +0000
changeset 564614 5279b71d0068a178739da9dcd57ec7c558781222
parent 564586 f8446e5139b64669581d5ba6667ea74f4a57ff87
permissions -rw-r--r--
Bug 1686603 Part 2 - Add StyleSizeOverrides parameter to ReflowInput's constructor & co. to override data from style system data. r=dholbert This patch adds the struct as a parameter to various functions. The struct is cached in ReflowInput so that we don't need to pass it down to the internal method where nsIFrame::ComputeSize() is called. In the subsequent patches, we'll use it to revise the implementation of flex container's flex base size resolution, and size overrides. Differential Revision:

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at */

#ifndef nsFirstLetterFrame_h__
#define nsFirstLetterFrame_h__

/* rendering object for CSS :first-letter pseudo-element */

#include "mozilla/Attributes.h"
#include "nsContainerFrame.h"

class nsFirstLetterFrame final : public nsContainerFrame {

  explicit nsFirstLetterFrame(ComputedStyle* aStyle,
                              nsPresContext* aPresContext)
      : nsContainerFrame(aStyle, aPresContext, kClassID) {}

  virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
                                const nsDisplayListSet& aLists) override;

  virtual void Init(nsIContent* aContent, nsContainerFrame* aParent,
                    nsIFrame* aPrevInFlow) override;
  virtual void SetInitialChildList(ChildListID aListID,
                                   nsFrameList& aChildList) override;
  virtual nsresult GetFrameName(nsAString& aResult) const override;

  bool IsFloating() const { return HasAnyStateBits(NS_FRAME_OUT_OF_FLOW); }

  virtual bool IsFrameOfType(uint32_t aFlags) const override {
    if (!IsFloating()) aFlags = aFlags & ~(nsIFrame::eLineParticipant);
    return nsContainerFrame::IsFrameOfType(aFlags &

  virtual nscoord GetMinISize(gfxContext* aRenderingContext) override;
  virtual nscoord GetPrefISize(gfxContext* aRenderingContext) override;
  virtual void AddInlineMinISize(gfxContext* aRenderingContext,
                                 InlineMinISizeData* aData) override;
  virtual void AddInlinePrefISize(gfxContext* aRenderingContext,
                                  InlinePrefISizeData* aData) override;

  SizeComputationResult ComputeSize(
      gfxContext* aRenderingContext, mozilla::WritingMode aWM,
      const mozilla::LogicalSize& aCBSize, nscoord aAvailableISize,
      const mozilla::LogicalSize& aMargin,
      const mozilla::LogicalSize& aBorderPadding,
      const mozilla::StyleSizeOverrides& aSizeOverrides,
      mozilla::ComputeSizeFlags aFlags) override;

  virtual void Reflow(nsPresContext* aPresContext, ReflowOutput& aDesiredSize,
                      const ReflowInput& aReflowInput,
                      nsReflowStatus& aStatus) override;

  virtual bool CanContinueTextRun() const override;
  virtual nscoord GetLogicalBaseline(
      mozilla::WritingMode aWritingMode) const override;
  virtual LogicalSides GetLogicalSkipSides() const override;

  // override of nsFrame method
  virtual nsresult GetChildFrameContainingOffset(
      int32_t inContentOffset, bool inHint, int32_t* outFrameContentOffset,
      nsIFrame** outChildFrame) override;

  nscoord GetFirstLetterBaseline() const { return mBaseline; }

  // For floating first letter frames, create a continuation for aChild and
  // place it in the correct place. aContinuation is an outparam for the
  // continuation that is created. aIsFluid determines if the continuation is
  // fluid or not.
  void CreateContinuationForFloatingParent(nsIFrame* aChild,
                                           nsIFrame** aContinuation,
                                           bool aIsFluid);

  nscoord mBaseline;

  void DrainOverflowFrames(nsPresContext* aPresContext);

#endif /* nsFirstLetterFrame_h__ */