Index: third_party/WebKit/Source/core/paint/BoxPaintInvalidator.cpp |
diff --git a/third_party/WebKit/Source/core/paint/BoxPaintInvalidator.cpp b/third_party/WebKit/Source/core/paint/BoxPaintInvalidator.cpp |
index 9e797d492e1dd2ef7483f973342a2050e26a5fb3..dbcdf4100ccce2776afa6a181f4e0b9d00df214b 100644 |
--- a/third_party/WebKit/Source/core/paint/BoxPaintInvalidator.cpp |
+++ b/third_party/WebKit/Source/core/paint/BoxPaintInvalidator.cpp |
@@ -312,13 +312,19 @@ PaintInvalidationReason BoxPaintInvalidator::invalidatePaintIfNeeded() { |
bool BoxPaintInvalidator::needsToSavePreviousBoxGeometries() { |
LayoutSize paintInvalidationSize = m_context.newVisualRect.size(); |
- // Don't save old box Geometries if the paint rect is empty because we'll |
- // full invalidate once the paint rect becomes non-empty. |
- if (paintInvalidationSize.isEmpty()) |
- return false; |
- if (m_box.paintedOutputOfObjectHasNoEffectRegardlessOfSize()) |
- return false; |
+ // The shortcuts doesn't apply to HTML element. ViewPaintInvalidator needs to |
+ // know its previous border box size even if it has visibility:hidden (causing |
+ // empty paintInvalidationSize) or has no painted output. |
+ if (!m_box.node() || !m_box.node()->isHTMLElement()) { |
+ // Don't save old box geometries if the paint rect is empty because we'll |
+ // fully invalidate once the paint rect becomes non-empty. |
+ if (paintInvalidationSize.isEmpty()) |
+ return false; |
+ |
+ if (m_box.paintedOutputOfObjectHasNoEffectRegardlessOfSize()) |
+ return false; |
+ } |
const ComputedStyle& style = m_box.styleRef(); |
@@ -360,15 +366,26 @@ void BoxPaintInvalidator::savePreviousBoxGeometriesIfNeeded() { |
m_box.getMutableForPainting().setHasPreviousBoxGeometries(true); |
} |
-LayoutSize BoxPaintInvalidator::previousBorderBoxSize() { |
- DCHECK(m_box.hasPreviousBoxGeometries() == |
- previousBoxGeometriesMap().contains(&m_box)); |
- if (m_box.hasPreviousBoxGeometries()) |
- return previousBoxGeometriesMap().get(&m_box).borderBoxSize; |
+static LayoutSize previousBorderBoxSizeInternal(const LayoutBox& box, |
+ const LayoutSize& defaultSize) { |
+ DCHECK(box.hasPreviousBoxGeometries() == |
+ previousBoxGeometriesMap().contains(&box)); |
+ if (box.hasPreviousBoxGeometries()) |
+ return previousBoxGeometriesMap().get(&box).borderBoxSize; |
+ return defaultSize; |
+} |
- // We didn't save the old border box size because it was the same as the size |
- // of oldVisualRect. |
- return m_context.oldVisualRect.size(); |
+// This is used by ViewPaintInvalidator to get the previous border box size |
+// of the HTML element, before the HTML element is paint invalidated. |
+LayoutSize BoxPaintInvalidator::previousBorderBoxSize(const LayoutBox& box) { |
chrishtr
2017/02/16 23:11:25
It's weird that there are two methods with the sam
Xianzhu
2017/02/16 23:39:35
Done.
|
+ return previousBorderBoxSizeInternal(box, box.visualRect().size()); |
+} |
+ |
+// This is used during paint invalidation of the m_box. PaintInvalidator has |
+// already updated m_box.visualRect() to the current value, so we need to use |
+// context.oldVisualRect as the default value. |
+LayoutSize BoxPaintInvalidator::previousBorderBoxSize() { |
+ return previousBorderBoxSizeInternal(m_box, m_context.oldVisualRect.size()); |
} |
LayoutRect BoxPaintInvalidator::previousContentBoxRect() { |