| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/paint/ObjectPaintInvalidator.h" | 5 #include "core/paint/ObjectPaintInvalidator.h" |
| 6 | 6 |
| 7 #include "core/frame/FrameView.h" | 7 #include "core/frame/FrameView.h" |
| 8 #include "core/frame/LocalFrame.h" | 8 #include "core/frame/LocalFrame.h" |
| 9 #include "core/layout/LayoutBlockFlow.h" | 9 #include "core/layout/LayoutBlockFlow.h" |
| 10 #include "core/layout/LayoutView.h" | 10 #include "core/layout/LayoutView.h" |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 backgroundObscurationChanged = true; | 404 backgroundObscurationChanged = true; |
| 405 } | 405 } |
| 406 | 406 |
| 407 if (m_context.forcedSubtreeInvalidationFlags & | 407 if (m_context.forcedSubtreeInvalidationFlags & |
| 408 PaintInvalidatorContext::ForcedSubtreeFullInvalidation) | 408 PaintInvalidatorContext::ForcedSubtreeFullInvalidation) |
| 409 return PaintInvalidationSubtree; | 409 return PaintInvalidationSubtree; |
| 410 | 410 |
| 411 if (m_object.shouldDoFullPaintInvalidation()) | 411 if (m_object.shouldDoFullPaintInvalidation()) |
| 412 return m_object.fullPaintInvalidationReason(); | 412 return m_object.fullPaintInvalidationReason(); |
| 413 | 413 |
| 414 if (m_context.oldBounds.isEmpty() && m_context.newBounds.isEmpty()) | 414 if (m_context.oldBounds.rect.isEmpty() && m_context.newBounds.rect.isEmpty()) |
| 415 return PaintInvalidationNone; | 415 return PaintInvalidationNone; |
| 416 | 416 |
| 417 if (backgroundObscurationChanged) | 417 if (backgroundObscurationChanged) |
| 418 return PaintInvalidationBackgroundObscurationChange; | 418 return PaintInvalidationBackgroundObscurationChange; |
| 419 | 419 |
| 420 if (m_object.paintedOutputOfObjectHasNoEffectRegardlessOfSize()) | 420 if (m_object.paintedOutputOfObjectHasNoEffectRegardlessOfSize()) |
| 421 return PaintInvalidationNone; | 421 return PaintInvalidationNone; |
| 422 | 422 |
| 423 const ComputedStyle& style = m_object.styleRef(); | 423 const ComputedStyle& style = m_object.styleRef(); |
| 424 | 424 |
| 425 // The outline may change shape because of position change of descendants. For | 425 // The outline may change shape because of position change of descendants. For |
| 426 // simplicity, just force full paint invalidation if this object is marked for | 426 // simplicity, just force full paint invalidation if this object is marked for |
| 427 // checking paint invalidation for any reason. | 427 // checking paint invalidation for any reason. |
| 428 // TODO(wangxianzhu): Optimize this. | 428 // TODO(wangxianzhu): Optimize this. |
| 429 if (style.hasOutline()) | 429 if (style.hasOutline()) |
| 430 return PaintInvalidationOutline; | 430 return PaintInvalidationOutline; |
| 431 | 431 |
| 432 // If the size is zero on one of our bounds then we know we're going to have | 432 // If the size is zero on one of our bounds then we know we're going to have |
| 433 // to do a full invalidation of either old bounds or new bounds. | 433 // to do a full invalidation of either old bounds or new bounds. |
| 434 if (m_context.oldBounds.isEmpty()) | 434 if (m_context.oldBounds.rect.isEmpty()) |
| 435 return PaintInvalidationBecameVisible; | 435 return PaintInvalidationBecameVisible; |
| 436 if (m_context.newBounds.isEmpty()) | 436 if (m_context.newBounds.rect.isEmpty()) |
| 437 return PaintInvalidationBecameInvisible; | 437 return PaintInvalidationBecameInvisible; |
| 438 | 438 |
| 439 // If we shifted, we don't know the exact reason so we are conservative and | 439 // If we shifted, we don't know the exact reason so we are conservative and |
| 440 // trigger a full invalidation. Shifting could be caused by some layout | 440 // trigger a full invalidation. Shifting could be caused by some layout |
| 441 // property (left / top) or some in-flow layoutObject inserted / removed | 441 // property (left / top) or some in-flow layoutObject inserted / removed |
| 442 // before us in the tree. | 442 // before us in the tree. |
| 443 if (m_context.newBounds.location() != m_context.oldBounds.location()) | 443 if (m_context.newBounds.rect.location() != |
| 444 m_context.oldBounds.rect.location()) |
| 444 return PaintInvalidationBoundsChange; | 445 return PaintInvalidationBoundsChange; |
| 445 | 446 |
| 446 if (m_context.newLocation != m_context.oldLocation) | 447 if (m_context.newLocation != m_context.oldLocation) |
| 447 return PaintInvalidationLocationChange; | 448 return PaintInvalidationLocationChange; |
| 448 | 449 |
| 449 // Incremental invalidation is only applicable to LayoutBoxes. Return | 450 // Incremental invalidation is only applicable to LayoutBoxes. Return |
| 450 // PaintInvalidationIncremental no matter if oldBounds and newBounds are equal | 451 // PaintInvalidationIncremental no matter if oldBounds and newBounds are equal |
| 451 // because a LayoutBox may need paint invalidation if its border box changes. | 452 // because a LayoutBox may need paint invalidation if its border box changes. |
| 452 if (m_object.isBox()) | 453 if (m_object.isBox()) |
| 453 return PaintInvalidationIncremental; | 454 return PaintInvalidationIncremental; |
| 454 | 455 |
| 455 if (m_context.oldBounds != m_context.newBounds) | 456 if (m_context.oldBounds.rect != m_context.newBounds.rect) |
| 456 return PaintInvalidationBoundsChange; | 457 return PaintInvalidationBoundsChange; |
| 457 | 458 |
| 458 return PaintInvalidationNone; | 459 return PaintInvalidationNone; |
| 459 } | 460 } |
| 460 | 461 |
| 461 void ObjectPaintInvalidatorWithContext::invalidateSelectionIfNeeded( | 462 void ObjectPaintInvalidatorWithContext::invalidateSelectionIfNeeded( |
| 462 PaintInvalidationReason reason) { | 463 PaintInvalidationReason reason) { |
| 463 // Update selection rect when we are doing full invalidation (in case that the | 464 // Update selection rect when we are doing full invalidation (in case that the |
| 464 // object is moved, composite status changed, etc.) or | 465 // object is moved, composite status changed, etc.) or |
| 465 // shouldInvalidationSelection is set (in case that the selection itself | 466 // shouldInvalidationSelection is set (in case that the selection itself |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 if (m_context.forcedSubtreeInvalidationFlags & | 507 if (m_context.forcedSubtreeInvalidationFlags & |
| 507 PaintInvalidatorContext::ForcedSubtreeInvalidationChecking) { | 508 PaintInvalidatorContext::ForcedSubtreeInvalidationChecking) { |
| 508 reason = PaintInvalidationLocationChange; | 509 reason = PaintInvalidationLocationChange; |
| 509 break; | 510 break; |
| 510 } | 511 } |
| 511 return PaintInvalidationNone; | 512 return PaintInvalidationNone; |
| 512 case PaintInvalidationDelayedFull: | 513 case PaintInvalidationDelayedFull: |
| 513 return PaintInvalidationDelayedFull; | 514 return PaintInvalidationDelayedFull; |
| 514 default: | 515 default: |
| 515 DCHECK(isImmediateFullPaintInvalidationReason(reason)); | 516 DCHECK(isImmediateFullPaintInvalidationReason(reason)); |
| 516 fullyInvalidatePaint(reason, m_context.oldBounds, m_context.newBounds); | 517 fullyInvalidatePaint(reason, m_context.oldBounds.rect, |
| 518 m_context.newBounds.rect); |
| 517 } | 519 } |
| 518 | 520 |
| 519 m_context.paintingLayer->setNeedsRepaint(); | 521 m_context.paintingLayer->setNeedsRepaint(); |
| 520 m_object.invalidateDisplayItemClients(reason); | 522 m_object.invalidateDisplayItemClients(reason); |
| 521 return reason; | 523 return reason; |
| 522 } | 524 } |
| 523 | 525 |
| 524 DisablePaintInvalidationStateAsserts::DisablePaintInvalidationStateAsserts() | 526 DisablePaintInvalidationStateAsserts::DisablePaintInvalidationStateAsserts() |
| 525 : m_disabler(&gDisablePaintInvalidationStateAsserts, true) {} | 527 : m_disabler(&gDisablePaintInvalidationStateAsserts, true) {} |
| 526 | 528 |
| 527 } // namespace blink | 529 } // namespace blink |
| OLD | NEW |