| 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" |
| 11 #include "core/layout/LayoutView.h" | 11 #include "core/layout/LayoutView.h" |
| 12 #include "core/layout/svg/LayoutSVGModelObject.h" | 12 #include "core/layout/svg/LayoutSVGModelObject.h" |
| 13 #include "core/layout/svg/LayoutSVGRoot.h" | 13 #include "core/layout/svg/LayoutSVGRoot.h" |
| 14 #include "core/layout/svg/SVGLayoutSupport.h" | 14 #include "core/layout/svg/SVGLayoutSupport.h" |
| 15 #include "core/paint/PaintLayer.h" | 15 #include "core/paint/PaintLayer.h" |
| 16 | 16 |
| 17 // We can't enable this by default because saturated operations of LayoutUnit | 17 // We can't enable this by default because saturated operations of LayoutUnit |
| 18 // don't conform commutative law for overflowing results, preventing us from | 18 // don't conform commutative law for overflowing results, preventing us from |
| 19 // making fast-path and slow-path always return the same result. | 19 // making fast-path and slow-path always return the same result. |
| 20 #define ASSERT_SAME_RESULT_SLOW_AND_FAST_PATH (0 && ENABLE(ASSERT)) | 20 #define ASSERT_SAME_RESULT_SLOW_AND_FAST_PATH (1 && ENABLE(ASSERT)) |
| 21 | 21 |
| 22 namespace blink { | 22 namespace blink { |
| 23 | 23 |
| 24 static bool isAbsolutePositionUnderRelativePositionInline(const LayoutObject& ob
ject) | 24 static bool isAbsolutePositionUnderRelativePositionInline(const LayoutObject& ob
ject) |
| 25 { | 25 { |
| 26 if (object.styleRef().position() != AbsolutePosition) | 26 if (object.styleRef().position() != AbsolutePosition) |
| 27 return false; | 27 return false; |
| 28 if (LayoutObject* container = object.container()) | 28 if (LayoutObject* container = object.container()) |
| 29 return container->isAnonymousBlock() && container->styleRef().position()
== RelativePosition; | 29 return container->isAnonymousBlock() && container->styleRef().position()
== RelativePosition; |
| 30 return false; | 30 return false; |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 { | 258 { |
| 259 LayoutRect rect; | 259 LayoutRect rect; |
| 260 if (m_cachedOffsetsEnabled) { | 260 if (m_cachedOffsetsEnabled) { |
| 261 FloatRect svgRect = SVGLayoutSupport::localOverflowRectForPaintInvalidat
ion(m_currentObject); | 261 FloatRect svgRect = SVGLayoutSupport::localOverflowRectForPaintInvalidat
ion(m_currentObject); |
| 262 rect = SVGLayoutSupport::transformPaintInvalidationRect(m_currentObject,
m_svgTransform, svgRect); | 262 rect = SVGLayoutSupport::transformPaintInvalidationRect(m_currentObject,
m_svgTransform, svgRect); |
| 263 rect.move(m_paintOffset); | 263 rect.move(m_paintOffset); |
| 264 if (m_clipped) | 264 if (m_clipped) |
| 265 rect.intersect(m_clipRect); | 265 rect.intersect(m_clipRect); |
| 266 #if ASSERT_SAME_RESULT_SLOW_AND_FAST_PATH | 266 #if ASSERT_SAME_RESULT_SLOW_AND_FAST_PATH |
| 267 LayoutRect slowPathRect = SVGLayoutSupport::clippedOverflowRectForPaintI
nvalidation(m_currentObject, m_paintInvalidationContainer); | 267 LayoutRect slowPathRect = SVGLayoutSupport::clippedOverflowRectForPaintI
nvalidation(m_currentObject, m_paintInvalidationContainer); |
| 268 // TODO(crbug.com/597902): Slow path misses clipping of paintInvalidatio
nContainer. | |
| 269 if (m_clipped) | |
| 270 slowPathRect.intersect(m_clipRect); | |
| 271 // TODO(crbug.com/597903): Fast path and slow path should generate equal
empty rects. | 268 // TODO(crbug.com/597903): Fast path and slow path should generate equal
empty rects. |
| 272 ASSERT((rect.isEmpty() && slowPathRect.isEmpty()) || rect == slowPathRec
t); | 269 ASSERT((rect.isEmpty() && slowPathRect.isEmpty()) || rect == slowPathRec
t); |
| 273 #endif | 270 #endif |
| 274 } else { | 271 } else { |
| 275 // TODO(wangxianzhu): Sometimes m_cachedOffsetsEnabled==false doesn't me
an we can't use cached | 272 // TODO(wangxianzhu): Sometimes m_cachedOffsetsEnabled==false doesn't me
an we can't use cached |
| 276 // m_svgTransform. We can use hybrid fast-path (for SVG) and slow-path (
for things above the SVGRoot). | 273 // m_svgTransform. We can use hybrid fast-path (for SVG) and slow-path (
for things above the SVGRoot). |
| 277 rect = SVGLayoutSupport::clippedOverflowRectForPaintInvalidation(m_curre
ntObject, m_paintInvalidationContainer); | 274 rect = SVGLayoutSupport::clippedOverflowRectForPaintInvalidation(m_curre
ntObject, m_paintInvalidationContainer); |
| 278 } | 275 } |
| 279 | 276 |
| 280 if (m_paintInvalidationContainer.layer()->groupedMapping()) | 277 if (m_paintInvalidationContainer.layer()->groupedMapping()) |
| 281 PaintLayer::mapRectInPaintInvalidationContainerToBacking(m_paintInvalida
tionContainer, rect); | 278 PaintLayer::mapRectInPaintInvalidationContainerToBacking(m_paintInvalida
tionContainer, rect); |
| 282 return rect; | 279 return rect; |
| 283 } | 280 } |
| 284 | 281 |
| 285 static void slowMapToVisibleRectInAncestorSpace(const LayoutObject& object, cons
t LayoutBoxModelObject& ancestor, LayoutRect& rect) | 282 static void slowMapToVisibleRectInAncestorSpace(const LayoutObject& object, cons
t LayoutBoxModelObject& ancestor, LayoutRect& rect) |
| 286 { | 283 { |
| 287 // TODO(crbug.com/597965): LayoutBox::mapToVisibleRectInAncestorSpace() inco
rrectly flips a rect | |
| 288 // in its own space for writing mode. Here flip to workaround the flip. | |
| 289 if (object.isBox() && (toLayoutBox(object).isWritingModeRoot() || (ancestor
== object && object.styleRef().isFlippedBlocksWritingMode()))) | |
| 290 toLayoutBox(object).flipForWritingMode(rect); | |
| 291 | |
| 292 if (object.isLayoutView()) { | 284 if (object.isLayoutView()) { |
| 293 toLayoutView(object).mapToVisibleRectInAncestorSpace(&ancestor, rect, In
putIsInFrameCoordinates, DefaultVisibleRectFlags); | 285 toLayoutView(object).mapToVisibleRectInAncestorSpace(&ancestor, rect, In
putIsInFrameCoordinates, DefaultVisibleRectFlags); |
| 294 } else if (object.isSVGRoot()) { | 286 } else if (object.isSVGRoot()) { |
| 295 // TODO(crbug.com/597813): This is to avoid the extra clip applied in La
youtSVGRoot::mapVisibleRectInAncestorSpace(). | 287 // TODO(crbug.com/597813): This is to avoid the extra clip applied in La
youtSVGRoot::mapVisibleRectInAncestorSpace(). |
| 296 toLayoutSVGRoot(object).LayoutReplaced::mapToVisibleRectInAncestorSpace(
&ancestor, rect); | 288 toLayoutSVGRoot(object).LayoutReplaced::mapToVisibleRectInAncestorSpace(
&ancestor, rect); |
| 297 } else { | 289 } else { |
| 298 object.mapToVisibleRectInAncestorSpace(&ancestor, rect); | 290 object.mapToVisibleRectInAncestorSpace(&ancestor, rect); |
| 299 } | 291 } |
| 300 } | 292 } |
| 301 | 293 |
| 302 void PaintInvalidationState::mapLocalRectToPaintInvalidationBacking(LayoutRect&
rect) const | 294 void PaintInvalidationState::mapLocalRectToPaintInvalidationBacking(LayoutRect&
rect) const |
| 303 { | 295 { |
| 304 ASSERT(!m_didUpdateForChildren); | 296 ASSERT(!m_didUpdateForChildren); |
| 305 | 297 |
| 306 if (m_cachedOffsetsEnabled) { | 298 if (m_cachedOffsetsEnabled) { |
| 307 #if ASSERT_SAME_RESULT_SLOW_AND_FAST_PATH | 299 #if ASSERT_SAME_RESULT_SLOW_AND_FAST_PATH |
| 308 LayoutRect slowPathRect(rect); | 300 LayoutRect slowPathRect(rect); |
| 309 slowMapToVisibleRectInAncestorSpace(m_currentObject, m_paintInvalidation
Container, slowPathRect); | 301 slowMapToVisibleRectInAncestorSpace(m_currentObject, m_paintInvalidation
Container, slowPathRect); |
| 310 #endif | 302 #endif |
| 311 rect.move(m_paintOffset); | 303 rect.move(m_paintOffset); |
| 312 if (m_clipped) | 304 if (m_clipped) |
| 313 rect.intersect(m_clipRect); | 305 rect.intersect(m_clipRect); |
| 314 #if ASSERT_SAME_RESULT_SLOW_AND_FAST_PATH | 306 #if ASSERT_SAME_RESULT_SLOW_AND_FAST_PATH |
| 315 // Make sure that the fast path and the slow path generate the same rect
. | 307 // Make sure that the fast path and the slow path generate the same rect
. |
| 316 // TODO(crbug.com/597902): Slow path misses clipping of paintInvalidatio
nContainer. | |
| 317 if (m_clipped) | |
| 318 slowPathRect.intersect(m_clipRect); | |
| 319 // TODO(wangxianzhu): The isLayoutView() condition is for cases that a s
ub-frame creates a | 308 // TODO(wangxianzhu): The isLayoutView() condition is for cases that a s
ub-frame creates a |
| 320 // root PaintInvalidationState which doesn't inherit clip from ancestor
frames. | 309 // root PaintInvalidationState which doesn't inherit clip from ancestor
frames. |
| 321 // Remove the condition when we eliminate the latter case of PaintInvali
dationState(const LayoutView&, ...). | 310 // Remove the condition when we eliminate the latter case of PaintInvali
dationState(const LayoutView&, ...). |
| 322 // TODO(crbug.com/597903): Fast path and slow path should generate equal
empty rects. | 311 // TODO(crbug.com/597903): Fast path and slow path should generate equal
empty rects. |
| 323 ASSERT(m_currentObject.isLayoutView() || (rect.isEmpty() && slowPathRect
.isEmpty()) || rect == slowPathRect); | 312 ASSERT(m_currentObject.isLayoutView() || (rect.isEmpty() && slowPathRect
.isEmpty()) || rect == slowPathRect); |
| 324 #endif | 313 #endif |
| 325 } else { | 314 } else { |
| 326 slowMapToVisibleRectInAncestorSpace(m_currentObject, m_paintInvalidation
Container, rect); | 315 slowMapToVisibleRectInAncestorSpace(m_currentObject, m_paintInvalidation
Container, rect); |
| 327 } | 316 } |
| 328 | 317 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 344 | 333 |
| 345 PaintLayer& PaintInvalidationState::enclosingSelfPaintingLayer(const LayoutObjec
t& layoutObject) const | 334 PaintLayer& PaintInvalidationState::enclosingSelfPaintingLayer(const LayoutObjec
t& layoutObject) const |
| 346 { | 335 { |
| 347 if (layoutObject.hasLayer() && toLayoutBoxModelObject(layoutObject).hasSelfP
aintingLayer()) | 336 if (layoutObject.hasLayer() && toLayoutBoxModelObject(layoutObject).hasSelfP
aintingLayer()) |
| 348 return *toLayoutBoxModelObject(layoutObject).layer(); | 337 return *toLayoutBoxModelObject(layoutObject).layer(); |
| 349 | 338 |
| 350 return m_enclosingSelfPaintingLayer; | 339 return m_enclosingSelfPaintingLayer; |
| 351 } | 340 } |
| 352 | 341 |
| 353 } // namespace blink | 342 } // namespace blink |
| OLD | NEW |