tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

AspectRatio.cpp (1418B)


      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/. */
      6 
      7 #include "AspectRatio.h"
      8 
      9 #include "mozilla/WritingModes.h"
     10 
     11 namespace mozilla {
     12 
     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);
     30 }
     31 
     32 }  // namespace mozilla