tor-browser

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

LayoutStructs.h (2489B)


      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 /* Helper structs or classes used throughout the Layout module */
      8 
      9 #ifndef mozilla_LayoutStructs_h
     10 #define mozilla_LayoutStructs_h
     11 
     12 #include "mozilla/AspectRatio.h"
     13 #include "mozilla/ServoStyleConsts.h"
     14 
     15 namespace mozilla {
     16 
     17 /**
     18 * A set of StyleSizes used as an input parameter to various functions that
     19 * compute sizes like nsIFrame::ComputeSize(). If any of the member fields has a
     20 * value, the function may use the value instead of retrieving it from the
     21 * frame's style.
     22 *
     23 * The logical sizes are assumed to be in the associated frame's writing-mode.
     24 */
     25 struct StyleSizeOverrides {
     26  Maybe<StyleSize> mStyleISize;
     27  Maybe<StyleSize> mStyleBSize;
     28  Maybe<AspectRatio> mAspectRatio;
     29 
     30  bool HasAnyOverrides() const { return mStyleISize || mStyleBSize; }
     31  bool HasAnyLengthOverrides() const {
     32    return (mStyleISize && mStyleISize->ConvertsToLength()) ||
     33           (mStyleBSize && mStyleBSize->ConvertsToLength());
     34  }
     35 
     36  // By default, table wrapper frame considers the size overrides applied to
     37  // itself, so it creates any length size overrides for inner table frame by
     38  // subtracting the area occupied by the caption and border & padding according
     39  // to box-sizing.
     40  //
     41  // When this flag is true, table wrapper frame is required to apply the size
     42  // overrides to the inner table frame directly, without any modification,
     43  // which is useful for flex container to override the inner table frame's
     44  // preferred main size with 'flex-basis'.
     45  //
     46  // Note: if mStyleISize is a LengthPercentage, the inner table frame will
     47  // comply with the inline-size override without enforcing its min-content
     48  // inline-size in nsTableFrame::ComputeSize(). This is necessary so that small
     49  // flex-basis values like 'flex-basis:1%' can be resolved correctly; the
     50  // flexbox layout algorithm does still explicitly clamp to min-sizes *at a
     51  // later step*, after the flex-basis has been resolved -- so this flag won't
     52  // actually produce any user-visible tables whose final inline size is smaller
     53  // than their min-content inline size.
     54  bool mApplyOverridesVerbatim = false;
     55 };
     56 
     57 }  // namespace mozilla
     58 
     59 #endif  // mozilla_LayoutStructs_h