layout/tables/BasicTableLayoutStrategy.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/layout/tables/BasicTableLayoutStrategy.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,81 @@
     1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     1.5 +// vim:cindent:ts=4:et:sw=4:
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +/*
    1.11 + * Web-compatible algorithms that determine column and table widths,
    1.12 + * used for CSS2's 'table-layout: auto'.
    1.13 + */
    1.14 +
    1.15 +#ifndef BasicTableLayoutStrategy_h_
    1.16 +#define BasicTableLayoutStrategy_h_
    1.17 +
    1.18 +#include "mozilla/Attributes.h"
    1.19 +#include "nsITableLayoutStrategy.h"
    1.20 +
    1.21 +class nsTableFrame;
    1.22 +
    1.23 +class BasicTableLayoutStrategy : public nsITableLayoutStrategy
    1.24 +{
    1.25 +public:
    1.26 +    BasicTableLayoutStrategy(nsTableFrame *aTableFrame);
    1.27 +    virtual ~BasicTableLayoutStrategy();
    1.28 +
    1.29 +    // nsITableLayoutStrategy implementation
    1.30 +    virtual nscoord GetMinWidth(nsRenderingContext* aRenderingContext) MOZ_OVERRIDE;
    1.31 +    virtual nscoord GetPrefWidth(nsRenderingContext* aRenderingContext,
    1.32 +                                 bool aComputingSize) MOZ_OVERRIDE;
    1.33 +    virtual void MarkIntrinsicWidthsDirty() MOZ_OVERRIDE;
    1.34 +    virtual void ComputeColumnWidths(const nsHTMLReflowState& aReflowState) MOZ_OVERRIDE;
    1.35 +
    1.36 +private:
    1.37 +    // NOTE: Using prefix "BTLS" to avoid overlapping names with 
    1.38 +    // the values of nsLayoutUtils::IntrinsicWidthType
    1.39 +    enum BtlsWidthType { BTLS_MIN_WIDTH, 
    1.40 +                         BTLS_PREF_WIDTH, 
    1.41 +                         BTLS_FINAL_WIDTH };
    1.42 +
    1.43 +    // Compute intrinsic width member variables on the columns.
    1.44 +    void ComputeColumnIntrinsicWidths(nsRenderingContext* aRenderingContext);
    1.45 +
    1.46 +    // Distribute a colspanning cell's percent width (if any) to its columns.
    1.47 +    void DistributePctWidthToColumns(float aSpanPrefPct,
    1.48 +                                     int32_t aFirstCol,
    1.49 +                                     int32_t aColCount);
    1.50 +
    1.51 +    // Distribute a width of some BltsWidthType type to a set of columns.
    1.52 +    //  aWidth: The amount of width to be distributed
    1.53 +    //  aFirstCol: The index (in the table) of the first column to be
    1.54 +    //             considered for receiving width
    1.55 +    //  aColCount: The number of consecutive columns (starting with aFirstCol)
    1.56 +    //             to be considered for receiving width
    1.57 +    //  aWidthType: The type of width being distributed.  (BTLS_MIN_WIDTH and
    1.58 +    //              BTLS_PREF_WIDTH are intended to be used for dividing up
    1.59 +    //              colspan's min & pref width.  BTLS_FINAL_WIDTH is intended
    1.60 +    //              to be used for distributing the table's final width across
    1.61 +    //              all its columns)
    1.62 +    //  aSpanHasSpecifiedWidth: Should be true iff:
    1.63 +    //                           - We're distributing a colspanning cell's
    1.64 +    //                             pref or min width to its columns
    1.65 +    //                           - The colspanning cell has a specified width.
    1.66 +    void DistributeWidthToColumns(nscoord aWidth, 
    1.67 +                                  int32_t aFirstCol, 
    1.68 +                                  int32_t aColCount,
    1.69 +                                  BtlsWidthType aWidthType,
    1.70 +                                  bool aSpanHasSpecifiedWidth);
    1.71 + 
    1.72 +
    1.73 +    // Compute the min and pref widths of the table from the width
    1.74 +    // variables on the columns.
    1.75 +    void ComputeIntrinsicWidths(nsRenderingContext* aRenderingContext);
    1.76 +
    1.77 +    nsTableFrame *mTableFrame;
    1.78 +    nscoord mMinWidth;
    1.79 +    nscoord mPrefWidth;
    1.80 +    nscoord mPrefWidthPctExpand;
    1.81 +    nscoord mLastCalcWidth;
    1.82 +};
    1.83 +
    1.84 +#endif /* !defined(BasicTableLayoutStrategy_h_) */

mercurial