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-text-container" */
8 
9 #ifndef nsRubyTextContainerFrame_h___
10 #define nsRubyTextContainerFrame_h___
11 
12 #include "nsBlockFrame.h"
13 
14 namespace mozilla {
15 class PresShell;
16 }  // namespace mozilla
17 
18 /**
19  * Factory function.
20  * @return a newly allocated nsRubyTextContainerFrame (infallible)
21  */
22 nsContainerFrame* NS_NewRubyTextContainerFrame(mozilla::PresShell* aPresShell,
23                                                mozilla::ComputedStyle* aStyle);
24 
25 class nsRubyTextContainerFrame final : public nsContainerFrame {
26  public:
27   NS_DECL_FRAMEARENA_HELPERS(nsRubyTextContainerFrame)
28   NS_DECL_QUERYFRAME
29 
30   // nsIFrame overrides
31   virtual bool IsFrameOfType(uint32_t aFlags) const override;
32   virtual void Reflow(nsPresContext* aPresContext, ReflowOutput& aDesiredSize,
33                       const ReflowInput& aReflowInput,
34                       nsReflowStatus& aStatus) override;
35 
36 #ifdef DEBUG_FRAME_DUMP
37   virtual nsresult GetFrameName(nsAString& aResult) const override;
38 #endif
39 
40   // nsContainerFrame overrides
41   virtual void SetInitialChildList(ChildListID aListID,
42                                    nsFrameList& aChildList) override;
43   virtual void AppendFrames(ChildListID aListID,
44                             nsFrameList& aFrameList) override;
45   virtual void InsertFrames(ChildListID aListID, nsIFrame* aPrevFrame,
46                             const nsLineList::iterator* aPrevFrameLine,
47                             nsFrameList& aFrameList) override;
48   virtual void RemoveFrame(ChildListID aListID, nsIFrame* aOldFrame) override;
49 
IsSpanContainer()50   bool IsSpanContainer() const {
51     return GetStateBits() & NS_RUBY_TEXT_CONTAINER_IS_SPAN;
52   }
53 
54  protected:
55   friend nsContainerFrame* NS_NewRubyTextContainerFrame(
56       mozilla::PresShell* aPresShell, ComputedStyle* aStyle);
57 
nsRubyTextContainerFrame(ComputedStyle * aStyle,nsPresContext * aPresContext)58   explicit nsRubyTextContainerFrame(ComputedStyle* aStyle,
59                                     nsPresContext* aPresContext)
60       : nsContainerFrame(aStyle, aPresContext, kClassID), mISize(0) {}
61 
62   void UpdateSpanFlag();
63 
64   friend class nsRubyBaseContainerFrame;
SetISize(nscoord aISize)65   void SetISize(nscoord aISize) { mISize = aISize; }
66 
67   // The intended inline size of the ruby text container. It is set by
68   // the corresponding ruby base container when the segment is reflowed,
69   // and used when the ruby text container is reflowed by its parent.
70   nscoord mISize;
71 };
72 
73 #endif /* nsRubyTextContainerFrame_h___ */
74