layout/tables/BasicTableLayoutStrategy.h

Fri, 16 Jan 2015 18:13:44 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 18:13:44 +0100
branch
TOR_BUG_9701
changeset 14
925c144e1f1f
permissions
-rw-r--r--

Integrate suggestion from review to improve consistency with existing code.

     1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     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/. */
     7 /*
     8  * Web-compatible algorithms that determine column and table widths,
     9  * used for CSS2's 'table-layout: auto'.
    10  */
    12 #ifndef BasicTableLayoutStrategy_h_
    13 #define BasicTableLayoutStrategy_h_
    15 #include "mozilla/Attributes.h"
    16 #include "nsITableLayoutStrategy.h"
    18 class nsTableFrame;
    20 class BasicTableLayoutStrategy : public nsITableLayoutStrategy
    21 {
    22 public:
    23     BasicTableLayoutStrategy(nsTableFrame *aTableFrame);
    24     virtual ~BasicTableLayoutStrategy();
    26     // nsITableLayoutStrategy implementation
    27     virtual nscoord GetMinWidth(nsRenderingContext* aRenderingContext) MOZ_OVERRIDE;
    28     virtual nscoord GetPrefWidth(nsRenderingContext* aRenderingContext,
    29                                  bool aComputingSize) MOZ_OVERRIDE;
    30     virtual void MarkIntrinsicWidthsDirty() MOZ_OVERRIDE;
    31     virtual void ComputeColumnWidths(const nsHTMLReflowState& aReflowState) MOZ_OVERRIDE;
    33 private:
    34     // NOTE: Using prefix "BTLS" to avoid overlapping names with 
    35     // the values of nsLayoutUtils::IntrinsicWidthType
    36     enum BtlsWidthType { BTLS_MIN_WIDTH, 
    37                          BTLS_PREF_WIDTH, 
    38                          BTLS_FINAL_WIDTH };
    40     // Compute intrinsic width member variables on the columns.
    41     void ComputeColumnIntrinsicWidths(nsRenderingContext* aRenderingContext);
    43     // Distribute a colspanning cell's percent width (if any) to its columns.
    44     void DistributePctWidthToColumns(float aSpanPrefPct,
    45                                      int32_t aFirstCol,
    46                                      int32_t aColCount);
    48     // Distribute a width of some BltsWidthType type to a set of columns.
    49     //  aWidth: The amount of width to be distributed
    50     //  aFirstCol: The index (in the table) of the first column to be
    51     //             considered for receiving width
    52     //  aColCount: The number of consecutive columns (starting with aFirstCol)
    53     //             to be considered for receiving width
    54     //  aWidthType: The type of width being distributed.  (BTLS_MIN_WIDTH and
    55     //              BTLS_PREF_WIDTH are intended to be used for dividing up
    56     //              colspan's min & pref width.  BTLS_FINAL_WIDTH is intended
    57     //              to be used for distributing the table's final width across
    58     //              all its columns)
    59     //  aSpanHasSpecifiedWidth: Should be true iff:
    60     //                           - We're distributing a colspanning cell's
    61     //                             pref or min width to its columns
    62     //                           - The colspanning cell has a specified width.
    63     void DistributeWidthToColumns(nscoord aWidth, 
    64                                   int32_t aFirstCol, 
    65                                   int32_t aColCount,
    66                                   BtlsWidthType aWidthType,
    67                                   bool aSpanHasSpecifiedWidth);
    70     // Compute the min and pref widths of the table from the width
    71     // variables on the columns.
    72     void ComputeIntrinsicWidths(nsRenderingContext* aRenderingContext);
    74     nsTableFrame *mTableFrame;
    75     nscoord mMinWidth;
    76     nscoord mPrefWidth;
    77     nscoord mPrefWidthPctExpand;
    78     nscoord mLastCalcWidth;
    79 };
    81 #endif /* !defined(BasicTableLayoutStrategy_h_) */

mercurial