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. All rights reserv
ed. | 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv
ed. |
7 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. | 7 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. |
8 * | 8 * |
9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 #include "core/layout/LayoutReplica.h" | 47 #include "core/layout/LayoutReplica.h" |
48 #include "core/layout/LayoutTableCell.h" | 48 #include "core/layout/LayoutTableCell.h" |
49 #include "core/layout/LayoutView.h" | 49 #include "core/layout/LayoutView.h" |
50 #include "core/layout/api/LineLayoutBox.h" | 50 #include "core/layout/api/LineLayoutBox.h" |
51 #include "core/layout/compositing/PaintLayerCompositor.h" | 51 #include "core/layout/compositing/PaintLayerCompositor.h" |
52 #include "core/layout/shapes/ShapeOutsideInfo.h" | 52 #include "core/layout/shapes/ShapeOutsideInfo.h" |
53 #include "core/page/AutoscrollController.h" | 53 #include "core/page/AutoscrollController.h" |
54 #include "core/page/Page.h" | 54 #include "core/page/Page.h" |
55 #include "core/page/scrolling/SnapCoordinator.h" | 55 #include "core/page/scrolling/SnapCoordinator.h" |
56 #include "core/paint/BackgroundImageGeometry.h" | 56 #include "core/paint/BackgroundImageGeometry.h" |
| 57 #include "core/paint/BoxPaintInvalidator.h" |
57 #include "core/paint/BoxPainter.h" | 58 #include "core/paint/BoxPainter.h" |
58 #include "core/paint/PaintLayer.h" | 59 #include "core/paint/PaintLayer.h" |
59 #include "core/style/ShadowList.h" | 60 #include "core/style/ShadowList.h" |
60 #include "platform/LengthFunctions.h" | 61 #include "platform/LengthFunctions.h" |
61 #include "platform/geometry/DoubleRect.h" | 62 #include "platform/geometry/DoubleRect.h" |
62 #include "platform/geometry/FloatQuad.h" | 63 #include "platform/geometry/FloatQuad.h" |
63 #include "platform/geometry/FloatRoundedRect.h" | 64 #include "platform/geometry/FloatRoundedRect.h" |
64 #include "wtf/PtrUtil.h" | 65 #include "wtf/PtrUtil.h" |
65 #include <algorithm> | 66 #include <algorithm> |
66 #include <math.h> | 67 #include <math.h> |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 clearExtraInlineAndBlockOffests(); | 126 clearExtraInlineAndBlockOffests(); |
126 | 127 |
127 if (isOutOfFlowPositioned()) | 128 if (isOutOfFlowPositioned()) |
128 LayoutBlock::removePositionedObject(this); | 129 LayoutBlock::removePositionedObject(this); |
129 removeFromPercentHeightContainer(); | 130 removeFromPercentHeightContainer(); |
130 if (isOrthogonalWritingModeRoot() && !documentBeingDestroyed()) | 131 if (isOrthogonalWritingModeRoot() && !documentBeingDestroyed()) |
131 unmarkOrthogonalWritingModeRoot(); | 132 unmarkOrthogonalWritingModeRoot(); |
132 | 133 |
133 ShapeOutsideInfo::removeInfo(*this); | 134 ShapeOutsideInfo::removeInfo(*this); |
134 | 135 |
| 136 BoxPaintInvalidator::boxWillBeDestroyed(*this); |
| 137 |
135 LayoutBoxModelObject::willBeDestroyed(); | 138 LayoutBoxModelObject::willBeDestroyed(); |
136 } | 139 } |
137 | 140 |
138 void LayoutBox::insertedIntoTree() | 141 void LayoutBox::insertedIntoTree() |
139 { | 142 { |
140 LayoutBoxModelObject::insertedIntoTree(); | 143 LayoutBoxModelObject::insertedIntoTree(); |
141 addScrollSnapMapping(); | 144 addScrollSnapMapping(); |
142 | 145 |
143 if (isOrthogonalWritingModeRoot()) | 146 if (isOrthogonalWritingModeRoot()) |
144 markOrthogonalWritingModeRoot(); | 147 markOrthogonalWritingModeRoot(); |
(...skipping 1410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1555 PaintInvalidationReason LayoutBox::invalidatePaintIfNeeded(const PaintInvalidati
onState& paintInvalidationState) | 1558 PaintInvalidationReason LayoutBox::invalidatePaintIfNeeded(const PaintInvalidati
onState& paintInvalidationState) |
1556 { | 1559 { |
1557 if (hasBoxDecorationBackground() | 1560 if (hasBoxDecorationBackground() |
1558 // We also paint overflow controls in background phase. | 1561 // We also paint overflow controls in background phase. |
1559 || (hasOverflowClip() && getScrollableArea()->hasOverflowControls())) { | 1562 || (hasOverflowClip() && getScrollableArea()->hasOverflowControls())) { |
1560 PaintLayer& layer = paintInvalidationState.paintingLayer(); | 1563 PaintLayer& layer = paintInvalidationState.paintingLayer(); |
1561 if (layer.layoutObject() != this) | 1564 if (layer.layoutObject() != this) |
1562 layer.setNeedsPaintPhaseDescendantBlockBackgrounds(); | 1565 layer.setNeedsPaintPhaseDescendantBlockBackgrounds(); |
1563 } | 1566 } |
1564 | 1567 |
1565 PaintInvalidationReason reason = LayoutBoxModelObject::invalidatePaintIfNeed
ed(paintInvalidationState); | 1568 return LayoutBoxModelObject::invalidatePaintIfNeeded(paintInvalidationState)
; |
| 1569 } |
1566 | 1570 |
1567 if (PaintLayerScrollableArea* area = getScrollableArea()) | 1571 PaintInvalidationReason LayoutBox::invalidatePaintIfNeeded(const PaintInvalidato
rContext& context) const |
1568 area->invalidatePaintOfScrollControlsIfNeeded(paintInvalidationState); | 1572 { |
1569 | 1573 return BoxPaintInvalidator(*this, context).invalidatePaintIfNeeded(); |
1570 // This is for the next invalidatePaintIfNeeded so must be at the end. | |
1571 savePreviousBoxSizesIfNeeded(); | |
1572 return reason; | |
1573 } | 1574 } |
1574 | 1575 |
1575 void LayoutBox::invalidatePaintOfSubtreesIfNeeded(const PaintInvalidationState&
childPaintInvalidationState) | 1576 void LayoutBox::invalidatePaintOfSubtreesIfNeeded(const PaintInvalidationState&
childPaintInvalidationState) |
1576 { | 1577 { |
1577 LayoutBoxModelObject::invalidatePaintOfSubtreesIfNeeded(childPaintInvalidati
onState); | 1578 LayoutBoxModelObject::invalidatePaintOfSubtreesIfNeeded(childPaintInvalidati
onState); |
1578 | 1579 |
1579 if (PaintLayer* layer = this->layer()) { | 1580 if (PaintLayer* layer = this->layer()) { |
1580 if (PaintLayerReflectionInfo* reflectionInfo = layer->reflectionInfo()) | 1581 if (PaintLayerReflectionInfo* reflectionInfo = layer->reflectionInfo()) |
1581 reflectionInfo->reflection()->invalidateTreeIfNeeded(childPaintInval
idationState); | 1582 reflectionInfo->reflection()->invalidateTreeIfNeeded(childPaintInval
idationState); |
1582 } | 1583 } |
(...skipping 2376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3959 { | 3960 { |
3960 if (PaintLayerScrollableArea* scrollableArea = this->getScrollableArea()) { | 3961 if (PaintLayerScrollableArea* scrollableArea = this->getScrollableArea()) { |
3961 if (scrollableArea->hasHorizontalScrollbar() && !scrollableArea->layerFo
rHorizontalScrollbar()) | 3962 if (scrollableArea->hasHorizontalScrollbar() && !scrollableArea->layerFo
rHorizontalScrollbar()) |
3962 return true; | 3963 return true; |
3963 if (scrollableArea->hasVerticalScrollbar() && !scrollableArea->layerForV
erticalScrollbar()) | 3964 if (scrollableArea->hasVerticalScrollbar() && !scrollableArea->layerForV
erticalScrollbar()) |
3964 return true; | 3965 return true; |
3965 } | 3966 } |
3966 return false; | 3967 return false; |
3967 } | 3968 } |
3968 | 3969 |
3969 PaintInvalidationReason LayoutBox::getPaintInvalidationReason(const PaintInvalid
ationState& paintInvalidationState, | |
3970 const LayoutRect& oldBounds, const LayoutPoint& oldLocation, const LayoutRec
t& newBounds, const LayoutPoint& newLocation) const | |
3971 { | |
3972 PaintInvalidationReason invalidationReason = LayoutBoxModelObject::getPaintI
nvalidationReason(paintInvalidationState, oldBounds, oldLocation, newBounds, new
Location); | |
3973 | |
3974 if (isFullPaintInvalidationReason(invalidationReason) && invalidationReason
!= PaintInvalidationDelayedFull) | |
3975 return invalidationReason; | |
3976 | |
3977 if (mayNeedPaintInvalidationAnimatedBackgroundImage() && !backgroundIsKnownT
oBeObscured()) | |
3978 invalidationReason = PaintInvalidationDelayedFull; | |
3979 | |
3980 // If the current paint invalidation reason is PaintInvalidationDelayedFull,
then this paint invalidation can delayed if the | |
3981 // LayoutBox in question is not on-screen. The logic to decide whether this
is appropriate exists at the site of the original | |
3982 // paint invalidation that chose PaintInvalidationDelayedFull. | |
3983 if (invalidationReason == PaintInvalidationDelayedFull) { | |
3984 // Do regular full paint invalidation if the object is onscreen. | |
3985 return intersectsVisibleViewport() ? PaintInvalidationFull : PaintInvali
dationDelayedFull; | |
3986 } | |
3987 | |
3988 if (isLayoutView()) { | |
3989 const LayoutView* layoutView = toLayoutView(this); | |
3990 // In normal compositing mode, root background doesn't need to be invali
dated for | |
3991 // box changes, because the background always covers the whole document
rect | |
3992 // and clipping is done by compositor()->m_containerLayer. Also the scro
llbars | |
3993 // are always composited. There are no other box decoration on the Layou
tView thus | |
3994 // we can safely exit here. | |
3995 if (layoutView->usesCompositing() && (!document().settings() || !documen
t().settings()->rootLayerScrolls())) | |
3996 return invalidationReason; | |
3997 } | |
3998 | |
3999 // If the transform is not identity or translation, incremental invalidation
is not applicable | |
4000 // because the difference between oldBounds and newBounds doesn't cover all
area needing invalidation. | |
4001 // FIXME: Should also consider ancestor transforms since paintInvalidationCo
ntainer. crbug.com/426111. | |
4002 if (invalidationReason == PaintInvalidationIncremental | |
4003 && paintInvalidationState.paintInvalidationContainer() != this | |
4004 && hasLayer() && layer()->transform() && !layer()->transform()->isIdenti
tyOrTranslation()) | |
4005 return PaintInvalidationBoundsChange; | |
4006 | |
4007 if (style()->backgroundLayers().thisOrNextLayersUseContentBox() || style()->
maskLayers().thisOrNextLayersUseContentBox() || style()->boxSizing() == BoxSizin
gBorderBox) { | |
4008 LayoutRect oldContentBoxRect = m_rareData ? m_rareData->m_previousConten
tBoxRect : LayoutRect(); | |
4009 LayoutRect newContentBoxRect = contentBoxRect(); | |
4010 if (oldContentBoxRect != newContentBoxRect) | |
4011 return PaintInvalidationContentBoxChange; | |
4012 } | |
4013 | |
4014 if (!style()->hasBackground() && !style()->hasBoxDecorations()) { | |
4015 // We could let incremental invalidation cover non-composited scrollbars
, but just | |
4016 // do a full invalidation because incremental invalidation will go away
with slimming paint. | |
4017 if (invalidationReason == PaintInvalidationIncremental && hasNonComposit
edScrollbars()) | |
4018 return PaintInvalidationBorderBoxChange; | |
4019 return invalidationReason; | |
4020 } | |
4021 | |
4022 if (style()->backgroundLayers().thisOrNextLayersHaveLocalAttachment()) { | |
4023 LayoutRect oldLayoutOverflowRect = m_rareData ? m_rareData->m_previousLa
youtOverflowRect : LayoutRect(); | |
4024 LayoutRect newLayoutOverflowRect = layoutOverflowRect(); | |
4025 if (oldLayoutOverflowRect != newLayoutOverflowRect) | |
4026 return PaintInvalidationLayoutOverflowBoxChange; | |
4027 } | |
4028 | |
4029 LayoutSize oldBorderBoxSize = computePreviousBorderBoxSize(oldBounds.size())
; | |
4030 LayoutSize newBorderBoxSize = size(); | |
4031 | |
4032 if (oldBorderBoxSize == newBorderBoxSize) | |
4033 return invalidationReason; | |
4034 | |
4035 // LayoutBox::incrementallyInvalidatePaint() depends on positionFromPaintInv
alidationBacking | |
4036 // which is not available when slimmingPaintOffsetCachingEnabled. | |
4037 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled() && (style()->
hasBoxDecorations() || style()->hasBackground())) | |
4038 return PaintInvalidationBorderBoxChange; | |
4039 | |
4040 // TODO(wangxianzhu): Remove incremental invalidation when we remove rect-ba
sed paint invalidation. | |
4041 // See another hasNonCompositedScrollbars() callsite above. | |
4042 if (hasNonCompositedScrollbars()) | |
4043 return PaintInvalidationBorderBoxChange; | |
4044 | |
4045 if (style()->hasVisualOverflowingEffect() || style()->hasAppearance() || sty
le()->hasFilterInducingProperty() || style()->resize() != RESIZE_NONE) | |
4046 return PaintInvalidationBorderBoxChange; | |
4047 | |
4048 if (style()->hasBorderRadius()) { | |
4049 // If a border-radius exists and width/height is smaller than radius wid
th/height, | |
4050 // we need to fully invalidate to cover the changed radius. | |
4051 FloatRoundedRect oldRoundedRect = style()->getRoundedBorderFor(LayoutRec
t(LayoutPoint(0, 0), oldBorderBoxSize)); | |
4052 FloatRoundedRect newRoundedRect = style()->getRoundedBorderFor(LayoutRec
t(LayoutPoint(0, 0), newBorderBoxSize)); | |
4053 if (oldRoundedRect.getRadii() != newRoundedRect.getRadii()) | |
4054 return PaintInvalidationBorderBoxChange; | |
4055 } | |
4056 | |
4057 if (oldBorderBoxSize.width() != newBorderBoxSize.width() && mustInvalidateBa
ckgroundOrBorderPaintOnWidthChange()) | |
4058 return PaintInvalidationBorderBoxChange; | |
4059 if (oldBorderBoxSize.height() != newBorderBoxSize.height() && mustInvalidate
BackgroundOrBorderPaintOnHeightChange()) | |
4060 return PaintInvalidationBorderBoxChange; | |
4061 | |
4062 return styleRef().hasBackground() || styleRef().hasBoxDecorations() ? PaintI
nvalidationIncremental : invalidationReason; | |
4063 } | |
4064 | |
4065 void LayoutBox::incrementallyInvalidatePaint(const LayoutBoxModelObject& paintIn
validationContainer, const LayoutRect& oldBounds, const LayoutRect& newBounds, c
onst LayoutPoint& positionFromPaintInvalidationBacking) | |
4066 { | |
4067 LayoutObject::incrementallyInvalidatePaint(paintInvalidationContainer, oldBo
unds, newBounds, positionFromPaintInvalidationBacking); | |
4068 | |
4069 bool hasBoxDecorations = style()->hasBoxDecorations(); | |
4070 if (!style()->hasBackground() && !hasBoxDecorations) | |
4071 return; | |
4072 | |
4073 LayoutSize oldBorderBoxSize = computePreviousBorderBoxSize(oldBounds.size())
; | |
4074 LayoutSize newBorderBoxSize = size(); | |
4075 | |
4076 // If border box size didn't change, LayoutObject's incrementallyInvalidateP
aint() is good. | |
4077 if (oldBorderBoxSize == newBorderBoxSize) | |
4078 return; | |
4079 | |
4080 // If size of the paint invalidation rect equals to size of border box, Layo
utObject::incrementallyInvalidatePaint() | |
4081 // is good for boxes having background without box decorations. | |
4082 ASSERT(oldBounds.location() == newBounds.location()); // Otherwise we won't
do incremental invalidation. | |
4083 if (!hasBoxDecorations | |
4084 && positionFromPaintInvalidationBacking == newBounds.location() | |
4085 && oldBorderBoxSize == oldBounds.size() | |
4086 && newBorderBoxSize == newBounds.size()) | |
4087 return; | |
4088 | |
4089 // Invalidate the right delta part and the right border of the old or new bo
x which has smaller width. | |
4090 LayoutUnit deltaWidth = absoluteValue(oldBorderBoxSize.width() - newBorderBo
xSize.width()); | |
4091 if (deltaWidth) { | |
4092 LayoutUnit smallerWidth = std::min(oldBorderBoxSize.width(), newBorderBo
xSize.width()); | |
4093 LayoutUnit borderTopRightRadiusWidth = valueForLength(style()->borderTop
RightRadius().width(), smallerWidth); | |
4094 LayoutUnit borderBottomRightRadiusWidth = valueForLength(style()->border
BottomRightRadius().width(), smallerWidth); | |
4095 LayoutUnit borderWidth = std::max(LayoutUnit(borderRight()), std::max(bo
rderTopRightRadiusWidth, borderBottomRightRadiusWidth)); | |
4096 LayoutRect rightDeltaRect(positionFromPaintInvalidationBacking.x() + sma
llerWidth - borderWidth, | |
4097 positionFromPaintInvalidationBacking.y(), | |
4098 deltaWidth + borderWidth, | |
4099 std::max(oldBorderBoxSize.height(), newBorderBoxSize.height())); | |
4100 invalidatePaintRectClippedByOldAndNewBounds(paintInvalidationContainer,
rightDeltaRect, oldBounds, newBounds); | |
4101 } | |
4102 | |
4103 // Invalidate the bottom delta part and the bottom border of the old or new
box which has smaller height. | |
4104 LayoutUnit deltaHeight = absoluteValue(oldBorderBoxSize.height() - newBorder
BoxSize.height()); | |
4105 if (deltaHeight) { | |
4106 LayoutUnit smallerHeight = std::min(oldBorderBoxSize.height(), newBorder
BoxSize.height()); | |
4107 LayoutUnit borderBottomLeftRadiusHeight = valueForLength(style()->border
BottomLeftRadius().height(), smallerHeight); | |
4108 LayoutUnit borderBottomRightRadiusHeight = valueForLength(style()->borde
rBottomRightRadius().height(), smallerHeight); | |
4109 LayoutUnit borderHeight = std::max(LayoutUnit(borderBottom()), std::max(
borderBottomLeftRadiusHeight, borderBottomRightRadiusHeight)); | |
4110 LayoutRect bottomDeltaRect(positionFromPaintInvalidationBacking.x(), | |
4111 positionFromPaintInvalidationBacking.y() + smallerHeight - borderHei
ght, | |
4112 std::max(oldBorderBoxSize.width(), newBorderBoxSize.width()), | |
4113 deltaHeight + borderHeight); | |
4114 invalidatePaintRectClippedByOldAndNewBounds(paintInvalidationContainer,
bottomDeltaRect, oldBounds, newBounds); | |
4115 } | |
4116 } | |
4117 | |
4118 void LayoutBox::invalidatePaintRectClippedByOldAndNewBounds(const LayoutBoxModel
Object& paintInvalidationContainer, const LayoutRect& rect, const LayoutRect& ol
dBounds, const LayoutRect& newBounds) | |
4119 { | |
4120 if (rect.isEmpty()) | |
4121 return; | |
4122 LayoutRect rectClippedByOldBounds = intersection(rect, oldBounds); | |
4123 LayoutRect rectClippedByNewBounds = intersection(rect, newBounds); | |
4124 // Invalidate only once if the clipped rects equal. | |
4125 if (rectClippedByOldBounds == rectClippedByNewBounds) { | |
4126 invalidatePaintUsingContainer(paintInvalidationContainer, rectClippedByO
ldBounds, PaintInvalidationIncremental); | |
4127 return; | |
4128 } | |
4129 // Invalidate the bigger one if one contains another. Otherwise invalidate b
oth. | |
4130 if (!rectClippedByNewBounds.contains(rectClippedByOldBounds)) | |
4131 invalidatePaintUsingContainer(paintInvalidationContainer, rectClippedByO
ldBounds, PaintInvalidationIncremental); | |
4132 if (!rectClippedByOldBounds.contains(rectClippedByNewBounds)) | |
4133 invalidatePaintUsingContainer(paintInvalidationContainer, rectClippedByN
ewBounds, PaintInvalidationIncremental); | |
4134 } | |
4135 | |
4136 void LayoutBox::markForPaginationRelayoutIfNeeded(SubtreeLayoutScope& layoutScop
e) | 3970 void LayoutBox::markForPaginationRelayoutIfNeeded(SubtreeLayoutScope& layoutScop
e) |
4137 { | 3971 { |
4138 ASSERT(!needsLayout()); | 3972 ASSERT(!needsLayout()); |
4139 // If fragmentation height has changed, we need to lay out. No need to enter
the layoutObject if it | 3973 // If fragmentation height has changed, we need to lay out. No need to enter
the layoutObject if it |
4140 // is childless, though. | 3974 // is childless, though. |
4141 if (view()->layoutState()->pageLogicalHeightChanged() && slowFirstChild()) | 3975 if (view()->layoutState()->pageLogicalHeightChanged() && slowFirstChild()) |
4142 layoutScope.setChildNeedsLayout(this); | 3976 layoutScope.setChildNeedsLayout(this); |
4143 } | 3977 } |
4144 | 3978 |
4145 void LayoutBox::markOrthogonalWritingModeRoot() | 3979 void LayoutBox::markOrthogonalWritingModeRoot() |
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4648 return containerBlock->offsetFromLogicalTopOfFirstPage() + logicalTop(); | 4482 return containerBlock->offsetFromLogicalTopOfFirstPage() + logicalTop(); |
4649 } | 4483 } |
4650 | 4484 |
4651 void LayoutBox::setPageLogicalOffset(LayoutUnit offset) | 4485 void LayoutBox::setPageLogicalOffset(LayoutUnit offset) |
4652 { | 4486 { |
4653 if (!m_rareData && !offset) | 4487 if (!m_rareData && !offset) |
4654 return; | 4488 return; |
4655 ensureRareData().m_pageLogicalOffset = offset; | 4489 ensureRareData().m_pageLogicalOffset = offset; |
4656 } | 4490 } |
4657 | 4491 |
4658 bool LayoutBox::needToSavePreviousBoxSizes() | |
4659 { | |
4660 // If m_rareData is already created, always save. | |
4661 if (m_rareData) | |
4662 return true; | |
4663 | |
4664 LayoutSize paintInvalidationSize = previousPaintInvalidationRectSize(); | |
4665 // Don't save old box sizes if the paint rect is empty because we'll | |
4666 // full invalidate once the paint rect becomes non-empty. | |
4667 if (paintInvalidationSize.isEmpty()) | |
4668 return false; | |
4669 | |
4670 // If we use border-box sizing we need to track changes in the size of the c
ontent box. | |
4671 if (style()->boxSizing() == BoxSizingBorderBox) | |
4672 return true; | |
4673 | |
4674 // We need the old box sizes only when the box has background, decorations,
or masks. | |
4675 // Main LayoutView paints base background, thus interested in box size. | |
4676 if (!isLayoutView() && !style()->hasBackground() && !style()->hasBoxDecorati
ons() && !style()->hasMask()) | |
4677 return false; | |
4678 | |
4679 // No need to save old border box size if we can use size of the old paint | |
4680 // rect as the old border box size in the next invalidation. | |
4681 if (paintInvalidationSize != size()) | |
4682 return true; | |
4683 | |
4684 // Background and mask layers can depend on other boxes than border box. See
crbug.com/490533 | |
4685 if (style()->backgroundLayers().thisOrNextLayersUseContentBox() || style()->
backgroundLayers().thisOrNextLayersHaveLocalAttachment() | |
4686 || style()->maskLayers().thisOrNextLayersUseContentBox()) | |
4687 return true; | |
4688 | |
4689 return false; | |
4690 } | |
4691 | |
4692 void LayoutBox::savePreviousBoxSizesIfNeeded() | |
4693 { | |
4694 if (!needToSavePreviousBoxSizes()) | |
4695 return; | |
4696 | |
4697 LayoutBoxRareData& rareData = ensureRareData(); | |
4698 rareData.m_previousBorderBoxSize = size(); | |
4699 rareData.m_previousContentBoxRect = contentBoxRect(); | |
4700 rareData.m_previousLayoutOverflowRect = layoutOverflowRect(); | |
4701 } | |
4702 | |
4703 LayoutSize LayoutBox::computePreviousBorderBoxSize(const LayoutSize& previousBou
ndsSize) const | |
4704 { | |
4705 // PreviousBorderBoxSize is only valid when there is background or box decor
ations. | |
4706 ASSERT(style()->hasBackground() || style()->hasBoxDecorations()); | |
4707 | |
4708 if (m_rareData && m_rareData->m_previousBorderBoxSize.width() != -1) | |
4709 return m_rareData->m_previousBorderBoxSize; | |
4710 | |
4711 // We didn't save the old border box size because it was the same as the siz
e of oldBounds. | |
4712 return previousBoundsSize; | |
4713 } | |
4714 | |
4715 void LayoutBox::logicalExtentAfterUpdatingLogicalWidth(const LayoutUnit& newLogi
calTop, LayoutBox::LogicalExtentComputedValues& computedValues) | 4492 void LayoutBox::logicalExtentAfterUpdatingLogicalWidth(const LayoutUnit& newLogi
calTop, LayoutBox::LogicalExtentComputedValues& computedValues) |
4716 { | 4493 { |
4717 // FIXME: None of this is right for perpendicular writing-mode children. | 4494 // FIXME: None of this is right for perpendicular writing-mode children. |
4718 LayoutUnit oldLogicalWidth = logicalWidth(); | 4495 LayoutUnit oldLogicalWidth = logicalWidth(); |
4719 LayoutUnit oldLogicalLeft = logicalLeft(); | 4496 LayoutUnit oldLogicalLeft = logicalLeft(); |
4720 LayoutUnit oldMarginLeft = marginLeft(); | 4497 LayoutUnit oldMarginLeft = marginLeft(); |
4721 LayoutUnit oldMarginRight = marginRight(); | 4498 LayoutUnit oldMarginRight = marginRight(); |
4722 LayoutUnit oldLogicalTop = logicalTop(); | 4499 LayoutUnit oldLogicalTop = logicalTop(); |
4723 | 4500 |
4724 setLogicalTop(newLogicalTop); | 4501 setLogicalTop(newLogicalTop); |
4725 updateLogicalWidth(); | 4502 updateLogicalWidth(); |
4726 | 4503 |
4727 computedValues.m_extent = logicalWidth(); | 4504 computedValues.m_extent = logicalWidth(); |
4728 computedValues.m_position = logicalLeft(); | 4505 computedValues.m_position = logicalLeft(); |
4729 computedValues.m_margins.m_start = marginStart(); | 4506 computedValues.m_margins.m_start = marginStart(); |
4730 computedValues.m_margins.m_end = marginEnd(); | 4507 computedValues.m_margins.m_end = marginEnd(); |
4731 | 4508 |
4732 setLogicalTop(oldLogicalTop); | 4509 setLogicalTop(oldLogicalTop); |
4733 setLogicalWidth(oldLogicalWidth); | 4510 setLogicalWidth(oldLogicalWidth); |
4734 setLogicalLeft(oldLogicalLeft); | 4511 setLogicalLeft(oldLogicalLeft); |
4735 setMarginLeft(oldMarginLeft); | 4512 setMarginLeft(oldMarginLeft); |
4736 setMarginRight(oldMarginRight); | 4513 setMarginRight(oldMarginRight); |
4737 } | 4514 } |
4738 | 4515 |
4739 bool LayoutBox::mustInvalidateFillLayersPaintOnHeightChange(const FillLayer& lay
er) const | 4516 bool LayoutBox::mustInvalidateFillLayersPaintOnHeightChange(const FillLayer& lay
er) |
4740 { | 4517 { |
4741 // Nobody will use multiple layers without wanting fancy positioning. | 4518 // Nobody will use multiple layers without wanting fancy positioning. |
4742 if (layer.next()) | 4519 if (layer.next()) |
4743 return true; | 4520 return true; |
4744 | 4521 |
4745 // Make sure we have a valid image. | 4522 // Make sure we have a valid image. |
4746 StyleImage* img = layer.image(); | 4523 StyleImage* img = layer.image(); |
4747 if (!img || !img->canRender()) | 4524 if (!img || !img->canRender()) |
4748 return false; | 4525 return false; |
4749 | 4526 |
(...skipping 18 matching lines...) Expand all Loading... |
4768 return true; | 4545 return true; |
4769 if (img->isGeneratedImage() && layer.sizeLength().height().isAuto()) | 4546 if (img->isGeneratedImage() && layer.sizeLength().height().isAuto()) |
4770 return true; | 4547 return true; |
4771 } else if (img->usesImageContainerSize()) { | 4548 } else if (img->usesImageContainerSize()) { |
4772 return true; | 4549 return true; |
4773 } | 4550 } |
4774 | 4551 |
4775 return false; | 4552 return false; |
4776 } | 4553 } |
4777 | 4554 |
4778 bool LayoutBox::mustInvalidateFillLayersPaintOnWidthChange(const FillLayer& laye
r) const | 4555 bool LayoutBox::mustInvalidateFillLayersPaintOnWidthChange(const FillLayer& laye
r) |
4779 { | 4556 { |
4780 // Nobody will use multiple layers without wanting fancy positioning. | 4557 // Nobody will use multiple layers without wanting fancy positioning. |
4781 if (layer.next()) | 4558 if (layer.next()) |
4782 return true; | 4559 return true; |
4783 | 4560 |
4784 // Make sure we have a valid image. | 4561 // Make sure we have a valid image. |
4785 StyleImage* img = layer.image(); | 4562 StyleImage* img = layer.image(); |
4786 if (!img || !img->canRender()) | 4563 if (!img || !img->canRender()) |
4787 return false; | 4564 return false; |
4788 | 4565 |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4991 m_rareData->m_snapAreas->remove(&snapArea); | 4768 m_rareData->m_snapAreas->remove(&snapArea); |
4992 } | 4769 } |
4993 } | 4770 } |
4994 | 4771 |
4995 SnapAreaSet* LayoutBox::snapAreas() const | 4772 SnapAreaSet* LayoutBox::snapAreas() const |
4996 { | 4773 { |
4997 return m_rareData ? m_rareData->m_snapAreas.get() : nullptr; | 4774 return m_rareData ? m_rareData->m_snapAreas.get() : nullptr; |
4998 } | 4775 } |
4999 | 4776 |
5000 } // namespace blink | 4777 } // namespace blink |
OLD | NEW |