Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(372)

Side by Side Diff: Source/core/layout/TableLayoutAlgorithmAuto.h

Issue 1111443003: Refactor the code distributing width to columns in auto layout tables. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Updated Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2002 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 2002 Lars Knoll (knoll@kde.org)
3 * (C) 2002 Dirk Mueller (mueller@kde.org) 3 * (C) 2002 Dirk Mueller (mueller@kde.org)
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License. 8 * version 2 of the License.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 13 matching lines...) Expand all
24 #include "core/layout/TableLayoutAlgorithm.h" 24 #include "core/layout/TableLayoutAlgorithm.h"
25 #include "platform/LayoutUnit.h" 25 #include "platform/LayoutUnit.h"
26 #include "platform/Length.h" 26 #include "platform/Length.h"
27 #include "wtf/Vector.h" 27 #include "wtf/Vector.h"
28 28
29 namespace blink { 29 namespace blink {
30 30
31 class LayoutTable; 31 class LayoutTable;
32 class LayoutTableCell; 32 class LayoutTableCell;
33 33
34 enum CellsToProcess {
35 AllCells,
36 NonEmptyCells
37 };
38
39 enum DistributionMode {
40 ExtraWidth,
41 InitialWidth,
42 LeftoverWidth
43 };
44
45 enum DistributionDirection {
46 StartToEnd,
47 EndToStart
48 };
49
34 class TableLayoutAlgorithmAuto final : public TableLayoutAlgorithm { 50 class TableLayoutAlgorithmAuto final : public TableLayoutAlgorithm {
35 public: 51 public:
36 TableLayoutAlgorithmAuto(LayoutTable*); 52 TableLayoutAlgorithmAuto(LayoutTable*);
37 virtual ~TableLayoutAlgorithmAuto(); 53 virtual ~TableLayoutAlgorithmAuto();
38 54
39 virtual void computeIntrinsicLogicalWidths(LayoutUnit& minWidth, LayoutUnit& maxWidth) override; 55 virtual void computeIntrinsicLogicalWidths(LayoutUnit& minWidth, LayoutUnit& maxWidth) override;
40 virtual void applyPreferredLogicalWidthQuirks(LayoutUnit& minWidth, LayoutUn it& maxWidth) const override; 56 virtual void applyPreferredLogicalWidthQuirks(LayoutUnit& minWidth, LayoutUn it& maxWidth) const override;
41 virtual void layout() override; 57 virtual void layout() override;
42 virtual void willChangeTableLayout() override { } 58 virtual void willChangeTableLayout() override { }
43 59
44 private: 60 private:
45 void fullRecalc(); 61 void fullRecalc();
46 void recalcColumn(unsigned effCol); 62 void recalcColumn(unsigned effCol);
47 63
48 int calcEffectiveLogicalWidth(); 64 int calcEffectiveLogicalWidth();
49 void shrinkCellWidth(const LengthType&, int& available); 65 void shrinkColumnWidth(const LengthType&, int& available);
66 template<typename Total> void distributeWidthToColumns(const LengthType&, in t& available, Total, CellsToProcess, DistributionMode, DistributionDirection);
mstensho (USE GERRIT) 2015/05/12 08:50:27 I was suggesting that you moved LengthType, CellsT
50 67
51 void insertSpanCell(LayoutTableCell*); 68 void insertSpanCell(LayoutTableCell*);
52 69
53 struct Layout { 70 struct Layout {
54 Layout() 71 Layout()
55 : minLogicalWidth(0) 72 : minLogicalWidth(0)
56 , maxLogicalWidth(0) 73 , maxLogicalWidth(0)
57 , effectiveMinLogicalWidth(0) 74 , effectiveMinLogicalWidth(0)
58 , effectiveMaxLogicalWidth(0) 75 , effectiveMaxLogicalWidth(0)
59 , computedLogicalWidth(0) 76 , computedLogicalWidth(0)
(...skipping 13 matching lines...) Expand all
73 90
74 Vector<Layout, 4> m_layoutStruct; 91 Vector<Layout, 4> m_layoutStruct;
75 Vector<LayoutTableCell*, 4> m_spanCells; 92 Vector<LayoutTableCell*, 4> m_spanCells;
76 bool m_hasPercent : 1; 93 bool m_hasPercent : 1;
77 mutable bool m_effectiveLogicalWidthDirty : 1; 94 mutable bool m_effectiveLogicalWidthDirty : 1;
78 }; 95 };
79 96
80 } // namespace blink 97 } // namespace blink
81 98
82 #endif // TableLayoutAlgorithmAuto 99 #endif // TableLayoutAlgorithmAuto
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698