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

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: 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
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/table/zero-width-on-table-is-auto-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 setMarginStart(computedValues.m_margins.m_start); 264 setMarginStart(computedValues.m_margins.m_start);
265 setMarginEnd(computedValues.m_margins.m_end); 265 setMarginEnd(computedValues.m_margins.m_end);
266 } 266 }
267 267
268 LayoutBlock* cb = containingBlock(); 268 LayoutBlock* cb = containingBlock();
269 269
270 LayoutUnit availableLogicalWidth = containingBlockLogicalWidthForContent() + (isOutOfFlowPositioned() ? cb->paddingLogicalWidth() : LayoutUnit()); 270 LayoutUnit availableLogicalWidth = containingBlockLogicalWidthForContent() + (isOutOfFlowPositioned() ? cb->paddingLogicalWidth() : LayoutUnit());
271 bool hasPerpendicularContainingBlock = cb->style()->isHorizontalWritingMode( ) != style()->isHorizontalWritingMode(); 271 bool hasPerpendicularContainingBlock = cb->style()->isHorizontalWritingMode( ) != style()->isHorizontalWritingMode();
272 LayoutUnit containerWidthInInlineDirection = hasPerpendicularContainingBlock ? perpendicularContainingBlockLogicalHeight() : availableLogicalWidth; 272 LayoutUnit containerWidthInInlineDirection = hasPerpendicularContainingBlock ? perpendicularContainingBlockLogicalHeight() : availableLogicalWidth;
273 273
274 ASSERT(!style()->logicalWidth().isNegative());
275 if (style()->logicalWidth().isSpecified() && style()->logicalWidth().isZero( )) {
276 mutableStyle()->setLogicalWidth(Length());
dgrogan 2016/02/09 03:27:19 I'm not sure how much of a no-no this is, to mutat
mstensho (USE GERRIT) 2016/02/09 10:52:45 I think this is bad. We should really leave comput
dgrogan 2016/02/10 02:47:56 No, we don't have negative widths, which is why I
277 }
274 Length styleLogicalWidth = style()->logicalWidth(); 278 Length styleLogicalWidth = style()->logicalWidth();
275 if ((styleLogicalWidth.isSpecified() && styleLogicalWidth.isPositive()) || s tyleLogicalWidth.isIntrinsic()) { 279 if (styleLogicalWidth.isSpecified() || styleLogicalWidth.isIntrinsic()) {
dgrogan 2016/02/09 03:27:19 With the above change this clause is always true.
276 setLogicalWidth(convertStyleLogicalWidthToComputedWidth(styleLogicalWidt h, containerWidthInInlineDirection)); 280 setLogicalWidth(convertStyleLogicalWidthToComputedWidth(styleLogicalWidt h, containerWidthInInlineDirection));
277 } else { 281 } else {
278 // Subtract out any fixed margins from our available width for auto widt h tables. 282 // Subtract out any fixed margins from our available width for auto widt h tables.
279 LayoutUnit marginStart = minimumValueForLength(style()->marginStart(), a vailableLogicalWidth); 283 LayoutUnit marginStart = minimumValueForLength(style()->marginStart(), a vailableLogicalWidth);
280 LayoutUnit marginEnd = minimumValueForLength(style()->marginEnd(), avail ableLogicalWidth); 284 LayoutUnit marginEnd = minimumValueForLength(style()->marginEnd(), avail ableLogicalWidth);
281 LayoutUnit marginTotal = marginStart + marginEnd; 285 LayoutUnit marginTotal = marginStart + marginEnd;
282 286
283 // Subtract out our margins to get the available content width. 287 // Subtract out our margins to get the available content width.
284 LayoutUnit availableContentLogicalWidth = (containerWidthInInlineDirecti on - marginTotal).clampNegativeToZero(); 288 LayoutUnit availableContentLogicalWidth = (containerWidthInInlineDirecti on - marginTotal).clampNegativeToZero();
285 if (shrinkToAvoidFloats() && cb->isLayoutBlockFlow() && toLayoutBlockFlo w(cb)->containsFloats() && !hasPerpendicularContainingBlock) 289 if (shrinkToAvoidFloats() && cb->isLayoutBlockFlow() && toLayoutBlockFlo w(cb)->containsFloats() && !hasPerpendicularContainingBlock)
286 availableContentLogicalWidth = shrinkLogicalWidthToAvoidFloats(margi nStart, marginEnd, toLayoutBlockFlow(cb)); 290 availableContentLogicalWidth = shrinkLogicalWidthToAvoidFloats(margi nStart, marginEnd, toLayoutBlockFlow(cb));
287 291
288 // Ensure we aren't bigger than our available width. 292 // Ensure we aren't bigger than our available width.
289 setLogicalWidth(LayoutUnit(std::min(availableContentLogicalWidth, maxPre ferredLogicalWidth()).floor())); 293 setLogicalWidth(LayoutUnit(std::min(availableContentLogicalWidth, maxPre ferredLogicalWidth()).floor()));
290 } 294 }
291 295
292 // Ensure we aren't bigger than our max-width style. 296 // Ensure we aren't bigger than our max-width style.
293 Length styleMaxLogicalWidth = style()->logicalMaxWidth(); 297 Length styleMaxLogicalWidth = style()->logicalMaxWidth();
294 if ((styleMaxLogicalWidth.isSpecified() && !styleMaxLogicalWidth.isNegative( )) || styleMaxLogicalWidth.isIntrinsic()) { 298 if ((styleMaxLogicalWidth.isSpecified() && !styleMaxLogicalWidth.isNegative( )) || styleMaxLogicalWidth.isIntrinsic()) {
dgrogan 2016/02/10 02:47:56 Like here: !styleMaxLogicalWidth.isNegative().
mstensho (USE GERRIT) 2016/02/10 10:04:09 o_O We should probably turn that into an ASSERT s
295 LayoutUnit computedMaxLogicalWidth = convertStyleLogicalWidthToComputedW idth(styleMaxLogicalWidth, availableLogicalWidth); 299 LayoutUnit computedMaxLogicalWidth = convertStyleLogicalWidthToComputedW idth(styleMaxLogicalWidth, availableLogicalWidth);
296 setLogicalWidth(LayoutUnit(std::min(logicalWidth(), computedMaxLogicalWi dth).floor())); 300 setLogicalWidth(LayoutUnit(std::min(logicalWidth(), computedMaxLogicalWi dth).floor()));
297 } 301 }
298 302
299 // Ensure we aren't smaller than our min preferred width. This MUST be done after 'max-width' as 303 // Ensure we aren't smaller than our min preferred width. This MUST be done after 'max-width' as
300 // we ignore it if it means we wouldn't accommodate our content. 304 // we ignore it if it means we wouldn't accommodate our content.
301 setLogicalWidth(LayoutUnit(std::max(logicalWidth(), minPreferredLogicalWidth ()).floor())); 305 setLogicalWidth(LayoutUnit(std::max(logicalWidth(), minPreferredLogicalWidth ()).floor()));
302 306
303 // Ensure we aren't smaller than our min-width style. 307 // Ensure we aren't smaller than our min-width style.
304 Length styleMinLogicalWidth = style()->logicalMinWidth(); 308 Length styleMinLogicalWidth = style()->logicalMinWidth();
(...skipping 1150 matching lines...) Expand 10 before | Expand all | Expand 10 after
1455 1459
1456 LayoutUnit LayoutTable::paddingRight() const 1460 LayoutUnit LayoutTable::paddingRight() const
1457 { 1461 {
1458 if (collapseBorders()) 1462 if (collapseBorders())
1459 return LayoutUnit(); 1463 return LayoutUnit();
1460 1464
1461 return LayoutBlock::paddingRight(); 1465 return LayoutBlock::paddingRight();
1462 } 1466 }
1463 1467
1464 } // namespace blink 1468 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/table/zero-width-on-table-is-auto-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698