| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2000 Dirk Mueller (mueller@kde.org) | 4 * (C) 2000 Dirk Mueller (mueller@kde.org) |
| 5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) | 5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) |
| 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv
ed. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv
ed. |
| 7 * Copyright (C) 2009 Google Inc. All rights reserved. | 7 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | 8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) |
| 9 * | 9 * |
| 10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
| (...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 666 // See if we have the thread cached because we're in the middle of layout. | 666 // See if we have the thread cached because we're in the middle of layout. |
| 667 if (LayoutState* layoutState = view()->layoutState()) { | 667 if (LayoutState* layoutState = view()->layoutState()) { |
| 668 if (LayoutFlowThread* flowThread = layoutState->flowThread()) | 668 if (LayoutFlowThread* flowThread = layoutState->flowThread()) |
| 669 return flowThread; | 669 return flowThread; |
| 670 } | 670 } |
| 671 | 671 |
| 672 // Not in the middle of layout so have to find the thread the slow way. | 672 // Not in the middle of layout so have to find the thread the slow way. |
| 673 return LayoutFlowThread::locateFlowThreadContainingBlockOf(*this); | 673 return LayoutFlowThread::locateFlowThreadContainingBlockOf(*this); |
| 674 } | 674 } |
| 675 | 675 |
| 676 // TODO: May remove this for slimming paint v2 because if the object paints |
| 677 // nothing, then repainting is fast and invalidation of it won't generate any |
| 678 // rastarization invalidation. |
| 676 bool LayoutObject::skipInvalidationWhenLaidOutChildren() const | 679 bool LayoutObject::skipInvalidationWhenLaidOutChildren() const |
| 677 { | 680 { |
| 678 if (!m_bitfields.neededLayoutBecauseOfChildren()) | 681 if (!m_bitfields.neededLayoutBecauseOfChildren()) |
| 679 return false; | 682 return false; |
| 680 | 683 |
| 681 // SVG layoutObjects need to be invalidated when their children are laid out
. | 684 // SVG layoutObjects need to be invalidated when their children are laid out
. |
| 682 // LayoutBlocks with line boxes are responsible to invalidate them so we can
't ignore them. | 685 // LayoutBlocks with line boxes are responsible to invalidate them so we can
't ignore them. |
| 683 if (isSVG() || (isLayoutBlockFlow() && toLayoutBlockFlow(this)->firstLineBox
())) | 686 if (isSVG() || (isLayoutBlockFlow() && toLayoutBlockFlow(this)->firstLineBox
())) |
| 684 return false; | 687 return false; |
| 685 | 688 |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1037 RELEASE_ASSERT(isRooted()); | 1040 RELEASE_ASSERT(isRooted()); |
| 1038 | 1041 |
| 1039 const LayoutBoxModelObject* paintInvalidationContainer = containerForPaintIn
validation(); | 1042 const LayoutBoxModelObject* paintInvalidationContainer = containerForPaintIn
validation(); |
| 1040 ASSERT(paintInvalidationContainer); | 1043 ASSERT(paintInvalidationContainer); |
| 1041 | 1044 |
| 1042 return *paintInvalidationContainer; | 1045 return *paintInvalidationContainer; |
| 1043 } | 1046 } |
| 1044 | 1047 |
| 1045 const LayoutBoxModelObject* LayoutObject::enclosingCompositedContainer() const | 1048 const LayoutBoxModelObject* LayoutObject::enclosingCompositedContainer() const |
| 1046 { | 1049 { |
| 1050 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 1051 // Get the LayoutView of the top level frame. This is temporary before w
e remove blink compositing. |
| 1052 return adjustCompositedContainerForSpecialAncestors(nullptr); |
| 1053 } |
| 1054 |
| 1047 LayoutBoxModelObject* container = nullptr; | 1055 LayoutBoxModelObject* container = nullptr; |
| 1048 // FIXME: CompositingState is not necessarily up to date for many callers of
this function. | 1056 // FIXME: CompositingState is not necessarily up to date for many callers of
this function. |
| 1049 DisableCompositingQueryAsserts disabler; | 1057 DisableCompositingQueryAsserts disabler; |
| 1050 | 1058 |
| 1051 if (DeprecatedPaintLayer* compositingLayer = enclosingLayer()->enclosingLaye
rForPaintInvalidationCrossingFrameBoundaries()) | 1059 if (DeprecatedPaintLayer* compositingLayer = enclosingLayer()->enclosingLaye
rForPaintInvalidationCrossingFrameBoundaries()) |
| 1052 container = compositingLayer->layoutObject(); | 1060 container = compositingLayer->layoutObject(); |
| 1053 return container; | 1061 return container; |
| 1054 } | 1062 } |
| 1055 | 1063 |
| 1056 const LayoutBoxModelObject* LayoutObject::adjustCompositedContainerForSpecialAnc
estors(const LayoutBoxModelObject* paintInvalidationContainer) const | 1064 const LayoutBoxModelObject* LayoutObject::adjustCompositedContainerForSpecialAnc
estors(const LayoutBoxModelObject* paintInvalidationContainer) const |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1197 { | 1205 { |
| 1198 ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled()); | 1206 ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled()); |
| 1199 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | 1207 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) |
| 1200 setNeedsRepaint(); | 1208 setNeedsRepaint(); |
| 1201 paintInvalidationContainer.invalidateDisplayItemClientOnBacking(*this); | 1209 paintInvalidationContainer.invalidateDisplayItemClientOnBacking(*this); |
| 1202 } | 1210 } |
| 1203 | 1211 |
| 1204 void LayoutObject::setNeedsRepaint() | 1212 void LayoutObject::setNeedsRepaint() |
| 1205 { | 1213 { |
| 1206 ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); | 1214 ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); |
| 1207 ASSERT(document().lifecycle().state() <= DocumentLifecycle::InPaintInvalidat
ion); | 1215 ASSERT(document().lifecycle().state() <= DocumentLifecycle::InPaintForSlimmi
ngPaintV2); |
| 1208 | 1216 |
| 1209 if (!selfNeedsRepaint()) { | 1217 if (!selfNeedsRepaint()) { |
| 1210 m_bitfields.setSelfNeedsRepaint(true); | 1218 m_bitfields.setSelfNeedsRepaint(true); |
| 1211 markStackingContextContainerChainForChildNeedsRepaint(); | 1219 markStackingContextContainerChainForChildNeedsRepaint(); |
| 1212 } | 1220 } |
| 1213 } | 1221 } |
| 1214 | 1222 |
| 1215 void LayoutObject::setChildNeedsRepaint() | 1223 void LayoutObject::setChildNeedsRepaint() |
| 1216 { | 1224 { |
| 1217 ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); | 1225 ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); |
| 1218 ASSERT(document().lifecycle().state() <= DocumentLifecycle::InPaintInvalidat
ion); | 1226 ASSERT(document().lifecycle().state() <= DocumentLifecycle::InPaintForSlimmi
ngPaintV2); |
| 1219 | 1227 |
| 1220 if (!childNeedsRepaint()) { | 1228 if (!childNeedsRepaint()) { |
| 1221 m_bitfields.setChildNeedsRepaint(true); | 1229 m_bitfields.setChildNeedsRepaint(true); |
| 1222 markStackingContextContainerChainForChildNeedsRepaint(); | 1230 markStackingContextContainerChainForChildNeedsRepaint(); |
| 1223 } | 1231 } |
| 1224 } | 1232 } |
| 1225 | 1233 |
| 1226 void LayoutObject::markStackingContextContainerChainForChildNeedsRepaint() | 1234 void LayoutObject::markStackingContextContainerChainForChildNeedsRepaint() |
| 1227 { | 1235 { |
| 1228 ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); | 1236 ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1436 | 1444 |
| 1437 if (invalidationReason == PaintInvalidationIncremental) { | 1445 if (invalidationReason == PaintInvalidationIncremental) { |
| 1438 incrementallyInvalidatePaint(paintInvalidationContainer, oldBounds, newB
ounds, newLocation); | 1446 incrementallyInvalidatePaint(paintInvalidationContainer, oldBounds, newB
ounds, newLocation); |
| 1439 return invalidationReason; | 1447 return invalidationReason; |
| 1440 } | 1448 } |
| 1441 | 1449 |
| 1442 fullyInvalidatePaint(paintInvalidationContainer, invalidationReason, oldBoun
ds, newBounds); | 1450 fullyInvalidatePaint(paintInvalidationContainer, invalidationReason, oldBoun
ds, newBounds); |
| 1443 return invalidationReason; | 1451 return invalidationReason; |
| 1444 } | 1452 } |
| 1445 | 1453 |
| 1454 PaintInvalidationReason LayoutObject::invalidatePaintIfNeededForSlimmingPaintV2(
const LayoutPoint& newPaintOffset) |
| 1455 { |
| 1456 ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); |
| 1457 if (!selfShouldCheckForPaintInvalidation()) |
| 1458 return PaintInvalidationNone; |
| 1459 |
| 1460 LayoutPoint oldPaintOffset = m_previousPaintOffset; |
| 1461 m_previousPaintOffset = newPaintOffset; |
| 1462 |
| 1463 const LayoutBoxModelObject& paintInvalidationContainer = containerForPaintIn
validationOnRootedTree(); // This is fast for slimming paint v2. |
| 1464 PaintInvalidationReason invalidationReason = paintInvalidationReason(paintIn
validationContainer, LayoutRect(), oldPaintOffset, LayoutRect(), newPaintOffset)
; |
| 1465 |
| 1466 bool boxDecorationBackgroundObscured = boxDecorationBackgroundIsKnownToBeObs
cured(); |
| 1467 if (!isFullPaintInvalidationReason(invalidationReason) && boxDecorationBackg
roundObscured != m_bitfields.lastBoxDecorationBackgroundObscured()) |
| 1468 invalidationReason = PaintInvalidationBackgroundObscurationChange; |
| 1469 m_bitfields.setLastBoxDecorationBackgroundObscured(boxDecorationBackgroundOb
scured); |
| 1470 |
| 1471 TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("blink.invalidation"), "LayoutObject:
:invalidatePaintIfNeededForSlimmingPaintV2()", |
| 1472 "object", this->debugName().ascii(), |
| 1473 // TODO: Update the function to reflect new meanings. |
| 1474 "", jsonObjectForOldAndNewRects(LayoutRect(), oldPaintOffset, LayoutRect
(), newPaintOffset)); |
| 1475 |
| 1476 if (invalidationReason == PaintInvalidationNone) |
| 1477 return invalidationReason; |
| 1478 |
| 1479 invalidateDisplayItemClients(paintInvalidationContainer); |
| 1480 |
| 1481 clearSelfPaintInvalidationFlags(); |
| 1482 return invalidationReason; |
| 1483 } |
| 1484 |
| 1446 PaintInvalidationReason LayoutObject::paintInvalidationReason(const LayoutBoxMod
elObject& paintInvalidationContainer, | 1485 PaintInvalidationReason LayoutObject::paintInvalidationReason(const LayoutBoxMod
elObject& paintInvalidationContainer, |
| 1447 const LayoutRect& oldBounds, const LayoutPoint& oldPositionFromPaintInvalida
tionBacking, | 1486 const LayoutRect& oldBounds, const LayoutPoint& oldPositionFromPaintInvalida
tionBacking, |
| 1448 const LayoutRect& newBounds, const LayoutPoint& newPositionFromPaintInvalida
tionBacking) const | 1487 const LayoutRect& newBounds, const LayoutPoint& newPositionFromPaintInvalida
tionBacking) const |
| 1449 { | 1488 { |
| 1450 // First check for InvalidationLocationChange to avoid it from being hidden
by other | 1489 // First check for InvalidationLocationChange to avoid it from being hidden
by other |
| 1451 // invalidation reasons because we'll need to force check for paint invalida
tion for | 1490 // invalidation reasons because we'll need to force check for paint invalida
tion for |
| 1452 // children when location of this object changed. | 1491 // children when location of this object changed. |
| 1453 if (newPositionFromPaintInvalidationBacking != oldPositionFromPaintInvalidat
ionBacking) | 1492 if (newPositionFromPaintInvalidationBacking != oldPositionFromPaintInvalidat
ionBacking) |
| 1454 return PaintInvalidationLocationChange; | 1493 return PaintInvalidationLocationChange; |
| 1455 | 1494 |
| (...skipping 1769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3225 } | 3264 } |
| 3226 | 3265 |
| 3227 inline void LayoutObject::markContainerChainForPaintInvalidation() | 3266 inline void LayoutObject::markContainerChainForPaintInvalidation() |
| 3228 { | 3267 { |
| 3229 for (LayoutObject* container = this->containerCrossingFrameBoundaries(); con
tainer && !container->shouldCheckForPaintInvalidationRegardlessOfPaintInvalidati
onState(); container = container->containerCrossingFrameBoundaries()) | 3268 for (LayoutObject* container = this->containerCrossingFrameBoundaries(); con
tainer && !container->shouldCheckForPaintInvalidationRegardlessOfPaintInvalidati
onState(); container = container->containerCrossingFrameBoundaries()) |
| 3230 container->m_bitfields.setChildShouldCheckForPaintInvalidation(true); | 3269 container->m_bitfields.setChildShouldCheckForPaintInvalidation(true); |
| 3231 } | 3270 } |
| 3232 | 3271 |
| 3233 void LayoutObject::setShouldInvalidateSelection() | 3272 void LayoutObject::setShouldInvalidateSelection() |
| 3234 { | 3273 { |
| 3274 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 3275 setShouldDoFullPaintInvalidation(PaintInvalidationSelection); |
| 3276 return; |
| 3277 } |
| 3278 |
| 3235 if (!canUpdateSelectionOnRootLineBoxes()) | 3279 if (!canUpdateSelectionOnRootLineBoxes()) |
| 3236 return; | 3280 return; |
| 3237 | 3281 |
| 3238 m_bitfields.setShouldInvalidateSelection(true); | 3282 m_bitfields.setShouldInvalidateSelection(true); |
| 3239 markContainerChainForPaintInvalidation(); | 3283 markContainerChainForPaintInvalidation(); |
| 3240 } | 3284 } |
| 3241 | 3285 |
| 3242 void LayoutObject::setShouldDoFullPaintInvalidation(PaintInvalidationReason reas
on) | 3286 void LayoutObject::setShouldDoFullPaintInvalidation(PaintInvalidationReason reas
on) |
| 3243 { | 3287 { |
| 3244 // Only full invalidation reasons are allowed. | 3288 // Only full invalidation reasons are allowed. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 3266 m_bitfields.setMayNeedPaintInvalidation(true); | 3310 m_bitfields.setMayNeedPaintInvalidation(true); |
| 3267 markContainerChainForPaintInvalidation(); | 3311 markContainerChainForPaintInvalidation(); |
| 3268 frame()->page()->animator().scheduleVisualUpdate(); // In case that this is
called outside of FrameView::updateLayoutAndStyleForPainting(). | 3312 frame()->page()->animator().scheduleVisualUpdate(); // In case that this is
called outside of FrameView::updateLayoutAndStyleForPainting(). |
| 3269 } | 3313 } |
| 3270 | 3314 |
| 3271 void LayoutObject::clearPaintInvalidationState(const PaintInvalidationState& pai
ntInvalidationState) | 3315 void LayoutObject::clearPaintInvalidationState(const PaintInvalidationState& pai
ntInvalidationState) |
| 3272 { | 3316 { |
| 3273 // paintInvalidationStateIsDirty should be kept in sync with the | 3317 // paintInvalidationStateIsDirty should be kept in sync with the |
| 3274 // booleans that are cleared below. | 3318 // booleans that are cleared below. |
| 3275 ASSERT(paintInvalidationState.ancestorHadPaintInvalidationForLocationChange(
) || paintInvalidationStateIsDirty()); | 3319 ASSERT(paintInvalidationState.ancestorHadPaintInvalidationForLocationChange(
) || paintInvalidationStateIsDirty()); |
| 3320 m_bitfields.setChildShouldCheckForPaintInvalidation(false); |
| 3321 clearSelfPaintInvalidationFlags(); |
| 3322 } |
| 3323 |
| 3324 void LayoutObject::clearSelfPaintInvalidationFlags() |
| 3325 { |
| 3276 clearShouldDoFullPaintInvalidation(); | 3326 clearShouldDoFullPaintInvalidation(); |
| 3277 m_bitfields.setChildShouldCheckForPaintInvalidation(false); | |
| 3278 m_bitfields.setNeededLayoutBecauseOfChildren(false); | 3327 m_bitfields.setNeededLayoutBecauseOfChildren(false); |
| 3279 m_bitfields.setShouldInvalidateOverflowForPaint(false); | 3328 m_bitfields.setShouldInvalidateOverflowForPaint(false); |
| 3280 m_bitfields.setMayNeedPaintInvalidation(false); | 3329 m_bitfields.setMayNeedPaintInvalidation(false); |
| 3281 m_bitfields.setShouldInvalidateSelection(false); | 3330 m_bitfields.setShouldInvalidateSelection(false); |
| 3282 } | 3331 } |
| 3283 | 3332 |
| 3284 bool LayoutObject::isAllowedToModifyLayoutTreeStructure(Document& document) | 3333 bool LayoutObject::isAllowedToModifyLayoutTreeStructure(Document& document) |
| 3285 { | 3334 { |
| 3286 return DeprecatedDisableModifyLayoutTreeStructureAsserts::canModifyLayoutTre
eStateInAnyState() | 3335 return DeprecatedDisableModifyLayoutTreeStructureAsserts::canModifyLayoutTre
eStateInAnyState() |
| 3287 || document.lifecycle().stateAllowsLayoutTreeMutations(); | 3336 || document.lifecycle().stateAllowsLayoutTreeMutations(); |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3477 const blink::LayoutObject* root = object1; | 3526 const blink::LayoutObject* root = object1; |
| 3478 while (root->parent()) | 3527 while (root->parent()) |
| 3479 root = root->parent(); | 3528 root = root->parent(); |
| 3480 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0); | 3529 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0); |
| 3481 } else { | 3530 } else { |
| 3482 fprintf(stderr, "Cannot showLayoutTree. Root is (nil)\n"); | 3531 fprintf(stderr, "Cannot showLayoutTree. Root is (nil)\n"); |
| 3483 } | 3532 } |
| 3484 } | 3533 } |
| 3485 | 3534 |
| 3486 #endif | 3535 #endif |
| OLD | NEW |