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. 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 4052 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4063 InvalidationReason RenderBox::getPaintInvalidationReason(const RenderLayerModelO bject& paintInvalidationContainer, | 4063 InvalidationReason RenderBox::getPaintInvalidationReason(const RenderLayerModelO bject& paintInvalidationContainer, |
| 4064 const LayoutRect& oldBounds, const LayoutPoint& oldLocation, const LayoutRec t& newBounds, const LayoutPoint& newLocation) | 4064 const LayoutRect& oldBounds, const LayoutPoint& oldLocation, const LayoutRec t& newBounds, const LayoutPoint& newLocation) |
| 4065 { | 4065 { |
| 4066 InvalidationReason invalidationReason = RenderBoxModelObject::getPaintInvali dationReason(paintInvalidationContainer, oldBounds, oldLocation, newBounds, newL ocation); | 4066 InvalidationReason invalidationReason = RenderBoxModelObject::getPaintInvali dationReason(paintInvalidationContainer, oldBounds, oldLocation, newBounds, newL ocation); |
| 4067 if (invalidationReason != InvalidationNone && invalidationReason != Invalida tionIncremental) | 4067 if (invalidationReason != InvalidationNone && invalidationReason != Invalida tionIncremental) |
| 4068 return invalidationReason; | 4068 return invalidationReason; |
| 4069 | 4069 |
| 4070 if (!style()->hasBackground() && !style()->hasBoxDecorations()) | 4070 if (!style()->hasBackground() && !style()->hasBoxDecorations()) |
| 4071 return invalidationReason; | 4071 return invalidationReason; |
| 4072 | 4072 |
| 4073 LayoutSize oldBorderBoxSize; | 4073 LayoutSize oldBorderBoxSize = getPreviousBorderBoxSize(oldBounds.size()); |
| 4074 if (m_rareData && m_rareData->m_previousBorderBoxSize.width() != -1) { | |
| 4075 oldBorderBoxSize = m_rareData->m_previousBorderBoxSize; | |
| 4076 } else { | |
| 4077 // We didn't save the old border box size because it was the same as the size of oldBounds. | |
| 4078 oldBorderBoxSize = oldBounds.size(); | |
| 4079 } | |
| 4080 | |
| 4081 LayoutSize newBorderBoxSize = size(); | 4074 LayoutSize newBorderBoxSize = size(); |
| 4082 | 4075 |
| 4083 if (oldBorderBoxSize == newBorderBoxSize) | 4076 if (oldBorderBoxSize == newBorderBoxSize) |
| 4084 return invalidationReason; | 4077 return invalidationReason; |
| 4085 | 4078 |
| 4079 // FIXME: Implement correct incremental invalidation for visual overflowing effects. | |
| 4080 if (style()->hasVisualOverflowingEffect() || style()->hasAppearance()) | |
| 4081 return InvalidationBorderBoxChange; | |
| 4082 | |
| 4083 if (style()->hasBorderRadius()) { | |
| 4084 // If a border-radius exists and width/height is smaller than | |
| 4085 // radius width/height, we cannot use incremental invalidation. | |
|
esprehn
2014/08/19 01:59:12
Why is this?
Xianzhu
2014/08/19 16:06:19
Modified comments to state the reason.
| |
| 4086 RoundedRect oldRoundedRect = style()->getRoundedBorderFor(LayoutRect(Lay outPoint(0, 0), oldBorderBoxSize)); | |
| 4087 RoundedRect newRoundedRect = style()->getRoundedBorderFor(LayoutRect(Lay outPoint(0, 0), newBorderBoxSize)); | |
| 4088 if (oldRoundedRect.radii() != newRoundedRect.radii()) | |
| 4089 return InvalidationBorderBoxChange; | |
| 4090 } | |
| 4091 | |
| 4086 if (oldBorderBoxSize.width() != newBorderBoxSize.width() && mustInvalidateBa ckgroundOrBorderPaintOnWidthChange()) | 4092 if (oldBorderBoxSize.width() != newBorderBoxSize.width() && mustInvalidateBa ckgroundOrBorderPaintOnWidthChange()) |
| 4087 return InvalidationBorderBoxChange; | 4093 return InvalidationBorderBoxChange; |
| 4088 if (oldBorderBoxSize.height() != newBorderBoxSize.height() && mustInvalidate BackgroundOrBorderPaintOnHeightChange()) | 4094 if (oldBorderBoxSize.height() != newBorderBoxSize.height() && mustInvalidate BackgroundOrBorderPaintOnHeightChange()) |
| 4089 return InvalidationBorderBoxChange; | 4095 return InvalidationBorderBoxChange; |
| 4090 | 4096 |
| 4091 // If size of repaint rect equals to size of border box, RenderObject::incre mentallyInvalidatePaint() | 4097 return InvalidationIncremental; |
| 4098 } | |
| 4099 | |
| 4100 void RenderBox::incrementallyInvalidatePaint(const RenderLayerModelObject& paint InvalidationContainer, const LayoutRect& oldBounds, const LayoutRect& newBounds, const LayoutPoint& positionFromPaintInvalidationContainer) | |
| 4101 { | |
| 4102 RenderObject::incrementallyInvalidatePaint(paintInvalidationContainer, oldBo unds, newBounds, positionFromPaintInvalidationContainer); | |
| 4103 | |
| 4104 LayoutSize oldBorderBoxSize = getPreviousBorderBoxSize(oldBounds.size()); | |
| 4105 LayoutSize newBorderBoxSize = size(); | |
| 4106 | |
| 4107 bool hasBoxDecorations = style()->hasBoxDecorations(); | |
| 4108 if (!style()->hasBackground() && !hasBoxDecorations) | |
| 4109 return; | |
| 4110 | |
| 4111 // If border box size didn't change, RenderBox's incrementallyInvalidatePain t() is good. | |
| 4112 if (oldBorderBoxSize == newBorderBoxSize) | |
| 4113 return; | |
| 4114 | |
| 4115 // If repaint rect equals border box, RenderObject::incrementallyInvalidateP aint() | |
| 4092 // is good for boxes having background without box decorations. | 4116 // is good for boxes having background without box decorations. |
| 4093 if (oldBorderBoxSize == oldBounds.size() && newBorderBoxSize == newBounds.si ze() && !style()->hasBoxDecorations()) | 4117 ASSERT(oldBounds.location() == newBounds.location()); // Otherwise we won't do incremental invalidation. |
| 4094 return invalidationReason; | 4118 if (!hasBoxDecorations && positionFromPaintInvalidationContainer == newBound s.location() |
| 4119 && oldBorderBoxSize == oldBounds.size() && newBorderBoxSize == newBounds .size()) | |
|
esprehn
2014/08/19 01:59:12
one statement per line might make this easier to r
Xianzhu
2014/08/19 16:06:19
Done.
| |
| 4120 return; | |
| 4095 | 4121 |
| 4096 // FIXME: Since we have accurate old border box size, we could do more accur ate | 4122 // Invalidate the right delta part and the right border of the old or new bo x which has smaller width. |
| 4097 // incremental invalidation instead of full invalidation. | 4123 LayoutUnit deltaWidth = absoluteValue(oldBorderBoxSize.width() - newBorderBo xSize.width()); |
|
esprehn
2014/08/19 01:59:12
= not () for initialization, it's nice to be consi
Xianzhu
2014/08/19 16:06:19
'=' is used in most cases except that the construc
| |
| 4098 return InvalidationBorderBoxChange; | 4124 if (deltaWidth) { |
| 4125 LayoutUnit smallerWidth = std::min(oldBorderBoxSize.width(), newBorderBo xSize.width()); | |
| 4126 LayoutUnit borderTopRightRadiusWidth = valueForLength(style()->borderTop RightRadius().width(), smallerWidth); | |
| 4127 LayoutUnit borderBottomRightRadiusWidth = valueForLength(style()->border BottomRightRadius().width(), smallerWidth); | |
| 4128 LayoutUnit borderWidth = std::max<LayoutUnit>(borderRight(), std::max(bo rderTopRightRadiusWidth, borderBottomRightRadiusWidth)); | |
| 4129 LayoutRect rightDeltaRect(positionFromPaintInvalidationContainer.x() + s mallerWidth - borderWidth, | |
| 4130 positionFromPaintInvalidationContainer.y(), | |
| 4131 deltaWidth + borderWidth, | |
| 4132 std::max(oldBorderBoxSize.height(), newBorderBoxSize.height())); | |
| 4133 invalidatePaintUsingContainer(&paintInvalidationContainer, rightDeltaRec t, InvalidationIncremental); | |
| 4134 } | |
| 4135 | |
| 4136 // Invalidate the bottom delta part and the bottom border of the old or new box which has smaller height. | |
| 4137 LayoutUnit deltaHeight = absoluteValue(oldBorderBoxSize.height() - newBorder BoxSize.height()); | |
| 4138 if (deltaHeight) { | |
| 4139 LayoutUnit smallerHeight = std::min(oldBorderBoxSize.height(), newBorder BoxSize.height()); | |
| 4140 LayoutUnit borderBottomLeftRadiusHeight = valueForLength(style()->border BottomLeftRadius().height(), smallerHeight); | |
| 4141 LayoutUnit borderBottomRightRadiusHeight = valueForLength(style()->borde rBottomRightRadius().height(), smallerHeight); | |
| 4142 LayoutUnit borderHeight = std::max<LayoutUnit>(borderBottom(), std::max( borderBottomLeftRadiusHeight, borderBottomRightRadiusHeight)); | |
| 4143 LayoutRect bottomDeltaRect(positionFromPaintInvalidationContainer.x(), | |
| 4144 positionFromPaintInvalidationContainer.y() + smallerHeight - borderH eight, | |
| 4145 std::max(oldBorderBoxSize.width(), newBorderBoxSize.width()), | |
| 4146 deltaHeight + borderHeight); | |
| 4147 invalidatePaintUsingContainer(&paintInvalidationContainer, bottomDeltaRe ct, InvalidationIncremental); | |
| 4148 } | |
| 4099 } | 4149 } |
| 4100 | 4150 |
| 4101 void RenderBox::markForPaginationRelayoutIfNeeded(SubtreeLayoutScope& layoutScop e) | 4151 void RenderBox::markForPaginationRelayoutIfNeeded(SubtreeLayoutScope& layoutScop e) |
| 4102 { | 4152 { |
| 4103 ASSERT(!needsLayout()); | 4153 ASSERT(!needsLayout()); |
| 4104 // If fragmentation height has changed, we need to lay out. No need to enter the renderer if it | 4154 // If fragmentation height has changed, we need to lay out. No need to enter the renderer if it |
| 4105 // is childless, though. | 4155 // is childless, though. |
| 4106 if (view()->layoutState()->pageLogicalHeightChanged() && slowFirstChild()) | 4156 if (view()->layoutState()->pageLogicalHeightChanged() && slowFirstChild()) |
| 4107 layoutScope.setChildNeedsLayout(this); | 4157 layoutScope.setChildNeedsLayout(this); |
| 4108 } | 4158 } |
| (...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4669 return; | 4719 return; |
| 4670 | 4720 |
| 4671 // We need the old border box size only when the box has background or b ox decorations. | 4721 // We need the old border box size only when the box has background or b ox decorations. |
| 4672 if (!style()->hasBackground() && !style()->hasBoxDecorations()) | 4722 if (!style()->hasBackground() && !style()->hasBoxDecorations()) |
| 4673 return; | 4723 return; |
| 4674 } | 4724 } |
| 4675 | 4725 |
| 4676 ensureRareData().m_previousBorderBoxSize = size(); | 4726 ensureRareData().m_previousBorderBoxSize = size(); |
| 4677 } | 4727 } |
| 4678 | 4728 |
| 4729 LayoutSize RenderBox::getPreviousBorderBoxSize(const LayoutSize& oldBoundsSize) const | |
| 4730 { | |
| 4731 // PreviousBorderBoxSize is only valid when there is background or box decor ations. | |
| 4732 ASSERT(style()->hasBackground() || style()->hasBoxDecorations()); | |
| 4733 | |
| 4734 if (m_rareData && m_rareData->m_previousBorderBoxSize.width() != -1) | |
| 4735 return m_rareData->m_previousBorderBoxSize; | |
| 4736 | |
| 4737 // We didn't save the old border box size because it was the same as the siz e of oldBounds. | |
| 4738 return oldBoundsSize; | |
| 4739 } | |
| 4740 | |
| 4679 RenderBox::BoxDecorationData::BoxDecorationData(const RenderStyle& style) | 4741 RenderBox::BoxDecorationData::BoxDecorationData(const RenderStyle& style) |
| 4680 { | 4742 { |
| 4681 backgroundColor = style.visitedDependentColor(CSSPropertyBackgroundColor); | 4743 backgroundColor = style.visitedDependentColor(CSSPropertyBackgroundColor); |
| 4682 hasBackground = backgroundColor.alpha() || style.hasBackgroundImage(); | 4744 hasBackground = backgroundColor.alpha() || style.hasBackgroundImage(); |
| 4683 ASSERT(hasBackground == style.hasBackground()); | 4745 ASSERT(hasBackground == style.hasBackground()); |
| 4684 hasBorder = style.hasBorder(); | 4746 hasBorder = style.hasBorder(); |
| 4685 hasAppearance = style.hasAppearance(); | 4747 hasAppearance = style.hasAppearance(); |
| 4686 } | 4748 } |
| 4687 | 4749 |
| 4688 } // namespace blink | 4750 } // namespace blink |
| OLD | NEW |