/src/mozilla-central/layout/tables/nsTableColFrame.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
3 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
4 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
5 | | #include "nsCOMPtr.h" |
6 | | #include "nsTableColFrame.h" |
7 | | #include "nsTableFrame.h" |
8 | | #include "nsContainerFrame.h" |
9 | | #include "mozilla/ComputedStyle.h" |
10 | | #include "nsStyleConsts.h" |
11 | | #include "nsPresContext.h" |
12 | | #include "nsGkAtoms.h" |
13 | | #include "nsCSSRendering.h" |
14 | | #include "nsIContent.h" |
15 | | |
16 | | using namespace mozilla; |
17 | | |
18 | 0 | #define COL_TYPE_BITS (NS_FRAME_STATE_BIT(28) | \ |
19 | 0 | NS_FRAME_STATE_BIT(29) | \ |
20 | 0 | NS_FRAME_STATE_BIT(30) | \ |
21 | 0 | NS_FRAME_STATE_BIT(31)) |
22 | 0 | #define COL_TYPE_OFFSET 28 |
23 | | |
24 | | using namespace mozilla; |
25 | | |
26 | | nsTableColFrame::nsTableColFrame(ComputedStyle* aStyle) |
27 | | : nsSplittableFrame(aStyle, kClassID) |
28 | | , mMinCoord(0) |
29 | | , mPrefCoord(0) |
30 | | , mSpanMinCoord(0) |
31 | | , mSpanPrefCoord(0) |
32 | | , mPrefPercent(0.0f) |
33 | | , mSpanPrefPercent(0.0f) |
34 | | , mFinalISize(0) |
35 | | , mColIndex(0) |
36 | | , mIStartBorderWidth(0) |
37 | | , mIEndBorderWidth(0) |
38 | | , mBStartContBorderWidth(0) |
39 | | , mIEndContBorderWidth(0) |
40 | | , mBEndContBorderWidth(0) |
41 | | , mHasSpecifiedCoord(false) |
42 | 0 | { |
43 | 0 | SetColType(eColContent); |
44 | 0 | ResetIntrinsics(); |
45 | 0 | ResetSpanIntrinsics(); |
46 | 0 | ResetFinalISize(); |
47 | 0 | } |
48 | | |
49 | | nsTableColFrame::~nsTableColFrame() |
50 | 0 | { |
51 | 0 | } |
52 | | |
53 | | nsTableColType |
54 | | nsTableColFrame::GetColType() const |
55 | 0 | { |
56 | 0 | return (nsTableColType)((mState & COL_TYPE_BITS) >> COL_TYPE_OFFSET); |
57 | 0 | } |
58 | | |
59 | | void |
60 | | nsTableColFrame::SetColType(nsTableColType aType) |
61 | 0 | { |
62 | 0 | NS_ASSERTION(aType != eColAnonymousCol || |
63 | 0 | (GetPrevContinuation() && |
64 | 0 | GetPrevContinuation()->GetNextContinuation() == this && |
65 | 0 | GetPrevContinuation()->GetNextSibling() == this), |
66 | 0 | "spanned content cols must be continuations"); |
67 | 0 | uint32_t type = aType - eColContent; |
68 | 0 | RemoveStateBits(COL_TYPE_BITS); |
69 | 0 | AddStateBits(nsFrameState(type << COL_TYPE_OFFSET)); |
70 | 0 | } |
71 | | |
72 | | /* virtual */ void |
73 | | nsTableColFrame::DidSetComputedStyle(ComputedStyle* aOldComputedStyle) |
74 | 0 | { |
75 | 0 | nsSplittableFrame::DidSetComputedStyle(aOldComputedStyle); |
76 | 0 |
|
77 | 0 | if (!aOldComputedStyle) //avoid this on init |
78 | 0 | return; |
79 | 0 | |
80 | 0 | nsTableFrame* tableFrame = GetTableFrame(); |
81 | 0 | if (tableFrame->IsBorderCollapse() && |
82 | 0 | tableFrame->BCRecalcNeeded(aOldComputedStyle, Style())) { |
83 | 0 | TableArea damageArea(GetColIndex(), 0, 1, tableFrame->GetRowCount()); |
84 | 0 | tableFrame->AddBCDamageArea(damageArea); |
85 | 0 | } |
86 | 0 | } |
87 | | |
88 | | void nsTableColFrame::SetContinuousBCBorderWidth(LogicalSide aForSide, |
89 | | BCPixelSize aPixelValue) |
90 | 0 | { |
91 | 0 | switch (aForSide) { |
92 | 0 | case eLogicalSideBStart: |
93 | 0 | mBStartContBorderWidth = aPixelValue; |
94 | 0 | return; |
95 | 0 | case eLogicalSideIEnd: |
96 | 0 | mIEndContBorderWidth = aPixelValue; |
97 | 0 | return; |
98 | 0 | case eLogicalSideBEnd: |
99 | 0 | mBEndContBorderWidth = aPixelValue; |
100 | 0 | return; |
101 | 0 | default: |
102 | 0 | NS_ERROR("invalid side arg"); |
103 | 0 | } |
104 | 0 | } |
105 | | |
106 | | void |
107 | | nsTableColFrame::Reflow(nsPresContext* aPresContext, |
108 | | ReflowOutput& aDesiredSize, |
109 | | const ReflowInput& aReflowInput, |
110 | | nsReflowStatus& aStatus) |
111 | 0 | { |
112 | 0 | MarkInReflow(); |
113 | 0 | DO_GLOBAL_REFLOW_COUNT("nsTableColFrame"); |
114 | 0 | DISPLAY_REFLOW(aPresContext, this, aReflowInput, aDesiredSize, aStatus); |
115 | 0 | MOZ_ASSERT(aStatus.IsEmpty(), "Caller should pass a fresh reflow status!"); |
116 | 0 | aDesiredSize.ClearSize(); |
117 | 0 | const nsStyleVisibility* colVis = StyleVisibility(); |
118 | 0 | bool collapseCol = (NS_STYLE_VISIBILITY_COLLAPSE == colVis->mVisible); |
119 | 0 | if (collapseCol) { |
120 | 0 | GetTableFrame()->SetNeedToCollapse(true); |
121 | 0 | } |
122 | 0 | NS_FRAME_SET_TRUNCATION(aStatus, aReflowInput, aDesiredSize); |
123 | 0 | } |
124 | | |
125 | | void |
126 | | nsTableColFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, |
127 | | const nsDisplayListSet& aLists) |
128 | 0 | { |
129 | 0 | nsTableFrame::DisplayGenericTablePart(aBuilder, this, aLists); |
130 | 0 | } |
131 | | |
132 | | int32_t nsTableColFrame::GetSpan() |
133 | 0 | { |
134 | 0 | return StyleTable()->mSpan; |
135 | 0 | } |
136 | | |
137 | | #ifdef DEBUG |
138 | | void nsTableColFrame::Dump(int32_t aIndent) |
139 | | { |
140 | | char* indent = new char[aIndent + 1]; |
141 | | if (!indent) return; |
142 | | for (int32_t i = 0; i < aIndent + 1; i++) { |
143 | | indent[i] = ' '; |
144 | | } |
145 | | indent[aIndent] = 0; |
146 | | |
147 | | printf("%s**START COL DUMP**\n%s colIndex=%d coltype=", |
148 | | indent, indent, mColIndex); |
149 | | nsTableColType colType = GetColType(); |
150 | | switch (colType) { |
151 | | case eColContent: |
152 | | printf(" content "); |
153 | | break; |
154 | | case eColAnonymousCol: |
155 | | printf(" anonymous-column "); |
156 | | break; |
157 | | case eColAnonymousColGroup: |
158 | | printf(" anonymous-colgroup "); |
159 | | break; |
160 | | case eColAnonymousCell: |
161 | | printf(" anonymous-cell "); |
162 | | break; |
163 | | } |
164 | | printf("\nm:%d c:%d(%c) p:%f sm:%d sc:%d sp:%f f:%d", |
165 | | int32_t(mMinCoord), int32_t(mPrefCoord), |
166 | | mHasSpecifiedCoord ? 's' : 'u', mPrefPercent, |
167 | | int32_t(mSpanMinCoord), int32_t(mSpanPrefCoord), |
168 | | mSpanPrefPercent, |
169 | | int32_t(GetFinalISize())); |
170 | | printf("\n%s**END COL DUMP** ", indent); |
171 | | delete [] indent; |
172 | | } |
173 | | #endif |
174 | | /* ----- global methods ----- */ |
175 | | |
176 | | nsTableColFrame* |
177 | | NS_NewTableColFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle) |
178 | 0 | { |
179 | 0 | return new (aPresShell) nsTableColFrame(aStyle); |
180 | 0 | } |
181 | | |
182 | | NS_IMPL_FRAMEARENA_HELPERS(nsTableColFrame) |
183 | | |
184 | | nsTableColFrame* |
185 | | nsTableColFrame::GetNextCol() const |
186 | 0 | { |
187 | 0 | nsIFrame* childFrame = GetNextSibling(); |
188 | 0 | while (childFrame) { |
189 | 0 | if (childFrame->IsTableColFrame()) { |
190 | 0 | return (nsTableColFrame*)childFrame; |
191 | 0 | } |
192 | 0 | childFrame = childFrame->GetNextSibling(); |
193 | 0 | } |
194 | 0 | return nullptr; |
195 | 0 | } |
196 | | |
197 | | #ifdef DEBUG_FRAME_DUMP |
198 | | nsresult |
199 | | nsTableColFrame::GetFrameName(nsAString& aResult) const |
200 | | { |
201 | | return MakeFrameName(NS_LITERAL_STRING("TableCol"), aResult); |
202 | | } |
203 | | #endif |
204 | | |
205 | | nsSplittableType |
206 | | nsTableColFrame::GetSplittableType() const |
207 | 0 | { |
208 | 0 | return NS_FRAME_NOT_SPLITTABLE; |
209 | 0 | } |
210 | | |
211 | | void |
212 | | nsTableColFrame::InvalidateFrame(uint32_t aDisplayItemKey, bool aRebuildDisplayItems) |
213 | 0 | { |
214 | 0 | nsIFrame::InvalidateFrame(aDisplayItemKey, aRebuildDisplayItems); |
215 | 0 | if (GetTableFrame()->IsBorderCollapse()) { |
216 | 0 | GetParent()->InvalidateFrameWithRect(GetVisualOverflowRect() + GetPosition(), aDisplayItemKey, false); |
217 | 0 | } |
218 | 0 | } |
219 | | |
220 | | void |
221 | | nsTableColFrame::InvalidateFrameWithRect(const nsRect& aRect, uint32_t aDisplayItemKey, bool aRebuildDisplayItems) |
222 | 0 | { |
223 | 0 | nsIFrame::InvalidateFrameWithRect(aRect, aDisplayItemKey, aRebuildDisplayItems); |
224 | 0 |
|
225 | 0 | // If we have filters applied that would affects our bounds, then |
226 | 0 | // we get an inactive layer created and this is computed |
227 | 0 | // within FrameLayerBuilder |
228 | 0 | GetParent()->InvalidateFrameWithRect(aRect + GetPosition(), aDisplayItemKey, false); |
229 | 0 | } |
230 | | |