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

Side by Side Diff: Source/core/rendering/RenderTable.cpp

Issue 82083002: Move viewport unit resolution to style recalc time (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: rename browser zoom to page zoom Created 6 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
« no previous file with comments | « Source/core/rendering/RenderScrollbarPart.cpp ('k') | Source/core/rendering/RenderTableCell.h » ('j') | 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 Apple Inc. All r ights reserved. 7 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All r ights 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 if (isOutOfFlowPositioned()) { 245 if (isOutOfFlowPositioned()) {
246 LogicalExtentComputedValues computedValues; 246 LogicalExtentComputedValues computedValues;
247 computePositionedLogicalWidth(computedValues); 247 computePositionedLogicalWidth(computedValues);
248 setLogicalWidth(computedValues.m_extent); 248 setLogicalWidth(computedValues.m_extent);
249 setLogicalLeft(computedValues.m_position); 249 setLogicalLeft(computedValues.m_position);
250 setMarginStart(computedValues.m_margins.m_start); 250 setMarginStart(computedValues.m_margins.m_start);
251 setMarginEnd(computedValues.m_margins.m_end); 251 setMarginEnd(computedValues.m_margins.m_end);
252 } 252 }
253 253
254 RenderBlock* cb = containingBlock(); 254 RenderBlock* cb = containingBlock();
255 RenderView* renderView = view();
256 255
257 LayoutUnit availableLogicalWidth = containingBlockLogicalWidthForContent(); 256 LayoutUnit availableLogicalWidth = containingBlockLogicalWidthForContent();
258 bool hasPerpendicularContainingBlock = cb->style()->isHorizontalWritingMode( ) != style()->isHorizontalWritingMode(); 257 bool hasPerpendicularContainingBlock = cb->style()->isHorizontalWritingMode( ) != style()->isHorizontalWritingMode();
259 LayoutUnit containerWidthInInlineDirection = hasPerpendicularContainingBlock ? perpendicularContainingBlockLogicalHeight() : availableLogicalWidth; 258 LayoutUnit containerWidthInInlineDirection = hasPerpendicularContainingBlock ? perpendicularContainingBlockLogicalHeight() : availableLogicalWidth;
260 259
261 Length styleLogicalWidth = style()->logicalWidth(); 260 Length styleLogicalWidth = style()->logicalWidth();
262 if ((styleLogicalWidth.isSpecified() && styleLogicalWidth.isPositive()) || s tyleLogicalWidth.isIntrinsic()) 261 if ((styleLogicalWidth.isSpecified() && styleLogicalWidth.isPositive()) || s tyleLogicalWidth.isIntrinsic())
263 setLogicalWidth(convertStyleLogicalWidthToComputedWidth(styleLogicalWidt h, containerWidthInInlineDirection)); 262 setLogicalWidth(convertStyleLogicalWidthToComputedWidth(styleLogicalWidt h, containerWidthInInlineDirection));
264 else { 263 else {
265 // Subtract out any fixed margins from our available width for auto widt h tables. 264 // Subtract out any fixed margins from our available width for auto widt h tables.
266 LayoutUnit marginStart = minimumValueForLength(style()->marginStart(), a vailableLogicalWidth, renderView); 265 LayoutUnit marginStart = minimumValueForLength(style()->marginStart(), a vailableLogicalWidth);
267 LayoutUnit marginEnd = minimumValueForLength(style()->marginEnd(), avail ableLogicalWidth, renderView); 266 LayoutUnit marginEnd = minimumValueForLength(style()->marginEnd(), avail ableLogicalWidth);
268 LayoutUnit marginTotal = marginStart + marginEnd; 267 LayoutUnit marginTotal = marginStart + marginEnd;
269 268
270 // Subtract out our margins to get the available content width. 269 // Subtract out our margins to get the available content width.
271 LayoutUnit availableContentLogicalWidth = max<LayoutUnit>(0, containerWi dthInInlineDirection - marginTotal); 270 LayoutUnit availableContentLogicalWidth = max<LayoutUnit>(0, containerWi dthInInlineDirection - marginTotal);
272 if (shrinkToAvoidFloats() && cb->containsFloats() && !hasPerpendicularCo ntainingBlock) { 271 if (shrinkToAvoidFloats() && cb->containsFloats() && !hasPerpendicularCo ntainingBlock) {
273 // FIXME: Work with regions someday. 272 // FIXME: Work with regions someday.
274 availableContentLogicalWidth = shrinkLogicalWidthToAvoidFloats(margi nStart, marginEnd, toRenderBlockFlow(cb), 0); 273 availableContentLogicalWidth = shrinkLogicalWidthToAvoidFloats(margi nStart, marginEnd, toRenderBlockFlow(cb), 0);
275 } 274 }
276 275
277 // Ensure we aren't bigger than our available width. 276 // Ensure we aren't bigger than our available width.
(...skipping 26 matching lines...) Expand all
304 if (avoidsFloats() && cb->containsFloats()) 303 if (avoidsFloats() && cb->containsFloats())
305 containerLogicalWidthForAutoMargins = containingBlockAvailableLineWi dthInRegion(0); // FIXME: Work with regions someday. 304 containerLogicalWidthForAutoMargins = containingBlockAvailableLineWi dthInRegion(0); // FIXME: Work with regions someday.
306 ComputedMarginValues marginValues; 305 ComputedMarginValues marginValues;
307 bool hasInvertedDirection = cb->style()->isLeftToRightDirection() == st yle()->isLeftToRightDirection(); 306 bool hasInvertedDirection = cb->style()->isLeftToRightDirection() == st yle()->isLeftToRightDirection();
308 computeInlineDirectionMargins(cb, containerLogicalWidthForAutoMargins, l ogicalWidth(), 307 computeInlineDirectionMargins(cb, containerLogicalWidthForAutoMargins, l ogicalWidth(),
309 hasInvertedDirection ? marginValues.m_start : marginValues.m_end, 308 hasInvertedDirection ? marginValues.m_start : marginValues.m_end,
310 hasInvertedDirection ? marginValues.m_end : marginValues.m_start); 309 hasInvertedDirection ? marginValues.m_end : marginValues.m_start);
311 setMarginStart(marginValues.m_start); 310 setMarginStart(marginValues.m_start);
312 setMarginEnd(marginValues.m_end); 311 setMarginEnd(marginValues.m_end);
313 } else { 312 } else {
314 setMarginStart(minimumValueForLength(style()->marginStart(), availableLo gicalWidth, renderView)); 313 setMarginStart(minimumValueForLength(style()->marginStart(), availableLo gicalWidth));
315 setMarginEnd(minimumValueForLength(style()->marginEnd(), availableLogica lWidth, renderView)); 314 setMarginEnd(minimumValueForLength(style()->marginEnd(), availableLogica lWidth));
316 } 315 }
317 316
318 // We should NEVER shrink the table below the min-content logical width, or else the table can't accomodate 317 // We should NEVER shrink the table below the min-content logical width, or else the table can't accomodate
319 // its own content which doesn't match CSS nor what authors expect. 318 // its own content which doesn't match CSS nor what authors expect.
320 // FIXME: When we convert to sub-pixel layout for tables we can remove the i nt conversion 319 // FIXME: When we convert to sub-pixel layout for tables we can remove the i nt conversion
321 // https://code.google.com/p/chromium/issues/detail?id=241198 320 // https://code.google.com/p/chromium/issues/detail?id=241198
322 ASSERT(logicalWidth().toInt() >= minPreferredLogicalWidth().toInt()); 321 ASSERT(logicalWidth().toInt() >= minPreferredLogicalWidth().toInt());
323 } 322 }
324 323
325 // This method takes a RenderStyle's logical width, min-width, or max-width leng th and computes its actual value. 324 // This method takes a RenderStyle's logical width, min-width, or max-width leng th and computes its actual value.
326 LayoutUnit RenderTable::convertStyleLogicalWidthToComputedWidth(const Length& st yleLogicalWidth, LayoutUnit availableWidth) 325 LayoutUnit RenderTable::convertStyleLogicalWidthToComputedWidth(const Length& st yleLogicalWidth, LayoutUnit availableWidth)
327 { 326 {
328 if (styleLogicalWidth.isIntrinsic()) 327 if (styleLogicalWidth.isIntrinsic())
329 return computeIntrinsicLogicalWidthUsing(styleLogicalWidth, availableWid th, bordersPaddingAndSpacingInRowDirection()); 328 return computeIntrinsicLogicalWidthUsing(styleLogicalWidth, availableWid th, bordersPaddingAndSpacingInRowDirection());
330 329
331 // HTML tables' width styles already include borders and paddings, but CSS t ables' width styles do not. 330 // HTML tables' width styles already include borders and paddings, but CSS t ables' width styles do not.
332 LayoutUnit borders = 0; 331 LayoutUnit borders = 0;
333 bool isCSSTable = !node() || !node()->hasTagName(tableTag); 332 bool isCSSTable = !node() || !node()->hasTagName(tableTag);
334 if (isCSSTable && styleLogicalWidth.isSpecified() && styleLogicalWidth.isPos itive() && style()->boxSizing() == CONTENT_BOX) 333 if (isCSSTable && styleLogicalWidth.isSpecified() && styleLogicalWidth.isPos itive() && style()->boxSizing() == CONTENT_BOX)
335 borders = borderStart() + borderEnd() + (collapseBorders() ? LayoutUnit( ) : paddingStart() + paddingEnd()); 334 borders = borderStart() + borderEnd() + (collapseBorders() ? LayoutUnit( ) : paddingStart() + paddingEnd());
336 335
337 return minimumValueForLength(styleLogicalWidth, availableWidth, view()) + bo rders; 336 return minimumValueForLength(styleLogicalWidth, availableWidth) + borders;
338 } 337 }
339 338
340 LayoutUnit RenderTable::convertStyleLogicalHeightToComputedHeight(const Length& styleLogicalHeight) 339 LayoutUnit RenderTable::convertStyleLogicalHeightToComputedHeight(const Length& styleLogicalHeight)
341 { 340 {
342 LayoutUnit borderAndPaddingBefore = borderBefore() + (collapseBorders() ? La youtUnit() : paddingBefore()); 341 LayoutUnit borderAndPaddingBefore = borderBefore() + (collapseBorders() ? La youtUnit() : paddingBefore());
343 LayoutUnit borderAndPaddingAfter = borderAfter() + (collapseBorders() ? Layo utUnit() : paddingAfter()); 342 LayoutUnit borderAndPaddingAfter = borderAfter() + (collapseBorders() ? Layo utUnit() : paddingAfter());
344 LayoutUnit borderAndPadding = borderAndPaddingBefore + borderAndPaddingAfter ; 343 LayoutUnit borderAndPadding = borderAndPaddingBefore + borderAndPaddingAfter ;
345 LayoutUnit computedLogicalHeight = 0; 344 LayoutUnit computedLogicalHeight = 0;
346 if (styleLogicalHeight.isFixed()) { 345 if (styleLogicalHeight.isFixed()) {
347 // HTML tables size as though CSS height includes border/padding, CSS ta bles do not. 346 // HTML tables size as though CSS height includes border/padding, CSS ta bles do not.
348 LayoutUnit borders = LayoutUnit(); 347 LayoutUnit borders = LayoutUnit();
349 // FIXME: We cannot apply box-sizing: content-box on <table> which other browsers allow. 348 // FIXME: We cannot apply box-sizing: content-box on <table> which other browsers allow.
350 if ((node() && node()->hasTagName(tableTag)) || style()->boxSizing() == BORDER_BOX) { 349 if ((node() && node()->hasTagName(tableTag)) || style()->boxSizing() == BORDER_BOX) {
351 borders = borderAndPadding; 350 borders = borderAndPadding;
352 } 351 }
353 computedLogicalHeight = styleLogicalHeight.value() - borders; 352 computedLogicalHeight = styleLogicalHeight.value() - borders;
354 } else if (styleLogicalHeight.isPercent()) 353 } else if (styleLogicalHeight.isPercent())
355 computedLogicalHeight = computePercentageLogicalHeight(styleLogicalHeigh t); 354 computedLogicalHeight = computePercentageLogicalHeight(styleLogicalHeigh t);
356 else if (styleLogicalHeight.isViewportPercentage())
357 computedLogicalHeight = minimumValueForLength(styleLogicalHeight, 0, vie w());
358 else if (styleLogicalHeight.isIntrinsic()) 355 else if (styleLogicalHeight.isIntrinsic())
359 computedLogicalHeight = computeIntrinsicLogicalContentHeightUsing(styleL ogicalHeight, logicalHeight() - borderAndPadding, borderAndPadding); 356 computedLogicalHeight = computeIntrinsicLogicalContentHeightUsing(styleL ogicalHeight, logicalHeight() - borderAndPadding, borderAndPadding);
360 else 357 else
361 ASSERT_NOT_REACHED(); 358 ASSERT_NOT_REACHED();
362 return max<LayoutUnit>(0, computedLogicalHeight); 359 return max<LayoutUnit>(0, computedLogicalHeight);
363 } 360 }
364 361
365 void RenderTable::layoutCaption(RenderTableCaption* caption) 362 void RenderTable::layoutCaption(RenderTableCaption* caption)
366 { 363 {
367 LayoutRect captionRect(caption->frameRect()); 364 LayoutRect captionRect(caption->frameRect());
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 int bordersPaddingAndSpacing = bordersPaddingAndSpacingInRowDirection(); 763 int bordersPaddingAndSpacing = bordersPaddingAndSpacingInRowDirection();
767 m_minPreferredLogicalWidth += bordersPaddingAndSpacing; 764 m_minPreferredLogicalWidth += bordersPaddingAndSpacing;
768 m_maxPreferredLogicalWidth += bordersPaddingAndSpacing; 765 m_maxPreferredLogicalWidth += bordersPaddingAndSpacing;
769 766
770 m_tableLayout->applyPreferredLogicalWidthQuirks(m_minPreferredLogicalWidth, m_maxPreferredLogicalWidth); 767 m_tableLayout->applyPreferredLogicalWidthQuirks(m_minPreferredLogicalWidth, m_maxPreferredLogicalWidth);
771 768
772 for (unsigned i = 0; i < m_captions.size(); i++) 769 for (unsigned i = 0; i < m_captions.size(); i++)
773 m_minPreferredLogicalWidth = max(m_minPreferredLogicalWidth, m_captions[ i]->minPreferredLogicalWidth()); 770 m_minPreferredLogicalWidth = max(m_minPreferredLogicalWidth, m_captions[ i]->minPreferredLogicalWidth());
774 771
775 RenderStyle* styleToUse = style(); 772 RenderStyle* styleToUse = style();
776 // FIXME: This should probably be checking for isSpecified since you should be able to use percentage, calc or viewport relative values for min-width. 773 // FIXME: This should probably be checking for isSpecified since you should be able to use percentage or calc values for min-width.
777 if (styleToUse->logicalMinWidth().isFixed() && styleToUse->logicalMinWidth() .value() > 0) { 774 if (styleToUse->logicalMinWidth().isFixed() && styleToUse->logicalMinWidth() .value() > 0) {
778 m_maxPreferredLogicalWidth = std::max(m_maxPreferredLogicalWidth, adjust ContentBoxLogicalWidthForBoxSizing(styleToUse->logicalMinWidth().value())); 775 m_maxPreferredLogicalWidth = std::max(m_maxPreferredLogicalWidth, adjust ContentBoxLogicalWidthForBoxSizing(styleToUse->logicalMinWidth().value()));
779 m_minPreferredLogicalWidth = std::max(m_minPreferredLogicalWidth, adjust ContentBoxLogicalWidthForBoxSizing(styleToUse->logicalMinWidth().value())); 776 m_minPreferredLogicalWidth = std::max(m_minPreferredLogicalWidth, adjust ContentBoxLogicalWidthForBoxSizing(styleToUse->logicalMinWidth().value()));
780 } 777 }
781 778
782 // FIXME: This should probably be checking for isSpecified since you should be able to use percentage, calc or viewport relative values for maxWidth. 779 // FIXME: This should probably be checking for isSpecified since you should be able to use percentage or calc values for maxWidth.
783 if (styleToUse->logicalMaxWidth().isFixed()) { 780 if (styleToUse->logicalMaxWidth().isFixed()) {
784 // We don't constrain m_minPreferredLogicalWidth as the table should be at least the size of its min-content, regardless of 'max-width'. 781 // We don't constrain m_minPreferredLogicalWidth as the table should be at least the size of its min-content, regardless of 'max-width'.
785 m_maxPreferredLogicalWidth = std::min(m_maxPreferredLogicalWidth, adjust ContentBoxLogicalWidthForBoxSizing(styleToUse->logicalMaxWidth().value())); 782 m_maxPreferredLogicalWidth = std::min(m_maxPreferredLogicalWidth, adjust ContentBoxLogicalWidthForBoxSizing(styleToUse->logicalMaxWidth().value()));
786 m_maxPreferredLogicalWidth = std::max(m_minPreferredLogicalWidth, m_maxP referredLogicalWidth); 783 m_maxPreferredLogicalWidth = std::max(m_minPreferredLogicalWidth, m_maxP referredLogicalWidth);
787 } 784 }
788 785
789 // FIXME: We should be adding borderAndPaddingLogicalWidth here, but m_table Layout->computePreferredLogicalWidths already does, 786 // FIXME: We should be adding borderAndPaddingLogicalWidth here, but m_table Layout->computePreferredLogicalWidths already does,
790 // so a bunch of tests break doing this naively. 787 // so a bunch of tests break doing this naively.
791 clearPreferredLogicalWidthsDirty(); 788 clearPreferredLogicalWidthsDirty();
792 } 789 }
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after
1439 const BorderValue& RenderTable::tableEndBorderAdjoiningCell(const RenderTableCel l* cell) const 1436 const BorderValue& RenderTable::tableEndBorderAdjoiningCell(const RenderTableCel l* cell) const
1440 { 1437 {
1441 ASSERT(cell->isFirstOrLastCellInRow()); 1438 ASSERT(cell->isFirstOrLastCellInRow());
1442 if (hasSameDirectionAs(cell->row())) 1439 if (hasSameDirectionAs(cell->row()))
1443 return style()->borderEnd(); 1440 return style()->borderEnd();
1444 1441
1445 return style()->borderStart(); 1442 return style()->borderStart();
1446 } 1443 }
1447 1444
1448 } 1445 }
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderScrollbarPart.cpp ('k') | Source/core/rendering/RenderTableCell.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698