Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) | 4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) |
| 5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) | 5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) |
| 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. | 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. |
| 7 * All rights reserved. | 7 * All rights reserved. |
| 8 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. | 8 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. |
| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 68 #include "platform/geometry/FloatRoundedRect.h" | 68 #include "platform/geometry/FloatRoundedRect.h" |
| 69 #include "wtf/PtrUtil.h" | 69 #include "wtf/PtrUtil.h" |
| 70 #include <algorithm> | 70 #include <algorithm> |
| 71 #include <math.h> | 71 #include <math.h> |
| 72 | 72 |
| 73 namespace blink { | 73 namespace blink { |
| 74 | 74 |
| 75 // Used by flexible boxes when flexing this element and by table cells. | 75 // Used by flexible boxes when flexing this element and by table cells. |
| 76 typedef WTF::HashMap<const LayoutBox*, LayoutUnit> OverrideSizeMap; | 76 typedef WTF::HashMap<const LayoutBox*, LayoutUnit> OverrideSizeMap; |
| 77 | 77 |
| 78 static OverrideSizeMap* gExtraInlineOffsetMap = nullptr; | |
| 79 static OverrideSizeMap* gExtraBlockOffsetMap = nullptr; | |
| 80 | |
| 81 // Size of border belt for autoscroll. When mouse pointer in border belt, | 78 // Size of border belt for autoscroll. When mouse pointer in border belt, |
| 82 // autoscroll is started. | 79 // autoscroll is started. |
| 83 static const int autoscrollBeltSize = 20; | 80 static const int autoscrollBeltSize = 20; |
| 84 static const unsigned backgroundObscurationTestMaxDepth = 4; | 81 static const unsigned backgroundObscurationTestMaxDepth = 4; |
| 85 | 82 |
| 86 struct SameSizeAsLayoutBox : public LayoutBoxModelObject { | 83 struct SameSizeAsLayoutBox : public LayoutBoxModelObject { |
| 87 LayoutRect frameRect; | 84 LayoutRect frameRect; |
| 88 LayoutUnit intrinsicContentLogicalHeight; | 85 LayoutUnit intrinsicContentLogicalHeight; |
| 89 LayoutRectOutsets marginBoxOutsets; | 86 LayoutRectOutsets marginBoxOutsets; |
| 90 LayoutUnit preferredLogicalWidth[2]; | 87 LayoutUnit preferredLogicalWidth[2]; |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 116 | 113 |
| 117 if (hasOverflowClip()) | 114 if (hasOverflowClip()) |
| 118 return OverflowClipPaintLayer; | 115 return OverflowClipPaintLayer; |
| 119 | 116 |
| 120 return NoPaintLayer; | 117 return NoPaintLayer; |
| 121 } | 118 } |
| 122 | 119 |
| 123 void LayoutBox::willBeDestroyed() { | 120 void LayoutBox::willBeDestroyed() { |
| 124 clearOverrideSize(); | 121 clearOverrideSize(); |
| 125 clearContainingBlockOverrideSize(); | 122 clearContainingBlockOverrideSize(); |
| 126 clearExtraInlineAndBlockOffests(); | |
| 127 | 123 |
| 128 if (isOutOfFlowPositioned()) | 124 if (isOutOfFlowPositioned()) |
| 129 LayoutBlock::removePositionedObject(this); | 125 LayoutBlock::removePositionedObject(this); |
| 130 removeFromPercentHeightContainer(); | 126 removeFromPercentHeightContainer(); |
| 131 if (isOrthogonalWritingModeRoot() && !documentBeingDestroyed()) | 127 if (isOrthogonalWritingModeRoot() && !documentBeingDestroyed()) |
| 132 unmarkOrthogonalWritingModeRoot(); | 128 unmarkOrthogonalWritingModeRoot(); |
| 133 | 129 |
| 134 ShapeOutsideInfo::removeInfo(*this); | 130 ShapeOutsideInfo::removeInfo(*this); |
| 135 | 131 |
| 136 BoxPaintInvalidator::boxWillBeDestroyed(*this); | 132 BoxPaintInvalidator::boxWillBeDestroyed(*this); |
| (...skipping 1166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1303 } | 1299 } |
| 1304 | 1300 |
| 1305 // TODO (lajava) Shouldn't we implement these functions based on physical | 1301 // TODO (lajava) Shouldn't we implement these functions based on physical |
| 1306 // direction ?. | 1302 // direction ?. |
| 1307 void LayoutBox::clearOverrideContainingBlockContentLogicalHeight() { | 1303 void LayoutBox::clearOverrideContainingBlockContentLogicalHeight() { |
| 1308 if (!m_rareData) | 1304 if (!m_rareData) |
| 1309 return; | 1305 return; |
| 1310 ensureRareData().m_hasOverrideContainingBlockContentLogicalHeight = false; | 1306 ensureRareData().m_hasOverrideContainingBlockContentLogicalHeight = false; |
| 1311 } | 1307 } |
| 1312 | 1308 |
| 1313 LayoutUnit LayoutBox::extraInlineOffset() const { | |
| 1314 return gExtraInlineOffsetMap ? gExtraInlineOffsetMap->get(this) | |
| 1315 : LayoutUnit(); | |
| 1316 } | |
| 1317 | |
| 1318 LayoutUnit LayoutBox::extraBlockOffset() const { | |
| 1319 return gExtraBlockOffsetMap ? gExtraBlockOffsetMap->get(this) : LayoutUnit(); | |
| 1320 } | |
| 1321 | |
| 1322 void LayoutBox::setExtraInlineOffset(LayoutUnit inlineOffest) { | |
| 1323 if (!gExtraInlineOffsetMap) | |
| 1324 gExtraInlineOffsetMap = new OverrideSizeMap; | |
| 1325 gExtraInlineOffsetMap->set(this, inlineOffest); | |
| 1326 } | |
| 1327 | |
| 1328 void LayoutBox::setExtraBlockOffset(LayoutUnit blockOffest) { | |
| 1329 if (!gExtraBlockOffsetMap) | |
| 1330 gExtraBlockOffsetMap = new OverrideSizeMap; | |
| 1331 gExtraBlockOffsetMap->set(this, blockOffest); | |
| 1332 } | |
| 1333 | |
| 1334 void LayoutBox::clearExtraInlineAndBlockOffests() { | |
| 1335 if (gExtraInlineOffsetMap) | |
| 1336 gExtraInlineOffsetMap->remove(this); | |
| 1337 if (gExtraBlockOffsetMap) | |
| 1338 gExtraBlockOffsetMap->remove(this); | |
| 1339 } | |
| 1340 | |
| 1341 LayoutUnit LayoutBox::adjustBorderBoxLogicalWidthForBoxSizing( | 1309 LayoutUnit LayoutBox::adjustBorderBoxLogicalWidthForBoxSizing( |
| 1342 float width) const { | 1310 float width) const { |
| 1343 LayoutUnit bordersPlusPadding = collapsedBorderAndCSSPaddingLogicalWidth(); | 1311 LayoutUnit bordersPlusPadding = collapsedBorderAndCSSPaddingLogicalWidth(); |
| 1344 LayoutUnit result(width); | 1312 LayoutUnit result(width); |
| 1345 if (style()->boxSizing() == EBoxSizing::kContentBox) | 1313 if (style()->boxSizing() == EBoxSizing::kContentBox) |
| 1346 return result + bordersPlusPadding; | 1314 return result + bordersPlusPadding; |
| 1347 return std::max(result, bordersPlusPadding); | 1315 return std::max(result, bordersPlusPadding); |
| 1348 } | 1316 } |
| 1349 | 1317 |
| 1350 LayoutUnit LayoutBox::adjustBorderBoxLogicalHeightForBoxSizing( | 1318 LayoutUnit LayoutBox::adjustBorderBoxLogicalHeightForBoxSizing( |
| (...skipping 2366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3717 | 3685 |
| 3718 void LayoutBox::computeInlineStaticDistance( | 3686 void LayoutBox::computeInlineStaticDistance( |
| 3719 Length& logicalLeft, | 3687 Length& logicalLeft, |
| 3720 Length& logicalRight, | 3688 Length& logicalRight, |
| 3721 const LayoutBox* child, | 3689 const LayoutBox* child, |
| 3722 const LayoutBoxModelObject* containerBlock, | 3690 const LayoutBoxModelObject* containerBlock, |
| 3723 LayoutUnit containerLogicalWidth) { | 3691 LayoutUnit containerLogicalWidth) { |
| 3724 if (!logicalLeft.isAuto() || !logicalRight.isAuto()) | 3692 if (!logicalLeft.isAuto() || !logicalRight.isAuto()) |
| 3725 return; | 3693 return; |
| 3726 | 3694 |
| 3695 if (child->isGridItem() && child->containingBlock() == child->parent()) { | |
| 3696 if (child->parent()->style()->direction() == TextDirection::kLtr) | |
| 3697 logicalLeft.setValue(Fixed, 0); | |
| 3698 else | |
| 3699 logicalRight.setValue(Fixed, 0); | |
| 3700 return; | |
| 3701 } | |
|
svillar
2017/01/31 15:28:40
Mind explaining this change?
Manuel Rego
2017/02/01 09:08:20
So this method is used when in a positioned elemen
svillar
2017/02/01 09:49:07
OK now I understand that we're just setting it to
Manuel Rego
2017/02/01 11:08:08
Actually I've realized we can do this in a differe
Manuel Rego
2017/02/01 11:10:34
Oops sorry this comment is wrong, it was about a d
| |
| 3702 | |
| 3727 // For multicol we also need to keep track of the block position, since that | 3703 // For multicol we also need to keep track of the block position, since that |
| 3728 // determines which column we're in and thus affects the inline position. | 3704 // determines which column we're in and thus affects the inline position. |
| 3729 LayoutUnit staticBlockPosition = child->layer()->staticBlockPosition(); | 3705 LayoutUnit staticBlockPosition = child->layer()->staticBlockPosition(); |
| 3730 | 3706 |
| 3731 // FIXME: The static distance computation has not been patched for mixed | 3707 // FIXME: The static distance computation has not been patched for mixed |
| 3732 // writing modes yet. | 3708 // writing modes yet. |
| 3733 if (child->parent()->style()->direction() == TextDirection::kLtr) { | 3709 if (child->parent()->style()->direction() == TextDirection::kLtr) { |
| 3734 LayoutUnit staticPosition = child->layer()->staticInlinePosition() - | 3710 LayoutUnit staticPosition = child->layer()->staticInlinePosition() - |
| 3735 containerBlock->borderLogicalLeft(); | 3711 containerBlock->borderLogicalLeft(); |
| 3736 for (LayoutObject* curr = child->parent(); curr && curr != containerBlock; | 3712 for (LayoutObject* curr = child->parent(); curr && curr != containerBlock; |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3897 logicalRightLength, marginLogicalLeft, marginLogicalRight, minValues); | 3873 logicalRightLength, marginLogicalLeft, marginLogicalRight, minValues); |
| 3898 | 3874 |
| 3899 if (computedValues.m_extent < minValues.m_extent) { | 3875 if (computedValues.m_extent < minValues.m_extent) { |
| 3900 computedValues.m_extent = minValues.m_extent; | 3876 computedValues.m_extent = minValues.m_extent; |
| 3901 computedValues.m_position = minValues.m_position; | 3877 computedValues.m_position = minValues.m_position; |
| 3902 computedValues.m_margins.m_start = minValues.m_margins.m_start; | 3878 computedValues.m_margins.m_start = minValues.m_margins.m_start; |
| 3903 computedValues.m_margins.m_end = minValues.m_margins.m_end; | 3879 computedValues.m_margins.m_end = minValues.m_margins.m_end; |
| 3904 } | 3880 } |
| 3905 } | 3881 } |
| 3906 | 3882 |
| 3907 if (!style()->hasStaticInlinePosition(isHorizontal)) | |
| 3908 computedValues.m_position += extraInlineOffset(); | |
| 3909 | |
| 3910 computedValues.m_extent += bordersPlusPadding; | 3883 computedValues.m_extent += bordersPlusPadding; |
| 3911 } | 3884 } |
| 3912 | 3885 |
| 3913 void LayoutBox::computeLogicalLeftPositionedOffset( | 3886 void LayoutBox::computeLogicalLeftPositionedOffset( |
| 3914 LayoutUnit& logicalLeftPos, | 3887 LayoutUnit& logicalLeftPos, |
| 3915 const LayoutBox* child, | 3888 const LayoutBox* child, |
| 3916 LayoutUnit logicalWidthValue, | 3889 LayoutUnit logicalWidthValue, |
| 3917 const LayoutBoxModelObject* containerBlock, | 3890 const LayoutBoxModelObject* containerBlock, |
| 3918 LayoutUnit containerLogicalWidth) { | 3891 LayoutUnit containerLogicalWidth) { |
| 3919 // Deal with differing writing modes here. Our offset needs to be in the | 3892 // Deal with differing writing modes here. Our offset needs to be in the |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4296 marginBefore, marginAfter, minValues); | 4269 marginBefore, marginAfter, minValues); |
| 4297 | 4270 |
| 4298 if (computedValues.m_extent < minValues.m_extent) { | 4271 if (computedValues.m_extent < minValues.m_extent) { |
| 4299 computedValues.m_extent = minValues.m_extent; | 4272 computedValues.m_extent = minValues.m_extent; |
| 4300 computedValues.m_position = minValues.m_position; | 4273 computedValues.m_position = minValues.m_position; |
| 4301 computedValues.m_margins.m_before = minValues.m_margins.m_before; | 4274 computedValues.m_margins.m_before = minValues.m_margins.m_before; |
| 4302 computedValues.m_margins.m_after = minValues.m_margins.m_after; | 4275 computedValues.m_margins.m_after = minValues.m_margins.m_after; |
| 4303 } | 4276 } |
| 4304 } | 4277 } |
| 4305 | 4278 |
| 4306 if (!style()->hasStaticBlockPosition(isHorizontalWritingMode())) | |
| 4307 computedValues.m_position += extraBlockOffset(); | |
| 4308 | |
| 4309 // Set final height value. | 4279 // Set final height value. |
| 4310 computedValues.m_extent += bordersPlusPadding; | 4280 computedValues.m_extent += bordersPlusPadding; |
| 4311 } | 4281 } |
| 4312 | 4282 |
| 4313 void LayoutBox::computeLogicalTopPositionedOffset( | 4283 void LayoutBox::computeLogicalTopPositionedOffset( |
| 4314 LayoutUnit& logicalTopPos, | 4284 LayoutUnit& logicalTopPos, |
| 4315 const LayoutBox* child, | 4285 const LayoutBox* child, |
| 4316 LayoutUnit logicalHeightValue, | 4286 LayoutUnit logicalHeightValue, |
| 4317 const LayoutBoxModelObject* containerBlock, | 4287 const LayoutBoxModelObject* containerBlock, |
| 4318 LayoutUnit containerLogicalHeight) { | 4288 LayoutUnit containerLogicalHeight) { |
| (...skipping 1375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5694 block->adjustChildDebugRect(rect); | 5664 block->adjustChildDebugRect(rect); |
| 5695 | 5665 |
| 5696 return rect; | 5666 return rect; |
| 5697 } | 5667 } |
| 5698 | 5668 |
| 5699 bool LayoutBox::shouldClipOverflow() const { | 5669 bool LayoutBox::shouldClipOverflow() const { |
| 5700 return hasOverflowClip() || styleRef().containsPaint() || hasControlClip(); | 5670 return hasOverflowClip() || styleRef().containsPaint() || hasControlClip(); |
| 5701 } | 5671 } |
| 5702 | 5672 |
| 5703 } // namespace blink | 5673 } // namespace blink |
| OLD | NEW |