Bug 1800044 [wpt PR 36907] - Fix same URL navigation test, a=testonly
[gecko.git] / layout / generic / AspectRatio.cpp
blob2fe51fed5ee7e783438ee9a168f191dfc1c86908
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"
11 namespace mozilla {
13 nscoord AspectRatio::ComputeRatioDependentSize(
14 LogicalAxis aRatioDependentAxis, const WritingMode& aWM,
15 nscoord aRatioDeterminingSize,
16 const LogicalSize& aContentBoxSizeToBoxSizingAdjust) const {
17 MOZ_ASSERT(*this,
18 "Infinite or zero ratio may have undefined behavior when "
19 "computing the size");
20 const LogicalSize& boxSizingAdjust = mUseBoxSizing == UseBoxSizing::No
21 ? LogicalSize(aWM)
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