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

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

Issue 2528253003: [table] Stretching tables when needed due to self-alignment properties (Closed)
Patch Set: Applied additional suggested changes. Created 3 years, 11 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. 7 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2013 Apple Inc.
8 * All rights reserved. 8 * All rights reserved.
9 * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com) 9 * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com)
10 * 10 *
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 290
291 // Subtract out our margins to get the available content width. 291 // Subtract out our margins to get the available content width.
292 LayoutUnit availableContentLogicalWidth = 292 LayoutUnit availableContentLogicalWidth =
293 (containerWidthInInlineDirection - marginTotal).clampNegativeToZero(); 293 (containerWidthInInlineDirection - marginTotal).clampNegativeToZero();
294 if (shrinkToAvoidFloats() && cb->isLayoutBlockFlow() && 294 if (shrinkToAvoidFloats() && cb->isLayoutBlockFlow() &&
295 toLayoutBlockFlow(cb)->containsFloats() && 295 toLayoutBlockFlow(cb)->containsFloats() &&
296 !hasPerpendicularContainingBlock) 296 !hasPerpendicularContainingBlock)
297 availableContentLogicalWidth = shrinkLogicalWidthToAvoidFloats( 297 availableContentLogicalWidth = shrinkLogicalWidthToAvoidFloats(
298 marginStart, marginEnd, toLayoutBlockFlow(cb)); 298 marginStart, marginEnd, toLayoutBlockFlow(cb));
299 299
300 // Ensure we aren't bigger than our available width. 300 if (hasStretchedLogicalWidth()) {
301 LayoutUnit maxWidth = maxPreferredLogicalWidth(); 301 setLogicalWidth(availableContentLogicalWidth);
302 // scaledWidthFromPercentColumns depends on m_layoutStruct in 302 } else {
303 // TableLayoutAlgorithmAuto, which maxPreferredLogicalWidth fills in. So 303 // Ensure we aren't bigger than our available width.
304 // scaledWidthFromPercentColumns has to be called after 304 LayoutUnit maxWidth = maxPreferredLogicalWidth();
305 // maxPreferredLogicalWidth. 305 // scaledWidthFromPercentColumns depends on m_layoutStruct in
306 LayoutUnit scaledWidth = m_tableLayout->scaledWidthFromPercentColumns() + 306 // TableLayoutAlgorithmAuto, which maxPreferredLogicalWidth fills in. So
307 bordersPaddingAndSpacingInRowDirection(); 307 // scaledWidthFromPercentColumns has to be called after
308 maxWidth = std::max(scaledWidth, maxWidth); 308 // maxPreferredLogicalWidth.
309 setLogicalWidth( 309 LayoutUnit scaledWidth = m_tableLayout->scaledWidthFromPercentColumns() +
310 LayoutUnit(std::min(availableContentLogicalWidth, maxWidth).floor())); 310 bordersPaddingAndSpacingInRowDirection();
311 maxWidth = std::max(scaledWidth, maxWidth);
312 setLogicalWidth(
313 LayoutUnit(std::min(availableContentLogicalWidth, maxWidth).floor()));
314 }
311 } 315 }
312 316
313 // Ensure we aren't bigger than our max-width style. 317 // Ensure we aren't bigger than our max-width style.
314 Length styleMaxLogicalWidth = style()->logicalMaxWidth(); 318 Length styleMaxLogicalWidth = style()->logicalMaxWidth();
315 if ((styleMaxLogicalWidth.isSpecified() && 319 if ((styleMaxLogicalWidth.isSpecified() &&
316 !styleMaxLogicalWidth.isNegative()) || 320 !styleMaxLogicalWidth.isNegative()) ||
317 styleMaxLogicalWidth.isIntrinsic()) { 321 styleMaxLogicalWidth.isIntrinsic()) {
318 LayoutUnit computedMaxLogicalWidth = 322 LayoutUnit computedMaxLogicalWidth =
319 convertStyleLogicalWidthToComputedWidth(styleMaxLogicalWidth, 323 convertStyleLogicalWidthToComputedWidth(styleMaxLogicalWidth,
320 availableLogicalWidth); 324 availableLogicalWidth);
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 section.layoutIfNeeded(); 458 section.layoutIfNeeded();
455 int sectionLogicalHeight = section.calcRowLogicalHeight(); 459 int sectionLogicalHeight = section.calcRowLogicalHeight();
456 section.setLogicalHeight(LayoutUnit(sectionLogicalHeight)); 460 section.setLogicalHeight(LayoutUnit(sectionLogicalHeight));
457 if (view()->layoutState()->isPaginated()) 461 if (view()->layoutState()->isPaginated())
458 updateFragmentationInfoForChild(section); 462 updateFragmentationInfoForChild(section);
459 setLogicalHeight(logicalHeight() + sectionLogicalHeight); 463 setLogicalHeight(logicalHeight() + sectionLogicalHeight);
460 } 464 }
461 465
462 LayoutUnit LayoutTable::logicalHeightFromStyle() const { 466 LayoutUnit LayoutTable::logicalHeightFromStyle() const {
463 LayoutUnit computedLogicalHeight; 467 LayoutUnit computedLogicalHeight;
464 Length logicalHeightLength = style()->logicalHeight(); 468 if (hasOverrideLogicalContentHeight()) {
465 if (logicalHeightLength.isIntrinsic() || 469 computedLogicalHeight = overrideLogicalContentHeight();
466 (logicalHeightLength.isSpecified() && logicalHeightLength.isPositive())) { 470 } else {
467 computedLogicalHeight = 471 Length logicalHeightLength = style()->logicalHeight();
468 convertStyleLogicalHeightToComputedHeight(logicalHeightLength); 472 if (logicalHeightLength.isIntrinsic() ||
473 (logicalHeightLength.isSpecified() &&
474 logicalHeightLength.isPositive())) {
475 computedLogicalHeight =
476 convertStyleLogicalHeightToComputedHeight(logicalHeightLength);
477 }
469 } 478 }
470 479
471 Length logicalMaxHeightLength = style()->logicalMaxHeight(); 480 Length logicalMaxHeightLength = style()->logicalMaxHeight();
472 if (logicalMaxHeightLength.isIntrinsic() || 481 if (logicalMaxHeightLength.isIntrinsic() ||
473 (logicalMaxHeightLength.isSpecified() && 482 (logicalMaxHeightLength.isSpecified() &&
474 !logicalMaxHeightLength.isNegative())) { 483 !logicalMaxHeightLength.isNegative())) {
475 LayoutUnit computedMaxLogicalHeight = 484 LayoutUnit computedMaxLogicalHeight =
476 convertStyleLogicalHeightToComputedHeight(logicalMaxHeightLength); 485 convertStyleLogicalHeightToComputedHeight(logicalMaxHeightLength);
477 computedLogicalHeight = 486 computedLogicalHeight =
478 std::min(computedLogicalHeight, computedMaxLogicalHeight); 487 std::min(computedLogicalHeight, computedMaxLogicalHeight);
(...skipping 1209 matching lines...) Expand 10 before | Expand all | Expand 10 after
1688 } 1697 }
1689 1698
1690 LayoutUnit LayoutTable::paddingRight() const { 1699 LayoutUnit LayoutTable::paddingRight() const {
1691 if (collapseBorders()) 1700 if (collapseBorders())
1692 return LayoutUnit(); 1701 return LayoutUnit();
1693 1702
1694 return LayoutBlock::paddingRight(); 1703 return LayoutBlock::paddingRight();
1695 } 1704 }
1696 1705
1697 } // namespace blink 1706 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698