BasicTableLayoutStrategy.h 3.4 KB

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