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

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

Issue 1682453004: Treat <table> widths of 0 as auto. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rename test; factor out isAuto method Created 4 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, 2010, 2013 Apple Inc. All rights reserved. 7 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2013 Apple Inc. All rights reserved.
8 * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com) 8 * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com)
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 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 245
246 void LayoutTable::removeColumn(const LayoutTableCol*) 246 void LayoutTable::removeColumn(const LayoutTableCol*)
247 { 247 {
248 invalidateCachedColumns(); 248 invalidateCachedColumns();
249 // We don't really need to recompute our sections, but we need to update our 249 // We don't really need to recompute our sections, but we need to update our
250 // column count and whether we have a column. Currently, we only have one 250 // column count and whether we have a column. Currently, we only have one
251 // size-fit-all flag but we may have to consider splitting it. 251 // size-fit-all flag but we may have to consider splitting it.
252 setNeedsSectionRecalc(); 252 setNeedsSectionRecalc();
253 } 253 }
254 254
255 bool LayoutTable::isLogicalWidthAuto() const
256 {
257 Length styleLogicalWidth = style()->logicalWidth();
258 return (!styleLogicalWidth.isSpecified() || !styleLogicalWidth.isPositive()) && !styleLogicalWidth.isIntrinsic();
259 }
260
255 void LayoutTable::updateLogicalWidth() 261 void LayoutTable::updateLogicalWidth()
256 { 262 {
257 recalcSectionsIfNeeded(); 263 recalcSectionsIfNeeded();
258 264
259 if (isOutOfFlowPositioned()) { 265 if (isOutOfFlowPositioned()) {
260 LogicalExtentComputedValues computedValues; 266 LogicalExtentComputedValues computedValues;
261 computePositionedLogicalWidth(computedValues); 267 computePositionedLogicalWidth(computedValues);
262 setLogicalWidth(computedValues.m_extent); 268 setLogicalWidth(computedValues.m_extent);
263 setLogicalLeft(computedValues.m_position); 269 setLogicalLeft(computedValues.m_position);
264 setMarginStart(computedValues.m_margins.m_start); 270 setMarginStart(computedValues.m_margins.m_start);
265 setMarginEnd(computedValues.m_margins.m_end); 271 setMarginEnd(computedValues.m_margins.m_end);
266 } 272 }
267 273
268 LayoutBlock* cb = containingBlock(); 274 LayoutBlock* cb = containingBlock();
269 275
270 LayoutUnit availableLogicalWidth = containingBlockLogicalWidthForContent() + (isOutOfFlowPositioned() ? cb->paddingLogicalWidth() : LayoutUnit()); 276 LayoutUnit availableLogicalWidth = containingBlockLogicalWidthForContent() + (isOutOfFlowPositioned() ? cb->paddingLogicalWidth() : LayoutUnit());
271 bool hasPerpendicularContainingBlock = cb->style()->isHorizontalWritingMode( ) != style()->isHorizontalWritingMode(); 277 bool hasPerpendicularContainingBlock = cb->style()->isHorizontalWritingMode( ) != style()->isHorizontalWritingMode();
272 LayoutUnit containerWidthInInlineDirection = hasPerpendicularContainingBlock ? perpendicularContainingBlockLogicalHeight() : availableLogicalWidth; 278 LayoutUnit containerWidthInInlineDirection = hasPerpendicularContainingBlock ? perpendicularContainingBlockLogicalHeight() : availableLogicalWidth;
273 279
274 Length styleLogicalWidth = style()->logicalWidth(); 280 Length styleLogicalWidth = style()->logicalWidth();
275 if ((styleLogicalWidth.isSpecified() && styleLogicalWidth.isPositive()) || s tyleLogicalWidth.isIntrinsic()) { 281 if (!isLogicalWidthAuto()) {
276 setLogicalWidth(convertStyleLogicalWidthToComputedWidth(styleLogicalWidt h, containerWidthInInlineDirection)); 282 setLogicalWidth(convertStyleLogicalWidthToComputedWidth(styleLogicalWidt h, containerWidthInInlineDirection));
277 } else { 283 } else {
278 // Subtract out any fixed margins from our available width for auto widt h tables. 284 // Subtract out any fixed margins from our available width for auto widt h tables.
279 LayoutUnit marginStart = minimumValueForLength(style()->marginStart(), a vailableLogicalWidth); 285 LayoutUnit marginStart = minimumValueForLength(style()->marginStart(), a vailableLogicalWidth);
280 LayoutUnit marginEnd = minimumValueForLength(style()->marginEnd(), avail ableLogicalWidth); 286 LayoutUnit marginEnd = minimumValueForLength(style()->marginEnd(), avail ableLogicalWidth);
281 LayoutUnit marginTotal = marginStart + marginEnd; 287 LayoutUnit marginTotal = marginStart + marginEnd;
282 288
283 // Subtract out our margins to get the available content width. 289 // Subtract out our margins to get the available content width.
284 LayoutUnit availableContentLogicalWidth = (containerWidthInInlineDirecti on - marginTotal).clampNegativeToZero(); 290 LayoutUnit availableContentLogicalWidth = (containerWidthInInlineDirecti on - marginTotal).clampNegativeToZero();
285 if (shrinkToAvoidFloats() && cb->isLayoutBlockFlow() && toLayoutBlockFlo w(cb)->containsFloats() && !hasPerpendicularContainingBlock) 291 if (shrinkToAvoidFloats() && cb->isLayoutBlockFlow() && toLayoutBlockFlo w(cb)->containsFloats() && !hasPerpendicularContainingBlock)
(...skipping 1169 matching lines...) Expand 10 before | Expand all | Expand 10 after
1455 1461
1456 LayoutUnit LayoutTable::paddingRight() const 1462 LayoutUnit LayoutTable::paddingRight() const
1457 { 1463 {
1458 if (collapseBorders()) 1464 if (collapseBorders())
1459 return LayoutUnit(); 1465 return LayoutUnit();
1460 1466
1461 return LayoutBlock::paddingRight(); 1467 return LayoutBlock::paddingRight();
1462 } 1468 }
1463 1469
1464 } // namespace blink 1470 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698