| 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 // this node to change it's preferred width because it maintains aspect rati
o. | 139 // this node to change it's preferred width because it maintains aspect rati
o. |
| 140 return hasRelativeLogicalHeight() && style()->logicalWidth().isAuto() && !ha
sAutoHeightOrContainingBlockWithAutoHeight(); | 140 return hasRelativeLogicalHeight() && style()->logicalWidth().isAuto() && !ha
sAutoHeightOrContainingBlockWithAutoHeight(); |
| 141 } | 141 } |
| 142 | 142 |
| 143 static inline bool layoutObjectHasAspectRatio(const LayoutObject* layoutObject) | 143 static inline bool layoutObjectHasAspectRatio(const LayoutObject* layoutObject) |
| 144 { | 144 { |
| 145 ASSERT(layoutObject); | 145 ASSERT(layoutObject); |
| 146 return layoutObject->isImage() || layoutObject->isCanvas() || layoutObject->
isVideo(); | 146 return layoutObject->isImage() || layoutObject->isCanvas() || layoutObject->
isVideo(); |
| 147 } | 147 } |
| 148 | 148 |
| 149 void LayoutReplaced::computeIntrinsicSizingInfoForLayoutBox(LayoutBox* contentLa
youtObject, IntrinsicSizingInfo& intrinsicSizingInfo) const | 149 void LayoutReplaced::computeIntrinsicSizingInfoForReplacedContent(LayoutReplaced
* contentLayoutObject, IntrinsicSizingInfo& intrinsicSizingInfo) const |
| 150 { | 150 { |
| 151 if (contentLayoutObject) { | 151 if (contentLayoutObject) { |
| 152 contentLayoutObject->computeIntrinsicSizingInfo(intrinsicSizingInfo); | 152 contentLayoutObject->computeIntrinsicSizingInfo(intrinsicSizingInfo); |
| 153 | 153 |
| 154 // Handle zoom & vertical writing modes here, as the embedded document d
oesn't know about them. | 154 // Handle zoom & vertical writing modes here, as the embedded document d
oesn't know about them. |
| 155 intrinsicSizingInfo.size.scale(style()->effectiveZoom()); | 155 intrinsicSizingInfo.size.scale(style()->effectiveZoom()); |
| 156 if (isLayoutImage()) | 156 if (isLayoutImage()) |
| 157 intrinsicSizingInfo.size.scale(toLayoutImage(this)->imageDevicePixel
Ratio()); | 157 intrinsicSizingInfo.size.scale(toLayoutImage(this)->imageDevicePixel
Ratio()); |
| 158 | 158 |
| 159 // Update our intrinsic size to match what the content layoutObject has
computed, so that when we | 159 // Update our intrinsic size to match what the content layoutObject has
computed, so that when we |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 | 553 |
| 554 LayoutUnit LayoutReplaced::computeReplacedLogicalWidth(ShouldComputePreferred sh
ouldComputePreferred) const | 554 LayoutUnit LayoutReplaced::computeReplacedLogicalWidth(ShouldComputePreferred sh
ouldComputePreferred) const |
| 555 { | 555 { |
| 556 if (style()->logicalWidth().isSpecified() || style()->logicalWidth().isIntri
nsic()) | 556 if (style()->logicalWidth().isSpecified() || style()->logicalWidth().isIntri
nsic()) |
| 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 computeIntrinsicSizingInfoForLayoutBox(contentLayoutObject, intrinsicSizingI
nfo); | 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 = hasAutoHeightOrContainingBlockWithAutoHeight
(); |
| 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()) { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 614 LayoutUnit LayoutReplaced::computeReplacedLogicalHeight() const | 614 LayoutUnit LayoutReplaced::computeReplacedLogicalHeight() const |
| 615 { | 615 { |
| 616 // 10.5 Content height: the 'height' property: http://www.w3.org/TR/CSS21/vi
sudet.html#propdef-height | 616 // 10.5 Content height: the 'height' property: http://www.w3.org/TR/CSS21/vi
sudet.html#propdef-height |
| 617 if (hasReplacedLogicalHeight()) | 617 if (hasReplacedLogicalHeight()) |
| 618 return computeReplacedLogicalHeightRespectingMinMaxHeight(computeReplace
dLogicalHeightUsing(MainOrPreferredSize, style()->logicalHeight())); | 618 return computeReplacedLogicalHeightRespectingMinMaxHeight(computeReplace
dLogicalHeightUsing(MainOrPreferredSize, style()->logicalHeight())); |
| 619 | 619 |
| 620 LayoutReplaced* contentLayoutObject = embeddedReplacedContent(); | 620 LayoutReplaced* contentLayoutObject = embeddedReplacedContent(); |
| 621 | 621 |
| 622 // 10.6.2 Inline, replaced elements: http://www.w3.org/TR/CSS21/visudet.html
#inline-replaced-height | 622 // 10.6.2 Inline, replaced elements: http://www.w3.org/TR/CSS21/visudet.html
#inline-replaced-height |
| 623 IntrinsicSizingInfo intrinsicSizingInfo; | 623 IntrinsicSizingInfo intrinsicSizingInfo; |
| 624 computeIntrinsicSizingInfoForLayoutBox(contentLayoutObject, intrinsicSizingI
nfo); | 624 computeIntrinsicSizingInfoForReplacedContent(contentLayoutObject, intrinsicS
izingInfo); |
| 625 FloatSize constrainedSize = constrainIntrinsicSizeToMinMax(intrinsicSizingIn
fo); | 625 FloatSize constrainedSize = constrainIntrinsicSizeToMinMax(intrinsicSizingIn
fo); |
| 626 | 626 |
| 627 bool widthIsAuto = style()->logicalWidth().isAuto(); | 627 bool widthIsAuto = style()->logicalWidth().isAuto(); |
| 628 | 628 |
| 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'. | 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'. |
| 630 if (widthIsAuto && intrinsicSizingInfo.hasHeight) | 630 if (widthIsAuto && intrinsicSizingInfo.hasHeight) |
| 631 return computeReplacedLogicalHeightRespectingMinMaxHeight(LayoutUnit(con
strainedSize.height())); | 631 return computeReplacedLogicalHeightRespectingMinMaxHeight(LayoutUnit(con
strainedSize.height())); |
| 632 | 632 |
| 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: | 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: |
| 634 // (used width) / (intrinsic ratio) | 634 // (used width) / (intrinsic ratio) |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 751 | 751 |
| 752 // We only include the space below the baseline in our layer's cached paint
invalidation rect if the | 752 // We only include the space below the baseline in our layer's cached paint
invalidation rect if the |
| 753 // image is selected. Since the selection state has changed update the rect. | 753 // image is selected. Since the selection state has changed update the rect. |
| 754 if (hasLayer()) | 754 if (hasLayer()) |
| 755 setPreviousPaintInvalidationRect(boundsRectForPaintInvalidation(containe
rForPaintInvalidation())); | 755 setPreviousPaintInvalidationRect(boundsRectForPaintInvalidation(containe
rForPaintInvalidation())); |
| 756 | 756 |
| 757 if (canUpdateSelectionOnRootLineBoxes()) | 757 if (canUpdateSelectionOnRootLineBoxes()) |
| 758 inlineBoxWrapper()->root().setHasSelectedChildren(state != SelectionNone
); | 758 inlineBoxWrapper()->root().setHasSelectedChildren(state != SelectionNone
); |
| 759 } | 759 } |
| 760 | 760 |
| 761 void LayoutReplaced::IntrinsicSizingInfo::transpose() |
| 762 { |
| 763 size = size.transposedSize(); |
| 764 aspectRatio = aspectRatio.transposedSize(); |
| 765 std::swap(hasWidth, hasHeight); |
| 766 } |
| 767 |
| 761 } // namespace blink | 768 } // namespace blink |
| OLD | NEW |