OLD | NEW |
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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 LayoutBox::styleDidChange(diff, oldStyle); | 70 LayoutBox::styleDidChange(diff, oldStyle); |
71 | 71 |
72 bool hadStyle = (oldStyle != 0); | 72 bool hadStyle = (oldStyle != 0); |
73 float oldZoom = | 73 float oldZoom = |
74 hadStyle ? oldStyle->effectiveZoom() : ComputedStyle::initialZoom(); | 74 hadStyle ? oldStyle->effectiveZoom() : ComputedStyle::initialZoom(); |
75 if (style() && style()->effectiveZoom() != oldZoom) | 75 if (style() && style()->effectiveZoom() != oldZoom) |
76 intrinsicSizeChanged(); | 76 intrinsicSizeChanged(); |
77 } | 77 } |
78 | 78 |
79 void LayoutReplaced::layout() { | 79 void LayoutReplaced::layout() { |
80 ASSERT(needsLayout()); | 80 DCHECK(needsLayout()); |
81 LayoutAnalyzer::Scope analyzer(*this); | 81 LayoutAnalyzer::Scope analyzer(*this); |
82 | 82 |
83 LayoutRect oldContentRect = replacedContentRect(); | 83 LayoutRect oldContentRect = replacedContentRect(); |
84 | 84 |
85 setHeight(minimumReplacedHeight()); | 85 setHeight(minimumReplacedHeight()); |
86 | 86 |
87 updateLogicalWidth(); | 87 updateLogicalWidth(); |
88 updateLogicalHeight(); | 88 updateLogicalHeight(); |
89 | 89 |
90 m_overflow.reset(); | 90 m_overflow.reset(); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 | 130 |
131 bool LayoutReplaced::needsPreferredWidthsRecalculation() const { | 131 bool LayoutReplaced::needsPreferredWidthsRecalculation() const { |
132 // If the height is a percentage and the width is auto, then the | 132 // If the height is a percentage and the width is auto, then the |
133 // containingBlocks's height changing can cause this node to change it's | 133 // containingBlocks's height changing can cause this node to change it's |
134 // preferred width because it maintains aspect ratio. | 134 // preferred width because it maintains aspect ratio. |
135 return hasRelativeLogicalHeight() && style()->logicalWidth().isAuto(); | 135 return hasRelativeLogicalHeight() && style()->logicalWidth().isAuto(); |
136 } | 136 } |
137 | 137 |
138 static inline bool layoutObjectHasAspectRatio( | 138 static inline bool layoutObjectHasAspectRatio( |
139 const LayoutObject* layoutObject) { | 139 const LayoutObject* layoutObject) { |
140 ASSERT(layoutObject); | 140 DCHECK(layoutObject); |
141 return layoutObject->isImage() || layoutObject->isCanvas() || | 141 return layoutObject->isImage() || layoutObject->isCanvas() || |
142 layoutObject->isVideo(); | 142 layoutObject->isVideo(); |
143 } | 143 } |
144 | 144 |
145 void LayoutReplaced::computeIntrinsicSizingInfoForReplacedContent( | 145 void LayoutReplaced::computeIntrinsicSizingInfoForReplacedContent( |
146 LayoutReplaced* contentLayoutObject, | 146 LayoutReplaced* contentLayoutObject, |
147 IntrinsicSizingInfo& intrinsicSizingInfo) const { | 147 IntrinsicSizingInfo& intrinsicSizingInfo) const { |
148 if (contentLayoutObject) { | 148 if (contentLayoutObject) { |
149 contentLayoutObject->computeIntrinsicSizingInfo(intrinsicSizingInfo); | 149 contentLayoutObject->computeIntrinsicSizingInfo(intrinsicSizingInfo); |
150 | 150 |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 // get equal values, unless this would make them negative, in which case | 278 // get equal values, unless this would make them negative, in which case |
279 // when the direction of the containing block is 'ltr' ('rtl'), set | 279 // when the direction of the containing block is 'ltr' ('rtl'), set |
280 // 'margin-left' ('margin-right') to zero and solve for 'margin-right' | 280 // 'margin-left' ('margin-right') to zero and solve for 'margin-right' |
281 // ('margin-left'). | 281 // ('margin-left'). |
282 // --------------------------------------------------------------------------- | 282 // --------------------------------------------------------------------------- |
283 LayoutUnit logicalLeftValue; | 283 LayoutUnit logicalLeftValue; |
284 LayoutUnit logicalRightValue; | 284 LayoutUnit logicalRightValue; |
285 | 285 |
286 if (marginLogicalLeft.isAuto() && marginLogicalRight.isAuto()) { | 286 if (marginLogicalLeft.isAuto() && marginLogicalRight.isAuto()) { |
287 // 'left' and 'right' cannot be 'auto' due to step 3 | 287 // 'left' and 'right' cannot be 'auto' due to step 3 |
288 ASSERT(!(logicalLeft.isAuto() && logicalRight.isAuto())); | 288 DCHECK(!(logicalLeft.isAuto() && logicalRight.isAuto())); |
289 | 289 |
290 logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth); | 290 logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth); |
291 logicalRightValue = valueForLength(logicalRight, containerLogicalWidth); | 291 logicalRightValue = valueForLength(logicalRight, containerLogicalWidth); |
292 | 292 |
293 LayoutUnit difference = | 293 LayoutUnit difference = |
294 availableSpace - (logicalLeftValue + logicalRightValue); | 294 availableSpace - (logicalLeftValue + logicalRightValue); |
295 if (difference > LayoutUnit()) { | 295 if (difference > LayoutUnit()) { |
296 marginLogicalLeftAlias = difference / 2; // split the difference | 296 marginLogicalLeftAlias = difference / 2; // split the difference |
297 marginLogicalRightAlias = | 297 marginLogicalRightAlias = |
298 difference - | 298 difference - |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 // --------------------------------------------------------------------------- | 478 // --------------------------------------------------------------------------- |
479 // 4. If at this point both 'margin-top' and 'margin-bottom' are still 'auto', | 479 // 4. If at this point both 'margin-top' and 'margin-bottom' are still 'auto', |
480 // solve the equation under the extra constraint that the two margins must | 480 // solve the equation under the extra constraint that the two margins must |
481 // get equal values. | 481 // get equal values. |
482 // --------------------------------------------------------------------------- | 482 // --------------------------------------------------------------------------- |
483 LayoutUnit logicalTopValue; | 483 LayoutUnit logicalTopValue; |
484 LayoutUnit logicalBottomValue; | 484 LayoutUnit logicalBottomValue; |
485 | 485 |
486 if (marginBefore.isAuto() && marginAfter.isAuto()) { | 486 if (marginBefore.isAuto() && marginAfter.isAuto()) { |
487 // 'top' and 'bottom' cannot be 'auto' due to step 2 and 3 combined. | 487 // 'top' and 'bottom' cannot be 'auto' due to step 2 and 3 combined. |
488 ASSERT(!(logicalTop.isAuto() || logicalBottom.isAuto())); | 488 DCHECK(!(logicalTop.isAuto() || logicalBottom.isAuto())); |
489 | 489 |
490 logicalTopValue = valueForLength(logicalTop, containerLogicalHeight); | 490 logicalTopValue = valueForLength(logicalTop, containerLogicalHeight); |
491 logicalBottomValue = valueForLength(logicalBottom, containerLogicalHeight); | 491 logicalBottomValue = valueForLength(logicalBottom, containerLogicalHeight); |
492 | 492 |
493 LayoutUnit difference = | 493 LayoutUnit difference = |
494 availableSpace - (logicalTopValue + logicalBottomValue); | 494 availableSpace - (logicalTopValue + logicalBottomValue); |
495 // NOTE: This may result in negative values. | 495 // NOTE: This may result in negative values. |
496 marginBeforeAlias = difference / 2; // split the difference | 496 marginBeforeAlias = difference / 2; // split the difference |
497 marginAfterAlias = | 497 marginAfterAlias = |
498 difference - marginBeforeAlias; // account for odd valued differences | 498 difference - marginBeforeAlias; // account for odd valued differences |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 } | 617 } |
618 | 618 |
619 LayoutRect LayoutReplaced::replacedContentRect() const { | 619 LayoutRect LayoutReplaced::replacedContentRect() const { |
620 return computeObjectFit(); | 620 return computeObjectFit(); |
621 } | 621 } |
622 | 622 |
623 void LayoutReplaced::computeIntrinsicSizingInfo( | 623 void LayoutReplaced::computeIntrinsicSizingInfo( |
624 IntrinsicSizingInfo& intrinsicSizingInfo) const { | 624 IntrinsicSizingInfo& intrinsicSizingInfo) const { |
625 // If there's an embeddedReplacedContent() of a remote, referenced document | 625 // If there's an embeddedReplacedContent() of a remote, referenced document |
626 // available, this code-path should never be used. | 626 // available, this code-path should never be used. |
627 ASSERT(!embeddedReplacedContent()); | 627 DCHECK(!embeddedReplacedContent()); |
628 intrinsicSizingInfo.size = FloatSize(intrinsicLogicalWidth().toFloat(), | 628 intrinsicSizingInfo.size = FloatSize(intrinsicLogicalWidth().toFloat(), |
629 intrinsicLogicalHeight().toFloat()); | 629 intrinsicLogicalHeight().toFloat()); |
630 | 630 |
631 // Figure out if we need to compute an intrinsic ratio. | 631 // Figure out if we need to compute an intrinsic ratio. |
632 if (intrinsicSizingInfo.size.isEmpty() || !layoutObjectHasAspectRatio(this)) | 632 if (intrinsicSizingInfo.size.isEmpty() || !layoutObjectHasAspectRatio(this)) |
633 return; | 633 return; |
634 | 634 |
635 intrinsicSizingInfo.aspectRatio = intrinsicSizingInfo.size; | 635 intrinsicSizingInfo.aspectRatio = intrinsicSizingInfo.size; |
636 } | 636 } |
637 | 637 |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
809 intrinsicLogicalHeight()); | 809 intrinsicLogicalHeight()); |
810 } | 810 } |
811 | 811 |
812 void LayoutReplaced::computeIntrinsicLogicalWidths( | 812 void LayoutReplaced::computeIntrinsicLogicalWidths( |
813 LayoutUnit& minLogicalWidth, | 813 LayoutUnit& minLogicalWidth, |
814 LayoutUnit& maxLogicalWidth) const { | 814 LayoutUnit& maxLogicalWidth) const { |
815 minLogicalWidth = maxLogicalWidth = intrinsicLogicalWidth(); | 815 minLogicalWidth = maxLogicalWidth = intrinsicLogicalWidth(); |
816 } | 816 } |
817 | 817 |
818 void LayoutReplaced::computePreferredLogicalWidths() { | 818 void LayoutReplaced::computePreferredLogicalWidths() { |
819 ASSERT(preferredLogicalWidthsDirty()); | 819 DCHECK(preferredLogicalWidthsDirty()); |
820 | 820 |
821 // We cannot resolve some logical width here (i.e. percent, fill-available or | 821 // We cannot resolve some logical width here (i.e. percent, fill-available or |
822 // fit-content) as the available logical width may not be set on our | 822 // fit-content) as the available logical width may not be set on our |
823 // containing block. | 823 // containing block. |
824 const Length& logicalWidth = style()->logicalWidth(); | 824 const Length& logicalWidth = style()->logicalWidth(); |
825 if (logicalWidth.isPercentOrCalc() || logicalWidth.isFillAvailable() || | 825 if (logicalWidth.isPercentOrCalc() || logicalWidth.isFillAvailable() || |
826 logicalWidth.isFitContent()) | 826 logicalWidth.isFitContent()) |
827 computeIntrinsicLogicalWidths(m_minPreferredLogicalWidth, | 827 computeIntrinsicLogicalWidths(m_minPreferredLogicalWidth, |
828 m_maxPreferredLogicalWidth); | 828 m_maxPreferredLogicalWidth); |
829 else | 829 else |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
927 inlineBoxWrapper()->root().setHasSelectedChildren(state != SelectionNone); | 927 inlineBoxWrapper()->root().setHasSelectedChildren(state != SelectionNone); |
928 } | 928 } |
929 | 929 |
930 void LayoutReplaced::IntrinsicSizingInfo::transpose() { | 930 void LayoutReplaced::IntrinsicSizingInfo::transpose() { |
931 size = size.transposedSize(); | 931 size = size.transposedSize(); |
932 aspectRatio = aspectRatio.transposedSize(); | 932 aspectRatio = aspectRatio.transposedSize(); |
933 std::swap(hasWidth, hasHeight); | 933 std::swap(hasWidth, hasHeight); |
934 } | 934 } |
935 | 935 |
936 } // namespace blink | 936 } // namespace blink |
OLD | NEW |