| 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/PaintInvalidator.h" | 5 #include "core/paint/PaintInvalidator.h" |
| 6 | 6 |
| 7 #include "core/editing/FrameSelection.h" | 7 #include "core/editing/FrameSelection.h" |
| 8 #include "core/frame/FrameView.h" | 8 #include "core/frame/FrameView.h" |
| 9 #include "core/frame/LocalFrame.h" | 9 #include "core/frame/LocalFrame.h" |
| 10 #include "core/frame/Settings.h" | 10 #include "core/frame/Settings.h" |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 frameView.frame().selection().invalidateCaretRect(); | 362 frameView.frame().selection().invalidateCaretRect(); |
| 363 | 363 |
| 364 // Temporary callback for crbug.com/487345,402044 | 364 // Temporary callback for crbug.com/487345,402044 |
| 365 // TODO(ojan): Make this more general to be used by PositionObserver | 365 // TODO(ojan): Make this more general to be used by PositionObserver |
| 366 // and rAF throttling. | 366 // and rAF throttling. |
| 367 IntRect visibleRect = | 367 IntRect visibleRect = |
| 368 frameView.rootFrameToContents(frameView.computeVisibleArea()); | 368 frameView.rootFrameToContents(frameView.computeVisibleArea()); |
| 369 layoutView->sendMediaPositionChangeNotifications(visibleRect); | 369 layoutView->sendMediaPositionChangeNotifications(visibleRect); |
| 370 } | 370 } |
| 371 | 371 |
| 372 static bool hasPercentageTransform(const ComputedStyle& style) { | |
| 373 if (TransformOperation* translate = style.translate()) { | |
| 374 if (translate->dependsOnBoxSize()) | |
| 375 return true; | |
| 376 } | |
| 377 return style.transform().dependsOnBoxSize() || | |
| 378 (style.transformOriginX() != Length(50, Percent) && | |
| 379 style.transformOriginX().isPercentOrCalc()) || | |
| 380 (style.transformOriginY() != Length(50, Percent) && | |
| 381 style.transformOriginY().isPercentOrCalc()); | |
| 382 } | |
| 383 | |
| 384 void PaintInvalidator::invalidatePaintIfNeeded( | 372 void PaintInvalidator::invalidatePaintIfNeeded( |
| 385 const LayoutObject& object, | 373 const LayoutObject& object, |
| 386 PaintInvalidatorContext& context) { | 374 PaintInvalidatorContext& context) { |
| 387 object.getMutableForPainting().ensureIsReadyForPaintInvalidation(); | 375 object.getMutableForPainting().ensureIsReadyForPaintInvalidation(); |
| 388 | 376 |
| 389 if (!context.forcedSubtreeInvalidationFlags && | 377 if (!context.forcedSubtreeInvalidationFlags && |
| 390 !object | 378 !object |
| 391 .shouldCheckForPaintInvalidationRegardlessOfPaintInvalidationState()) | 379 .shouldCheckForPaintInvalidationRegardlessOfPaintInvalidationState()) |
| 392 return; | 380 return; |
| 393 | 381 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 PaintInvalidatorContext::ForcedSubtreeSVGResourceChange; | 415 PaintInvalidatorContext::ForcedSubtreeSVGResourceChange; |
| 428 break; | 416 break; |
| 429 default: | 417 default: |
| 430 break; | 418 break; |
| 431 } | 419 } |
| 432 | 420 |
| 433 if (context.oldLocation != context.newLocation) | 421 if (context.oldLocation != context.newLocation) |
| 434 context.forcedSubtreeInvalidationFlags |= | 422 context.forcedSubtreeInvalidationFlags |= |
| 435 PaintInvalidatorContext::ForcedSubtreeInvalidationChecking; | 423 PaintInvalidatorContext::ForcedSubtreeInvalidationChecking; |
| 436 | 424 |
| 437 // TODO(crbug.com/533277): This is a workaround for the bug. Remove when we | |
| 438 // detect paint offset change. | |
| 439 if (reason != PaintInvalidationNone && | |
| 440 hasPercentageTransform(object.styleRef())) | |
| 441 context.forcedSubtreeInvalidationFlags |= | |
| 442 PaintInvalidatorContext::ForcedSubtreeInvalidationChecking; | |
| 443 | |
| 444 // TODO(crbug.com/490725): This is a workaround for the bug, to force | 425 // TODO(crbug.com/490725): This is a workaround for the bug, to force |
| 445 // descendant to update visual rects on clipping change. | 426 // descendant to update visual rects on clipping change. |
| 446 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled() && | 427 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled() && |
| 447 context.oldVisualRect != context.newVisualRect | 428 context.oldVisualRect != context.newVisualRect |
| 448 // Note that isLayoutView() below becomes unnecessary after the launch of | 429 // Note that isLayoutView() below becomes unnecessary after the launch of |
| 449 // root layer scrolling. | 430 // root layer scrolling. |
| 450 && (object.hasOverflowClip() || object.isLayoutView()) && | 431 && (object.hasOverflowClip() || object.isLayoutView()) && |
| 451 !toLayoutBox(object).usesCompositedScrolling()) | 432 !toLayoutBox(object).usesCompositedScrolling()) |
| 452 context.forcedSubtreeInvalidationFlags |= | 433 context.forcedSubtreeInvalidationFlags |= |
| 453 PaintInvalidatorContext::ForcedSubtreeInvalidationRectUpdate; | 434 PaintInvalidatorContext::ForcedSubtreeInvalidationRectUpdate; |
| 454 | 435 |
| 455 object.getMutableForPainting().clearPaintInvalidationFlags(); | 436 object.getMutableForPainting().clearPaintInvalidationFlags(); |
| 456 } | 437 } |
| 457 | 438 |
| 458 void PaintInvalidator::processPendingDelayedPaintInvalidations() { | 439 void PaintInvalidator::processPendingDelayedPaintInvalidations() { |
| 459 for (auto target : m_pendingDelayedPaintInvalidations) | 440 for (auto target : m_pendingDelayedPaintInvalidations) |
| 460 target->getMutableForPainting().setShouldDoFullPaintInvalidation( | 441 target->getMutableForPainting().setShouldDoFullPaintInvalidation( |
| 461 PaintInvalidationDelayedFull); | 442 PaintInvalidationDelayedFull); |
| 462 } | 443 } |
| 463 | 444 |
| 464 } // namespace blink | 445 } // namespace blink |
| OLD | NEW |