Bumping manifests a=b2g-bump
[gecko.git] / layout / generic / RubyUtils.cpp
blobe1a9d7a1fb72117fe88e6c3baea4ec533ec4acf2
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 #include "RubyUtils.h"
9 using namespace mozilla;
11 NS_DECLARE_FRAME_PROPERTY(ReservedISize, nullptr);
13 union NSCoordValue
15 nscoord mCoord;
16 void* mPointer;
17 static_assert(sizeof(nscoord) <= sizeof(void*),
18 "Cannot store nscoord in pointer");
21 /* static */ void
22 RubyUtils::SetReservedISize(nsIFrame* aFrame, nscoord aISize)
24 MOZ_ASSERT(IsExpandableRubyBox(aFrame));
25 NSCoordValue value = { aISize };
26 aFrame->Properties().Set(ReservedISize(), value.mPointer);
29 /* static */ void
30 RubyUtils::ClearReservedISize(nsIFrame* aFrame)
32 MOZ_ASSERT(IsExpandableRubyBox(aFrame));
33 aFrame->Properties().Remove(ReservedISize());
36 /* static */ nscoord
37 RubyUtils::GetReservedISize(nsIFrame* aFrame)
39 MOZ_ASSERT(IsExpandableRubyBox(aFrame));
40 NSCoordValue value;
41 value.mPointer = aFrame->Properties().Get(ReservedISize());
42 return value.mCoord;
45 RubyTextContainerIterator::RubyTextContainerIterator(
46 nsRubyBaseContainerFrame* aBaseContainer)
48 mFrame = aBaseContainer;
49 Next();
52 void
53 RubyTextContainerIterator::Next()
55 MOZ_ASSERT(mFrame, "Should have checked AtEnd()");
56 mFrame = mFrame->GetNextSibling();
57 if (mFrame && mFrame->GetType() != nsGkAtoms::rubyTextContainerFrame) {
58 mFrame = nullptr;