Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
michael@0 | 2 | // vim:cindent:ts=4:et:sw=4: |
michael@0 | 3 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | /* |
michael@0 | 8 | * Web-compatible algorithms that determine column and table widths, |
michael@0 | 9 | * used for CSS2's 'table-layout: auto'. |
michael@0 | 10 | */ |
michael@0 | 11 | |
michael@0 | 12 | #ifndef BasicTableLayoutStrategy_h_ |
michael@0 | 13 | #define BasicTableLayoutStrategy_h_ |
michael@0 | 14 | |
michael@0 | 15 | #include "mozilla/Attributes.h" |
michael@0 | 16 | #include "nsITableLayoutStrategy.h" |
michael@0 | 17 | |
michael@0 | 18 | class nsTableFrame; |
michael@0 | 19 | |
michael@0 | 20 | class BasicTableLayoutStrategy : public nsITableLayoutStrategy |
michael@0 | 21 | { |
michael@0 | 22 | public: |
michael@0 | 23 | BasicTableLayoutStrategy(nsTableFrame *aTableFrame); |
michael@0 | 24 | virtual ~BasicTableLayoutStrategy(); |
michael@0 | 25 | |
michael@0 | 26 | // nsITableLayoutStrategy implementation |
michael@0 | 27 | virtual nscoord GetMinWidth(nsRenderingContext* aRenderingContext) MOZ_OVERRIDE; |
michael@0 | 28 | virtual nscoord GetPrefWidth(nsRenderingContext* aRenderingContext, |
michael@0 | 29 | bool aComputingSize) MOZ_OVERRIDE; |
michael@0 | 30 | virtual void MarkIntrinsicWidthsDirty() MOZ_OVERRIDE; |
michael@0 | 31 | virtual void ComputeColumnWidths(const nsHTMLReflowState& aReflowState) MOZ_OVERRIDE; |
michael@0 | 32 | |
michael@0 | 33 | private: |
michael@0 | 34 | // NOTE: Using prefix "BTLS" to avoid overlapping names with |
michael@0 | 35 | // the values of nsLayoutUtils::IntrinsicWidthType |
michael@0 | 36 | enum BtlsWidthType { BTLS_MIN_WIDTH, |
michael@0 | 37 | BTLS_PREF_WIDTH, |
michael@0 | 38 | BTLS_FINAL_WIDTH }; |
michael@0 | 39 | |
michael@0 | 40 | // Compute intrinsic width member variables on the columns. |
michael@0 | 41 | void ComputeColumnIntrinsicWidths(nsRenderingContext* aRenderingContext); |
michael@0 | 42 | |
michael@0 | 43 | // Distribute a colspanning cell's percent width (if any) to its columns. |
michael@0 | 44 | void DistributePctWidthToColumns(float aSpanPrefPct, |
michael@0 | 45 | int32_t aFirstCol, |
michael@0 | 46 | int32_t aColCount); |
michael@0 | 47 | |
michael@0 | 48 | // Distribute a width of some BltsWidthType type to a set of columns. |
michael@0 | 49 | // aWidth: The amount of width to be distributed |
michael@0 | 50 | // aFirstCol: The index (in the table) of the first column to be |
michael@0 | 51 | // considered for receiving width |
michael@0 | 52 | // aColCount: The number of consecutive columns (starting with aFirstCol) |
michael@0 | 53 | // to be considered for receiving width |
michael@0 | 54 | // aWidthType: The type of width being distributed. (BTLS_MIN_WIDTH and |
michael@0 | 55 | // BTLS_PREF_WIDTH are intended to be used for dividing up |
michael@0 | 56 | // colspan's min & pref width. BTLS_FINAL_WIDTH is intended |
michael@0 | 57 | // to be used for distributing the table's final width across |
michael@0 | 58 | // all its columns) |
michael@0 | 59 | // aSpanHasSpecifiedWidth: Should be true iff: |
michael@0 | 60 | // - We're distributing a colspanning cell's |
michael@0 | 61 | // pref or min width to its columns |
michael@0 | 62 | // - The colspanning cell has a specified width. |
michael@0 | 63 | void DistributeWidthToColumns(nscoord aWidth, |
michael@0 | 64 | int32_t aFirstCol, |
michael@0 | 65 | int32_t aColCount, |
michael@0 | 66 | BtlsWidthType aWidthType, |
michael@0 | 67 | bool aSpanHasSpecifiedWidth); |
michael@0 | 68 | |
michael@0 | 69 | |
michael@0 | 70 | // Compute the min and pref widths of the table from the width |
michael@0 | 71 | // variables on the columns. |
michael@0 | 72 | void ComputeIntrinsicWidths(nsRenderingContext* aRenderingContext); |
michael@0 | 73 | |
michael@0 | 74 | nsTableFrame *mTableFrame; |
michael@0 | 75 | nscoord mMinWidth; |
michael@0 | 76 | nscoord mPrefWidth; |
michael@0 | 77 | nscoord mPrefWidthPctExpand; |
michael@0 | 78 | nscoord mLastCalcWidth; |
michael@0 | 79 | }; |
michael@0 | 80 | |
michael@0 | 81 | #endif /* !defined(BasicTableLayoutStrategy_h_) */ |