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" */
8 
9 #ifndef nsRubyFrame_h___
10 #define nsRubyFrame_h___
11 
12 #include "nsInlineFrame.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 nsRubyFrame (infallible)
22  */
23 nsContainerFrame* NS_NewRubyFrame(mozilla::PresShell* aPresShell,
24                                   mozilla::ComputedStyle* aStyle);
25 
26 class nsRubyFrame final : public nsInlineFrame {
27  public:
28   NS_DECL_FRAMEARENA_HELPERS(nsRubyFrame)
29   NS_DECL_QUERYFRAME
30 
31   // nsIFrame overrides
32   virtual bool IsFrameOfType(uint32_t aFlags) const override;
33   virtual void AddInlineMinISize(gfxContext* aRenderingContext,
34                                  InlineMinISizeData* aData) override;
35   virtual void AddInlinePrefISize(gfxContext* aRenderingContext,
36                                   InlinePrefISizeData* aData) override;
37   virtual void Reflow(nsPresContext* aPresContext, ReflowOutput& aDesiredSize,
38                       const ReflowInput& aReflowInput,
39                       nsReflowStatus& aStatus) override;
40 
41 #ifdef DEBUG_FRAME_DUMP
42   virtual nsresult GetFrameName(nsAString& aResult) const override;
43 #endif
44 
GetBlockLeadings()45   mozilla::RubyBlockLeadings GetBlockLeadings() const { return mLeadings; }
46 
47  protected:
48   friend nsContainerFrame* NS_NewRubyFrame(mozilla::PresShell* aPresShell,
49                                            ComputedStyle* aStyle);
nsRubyFrame(ComputedStyle * aStyle,nsPresContext * aPresContext)50   explicit nsRubyFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
51       : nsInlineFrame(aStyle, aPresContext, kClassID) {}
52 
53   void ReflowSegment(nsPresContext* aPresContext,
54                      const ReflowInput& aReflowInput, nscoord aBlockStartAscent,
55                      nscoord aBlockSize,
56                      nsRubyBaseContainerFrame* aBaseContainer,
57                      nsReflowStatus& aStatus);
58 
59   nsRubyBaseContainerFrame* PullOneSegment(const nsLineLayout* aLineLayout,
60                                            ContinuationTraversingState& aState);
61 
62   // The leadings required to put the annotations. They are dummy-
63   // initialized to 0, and get meaningful values at first reflow.
64   mozilla::RubyBlockLeadings mLeadings;
65 };
66 
67 #endif /* nsRubyFrame_h___ */
68