tor-browser

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

BasicTableLayoutStrategy.h (3170B)


      1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 // vim:cindent:ts=4:et:sw=4:
      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 /*
      8 * Web-compatible algorithms that determine column and table isizes,
      9 * used for CSS2's 'table-layout: auto'.
     10 */
     11 
     12 #ifndef BasicTableLayoutStrategy_h_
     13 #define BasicTableLayoutStrategy_h_
     14 
     15 #include "nsITableLayoutStrategy.h"
     16 
     17 class nsTableFrame;
     18 
     19 class BasicTableLayoutStrategy : public nsITableLayoutStrategy {
     20 public:
     21  explicit BasicTableLayoutStrategy(nsTableFrame* aTableFrame);
     22  virtual ~BasicTableLayoutStrategy();
     23 
     24  // nsITableLayoutStrategy implementation
     25  virtual nscoord GetMinISize(gfxContext* aRenderingContext) override;
     26  virtual nscoord GetPrefISize(gfxContext* aRenderingContext,
     27                               bool aComputingSize) override;
     28  virtual void MarkIntrinsicISizesDirty() override;
     29  virtual void ComputeColumnISizes(const ReflowInput& aReflowInput) override;
     30 
     31 private:
     32  // NOTE: Using prefix "BTLS" to avoid overlapping names with
     33  // the values of mozilla::IntrinsicISizeType.
     34  enum class BtlsISizeType : uint8_t { MinISize, PrefISize, FinalISize };
     35 
     36  // Compute intrinsic isize member variables on the columns.
     37  void ComputeColumnIntrinsicISizes(gfxContext* aRenderingContext);
     38 
     39  // Distribute a colspanning cell's percent isize (if any) to its columns.
     40  void DistributePctISizeToColumns(float aSpanPrefPct, int32_t aFirstCol,
     41                                   int32_t aColCount);
     42 
     43  // Distribute an isize of some BltsISizeType type to a set of columns.
     44  //  aISize: The amount of isize to be distributed
     45  //  aFirstCol: The index (in the table) of the first column to be
     46  //             considered for receiving isize
     47  //  aColCount: The number of consecutive columns (starting with aFirstCol)
     48  //             to be considered for receiving isize
     49  //  aISizeType: The type of isize being distributed.  (BTLS_MIN_ISIZE and
     50  //              BTLS_PREF_ISIZE are intended to be used for dividing up
     51  //              colspan's min & pref isize.  BTLS_FINAL_ISIZE is intended
     52  //              to be used for distributing the table's final isize across
     53  //              all its columns)
     54  //  aSpanHasSpecifiedISize: Should be true iff:
     55  //                           - We're distributing a colspanning cell's
     56  //                             pref or min isize to its columns
     57  //                           - The colspanning cell has a specified isize.
     58  void DistributeISizeToColumns(nscoord aISize, int32_t aFirstCol,
     59                                int32_t aColCount, BtlsISizeType aISizeType,
     60                                bool aSpanHasSpecifiedISize);
     61 
     62  // Compute the min and pref isizes of the table from the isize
     63  // variables on the columns.
     64  void ComputeIntrinsicISizes(gfxContext* aRenderingContext);
     65 
     66  nsTableFrame* mTableFrame;
     67  nscoord mMinISize;
     68  nscoord mPrefISize;
     69  nscoord mPrefISizePctExpand;
     70  nscoord mLastCalcISize;
     71 };
     72 
     73 #endif /* !defined(BasicTableLayoutStrategy_h_) */