Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 106 // Cols cannot have children. This is actually necessary to fix a bug | 106 // Cols cannot have children. This is actually necessary to fix a bug |
| 107 // with libraries.uc.edu, which makes a <p> be a table-column. | 107 // with libraries.uc.edu, which makes a <p> be a table-column. |
| 108 return isTableColumnGroup(); | 108 return isTableColumnGroup(); |
| 109 } | 109 } |
| 110 | 110 |
| 111 LayoutRect LayoutTableCol::clippedOverflowRectForPaintInvalidation(const LayoutB oxModelObject* paintInvalidationContainer, const PaintInvalidationState* paintIn validationState) const | 111 LayoutRect LayoutTableCol::clippedOverflowRectForPaintInvalidation(const LayoutB oxModelObject* paintInvalidationContainer, const PaintInvalidationState* paintIn validationState) const |
| 112 { | 112 { |
| 113 // For now, just paint invalidate the whole table. | 113 // For now, just paint invalidate the whole table. |
| 114 // FIXME: Find a better way to do this, e.g., need to paint invalidate all t he cells that we | 114 // FIXME: Find a better way to do this, e.g., need to paint invalidate all t he cells that we |
| 115 // might have propagated a background color or borders into. | 115 // might have propagated a background color or borders into. |
| 116 // FIXME: check for paintInvalidationContainer each time here? | 116 // FIXME: check for paintInvalidationContainer each time here? |
|
Xianzhu
2016/03/09 18:40:55
Remove the above FIXMEs.
atotic1
2016/03/15 16:50:48
Done.
| |
| 117 | 117 LayoutRect r = positionByCellSpan(); |
| 118 LayoutTable* parentTable = table(); | 118 mapToVisibleRectInAncestorSpace(paintInvalidationContainer, r, paintInvalida tionState); |
| 119 if (!parentTable) | 119 return r; |
| 120 return LayoutRect(); | |
| 121 return parentTable->clippedOverflowRectForPaintInvalidation(paintInvalidatio nContainer, paintInvalidationState); | |
| 122 } | 120 } |
| 123 | 121 |
| 124 void LayoutTableCol::imageChanged(WrappedImagePtr, const IntRect*) | 122 void LayoutTableCol::imageChanged(WrappedImagePtr, const IntRect*) |
| 125 { | 123 { |
| 126 // FIXME: Issue paint invalidation of only the rect the image paints in. | 124 // FIXME: Issue paint invalidation of only the rect the image paints in. |
| 127 setShouldDoFullPaintInvalidation(); | 125 setShouldDoFullPaintInvalidation(); |
| 128 } | 126 } |
| 129 | 127 |
| 130 void LayoutTableCol::clearPreferredLogicalWidthsDirtyBits() | 128 void LayoutTableCol::clearPreferredLogicalWidthsDirtyBits() |
| 131 { | 129 { |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 147 { | 145 { |
| 148 if (!parent()->isLayoutTableCol()) | 146 if (!parent()->isLayoutTableCol()) |
| 149 return nullptr; | 147 return nullptr; |
| 150 | 148 |
| 151 LayoutTableCol* parentColumnGroup = toLayoutTableCol(parent()); | 149 LayoutTableCol* parentColumnGroup = toLayoutTableCol(parent()); |
| 152 ASSERT(parentColumnGroup->isTableColumnGroup()); | 150 ASSERT(parentColumnGroup->isTableColumnGroup()); |
| 153 ASSERT(isTableColumn()); | 151 ASSERT(isTableColumn()); |
| 154 return parentColumnGroup; | 152 return parentColumnGroup; |
| 155 } | 153 } |
| 156 | 154 |
| 155 LayoutTableCol * LayoutTableCol::lastColumnInGroup() const | |
|
Xianzhu
2016/03/09 18:40:55
Remove extra space before '*'.
atotic1
2016/03/15 16:50:48
Done.
| |
| 156 { | |
| 157 ASSERT(this->isTableColumnGroup()); | |
| 158 | |
| 159 LayoutTableCol * endCol = 0; | |
| 160 LayoutTableCol * currentCol = this->nextColumn(); | |
|
Xianzhu
2016/03/09 18:40:56
Remove extra spaces.
atotic1
2016/03/15 16:50:48
Done.
| |
| 161 // if column has children, traverse the children to find last | |
|
Xianzhu
2016/03/09 18:40:55
Start a sentence with uppercase letter. End a sent
atotic1
2016/03/15 16:50:48
Done.
| |
| 162 if (this->firstChild()) { | |
| 163 while (currentCol && currentCol->enclosingColumnGroup() == this) { | |
| 164 endCol = currentCol; | |
| 165 currentCol = currentCol->nextColumn(); | |
| 166 } | |
| 167 } else { // otherwise, if we have span, use that to find next child | |
| 168 auto span = this->span(); | |
| 169 endCol = currentCol; | |
| 170 while (--span > 0 && currentCol) { | |
| 171 currentCol = currentCol->nextColumn(); | |
| 172 endCol = currentCol; | |
| 173 } | |
| 174 } | |
| 175 return endCol; | |
| 176 } | |
| 177 | |
| 157 LayoutTableCol* LayoutTableCol::nextColumn() const | 178 LayoutTableCol* LayoutTableCol::nextColumn() const |
| 158 { | 179 { |
| 159 // If |this| is a column-group, the next column is the colgroup's first chil d column. | 180 // If |this| is a column-group, the next column is the colgroup's first chil d column. |
| 160 if (LayoutObject* firstChild = this->firstChild()) | 181 if (LayoutObject* firstChild = this->firstChild()) |
| 161 return toLayoutTableCol(firstChild); | 182 return toLayoutTableCol(firstChild); |
| 162 | 183 |
| 163 // Otherwise it's the next column along. | 184 // Otherwise it's the next column along. |
| 164 LayoutObject* next = nextSibling(); | 185 LayoutObject* next = nextSibling(); |
| 165 | 186 |
| 166 // Failing that, the child is the last column in a column-group, so the next column is the next column/column-group after its column-group. | 187 // Failing that, the child is the last column in a column-group, so the next column is the next column/column-group after its column-group. |
| 167 if (!next && parent()->isLayoutTableCol()) | 188 auto p = parent(); |
| 168 next = parent()->nextSibling(); | 189 if (!next && p && p->isLayoutTableCol()) |
| 190 next = p->nextSibling(); | |
| 169 | 191 |
| 170 for (; next && !next->isLayoutTableCol(); next = next->nextSibling()) { } | 192 for (; next && !next->isLayoutTableCol(); next = next->nextSibling()) { } |
| 171 | 193 |
| 172 return toLayoutTableCol(next); | 194 return toLayoutTableCol(next); |
| 173 } | 195 } |
| 174 | 196 |
| 175 const BorderValue& LayoutTableCol::borderAdjoiningCellStartBorder(const LayoutTa bleCell*) const | 197 const BorderValue& LayoutTableCol::borderAdjoiningCellStartBorder(const LayoutTa bleCell*) const |
| 176 { | 198 { |
| 177 return style()->borderStart(); | 199 return style()->borderStart(); |
| 178 } | 200 } |
| 179 | 201 |
| 180 const BorderValue& LayoutTableCol::borderAdjoiningCellEndBorder(const LayoutTabl eCell*) const | 202 const BorderValue& LayoutTableCol::borderAdjoiningCellEndBorder(const LayoutTabl eCell*) const |
| 181 { | 203 { |
| 182 return style()->borderEnd(); | 204 return style()->borderEnd(); |
| 183 } | 205 } |
| 184 | 206 |
| 185 const BorderValue& LayoutTableCol::borderAdjoiningCellBefore(const LayoutTableCe ll* cell) const | 207 const BorderValue& LayoutTableCol::borderAdjoiningCellBefore(const LayoutTableCe ll* cell) const |
| 186 { | 208 { |
| 187 ASSERT_UNUSED(cell, table()->colElementAtAbsoluteColumn(cell->absoluteColumn Index() + cell->colSpan()).innermostColOrColGroup() == this); | 209 ASSERT_UNUSED(cell, table()->colElementAtAbsoluteColumn(cell->absoluteColumn Index() + cell->colSpan()).innermostColOrColGroup() == this); |
| 188 return style()->borderStart(); | 210 return style()->borderStart(); |
| 189 } | 211 } |
| 190 | 212 |
| 191 const BorderValue& LayoutTableCol::borderAdjoiningCellAfter(const LayoutTableCel l* cell) const | 213 const BorderValue& LayoutTableCol::borderAdjoiningCellAfter(const LayoutTableCel l* cell) const |
| 192 { | 214 { |
| 193 ASSERT_UNUSED(cell, table()->colElementAtAbsoluteColumn(cell->absoluteColumn Index() - 1).innermostColOrColGroup() == this); | 215 ASSERT_UNUSED(cell, table()->colElementAtAbsoluteColumn(cell->absoluteColumn Index() - 1).innermostColOrColGroup() == this); |
| 194 return style()->borderEnd(); | 216 return style()->borderEnd(); |
| 195 } | 217 } |
| 196 | 218 |
| 219 // computes col/colgroup position that only spans cells | |
|
Xianzhu
2016/03/09 18:40:55
Move the comment into header file.
atotic1
2016/03/15 16:50:48
Done.
| |
| 220 LayoutRect LayoutTableCol::positionByCellSpan() const | |
| 221 { | |
| 222 | |
| 223 LayoutTable * myTable = table(); | |
|
Xianzhu
2016/03/09 18:40:56
Suggestion: LayoutTable* table = this->table();
atotic1
2016/03/15 16:50:48
Done.
| |
| 224 LayoutRect position; | |
| 225 | |
| 226 if (!myTable) | |
| 227 return position; | |
|
Xianzhu
2016/03/09 18:40:56
We don't need to check null of table().
atotic1
2016/03/15 16:50:48
table() can return nullptr. and I have to guard ag
| |
| 228 | |
| 229 LayoutTableSection* topSection = myTable->topNonEmptySection(); | |
| 230 LayoutTableSection* bottomSection = myTable->bottomNonEmptySection(); | |
| 231 if (!topSection || !bottomSection) | |
| 232 return position; | |
| 233 | |
| 234 Vector<unsigned> colIndexes = getEffectiveColumnIndexes(); | |
| 235 | |
| 236 if (colIndexes.size() == 0) | |
| 237 return position; | |
| 238 | |
| 239 unsigned startColumnIndex = colIndexes[0]; | |
| 240 unsigned endColumnIndex = colIndexes.last(); | |
| 241 | |
| 242 position = topSection->positionOfIdealCell(0, startColumnIndex); | |
| 243 position.moveBy(topSection->location()); | |
| 244 LayoutRect bottomPosition = bottomSection->positionOfIdealCell(bottomSection ->numRows() - 1, endColumnIndex); | |
| 245 bottomPosition.moveBy(bottomSection->location()); | |
| 246 position.unite(bottomPosition); | |
| 247 return position; | |
|
Xianzhu
2016/03/09 20:15:57
What if the column contains some cell having a spa
Xianzhu
2016/03/09 20:24:34
The test case for my question:
<!DOCTYPE html>
<t
atotic1
2016/03/15 16:50:48
That's ok. We are not looking for cell position, b
| |
| 248 } | |
| 249 | |
| 250 // returns indexes to all columns that span this column | |
| 251 // could return vector with size 0 if out of range | |
|
Xianzhu
2016/03/09 18:40:55
Ditto (comment style).
atotic1
2016/03/15 16:50:48
Done.
| |
| 252 Vector<unsigned> LayoutTableCol::getEffectiveColumnIndexes() const | |
| 253 { | |
| 254 LayoutTable * myTable = table(); | |
| 255 Vector<unsigned> indexes; | |
| 256 if (isTableColumn()) { | |
| 257 unsigned idx = myTable->colElementToEffectiveColumn(this); | |
| 258 if (idx != LayoutTable::npos) { | |
| 259 auto span = this->span(); | |
| 260 while (span--) { | |
| 261 if (idx < myTable->numEffectiveColumns()) | |
| 262 indexes.append(idx); | |
| 263 } | |
| 264 } | |
| 265 } else { | |
| 266 // isTableColumnGroup | |
| 267 if (isTableColumnGroupWithColumnChildren()) { | |
| 268 LayoutTableCol* currentCol = nullptr; | |
| 269 auto lastCol = lastColumnInGroup(); | |
| 270 do { | |
| 271 currentCol = currentCol ? currentCol->nextColumn() : nextColumn( ); | |
| 272 if (currentCol) { | |
| 273 auto colIndexes = currentCol->getEffectiveColumnIndexes(); | |
| 274 for (auto c = colIndexes.begin(); c != colIndexes.end(); c++ ) | |
| 275 indexes.append(*c); | |
| 276 } | |
| 277 } while (currentCol && currentCol != lastCol); | |
| 278 } else { | |
| 279 unsigned idx = myTable->colElementToEffectiveColumn(this); | |
| 280 auto span = this->span(); | |
| 281 while (span--) { | |
| 282 if (idx < myTable->numEffectiveColumns()) | |
| 283 indexes.append(idx); | |
| 284 } | |
| 285 } | |
| 286 } | |
| 287 return indexes; | |
| 288 } | |
| 197 } // namespace blink | 289 } // namespace blink |
| OLD | NEW |