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

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

Issue 2640143005: Support subpixel layout for borders. (Closed)
Patch Set: Rebaselined tests. Created 3 years, 10 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, 2007, 2008, 2009 Apple Inc. 7 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc.
8 * All rights reserved. 8 * All rights reserved.
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 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 LayoutRect LayoutTableCell::localVisualRect() const { 408 LayoutRect LayoutTableCell::localVisualRect() const {
409 // If the table grid is dirty, we cannot get reliable information about 409 // If the table grid is dirty, we cannot get reliable information about
410 // adjoining cells, so we ignore outside borders. This should not be a problem 410 // adjoining cells, so we ignore outside borders. This should not be a problem
411 // because it means that the table is going to recalculate the grid, relayout 411 // because it means that the table is going to recalculate the grid, relayout
412 // and issue a paint invalidation of its current rect, which includes any 412 // and issue a paint invalidation of its current rect, which includes any
413 // outside borders of this cell. 413 // outside borders of this cell.
414 if (!table()->collapseBorders() || table()->needsSectionRecalc()) 414 if (!table()->collapseBorders() || table()->needsSectionRecalc())
415 return LayoutBlockFlow::localVisualRect(); 415 return LayoutBlockFlow::localVisualRect();
416 416
417 bool rtl = !styleForCellFlow().isLeftToRightDirection(); 417 bool rtl = !styleForCellFlow().isLeftToRightDirection();
418 int outlineOutset = style()->outlineOutsetExtent(); 418 LayoutUnit outlineOutset(style()->outlineOutsetExtent());
419 int left = std::max(borderHalfLeft(true), outlineOutset); 419 LayoutUnit left(std::max(borderHalfLeft(true), outlineOutset));
420 int right = std::max(borderHalfRight(true), outlineOutset); 420 LayoutUnit right(std::max(borderHalfRight(true), outlineOutset));
421 int top = std::max(borderHalfTop(true), outlineOutset); 421 LayoutUnit top(std::max(borderHalfTop(true), outlineOutset));
422 int bottom = std::max(borderHalfBottom(true), outlineOutset); 422 LayoutUnit bottom(std::max(borderHalfBottom(true), outlineOutset));
423 if ((left && !rtl) || (right && rtl)) { 423 if ((left && !rtl) || (right && rtl)) {
424 if (LayoutTableCell* before = table()->cellBefore(this)) { 424 if (LayoutTableCell* before = table()->cellBefore(this)) {
425 top = std::max(top, before->borderHalfTop(true)); 425 top = std::max(top, before->borderHalfTop(true));
426 bottom = std::max(bottom, before->borderHalfBottom(true)); 426 bottom = std::max(bottom, before->borderHalfBottom(true));
427 } 427 }
428 } 428 }
429 if ((left && rtl) || (right && !rtl)) { 429 if ((left && rtl) || (right && !rtl)) {
430 if (LayoutTableCell* after = table()->cellAfter(this)) { 430 if (LayoutTableCell* after = table()->cellAfter(this)) {
431 top = std::max(top, after->borderHalfTop(true)); 431 top = std::max(top, after->borderHalfTop(true));
432 bottom = std::max(bottom, after->borderHalfBottom(true)); 432 bottom = std::max(bottom, after->borderHalfBottom(true));
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after
1170 table->style()->borderAfter(), 1170 table->style()->borderAfter(),
1171 includeColor ? table->resolveColor(afterColorProperty) : Color(), 1171 includeColor ? table->resolveColor(afterColorProperty) : Color(),
1172 BorderPrecedenceTable)); 1172 BorderPrecedenceTable));
1173 if (!result.exists()) 1173 if (!result.exists())
1174 return result; 1174 return result;
1175 } 1175 }
1176 1176
1177 return result; 1177 return result;
1178 } 1178 }
1179 1179
1180 int LayoutTableCell::borderLeft() const { 1180 LayoutUnit LayoutTableCell::borderLeft() const {
1181 return table()->collapseBorders() ? borderHalfLeft(false) 1181 return table()->collapseBorders() ? borderHalfLeft(false)
1182 : LayoutBlockFlow::borderLeft(); 1182 : LayoutBlockFlow::borderLeft();
1183 } 1183 }
1184 1184
1185 int LayoutTableCell::borderRight() const { 1185 LayoutUnit LayoutTableCell::borderRight() const {
1186 return table()->collapseBorders() ? borderHalfRight(false) 1186 return table()->collapseBorders() ? borderHalfRight(false)
1187 : LayoutBlockFlow::borderRight(); 1187 : LayoutBlockFlow::borderRight();
1188 } 1188 }
1189 1189
1190 int LayoutTableCell::borderTop() const { 1190 LayoutUnit LayoutTableCell::borderTop() const {
1191 return table()->collapseBorders() ? borderHalfTop(false) 1191 return table()->collapseBorders() ? borderHalfTop(false)
1192 : LayoutBlockFlow::borderTop(); 1192 : LayoutBlockFlow::borderTop();
1193 } 1193 }
1194 1194
1195 int LayoutTableCell::borderBottom() const { 1195 LayoutUnit LayoutTableCell::borderBottom() const {
1196 return table()->collapseBorders() ? borderHalfBottom(false) 1196 return table()->collapseBorders() ? borderHalfBottom(false)
1197 : LayoutBlockFlow::borderBottom(); 1197 : LayoutBlockFlow::borderBottom();
1198 } 1198 }
1199 1199
1200 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=46191, make the collapsed 1200 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=46191, make the collapsed
1201 // border drawing work with different block flow values instead of being 1201 // border drawing work with different block flow values instead of being
1202 // hard-coded to top-to-bottom. 1202 // hard-coded to top-to-bottom.
1203 int LayoutTableCell::borderStart() const { 1203 LayoutUnit LayoutTableCell::borderStart() const {
1204 return table()->collapseBorders() ? borderHalfStart(false) 1204 return table()->collapseBorders() ? borderHalfStart(false)
1205 : LayoutBlockFlow::borderStart(); 1205 : LayoutBlockFlow::borderStart();
1206 } 1206 }
1207 1207
1208 int LayoutTableCell::borderEnd() const { 1208 LayoutUnit LayoutTableCell::borderEnd() const {
1209 return table()->collapseBorders() ? borderHalfEnd(false) 1209 return table()->collapseBorders() ? borderHalfEnd(false)
1210 : LayoutBlockFlow::borderEnd(); 1210 : LayoutBlockFlow::borderEnd();
1211 } 1211 }
1212 1212
1213 int LayoutTableCell::borderBefore() const { 1213 LayoutUnit LayoutTableCell::borderBefore() const {
1214 return table()->collapseBorders() ? borderHalfBefore(false) 1214 return table()->collapseBorders() ? borderHalfBefore(false)
1215 : LayoutBlockFlow::borderBefore(); 1215 : LayoutBlockFlow::borderBefore();
1216 } 1216 }
1217 1217
1218 int LayoutTableCell::borderAfter() const { 1218 LayoutUnit LayoutTableCell::borderAfter() const {
1219 return table()->collapseBorders() ? borderHalfAfter(false) 1219 return table()->collapseBorders() ? borderHalfAfter(false)
1220 : LayoutBlockFlow::borderAfter(); 1220 : LayoutBlockFlow::borderAfter();
1221 } 1221 }
1222 1222
1223 int LayoutTableCell::borderHalfLeft(bool outer) const { 1223 LayoutUnit LayoutTableCell::borderHalfLeft(bool outer) const {
1224 const ComputedStyle& styleForCellFlow = this->styleForCellFlow(); 1224 const ComputedStyle& styleForCellFlow = this->styleForCellFlow();
1225 if (styleForCellFlow.isHorizontalWritingMode()) 1225 if (styleForCellFlow.isHorizontalWritingMode())
1226 return styleForCellFlow.isLeftToRightDirection() ? borderHalfStart(outer) 1226 return styleForCellFlow.isLeftToRightDirection() ? borderHalfStart(outer)
1227 : borderHalfEnd(outer); 1227 : borderHalfEnd(outer);
1228 return styleForCellFlow.isFlippedBlocksWritingMode() 1228 return styleForCellFlow.isFlippedBlocksWritingMode()
1229 ? borderHalfAfter(outer) 1229 ? borderHalfAfter(outer)
1230 : borderHalfBefore(outer); 1230 : borderHalfBefore(outer);
1231 } 1231 }
1232 1232
1233 int LayoutTableCell::borderHalfRight(bool outer) const { 1233 LayoutUnit LayoutTableCell::borderHalfRight(bool outer) const {
1234 const ComputedStyle& styleForCellFlow = this->styleForCellFlow(); 1234 const ComputedStyle& styleForCellFlow = this->styleForCellFlow();
1235 if (styleForCellFlow.isHorizontalWritingMode()) 1235 if (styleForCellFlow.isHorizontalWritingMode())
1236 return styleForCellFlow.isLeftToRightDirection() ? borderHalfEnd(outer) 1236 return styleForCellFlow.isLeftToRightDirection() ? borderHalfEnd(outer)
1237 : borderHalfStart(outer); 1237 : borderHalfStart(outer);
1238 return styleForCellFlow.isFlippedBlocksWritingMode() ? borderHalfBefore(outer) 1238 return styleForCellFlow.isFlippedBlocksWritingMode() ? borderHalfBefore(outer)
1239 : borderHalfAfter(outer); 1239 : borderHalfAfter(outer);
1240 } 1240 }
1241 1241
1242 int LayoutTableCell::borderHalfTop(bool outer) const { 1242 LayoutUnit LayoutTableCell::borderHalfTop(bool outer) const {
1243 const ComputedStyle& styleForCellFlow = this->styleForCellFlow(); 1243 const ComputedStyle& styleForCellFlow = this->styleForCellFlow();
1244 if (styleForCellFlow.isHorizontalWritingMode()) 1244 if (styleForCellFlow.isHorizontalWritingMode())
1245 return styleForCellFlow.isFlippedBlocksWritingMode() 1245 return styleForCellFlow.isFlippedBlocksWritingMode()
1246 ? borderHalfAfter(outer) 1246 ? borderHalfAfter(outer)
1247 : borderHalfBefore(outer); 1247 : borderHalfBefore(outer);
1248 return styleForCellFlow.isLeftToRightDirection() ? borderHalfStart(outer) 1248 return styleForCellFlow.isLeftToRightDirection() ? borderHalfStart(outer)
1249 : borderHalfEnd(outer); 1249 : borderHalfEnd(outer);
1250 } 1250 }
1251 1251
1252 int LayoutTableCell::borderHalfBottom(bool outer) const { 1252 LayoutUnit LayoutTableCell::borderHalfBottom(bool outer) const {
1253 const ComputedStyle& styleForCellFlow = this->styleForCellFlow(); 1253 const ComputedStyle& styleForCellFlow = this->styleForCellFlow();
1254 if (styleForCellFlow.isHorizontalWritingMode()) 1254 if (styleForCellFlow.isHorizontalWritingMode())
1255 return styleForCellFlow.isFlippedBlocksWritingMode() 1255 return styleForCellFlow.isFlippedBlocksWritingMode()
1256 ? borderHalfBefore(outer) 1256 ? borderHalfBefore(outer)
1257 : borderHalfAfter(outer); 1257 : borderHalfAfter(outer);
1258 return styleForCellFlow.isLeftToRightDirection() ? borderHalfEnd(outer) 1258 return styleForCellFlow.isLeftToRightDirection() ? borderHalfEnd(outer)
1259 : borderHalfStart(outer); 1259 : borderHalfStart(outer);
1260 } 1260 }
1261 1261
1262 int LayoutTableCell::borderHalfStart(bool outer) const { 1262 LayoutUnit LayoutTableCell::borderHalfStart(bool outer) const {
1263 CollapsedBorderValue border = 1263 CollapsedBorderValue border =
1264 computeCollapsedStartBorder(DoNotIncludeBorderColor); 1264 computeCollapsedStartBorder(DoNotIncludeBorderColor);
1265 if (border.exists()) 1265 if (border.exists()) {
1266 return (border.width() + 1266 return LayoutUnit(
1267 ((styleForCellFlow().isLeftToRightDirection() ^ outer) ? 1 : 0)) / 1267 (border.width() +
1268 2; // Give the extra pixel to top and left. 1268 ((styleForCellFlow().isLeftToRightDirection() ^ outer) ? 1 : 0)) /
1269 return 0; 1269 2); // Give the extra pixel to top and left.
1270 }
1271 return LayoutUnit();
1270 } 1272 }
1271 1273
1272 int LayoutTableCell::borderHalfEnd(bool outer) const { 1274 LayoutUnit LayoutTableCell::borderHalfEnd(bool outer) const {
1273 CollapsedBorderValue border = 1275 CollapsedBorderValue border =
1274 computeCollapsedEndBorder(DoNotIncludeBorderColor); 1276 computeCollapsedEndBorder(DoNotIncludeBorderColor);
1275 if (border.exists()) 1277 if (border.exists()) {
1276 return (border.width() + 1278 return LayoutUnit(
1277 ((styleForCellFlow().isLeftToRightDirection() ^ outer) ? 0 : 1)) / 1279 (border.width() +
1278 2; 1280 ((styleForCellFlow().isLeftToRightDirection() ^ outer) ? 0 : 1)) /
1279 return 0; 1281 2);
1282 }
1283 return LayoutUnit();
1280 } 1284 }
1281 1285
1282 int LayoutTableCell::borderHalfBefore(bool outer) const { 1286 LayoutUnit LayoutTableCell::borderHalfBefore(bool outer) const {
1283 CollapsedBorderValue border = 1287 CollapsedBorderValue border =
1284 computeCollapsedBeforeBorder(DoNotIncludeBorderColor); 1288 computeCollapsedBeforeBorder(DoNotIncludeBorderColor);
1285 if (border.exists()) 1289 if (border.exists()) {
1286 return (border.width() + 1290 return LayoutUnit(
1287 ((styleForCellFlow().isFlippedBlocksWritingMode() ^ outer) ? 0 1291 (border.width() +
1288 : 1)) / 1292 ((styleForCellFlow().isFlippedBlocksWritingMode() ^ outer) ? 0 : 1)) /
1289 2; // Give the extra pixel to top and left. 1293 2); // Give the extra pixel to top and left.
1290 return 0; 1294 }
1295 return LayoutUnit();
1291 } 1296 }
1292 1297
1293 int LayoutTableCell::borderHalfAfter(bool outer) const { 1298 LayoutUnit LayoutTableCell::borderHalfAfter(bool outer) const {
1294 CollapsedBorderValue border = 1299 CollapsedBorderValue border =
1295 computeCollapsedAfterBorder(DoNotIncludeBorderColor); 1300 computeCollapsedAfterBorder(DoNotIncludeBorderColor);
1296 if (border.exists()) 1301 if (border.exists()) {
1297 return (border.width() + 1302 return LayoutUnit(
1298 ((styleForCellFlow().isFlippedBlocksWritingMode() ^ outer) ? 1 1303 (border.width() +
1299 : 0)) / 1304 ((styleForCellFlow().isFlippedBlocksWritingMode() ^ outer) ? 1 : 0)) /
1300 2; 1305 2);
1301 return 0; 1306 }
1307 return LayoutUnit();
1302 } 1308 }
1303 1309
1304 void LayoutTableCell::paint(const PaintInfo& paintInfo, 1310 void LayoutTableCell::paint(const PaintInfo& paintInfo,
1305 const LayoutPoint& paintOffset) const { 1311 const LayoutPoint& paintOffset) const {
1306 TableCellPainter(*this).paint(paintInfo, paintOffset); 1312 TableCellPainter(*this).paint(paintInfo, paintOffset);
1307 } 1313 }
1308 1314
1309 static void addBorderStyle(LayoutTable::CollapsedBorderValues& borderValues, 1315 static void addBorderStyle(LayoutTable::CollapsedBorderValues& borderValues,
1310 CollapsedBorderValue borderValue) { 1316 CollapsedBorderValue borderValue) {
1311 if (!borderValue.isVisible()) 1317 if (!borderValue.isVisible())
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
1492 } 1498 }
1493 1499
1494 bool LayoutTableCell::hasLineIfEmpty() const { 1500 bool LayoutTableCell::hasLineIfEmpty() const {
1495 if (node() && hasEditableStyle(*node())) 1501 if (node() && hasEditableStyle(*node()))
1496 return true; 1502 return true;
1497 1503
1498 return LayoutBlock::hasLineIfEmpty(); 1504 return LayoutBlock::hasLineIfEmpty();
1499 } 1505 }
1500 1506
1501 } // namespace blink 1507 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutTableCell.h ('k') | third_party/WebKit/Source/core/layout/api/LayoutBoxModel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698