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

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutTableCol.cpp

Issue 2791433003: Fix Border collapsing with colpsan / rowspan cells
Patch Set: bug 2902 Created 3 years, 8 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1997 Martin Jones (mjones@kde.org) 2 * Copyright (C) 1997 Martin Jones (mjones@kde.org)
3 * (C) 1997 Torben Weis (weis@kde.org) 3 * (C) 1997 Torben Weis (weis@kde.org)
4 * (C) 1998 Waldo Bastian (bastian@kde.org) 4 * (C) 1998 Waldo Bastian (bastian@kde.org)
5 * (C) 1999 Lars Knoll (knoll@kde.org) 5 * (C) 1999 Lars Knoll (knoll@kde.org)
6 * (C) 1999 Antti Koivisto (koivisto@kde.org) 6 * (C) 1999 Antti Koivisto (koivisto@kde.org)
7 * Copyright (C) 2003, 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. 7 * Copyright (C) 2003, 2004, 2005, 2006, 2009 Apple Inc. All rights reserved.
8 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 8 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 Table()->AddColumn(this); 94 Table()->AddColumn(this);
95 } 95 }
96 96
97 void LayoutTableCol::WillBeRemovedFromTree() { 97 void LayoutTableCol::WillBeRemovedFromTree() {
98 LayoutTableBoxComponent::WillBeRemovedFromTree(); 98 LayoutTableBoxComponent::WillBeRemovedFromTree();
99 Table()->RemoveColumn(this); 99 Table()->RemoveColumn(this);
100 } 100 }
101 101
102 bool LayoutTableCol::IsChildAllowed(LayoutObject* child, 102 bool LayoutTableCol::IsChildAllowed(LayoutObject* child,
103 const ComputedStyle& style) const { 103 const ComputedStyle& style) const {
104 // We cannot use isTableColumn here as style() may return 0. 104 // We cannot use IsTableColumn here as style() may return 0.
105 return child->IsLayoutTableCol() && style.Display() == EDisplay::kTableColumn; 105 return child->IsLayoutTableCol() && style.Display() == EDisplay::kTableColumn;
106 } 106 }
107 107
108 bool LayoutTableCol::CanHaveChildren() const { 108 bool LayoutTableCol::CanHaveChildren() const {
109 // Cols cannot have children. This is actually necessary to fix a bug 109 // Cols cannot have children. This is actually necessary to fix a bug
110 // with libraries.uc.edu, which makes a <p> be a table-column. 110 // with libraries.uc.edu, which makes a <p> be a table-column.
111 return IsTableColumnGroup(); 111 return IsTableColumnGroup();
112 } 112 }
113 113
114 LayoutRect LayoutTableCol::LocalVisualRect() const { 114 LayoutRect LayoutTableCol::LocalVisualRect() const {
(...skipping 28 matching lines...) Expand all
143 LayoutTableCol* LayoutTableCol::EnclosingColumnGroup() const { 143 LayoutTableCol* LayoutTableCol::EnclosingColumnGroup() const {
144 if (!Parent()->IsLayoutTableCol()) 144 if (!Parent()->IsLayoutTableCol())
145 return nullptr; 145 return nullptr;
146 146
147 LayoutTableCol* parent_column_group = ToLayoutTableCol(Parent()); 147 LayoutTableCol* parent_column_group = ToLayoutTableCol(Parent());
148 DCHECK(parent_column_group->IsTableColumnGroup()); 148 DCHECK(parent_column_group->IsTableColumnGroup());
149 DCHECK(IsTableColumn()); 149 DCHECK(IsTableColumn());
150 return parent_column_group; 150 return parent_column_group;
151 } 151 }
152 152
153 LayoutTableCol* LayoutTableCol::LastColumnInGroup() const {
154 DCHECK(this->IsTableColumnGroupWithColumnChildren());
155 LayoutTableCol* end_col = nullptr;
156 LayoutTableCol* current_col = this->NextColumn();
157 // If column has children, traverse the children to find last.
158 if (this->FirstChild()) {
159 while (current_col && current_col->EnclosingColumnGroup() == this) {
160 end_col = current_col;
161 current_col = current_col->NextColumn();
162 }
163 }
164 return end_col;
165 }
166
153 LayoutTableCol* LayoutTableCol::NextColumn() const { 167 LayoutTableCol* LayoutTableCol::NextColumn() const {
154 // If |this| is a column-group, the next column is the colgroup's first child 168 // If |this| is a column-group, the next column is the colgroup's first child
155 // column. 169 // column.
156 if (LayoutObject* first_child = this->FirstChild()) 170 if (LayoutObject* first_child = this->FirstChild())
157 return ToLayoutTableCol(first_child); 171 return ToLayoutTableCol(first_child);
158 172
159 // Otherwise it's the next column along. 173 // Otherwise it's the next column along.
160 LayoutObject* next = NextSibling(); 174 LayoutObject* next = NextSibling();
161 175
162 // Failing that, the child is the last column in a column-group, so the next 176 // Failing that, the child is the last column in a column-group, so the next
163 // column is the next column/column-group after its column-group. 177 // column is the next column/column-group after its column-group.
164 if (!next && Parent()->IsLayoutTableCol()) 178 auto p = Parent();
165 next = Parent()->NextSibling(); 179 if (!next && p && p->IsLayoutTableCol())
180 next = p->NextSibling();
166 181
167 for (; next && !next->IsLayoutTableCol(); next = next->NextSibling()) { 182 for (; next && !next->IsLayoutTableCol(); next = next->NextSibling()) {
168 } 183 }
169 184
170 return ToLayoutTableCol(next); 185 return ToLayoutTableCol(next);
171 } 186 }
172 187
173 const BorderValue& LayoutTableCol::BorderAdjoiningCellStartBorder( 188 const BorderValue& LayoutTableCol::BorderAdjoiningCellStartBorder(
174 const LayoutTableCell*) const { 189 const LayoutTableCell*) const {
175 return Style()->BorderStart(); 190 return Style()->BorderStart();
(...skipping 16 matching lines...) Expand all
192 207
193 const BorderValue& LayoutTableCol::BorderAdjoiningCellAfter( 208 const BorderValue& LayoutTableCol::BorderAdjoiningCellAfter(
194 const LayoutTableCell* cell) const { 209 const LayoutTableCell* cell) const {
195 DCHECK_EQ(Table() 210 DCHECK_EQ(Table()
196 ->ColElementAtAbsoluteColumn(cell->AbsoluteColumnIndex() - 1) 211 ->ColElementAtAbsoluteColumn(cell->AbsoluteColumnIndex() - 1)
197 .InnermostColOrColGroup(), 212 .InnermostColOrColGroup(),
198 this); 213 this);
199 return Style()->BorderEnd(); 214 return Style()->BorderEnd();
200 } 215 }
201 216
217 Vector<unsigned> LayoutTableCol::GetEffectiveColumnIndexes() const {
218 LayoutTable* table = this->Table();
219 Vector<unsigned> indexes;
220 if (!table)
221 return indexes;
222 unsigned last_effective_column = table->LastEffectiveColumnIndex();
223 if (IsTableColumn()) {
224 unsigned idx = table->ColElementToAbsoluteColumn(this);
225 auto span = this->Span();
226 unsigned last_seen_column = 0xFFFFFFFF;
227 while (span--) {
228 unsigned effective_column = table->AbsoluteColumnToEffectiveColumn(idx++);
229 if (effective_column != last_seen_column &&
230 effective_column <= last_effective_column) {
231 indexes.push_back(effective_column);
232 last_seen_column = effective_column;
233 }
234 }
235 } else { // IsTableColumnGroup
236 if (IsTableColumnGroupWithColumnChildren()) {
237 LayoutTableCol* current_col = nullptr;
238 auto last_col = LastColumnInGroup();
239 do {
240 current_col = current_col ? current_col->NextColumn() : NextColumn();
241 if (current_col) {
242 auto colIndexes = current_col->GetEffectiveColumnIndexes();
243 for (auto c = colIndexes.begin(); c != colIndexes.end(); c++)
244 indexes.push_back(*c);
245 }
246 } while (current_col && current_col != last_col);
247 } else { // tableColumnGroup with no children
248 // its covers span columns
249 unsigned idx = table->ColElementToAbsoluteColumn(this);
250 auto span = this->Span();
251 unsigned last_seen_column = 0xFFFFFFFF;
252 while (span--) {
253 unsigned effective_column =
254 table->AbsoluteColumnToEffectiveColumn(idx++);
255 if (effective_column != last_seen_column &&
256 effective_column <= last_effective_column) {
257 indexes.push_back(effective_column);
258 last_seen_column = effective_column;
259 }
260 }
261 }
262 }
263 return indexes;
264 }
265
202 } // namespace blink 266 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutTableCol.h ('k') | third_party/WebKit/Source/core/layout/LayoutTableSection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698