Bug 1892041 - Part 1: Update test262 features. r=spidermonkey-reviewers,dminor
[gecko.git] / layout / generic / AspectRatio.cpp
blob0a8ef181e4185f4e879b5f81b633a7f29acbd2b6
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::Inline
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