michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: // vim:cindent:ts=4:et:sw=4: michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /* michael@0: * Web-compatible algorithms that determine column and table widths, michael@0: * used for CSS2's 'table-layout: auto'. michael@0: */ michael@0: michael@0: #ifndef BasicTableLayoutStrategy_h_ michael@0: #define BasicTableLayoutStrategy_h_ michael@0: michael@0: #include "mozilla/Attributes.h" michael@0: #include "nsITableLayoutStrategy.h" michael@0: michael@0: class nsTableFrame; michael@0: michael@0: class BasicTableLayoutStrategy : public nsITableLayoutStrategy michael@0: { michael@0: public: michael@0: BasicTableLayoutStrategy(nsTableFrame *aTableFrame); michael@0: virtual ~BasicTableLayoutStrategy(); michael@0: michael@0: // nsITableLayoutStrategy implementation michael@0: virtual nscoord GetMinWidth(nsRenderingContext* aRenderingContext) MOZ_OVERRIDE; michael@0: virtual nscoord GetPrefWidth(nsRenderingContext* aRenderingContext, michael@0: bool aComputingSize) MOZ_OVERRIDE; michael@0: virtual void MarkIntrinsicWidthsDirty() MOZ_OVERRIDE; michael@0: virtual void ComputeColumnWidths(const nsHTMLReflowState& aReflowState) MOZ_OVERRIDE; michael@0: michael@0: private: michael@0: // NOTE: Using prefix "BTLS" to avoid overlapping names with michael@0: // the values of nsLayoutUtils::IntrinsicWidthType michael@0: enum BtlsWidthType { BTLS_MIN_WIDTH, michael@0: BTLS_PREF_WIDTH, michael@0: BTLS_FINAL_WIDTH }; michael@0: michael@0: // Compute intrinsic width member variables on the columns. michael@0: void ComputeColumnIntrinsicWidths(nsRenderingContext* aRenderingContext); michael@0: michael@0: // Distribute a colspanning cell's percent width (if any) to its columns. michael@0: void DistributePctWidthToColumns(float aSpanPrefPct, michael@0: int32_t aFirstCol, michael@0: int32_t aColCount); michael@0: michael@0: // Distribute a width of some BltsWidthType type to a set of columns. michael@0: // aWidth: The amount of width to be distributed michael@0: // aFirstCol: The index (in the table) of the first column to be michael@0: // considered for receiving width michael@0: // aColCount: The number of consecutive columns (starting with aFirstCol) michael@0: // to be considered for receiving width michael@0: // aWidthType: The type of width being distributed. (BTLS_MIN_WIDTH and michael@0: // BTLS_PREF_WIDTH are intended to be used for dividing up michael@0: // colspan's min & pref width. BTLS_FINAL_WIDTH is intended michael@0: // to be used for distributing the table's final width across michael@0: // all its columns) michael@0: // aSpanHasSpecifiedWidth: Should be true iff: michael@0: // - We're distributing a colspanning cell's michael@0: // pref or min width to its columns michael@0: // - The colspanning cell has a specified width. michael@0: void DistributeWidthToColumns(nscoord aWidth, michael@0: int32_t aFirstCol, michael@0: int32_t aColCount, michael@0: BtlsWidthType aWidthType, michael@0: bool aSpanHasSpecifiedWidth); michael@0: michael@0: michael@0: // Compute the min and pref widths of the table from the width michael@0: // variables on the columns. michael@0: void ComputeIntrinsicWidths(nsRenderingContext* aRenderingContext); michael@0: michael@0: nsTableFrame *mTableFrame; michael@0: nscoord mMinWidth; michael@0: nscoord mPrefWidth; michael@0: nscoord mPrefWidthPctExpand; michael@0: nscoord mLastCalcWidth; michael@0: }; michael@0: michael@0: #endif /* !defined(BasicTableLayoutStrategy_h_) */