Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(757)

Side by Side Diff: Source/core/rendering/RenderBox.cpp

Issue 399173005: Incrementally invalidate boxes with borders if possible (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/rendering/RenderBox.h ('k') | Source/core/rendering/RenderObject.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 4056 matching lines...) Expand 10 before | Expand all | Expand 10 after
4067 InvalidationReason RenderBox::getPaintInvalidationReason(const RenderLayerModelO bject& paintInvalidationContainer, 4067 InvalidationReason RenderBox::getPaintInvalidationReason(const RenderLayerModelO bject& paintInvalidationContainer,
4068 const LayoutRect& oldBounds, const LayoutPoint& oldLocation, const LayoutRec t& newBounds, const LayoutPoint& newLocation) 4068 const LayoutRect& oldBounds, const LayoutPoint& oldLocation, const LayoutRec t& newBounds, const LayoutPoint& newLocation)
4069 { 4069 {
4070 InvalidationReason invalidationReason = RenderBoxModelObject::getPaintInvali dationReason(paintInvalidationContainer, oldBounds, oldLocation, newBounds, newL ocation); 4070 InvalidationReason invalidationReason = RenderBoxModelObject::getPaintInvali dationReason(paintInvalidationContainer, oldBounds, oldLocation, newBounds, newL ocation);
4071 if (invalidationReason != InvalidationNone && invalidationReason != Invalida tionIncremental) 4071 if (invalidationReason != InvalidationNone && invalidationReason != Invalida tionIncremental)
4072 return invalidationReason; 4072 return invalidationReason;
4073 4073
4074 if (!style()->hasBackground() && !style()->hasBoxDecorations()) 4074 if (!style()->hasBackground() && !style()->hasBoxDecorations())
4075 return invalidationReason; 4075 return invalidationReason;
4076 4076
4077 LayoutSize oldBorderBoxSize; 4077 LayoutSize oldBorderBoxSize = computePreviousBorderBoxSize(oldBounds.size()) ;
4078 if (m_rareData && m_rareData->m_previousBorderBoxSize.width() != -1) {
4079 oldBorderBoxSize = m_rareData->m_previousBorderBoxSize;
4080 } else {
4081 // We didn't save the old border box size because it was the same as the size of oldBounds.
4082 oldBorderBoxSize = oldBounds.size();
4083 }
4084
4085 LayoutSize newBorderBoxSize = size(); 4078 LayoutSize newBorderBoxSize = size();
4086 4079
4087 if (oldBorderBoxSize == newBorderBoxSize) 4080 if (oldBorderBoxSize == newBorderBoxSize)
4088 return invalidationReason; 4081 return invalidationReason;
4089 4082
4083 // FIXME: Implement correct incremental invalidation for visual overflowing effects.
4084 if (style()->hasVisualOverflowingEffect() || style()->hasAppearance() || sty le()->hasFilter())
4085 return InvalidationBorderBoxChange;
4086
4087 if (style()->hasBorderRadius()) {
4088 // If a border-radius exists and width/height is smaller than radius wid th/height,
4089 // we need to fully invalidate to cover the changed radius.
4090 RoundedRect oldRoundedRect = style()->getRoundedBorderFor(LayoutRect(Lay outPoint(0, 0), oldBorderBoxSize));
4091 RoundedRect newRoundedRect = style()->getRoundedBorderFor(LayoutRect(Lay outPoint(0, 0), newBorderBoxSize));
4092 if (oldRoundedRect.radii() != newRoundedRect.radii())
4093 return InvalidationBorderBoxChange;
4094 }
4095
4090 if (oldBorderBoxSize.width() != newBorderBoxSize.width() && mustInvalidateBa ckgroundOrBorderPaintOnWidthChange()) 4096 if (oldBorderBoxSize.width() != newBorderBoxSize.width() && mustInvalidateBa ckgroundOrBorderPaintOnWidthChange())
4091 return InvalidationBorderBoxChange; 4097 return InvalidationBorderBoxChange;
4092 if (oldBorderBoxSize.height() != newBorderBoxSize.height() && mustInvalidate BackgroundOrBorderPaintOnHeightChange()) 4098 if (oldBorderBoxSize.height() != newBorderBoxSize.height() && mustInvalidate BackgroundOrBorderPaintOnHeightChange())
4093 return InvalidationBorderBoxChange; 4099 return InvalidationBorderBoxChange;
4094 4100
4101 return InvalidationIncremental;
4102 }
4103
4104 void RenderBox::incrementallyInvalidatePaint(const RenderLayerModelObject& paint InvalidationContainer, const LayoutRect& oldBounds, const LayoutRect& newBounds, const LayoutPoint& positionFromPaintInvalidationContainer)
4105 {
4106 RenderObject::incrementallyInvalidatePaint(paintInvalidationContainer, oldBo unds, newBounds, positionFromPaintInvalidationContainer);
4107
4108 bool hasBoxDecorations = style()->hasBoxDecorations();
4109 if (!style()->hasBackground() && !hasBoxDecorations)
4110 return;
4111
4112 LayoutSize oldBorderBoxSize = computePreviousBorderBoxSize(oldBounds.size()) ;
4113 LayoutSize newBorderBoxSize = size();
4114
4115 // If border box size didn't change, RenderBox's incrementallyInvalidatePain t() is good.
4116 if (oldBorderBoxSize == newBorderBoxSize)
4117 return;
4118
4095 // If size of the paint invalidation rect equals to size of border box, Rend erObject::incrementallyInvalidatePaint() 4119 // If size of the paint invalidation rect equals to size of border box, Rend erObject::incrementallyInvalidatePaint()
4096 // is good for boxes having background without box decorations. 4120 // is good for boxes having background without box decorations.
4097 if (oldBorderBoxSize == oldBounds.size() && newBorderBoxSize == newBounds.si ze() && !style()->hasBoxDecorations()) 4121 ASSERT(oldBounds.location() == newBounds.location()); // Otherwise we won't do incremental invalidation.
4098 return invalidationReason; 4122 if (!hasBoxDecorations
4123 && positionFromPaintInvalidationContainer == newBounds.location()
4124 && oldBorderBoxSize == oldBounds.size()
4125 && newBorderBoxSize == newBounds.size())
4126 return;
4099 4127
4100 // FIXME: Since we have accurate old border box size, we could do more accur ate 4128 // Invalidate the right delta part and the right border of the old or new bo x which has smaller width.
4101 // incremental invalidation instead of full invalidation. 4129 LayoutUnit deltaWidth = absoluteValue(oldBorderBoxSize.width() - newBorderBo xSize.width());
4102 return InvalidationBorderBoxChange; 4130 if (deltaWidth) {
4131 LayoutUnit smallerWidth = std::min(oldBorderBoxSize.width(), newBorderBo xSize.width());
4132 LayoutUnit borderTopRightRadiusWidth = valueForLength(style()->borderTop RightRadius().width(), smallerWidth);
4133 LayoutUnit borderBottomRightRadiusWidth = valueForLength(style()->border BottomRightRadius().width(), smallerWidth);
4134 LayoutUnit borderWidth = std::max<LayoutUnit>(borderRight(), std::max(bo rderTopRightRadiusWidth, borderBottomRightRadiusWidth));
4135 LayoutRect rightDeltaRect(positionFromPaintInvalidationContainer.x() + s mallerWidth - borderWidth,
4136 positionFromPaintInvalidationContainer.y(),
4137 deltaWidth + borderWidth,
4138 std::max(oldBorderBoxSize.height(), newBorderBoxSize.height()));
4139 invalidatePaintUsingContainer(&paintInvalidationContainer, rightDeltaRec t, InvalidationIncremental);
4140 }
4141
4142 // Invalidate the bottom delta part and the bottom border of the old or new box which has smaller height.
4143 LayoutUnit deltaHeight = absoluteValue(oldBorderBoxSize.height() - newBorder BoxSize.height());
4144 if (deltaHeight) {
4145 LayoutUnit smallerHeight = std::min(oldBorderBoxSize.height(), newBorder BoxSize.height());
4146 LayoutUnit borderBottomLeftRadiusHeight = valueForLength(style()->border BottomLeftRadius().height(), smallerHeight);
4147 LayoutUnit borderBottomRightRadiusHeight = valueForLength(style()->borde rBottomRightRadius().height(), smallerHeight);
4148 LayoutUnit borderHeight = std::max<LayoutUnit>(borderBottom(), std::max( borderBottomLeftRadiusHeight, borderBottomRightRadiusHeight));
4149 LayoutRect bottomDeltaRect(positionFromPaintInvalidationContainer.x(),
4150 positionFromPaintInvalidationContainer.y() + smallerHeight - borderH eight,
4151 std::max(oldBorderBoxSize.width(), newBorderBoxSize.width()),
4152 deltaHeight + borderHeight);
4153 invalidatePaintUsingContainer(&paintInvalidationContainer, bottomDeltaRe ct, InvalidationIncremental);
4154 }
4103 } 4155 }
4104 4156
4105 void RenderBox::markForPaginationRelayoutIfNeeded(SubtreeLayoutScope& layoutScop e) 4157 void RenderBox::markForPaginationRelayoutIfNeeded(SubtreeLayoutScope& layoutScop e)
4106 { 4158 {
4107 ASSERT(!needsLayout()); 4159 ASSERT(!needsLayout());
4108 // If fragmentation height has changed, we need to lay out. No need to enter the renderer if it 4160 // If fragmentation height has changed, we need to lay out. No need to enter the renderer if it
4109 // is childless, though. 4161 // is childless, though.
4110 if (view()->layoutState()->pageLogicalHeightChanged() && slowFirstChild()) 4162 if (view()->layoutState()->pageLogicalHeightChanged() && slowFirstChild())
4111 layoutScope.setChildNeedsLayout(this); 4163 layoutScope.setChildNeedsLayout(this);
4112 } 4164 }
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after
4686 return; 4738 return;
4687 4739
4688 // We need the old border box size only when the box has background or b ox decorations. 4740 // We need the old border box size only when the box has background or b ox decorations.
4689 if (!style()->hasBackground() && !style()->hasBoxDecorations()) 4741 if (!style()->hasBackground() && !style()->hasBoxDecorations())
4690 return; 4742 return;
4691 } 4743 }
4692 4744
4693 ensureRareData().m_previousBorderBoxSize = size(); 4745 ensureRareData().m_previousBorderBoxSize = size();
4694 } 4746 }
4695 4747
4748 LayoutSize RenderBox::computePreviousBorderBoxSize(const LayoutSize& previousBou ndsSize) const
4749 {
4750 // PreviousBorderBoxSize is only valid when there is background or box decor ations.
4751 ASSERT(style()->hasBackground() || style()->hasBoxDecorations());
4752
4753 if (m_rareData && m_rareData->m_previousBorderBoxSize.width() != -1)
4754 return m_rareData->m_previousBorderBoxSize;
4755
4756 // We didn't save the old border box size because it was the same as the siz e of oldBounds.
4757 return previousBoundsSize;
4758 }
4759
4696 RenderBox::BoxDecorationData::BoxDecorationData(const RenderStyle& style) 4760 RenderBox::BoxDecorationData::BoxDecorationData(const RenderStyle& style)
4697 { 4761 {
4698 backgroundColor = style.visitedDependentColor(CSSPropertyBackgroundColor); 4762 backgroundColor = style.visitedDependentColor(CSSPropertyBackgroundColor);
4699 hasBackground = backgroundColor.alpha() || style.hasBackgroundImage(); 4763 hasBackground = backgroundColor.alpha() || style.hasBackgroundImage();
4700 ASSERT(hasBackground == style.hasBackground()); 4764 ASSERT(hasBackground == style.hasBackground());
4701 hasBorder = style.hasBorder(); 4765 hasBorder = style.hasBorder();
4702 hasAppearance = style.hasAppearance(); 4766 hasAppearance = style.hasAppearance();
4703 } 4767 }
4704 4768
4705 } // namespace blink 4769 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderBox.h ('k') | Source/core/rendering/RenderObject.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698