| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/layout/PaintInvalidationState.h" | 5 #include "core/layout/PaintInvalidationState.h" |
| 6 | 6 |
| 7 #include "core/frame/FrameView.h" | 7 #include "core/frame/FrameView.h" |
| 8 #include "core/frame/Settings.h" | 8 #include "core/frame/Settings.h" |
| 9 #include "core/layout/LayoutInline.h" | 9 #include "core/layout/LayoutInline.h" |
| 10 #include "core/layout/LayoutPart.h" | 10 #include "core/layout/LayoutPart.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 , m_enclosingSelfPaintingLayer(*layoutView.layer()) | 92 , m_enclosingSelfPaintingLayer(*layoutView.layer()) |
| 93 #if ENABLE(ASSERT) | 93 #if ENABLE(ASSERT) |
| 94 , m_didUpdateForChildren(false) | 94 , m_didUpdateForChildren(false) |
| 95 #endif | 95 #endif |
| 96 { | 96 { |
| 97 if (!supportsCachedOffsets(layoutView)) { | 97 if (!supportsCachedOffsets(layoutView)) { |
| 98 m_cachedOffsetsEnabled = false; | 98 m_cachedOffsetsEnabled = false; |
| 99 return; | 99 return; |
| 100 } | 100 } |
| 101 | 101 |
| 102 FloatPoint point = layoutView.localToAncestorPoint(FloatPoint(), &m_paintInv
alidationContainer, TraverseDocumentBoundaries | InputIsInFrameCoordinates); | 102 FloatPoint point = layoutView.localToAncestorPoint(FloatPoint(), &m_paintInv
alidationContainer, TraverseDocumentBoundaries); |
| 103 m_paintOffset = LayoutSize(point.x(), point.y()); | 103 m_paintOffset = LayoutSize(point.x(), point.y()); |
| 104 } | 104 } |
| 105 | 105 |
| 106 // TODO(wangxianzhu): This is temporary for positioned object whose paintInvalid
ationContainer is different from | 106 // TODO(wangxianzhu): This is temporary for positioned object whose paintInvalid
ationContainer is different from |
| 107 // the one we find during tree walk. Remove this after we fix the issue with tre
e walk in DOM-order. | 107 // the one we find during tree walk. Remove this after we fix the issue with tre
e walk in DOM-order. |
| 108 PaintInvalidationState::PaintInvalidationState(const PaintInvalidationState& par
entState, const LayoutBoxModelObject& currentObject, const LayoutBoxModelObject&
paintInvalidationContainer) | 108 PaintInvalidationState::PaintInvalidationState(const PaintInvalidationState& par
entState, const LayoutBoxModelObject& currentObject, const LayoutBoxModelObject&
paintInvalidationContainer) |
| 109 : m_currentObject(currentObject) | 109 : m_currentObject(currentObject) |
| 110 , m_clipped(parentState.m_clipped) | 110 , m_clipped(parentState.m_clipped) |
| 111 , m_cachedOffsetsEnabled(parentState.m_cachedOffsetsEnabled) | 111 , m_cachedOffsetsEnabled(parentState.m_cachedOffsetsEnabled) |
| 112 , m_forcedSubtreeInvalidationWithinContainer(parentState.m_forcedSubtreeInva
lidationWithinContainer) | 112 , m_forcedSubtreeInvalidationWithinContainer(parentState.m_forcedSubtreeInva
lidationWithinContainer) |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 m_paintOffset -= toLayoutBox(m_currentObject).locationOffset(); | 232 m_paintOffset -= toLayoutBox(m_currentObject).locationOffset(); |
| 233 } | 233 } |
| 234 | 234 |
| 235 if (!m_currentObject.hasOverflowClip()) | 235 if (!m_currentObject.hasOverflowClip()) |
| 236 return; | 236 return; |
| 237 | 237 |
| 238 const LayoutBox& box = toLayoutBox(m_currentObject); | 238 const LayoutBox& box = toLayoutBox(m_currentObject); |
| 239 | 239 |
| 240 // Do not clip scroll layer contents because the compositor expects the whol
e layer | 240 // Do not clip scroll layer contents because the compositor expects the whol
e layer |
| 241 // to be always invalidated in-time. | 241 // to be always invalidated in-time. |
| 242 if (box.usesCompositedScrolling()) | 242 if (box == m_paintInvalidationContainer && box.scrollsOverflow()) |
| 243 ASSERT(!m_clipped); // The box should establish paint invalidation conta
iner, so no m_clipped inherited. | 243 ASSERT(!m_clipped); // The box should establish paint invalidation conta
iner, so no m_clipped inherited. |
| 244 else | 244 else |
| 245 addClipRectRelativeToPaintOffset(box.overflowClipRect(LayoutPoint())); | 245 addClipRectRelativeToPaintOffset(box.overflowClipRect(LayoutPoint())); |
| 246 | 246 |
| 247 m_paintOffset -= box.scrolledContentOffset(); | 247 m_paintOffset -= box.scrolledContentOffset(); |
| 248 | 248 |
| 249 // FIXME: <http://bugs.webkit.org/show_bug.cgi?id=13443> Apply control clip
if present. | 249 // FIXME: <http://bugs.webkit.org/show_bug.cgi?id=13443> Apply control clip
if present. |
| 250 } | 250 } |
| 251 | 251 |
| 252 static FloatPoint slowLocalToAncestorPoint(const LayoutObject& object, const Lay
outBoxModelObject& ancestor, const FloatPoint& point) | 252 static FloatPoint slowLocalToAncestorPoint(const LayoutObject& object, const Lay
outBoxModelObject& ancestor, const FloatPoint& point) |
| 253 { | 253 { |
| 254 if (object.isLayoutView()) | 254 if (object.isLayoutView()) |
| 255 return toLayoutView(object).localToAncestorPoint(point, &ancestor, Trave
rseDocumentBoundaries | InputIsInFrameCoordinates); | 255 return toLayoutView(object).localToAncestorPoint(point, &ancestor, Trave
rseDocumentBoundaries); |
| 256 return object.localToAncestorPoint(point, &ancestor, TraverseDocumentBoundar
ies); | 256 return object.localToAncestorPoint(point, &ancestor, TraverseDocumentBoundar
ies); |
| 257 } | 257 } |
| 258 | 258 |
| 259 LayoutPoint PaintInvalidationState::computePositionFromPaintInvalidationBacking(
) const | 259 LayoutPoint PaintInvalidationState::computePositionFromPaintInvalidationBacking(
) const |
| 260 { | 260 { |
| 261 ASSERT(!m_didUpdateForChildren); | 261 ASSERT(!m_didUpdateForChildren); |
| 262 | 262 |
| 263 FloatPoint point; | 263 FloatPoint point; |
| 264 if (m_paintInvalidationContainer != m_currentObject) { | 264 if (m_paintInvalidationContainer != m_currentObject) { |
| 265 if (m_cachedOffsetsEnabled) { | 265 if (m_cachedOffsetsEnabled) { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 rect = SVGLayoutSupport::clippedOverflowRectForPaintInvalidation(m_curre
ntObject, m_paintInvalidationContainer); | 315 rect = SVGLayoutSupport::clippedOverflowRectForPaintInvalidation(m_curre
ntObject, m_paintInvalidationContainer); |
| 316 } | 316 } |
| 317 | 317 |
| 318 if (m_paintInvalidationContainer.layer()->groupedMapping()) | 318 if (m_paintInvalidationContainer.layer()->groupedMapping()) |
| 319 PaintLayer::mapRectInPaintInvalidationContainerToBacking(m_paintInvalida
tionContainer, rect); | 319 PaintLayer::mapRectInPaintInvalidationContainerToBacking(m_paintInvalida
tionContainer, rect); |
| 320 return rect; | 320 return rect; |
| 321 } | 321 } |
| 322 | 322 |
| 323 static void slowMapToVisualRectInAncestorSpace(const LayoutObject& object, const
LayoutBoxModelObject& ancestor, LayoutRect& rect) | 323 static void slowMapToVisualRectInAncestorSpace(const LayoutObject& object, const
LayoutBoxModelObject& ancestor, LayoutRect& rect) |
| 324 { | 324 { |
| 325 if (object.isLayoutView()) { | 325 object.mapToVisualRectInAncestorSpace(&ancestor, rect); |
| 326 toLayoutView(object).mapToVisualRectInAncestorSpace(&ancestor, rect, Inp
utIsInFrameCoordinates, DefaultVisualRectFlags); | 326 if (ancestor.hasOverflowClip() && !toLayoutBox(ancestor).scrollsOverflow()) |
| 327 } else { | 327 rect.intersect(toLayoutBox(ancestor).overflowClipRect(LayoutPoint())); |
| 328 object.mapToVisualRectInAncestorSpace(&ancestor, rect); | |
| 329 } | |
| 330 } | 328 } |
| 331 | 329 |
| 332 void PaintInvalidationState::mapLocalRectToPaintInvalidationBacking(LayoutRect&
rect) const | 330 void PaintInvalidationState::mapLocalRectToPaintInvalidationBacking(LayoutRect&
rect) const |
| 333 { | 331 { |
| 334 ASSERT(!m_didUpdateForChildren); | 332 ASSERT(!m_didUpdateForChildren); |
| 335 | 333 |
| 336 if (m_cachedOffsetsEnabled) { | 334 if (m_cachedOffsetsEnabled) { |
| 337 #if ASSERT_SAME_RESULT_SLOW_AND_FAST_PATH | 335 #if ASSERT_SAME_RESULT_SLOW_AND_FAST_PATH |
| 338 LayoutRect slowPathRect(rect); | 336 LayoutRect slowPathRect(rect); |
| 339 slowMapToVisualRectInAncestorSpace(m_currentObject, m_paintInvalidationC
ontainer, slowPathRect); | 337 slowMapToVisualRectInAncestorSpace(m_currentObject, m_paintInvalidationC
ontainer, slowPathRect); |
| 340 #endif | 338 #endif |
| 341 rect.move(m_paintOffset); | 339 rect.move(m_paintOffset); |
| 342 if (m_clipped) | 340 if (m_clipped) |
| 343 rect.intersect(m_clipRect); | 341 rect.intersect(m_clipRect); |
| 344 #if ASSERT_SAME_RESULT_SLOW_AND_FAST_PATH | 342 #if ASSERT_SAME_RESULT_SLOW_AND_FAST_PATH |
| 345 // TODO(crbug.com/597902): Slow path misses clipping of paintInvalidatio
nContainer. | |
| 346 if (m_clipped) | |
| 347 slowPathRect.intersect(m_clipRect); | |
| 348 assertRectsEqual(m_currentObject, m_paintInvalidationContainer, rect, sl
owPathRect); | 343 assertRectsEqual(m_currentObject, m_paintInvalidationContainer, rect, sl
owPathRect); |
| 349 #endif | 344 #endif |
| 350 } else { | 345 } else { |
| 351 slowMapToVisualRectInAncestorSpace(m_currentObject, m_paintInvalidationC
ontainer, rect); | 346 slowMapToVisualRectInAncestorSpace(m_currentObject, m_paintInvalidationC
ontainer, rect); |
| 352 } | 347 } |
| 353 | 348 |
| 354 if (m_paintInvalidationContainer.layer()->groupedMapping()) | 349 if (m_paintInvalidationContainer.layer()->groupedMapping()) |
| 355 PaintLayer::mapRectInPaintInvalidationContainerToBacking(m_paintInvalida
tionContainer, rect); | 350 PaintLayer::mapRectInPaintInvalidationContainerToBacking(m_paintInvalida
tionContainer, rect); |
| 356 } | 351 } |
| 357 | 352 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 369 | 364 |
| 370 PaintLayer& PaintInvalidationState::enclosingSelfPaintingLayer(const LayoutObjec
t& layoutObject) const | 365 PaintLayer& PaintInvalidationState::enclosingSelfPaintingLayer(const LayoutObjec
t& layoutObject) const |
| 371 { | 366 { |
| 372 if (layoutObject.hasLayer() && toLayoutBoxModelObject(layoutObject).hasSelfP
aintingLayer()) | 367 if (layoutObject.hasLayer() && toLayoutBoxModelObject(layoutObject).hasSelfP
aintingLayer()) |
| 373 return *toLayoutBoxModelObject(layoutObject).layer(); | 368 return *toLayoutBoxModelObject(layoutObject).layer(); |
| 374 | 369 |
| 375 return m_enclosingSelfPaintingLayer; | 370 return m_enclosingSelfPaintingLayer; |
| 376 } | 371 } |
| 377 | 372 |
| 378 } // namespace blink | 373 } // namespace blink |
| OLD | NEW |