1 /* -*- Mode: C++; tab-width: 2; 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/. */
7 #ifndef mozilla_RubyUtils_h_
8 #define mozilla_RubyUtils_h_
10 #include "nsGkAtoms.h"
11 #include "nsRubyBaseContainerFrame.h"
12 #include "nsRubyTextContainerFrame.h"
19 * With some exceptions, each ruby internal box has two isizes, which
20 * are the reflowed isize and the final isize. The reflowed isize is
21 * what a box itself needs. It is determined when the box gets reflowed.
23 * The final isize is what a box should be as the final result. For a
24 * ruby base/text box, the final isize is the size of its ruby column.
25 * For a ruby base/text container, the final isize is the size of its
26 * ruby segment. The final isize is never smaller than the reflowed
27 * isize. It is initially determined when a ruby column/segment gets
28 * fully reflowed, and may be advanced when a box is expanded, e.g.
31 * The difference between the reflowed isize and the final isize is
32 * reserved in the line layout after reflowing a box, hence it is called
33 * "Reserved ISize" here. It is used to expand the ruby boxes from their
34 * reflowed isize to the final isize during alignment of the line.
36 * There are three exceptions for the final isize:
37 * 1. A ruby text container has a larger final isize only if it is for
38 * a span or collapsed annotations.
39 * 2. A ruby base container has a larger final isize only if at least
40 * one of its ruby text containers does.
41 * 3. If a ruby text container has a larger final isize, its children
48 static inline bool IsExpandableRubyBox(nsIFrame
* aFrame
)
50 nsIAtom
* type
= aFrame
->GetType();
51 return type
== nsGkAtoms::rubyBaseFrame
||
52 type
== nsGkAtoms::rubyTextFrame
||
53 type
== nsGkAtoms::rubyBaseContainerFrame
||
54 type
== nsGkAtoms::rubyTextContainerFrame
;
57 static void SetReservedISize(nsIFrame
* aFrame
, nscoord aISize
);
58 static void ClearReservedISize(nsIFrame
* aFrame
);
59 static nscoord
GetReservedISize(nsIFrame
* aFrame
);
63 * This class iterates all ruby text containers paired with
64 * the given ruby base container.
66 class MOZ_STACK_CLASS RubyTextContainerIterator
69 explicit RubyTextContainerIterator(nsRubyBaseContainerFrame
* aBaseContainer
);
72 bool AtEnd() const { return !mFrame
; }
73 nsRubyTextContainerFrame
* GetTextContainer() const
75 return static_cast<nsRubyTextContainerFrame
*>(mFrame
);
84 #endif /* !defined(mozilla_RubyUtils_h_) */