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

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

Issue 1868013002: Percent height in auto height containers no longer computes as auto (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@303728-6
Patch Set: Updated Created 4 years, 8 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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2000 Dirk Mueller (mueller@kde.org) 3 * Copyright (C) 2000 Dirk Mueller (mueller@kde.org)
4 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. 4 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved.
5 * Copyright (C) Research In Motion Limited 2011-2012. All rights reserved. 5 * Copyright (C) Research In Motion Limited 2011-2012. All rights reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 return computeReplacedLogicalWidthRespectingMinMaxWidth(computeReplacedL ogicalWidthUsing(MainOrPreferredSize, style()->logicalWidth()), shouldComputePre ferred); 557 return computeReplacedLogicalWidthRespectingMinMaxWidth(computeReplacedL ogicalWidthUsing(MainOrPreferredSize, style()->logicalWidth()), shouldComputePre ferred);
558 558
559 LayoutReplaced* contentLayoutObject = embeddedReplacedContent(); 559 LayoutReplaced* contentLayoutObject = embeddedReplacedContent();
560 560
561 // 10.3.2 Inline, replaced elements: http://www.w3.org/TR/CSS21/visudet.html #inline-replaced-width 561 // 10.3.2 Inline, replaced elements: http://www.w3.org/TR/CSS21/visudet.html #inline-replaced-width
562 IntrinsicSizingInfo intrinsicSizingInfo; 562 IntrinsicSizingInfo intrinsicSizingInfo;
563 computeIntrinsicSizingInfoForReplacedContent(contentLayoutObject, intrinsicS izingInfo); 563 computeIntrinsicSizingInfoForReplacedContent(contentLayoutObject, intrinsicS izingInfo);
564 FloatSize constrainedSize = constrainIntrinsicSizeToMinMax(intrinsicSizingIn fo); 564 FloatSize constrainedSize = constrainIntrinsicSizeToMinMax(intrinsicSizingIn fo);
565 565
566 if (style()->logicalWidth().isAuto()) { 566 if (style()->logicalWidth().isAuto()) {
567 bool computedHeightIsAuto = hasAutoHeightOrContainingBlockWithAutoHeight (); 567 bool computedHeightIsAuto = style()->logicalHeight().isAuto();
568 568
569 // If 'height' and 'width' both have computed values of 'auto' and the e lement also has an intrinsic width, then that intrinsic width is the used value of 'width'. 569 // If 'height' and 'width' both have computed values of 'auto' and the e lement also has an intrinsic width, then that intrinsic width is the used value of 'width'.
570 if (computedHeightIsAuto && intrinsicSizingInfo.hasWidth) 570 if (computedHeightIsAuto && intrinsicSizingInfo.hasWidth)
571 return computeReplacedLogicalWidthRespectingMinMaxWidth(LayoutUnit(c onstrainedSize.width()), shouldComputePreferred); 571 return computeReplacedLogicalWidthRespectingMinMaxWidth(LayoutUnit(c onstrainedSize.width()), shouldComputePreferred);
572 572
573 if (!intrinsicSizingInfo.aspectRatio.isEmpty()) { 573 if (!intrinsicSizingInfo.aspectRatio.isEmpty()) {
574 // If 'height' and 'width' both have computed values of 'auto' and t he element has no intrinsic width, but does have an intrinsic height and intrins ic ratio; 574 // If 'height' and 'width' both have computed values of 'auto' and t he element has no intrinsic width, but does have an intrinsic height and intrins ic ratio;
575 // or if 'width' has a computed value of 'auto', 'height' has some o ther computed value, and the element does have an intrinsic ratio; then the used value 575 // or if 'width' has a computed value of 'auto', 'height' has some o ther computed value, and the element does have an intrinsic ratio; then the used value
576 // of 'width' is: (used height) * (intrinsic ratio) 576 // of 'width' is: (used height) * (intrinsic ratio)
577 if ((computedHeightIsAuto && !intrinsicSizingInfo.hasWidth && intrin sicSizingInfo.hasHeight) || !computedHeightIsAuto) { 577 if ((computedHeightIsAuto && !intrinsicSizingInfo.hasWidth && intrin sicSizingInfo.hasHeight) || !computedHeightIsAuto) {
578 LayoutUnit logicalHeight = computeReplacedLogicalHeight(); 578 LayoutUnit estimatedUsedWidth = intrinsicSizingInfo.hasWidth ? L ayoutUnit(constrainedSize.width()) : containingBlock()->availableLogicalWidth();
579 return computeReplacedLogicalWidthRespectingMinMaxWidth(resolveW idthForRatio(logicalHeight, intrinsicSizingInfo.aspectRatio), shouldComputePrefe rred); 579 LayoutUnit logicalHeight = computeReplacedLogicalHeight(estimate dUsedWidth);
580 LayoutUnit width = computeReplacedLogicalWidthRespectingMinMaxWi dth(resolveWidthForRatio(logicalHeight, intrinsicSizingInfo.aspectRatio), should ComputePreferred);
581 return width;
cbiesinger 2016/04/15 21:44:39 I would merge this line with the previous one and
580 } 582 }
581 583
582 // If 'height' and 'width' both have computed values of 'auto' and t he element has an intrinsic ratio but no intrinsic height or width, then the use d value of 584 // If 'height' and 'width' both have computed values of 'auto' and t he element has an intrinsic ratio but no intrinsic height or width, then the use d value of
583 // 'width' is undefined in CSS 2.1. However, it is suggested that, i f the containing block's width does not itself depend on the replaced element's width, then 585 // 'width' is undefined in CSS 2.1. However, it is suggested that, i f the containing block's width does not itself depend on the replaced element's width, then
584 // the used value of 'width' is calculated from the constraint equat ion used for block-level, non-replaced elements in normal flow. 586 // the used value of 'width' is calculated from the constraint equat ion used for block-level, non-replaced elements in normal flow.
585 if (computedHeightIsAuto && !intrinsicSizingInfo.hasWidth && !intrin sicSizingInfo.hasHeight) { 587 if (computedHeightIsAuto && !intrinsicSizingInfo.hasWidth && !intrin sicSizingInfo.hasHeight) {
586 if (shouldComputePreferred == ComputePreferred) 588 if (shouldComputePreferred == ComputePreferred)
587 return computeReplacedLogicalWidthRespectingMinMaxWidth(Layo utUnit(), ComputePreferred); 589 return computeReplacedLogicalWidthRespectingMinMaxWidth(Layo utUnit(), ComputePreferred);
588 // The aforementioned 'constraint equation' used for block-level , non-replaced elements in normal flow: 590 // The aforementioned 'constraint equation' used for block-level , non-replaced elements in normal flow:
589 // 'margin-left' + 'border-left-width' + 'padding-left' + 'width ' + 'padding-right' + 'border-right-width' + 'margin-right' = width of containin g block 591 // 'margin-left' + 'border-left-width' + 'padding-left' + 'width ' + 'padding-right' + 'border-right-width' + 'margin-right' = width of containin g block
(...skipping 14 matching lines...) Expand all
604 // Otherwise, if 'width' has a computed value of 'auto', but none of the conditions above are met, then the used value of 'width' becomes 300px. If 300p x is too 606 // Otherwise, if 'width' has a computed value of 'auto', but none of the conditions above are met, then the used value of 'width' becomes 300px. If 300p x is too
605 // wide to fit the device, UAs should use the width of the largest recta ngle that has a 2:1 ratio and fits the device instead. 607 // wide to fit the device, UAs should use the width of the largest recta ngle that has a 2:1 ratio and fits the device instead.
606 // Note: We fall through and instead return intrinsicLogicalWidth() here - to preserve existing WebKit behavior, which might or might not be correct, or desired. 608 // Note: We fall through and instead return intrinsicLogicalWidth() here - to preserve existing WebKit behavior, which might or might not be correct, or desired.
607 // Changing this to return cDefaultWidth, will affect lots of test resul ts. Eg. some tests assume that a blank <img> tag (which implies width/height=aut o) 609 // Changing this to return cDefaultWidth, will affect lots of test resul ts. Eg. some tests assume that a blank <img> tag (which implies width/height=aut o)
608 // has no intrinsic size, which is wrong per CSS 2.1, but matches our be havior since a long time. 610 // has no intrinsic size, which is wrong per CSS 2.1, but matches our be havior since a long time.
609 } 611 }
610 612
611 return computeReplacedLogicalWidthRespectingMinMaxWidth(intrinsicLogicalWidt h(), shouldComputePreferred); 613 return computeReplacedLogicalWidthRespectingMinMaxWidth(intrinsicLogicalWidt h(), shouldComputePreferred);
612 } 614 }
613 615
614 LayoutUnit LayoutReplaced::computeReplacedLogicalHeight() const 616 LayoutUnit LayoutReplaced::computeReplacedLogicalHeight(LayoutUnit estimatedUsed Width) const
615 { 617 {
616 // 10.5 Content height: the 'height' property: http://www.w3.org/TR/CSS21/vi sudet.html#propdef-height 618 // 10.5 Content height: the 'height' property: http://www.w3.org/TR/CSS21/vi sudet.html#propdef-height
617 if (hasReplacedLogicalHeight()) 619 if (hasReplacedLogicalHeight())
618 return computeReplacedLogicalHeightRespectingMinMaxHeight(computeReplace dLogicalHeightUsing(MainOrPreferredSize, style()->logicalHeight())); 620 return computeReplacedLogicalHeightRespectingMinMaxHeight(computeReplace dLogicalHeightUsing(MainOrPreferredSize, style()->logicalHeight()));
619 621
620 LayoutReplaced* contentLayoutObject = embeddedReplacedContent(); 622 LayoutReplaced* contentLayoutObject = embeddedReplacedContent();
621 623
622 // 10.6.2 Inline, replaced elements: http://www.w3.org/TR/CSS21/visudet.html #inline-replaced-height 624 // 10.6.2 Inline, replaced elements: http://www.w3.org/TR/CSS21/visudet.html #inline-replaced-height
623 IntrinsicSizingInfo intrinsicSizingInfo; 625 IntrinsicSizingInfo intrinsicSizingInfo;
624 computeIntrinsicSizingInfoForReplacedContent(contentLayoutObject, intrinsicS izingInfo); 626 computeIntrinsicSizingInfoForReplacedContent(contentLayoutObject, intrinsicS izingInfo);
625 FloatSize constrainedSize = constrainIntrinsicSizeToMinMax(intrinsicSizingIn fo); 627 FloatSize constrainedSize = constrainIntrinsicSizeToMinMax(intrinsicSizingIn fo);
626 628
627 bool widthIsAuto = style()->logicalWidth().isAuto(); 629 bool widthIsAuto = style()->logicalWidth().isAuto();
628 630
629 // If 'height' and 'width' both have computed values of 'auto' and the eleme nt also has an intrinsic height, then that intrinsic height is the used value of 'height'. 631 // If 'height' and 'width' both have computed values of 'auto' and the eleme nt also has an intrinsic height, then that intrinsic height is the used value of 'height'.
630 if (widthIsAuto && intrinsicSizingInfo.hasHeight) 632 if (widthIsAuto && intrinsicSizingInfo.hasHeight)
631 return computeReplacedLogicalHeightRespectingMinMaxHeight(LayoutUnit(con strainedSize.height())); 633 return computeReplacedLogicalHeightRespectingMinMaxHeight(LayoutUnit(con strainedSize.height()));
632 634
633 // Otherwise, if 'height' has a computed value of 'auto', and the element ha s an intrinsic ratio then the used value of 'height' is: 635 // Otherwise, if 'height' has a computed value of 'auto', and the element ha s an intrinsic ratio then the used value of 'height' is:
634 // (used width) / (intrinsic ratio) 636 // (used width) / (intrinsic ratio)
635 if (!intrinsicSizingInfo.aspectRatio.isEmpty()) 637 if (!intrinsicSizingInfo.aspectRatio.isEmpty()) {
636 return computeReplacedLogicalHeightRespectingMinMaxHeight(resolveHeightF orRatio(availableLogicalWidth(), intrinsicSizingInfo.aspectRatio)); 638 LayoutUnit usedWidth = estimatedUsedWidth ? estimatedUsedWidth : availab leLogicalWidth();
639 return computeReplacedLogicalHeightRespectingMinMaxHeight(resolveHeightF orRatio(usedWidth, intrinsicSizingInfo.aspectRatio));
640 }
637 641
638 // Otherwise, if 'height' has a computed value of 'auto', and the element ha s an intrinsic height, then that intrinsic height is the used value of 'height'. 642 // Otherwise, if 'height' has a computed value of 'auto', and the element ha s an intrinsic height, then that intrinsic height is the used value of 'height'.
639 if (intrinsicSizingInfo.hasHeight) 643 if (intrinsicSizingInfo.hasHeight)
640 return computeReplacedLogicalHeightRespectingMinMaxHeight(LayoutUnit(con strainedSize.height())); 644 return computeReplacedLogicalHeightRespectingMinMaxHeight(LayoutUnit(con strainedSize.height()));
641 645
642 // Otherwise, if 'height' has a computed value of 'auto', but none of the co nditions above are met, then the used value of 'height' must be set to the heigh t 646 // Otherwise, if 'height' has a computed value of 'auto', but none of the co nditions above are met, then the used value of 'height' must be set to the heigh t
643 // of the largest rectangle that has a 2:1 ratio, has a height not greater t han 150px, and has a width not greater than the device width. 647 // of the largest rectangle that has a 2:1 ratio, has a height not greater t han 150px, and has a width not greater than the device width.
644 return computeReplacedLogicalHeightRespectingMinMaxHeight(intrinsicLogicalHe ight()); 648 return computeReplacedLogicalHeightRespectingMinMaxHeight(intrinsicLogicalHe ight());
645 } 649 }
646 650
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 } 751 }
748 752
749 void LayoutReplaced::IntrinsicSizingInfo::transpose() 753 void LayoutReplaced::IntrinsicSizingInfo::transpose()
750 { 754 {
751 size = size.transposedSize(); 755 size = size.transposedSize();
752 aspectRatio = aspectRatio.transposedSize(); 756 aspectRatio = aspectRatio.transposedSize();
753 std::swap(hasWidth, hasHeight); 757 std::swap(hasWidth, hasHeight);
754 } 758 }
755 759
756 } // namespace blink 760 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutReplaced.h ('k') | third_party/WebKit/Source/core/layout/LayoutVideo.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698