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 CSS "display: ruby-base-container" */
8 
9 #ifndef nsRubyBaseContainerFrame_h___
10 #define nsRubyBaseContainerFrame_h___
11 
12 #include "nsContainerFrame.h"
13 #include "RubyUtils.h"
14 
15 namespace mozilla {
16 class PresShell;
17 }  // namespace mozilla
18 
19 /**
20  * Factory function.
21  * @return a newly allocated nsRubyBaseContainerFrame (infallible)
22  */
23 nsContainerFrame* NS_NewRubyBaseContainerFrame(mozilla::PresShell* aPresShell,
24                                                mozilla::ComputedStyle* aStyle);
25 
26 class nsRubyBaseContainerFrame final : public nsContainerFrame {
27  public:
28   NS_DECL_FRAMEARENA_HELPERS(nsRubyBaseContainerFrame)
29   NS_DECL_QUERYFRAME
30 
31   // nsIFrame overrides
32   virtual bool IsFrameOfType(uint32_t aFlags) const override;
33   virtual bool CanContinueTextRun() const override;
34   virtual void AddInlineMinISize(gfxContext* aRenderingContext,
35                                  InlineMinISizeData* aData) override;
36   virtual void AddInlinePrefISize(gfxContext* aRenderingContext,
37                                   InlinePrefISizeData* aData) override;
38   SizeComputationResult ComputeSize(
39       gfxContext* aRenderingContext, mozilla::WritingMode aWM,
40       const mozilla::LogicalSize& aCBSize, nscoord aAvailableISize,
41       const mozilla::LogicalSize& aMargin,
42       const mozilla::LogicalSize& aBorderPadding,
43       const mozilla::StyleSizeOverrides& aSizeOverrides,
44       mozilla::ComputeSizeFlags aFlags) override;
45   virtual void Reflow(nsPresContext* aPresContext, ReflowOutput& aDesiredSize,
46                       const ReflowInput& aReflowInput,
47                       nsReflowStatus& aStatus) override;
48 
49   virtual nscoord GetLogicalBaseline(
50       mozilla::WritingMode aWritingMode) const override;
51 
52 #ifdef DEBUG_FRAME_DUMP
53   virtual nsresult GetFrameName(nsAString& aResult) const override;
54 #endif
55 
UpdateDescendantLeadings(const mozilla::RubyBlockLeadings & aLeadings)56   void UpdateDescendantLeadings(const mozilla::RubyBlockLeadings& aLeadings) {
57     mDescendantLeadings.Update(aLeadings);
58   }
GetDescendantLeadings()59   mozilla::RubyBlockLeadings GetDescendantLeadings() const {
60     return mDescendantLeadings;
61   }
62 
63  protected:
64   friend nsContainerFrame* NS_NewRubyBaseContainerFrame(
65       mozilla::PresShell* aPresShell, ComputedStyle* aStyle);
66 
nsRubyBaseContainerFrame(ComputedStyle * aStyle,nsPresContext * aPresContext)67   explicit nsRubyBaseContainerFrame(ComputedStyle* aStyle,
68                                     nsPresContext* aPresContext)
69       : nsContainerFrame(aStyle, aPresContext, kClassID) {}
70 
71   struct RubyReflowInput;
72   nscoord ReflowColumns(const RubyReflowInput& aReflowInput,
73                         ReflowOutput& aDesiredSize, nsReflowStatus& aStatus);
74   nscoord ReflowOneColumn(const RubyReflowInput& aReflowInput,
75                           uint32_t aColumnIndex,
76                           const mozilla::RubyColumn& aColumn,
77                           ReflowOutput& aDesiredSize, nsReflowStatus& aStatus);
78   nscoord ReflowSpans(const RubyReflowInput& aReflowInput);
79 
80   struct PullFrameState;
81 
82   // Pull ruby base and corresponding ruby text frames from
83   // continuations after them.
84   void PullOneColumn(nsLineLayout* aLineLayout, PullFrameState& aPullFrameState,
85                      mozilla::RubyColumn& aColumn, bool& aIsComplete);
86 
87   nscoord mBaseline;
88 
89   // Leading produced by descendant ruby annotations.
90   mozilla::RubyBlockLeadings mDescendantLeadings;
91 };
92 
93 #endif /* nsRubyBaseContainerFrame_h___ */
94