Bumping manifests a=b2g-bump
[gecko.git] / layout / generic / RubyUtils.h
blob5ccb71c2fda73a7b8f8952a4a2e5b1196d8d4a8d
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"
14 namespace mozilla {
16 /**
17 * Reserved ISize
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.
29 * for justification.
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
42 * must not have.
45 class RubyUtils
47 public:
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);
62 /**
63 * This class iterates all ruby text containers paired with
64 * the given ruby base container.
66 class MOZ_STACK_CLASS RubyTextContainerIterator
68 public:
69 explicit RubyTextContainerIterator(nsRubyBaseContainerFrame* aBaseContainer);
71 void Next();
72 bool AtEnd() const { return !mFrame; }
73 nsRubyTextContainerFrame* GetTextContainer() const
75 return static_cast<nsRubyTextContainerFrame*>(mFrame);
78 private:
79 nsIFrame* mFrame;
84 #endif /* !defined(mozilla_RubyUtils_h_) */