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/. */
7 #include "AspectRatio.h"
9 #include "mozilla/WritingModes.h"
13 nscoord
AspectRatio::ComputeRatioDependentSize(
14 LogicalAxis aRatioDependentAxis
, const WritingMode
& aWM
,
15 nscoord aRatioDeterminingSize
,
16 const LogicalSize
& aContentBoxSizeToBoxSizingAdjust
) const {
18 "Infinite or zero ratio may have undefined behavior when "
19 "computing the size");
20 const LogicalSize
& boxSizingAdjust
= mUseBoxSizing
== UseBoxSizing::No
22 : aContentBoxSizeToBoxSizingAdjust
;
23 return aRatioDependentAxis
== LogicalAxis::eLogicalAxisInline
24 ? ConvertToWritingMode(aWM
).ApplyTo(aRatioDeterminingSize
+
25 boxSizingAdjust
.BSize(aWM
)) -
26 boxSizingAdjust
.ISize(aWM
)
27 : ConvertToWritingMode(aWM
).Inverted().ApplyTo(
28 aRatioDeterminingSize
+ boxSizingAdjust
.ISize(aWM
)) -
29 boxSizingAdjust
.BSize(aWM
);
32 } // namespace mozilla